This commit is contained in:
Bastian Kauschke 2020-07-27 21:17:28 +02:00
parent 6ce37fab95
commit 133e1d6773

View File

@ -4,7 +4,7 @@ use rustc_hir::def_id::DefId;
use rustc_hir::{Expr, ExprKind, StmtKind}; use rustc_hir::{Expr, ExprKind, StmtKind};
use rustc_lint::{LateContext, LateLintPass}; use rustc_lint::{LateContext, LateLintPass};
use rustc_middle::ty; use rustc_middle::ty;
use rustc_middle::ty::{GenericPredicates, PredicateKind, ProjectionPredicate, TraitPredicate}; use rustc_middle::ty::{GenericPredicates, PredicateAtom, ProjectionPredicate, TraitPredicate};
use rustc_session::{declare_lint_pass, declare_tool_lint}; use rustc_session::{declare_lint_pass, declare_tool_lint};
use rustc_span::{BytePos, Span}; use rustc_span::{BytePos, Span};
@ -42,8 +42,8 @@ fn get_trait_predicates_for_trait_id<'tcx>(
let mut preds = Vec::new(); let mut preds = Vec::new();
for (pred, _) in generics.predicates { for (pred, _) in generics.predicates {
if_chain! { if_chain! {
if let PredicateKind::Trait(poly_trait_pred, _) = pred.kind(); if let PredicateAtom::Trait(poly_trait_pred, _) = pred.skip_binders();
let trait_pred = cx.tcx.erase_late_bound_regions(&poly_trait_pred); let trait_pred = cx.tcx.erase_late_bound_regions(&ty::Binder::bind(poly_trait_pred));
if let Some(trait_def_id) = trait_id; if let Some(trait_def_id) = trait_id;
if trait_def_id == trait_pred.trait_ref.def_id; if trait_def_id == trait_pred.trait_ref.def_id;
then { then {
@ -60,8 +60,8 @@ fn get_projection_pred<'tcx>(
pred: TraitPredicate<'tcx>, pred: TraitPredicate<'tcx>,
) -> Option<ProjectionPredicate<'tcx>> { ) -> Option<ProjectionPredicate<'tcx>> {
generics.predicates.iter().find_map(|(proj_pred, _)| { generics.predicates.iter().find_map(|(proj_pred, _)| {
if let PredicateKind::Projection(proj_pred) = proj_pred.kind() { if let ty::PredicateAtom::Projection(proj_pred) = proj_pred.skip_binders() {
let projection_pred = cx.tcx.erase_late_bound_regions(proj_pred); let projection_pred = cx.tcx.erase_late_bound_regions(&ty::Binder::bind(proj_pred));
if projection_pred.projection_ty.substs == pred.trait_ref.substs { if projection_pred.projection_ty.substs == pred.trait_ref.substs {
return Some(projection_pred); return Some(projection_pred);
} }