@@ -8,7 +8,7 @@ use rustc::hir::map::Node;
8
8
use rustc:: lint:: { LateContext , Level , Lint , LintContext } ;
9
9
use rustc:: session:: Session ;
10
10
use rustc:: traits;
11
- use rustc:: ty:: { self , Ty , TyCtxt , layout:: { self , IntegerExt } , subst:: Kind } ;
11
+ use rustc:: ty:: { self , Binder , Ty , TyCtxt , layout:: { self , IntegerExt } , subst:: Kind } ;
12
12
use rustc_errors:: { Applicability , CodeSuggestion , Substitution , SubstitutionPart } ;
13
13
use std:: borrow:: Cow ;
14
14
use std:: env;
@@ -869,10 +869,14 @@ pub fn return_ty<'a, 'tcx>(cx: &LateContext<'a, 'tcx>, fn_item: NodeId) -> Ty<'t
869
869
}
870
870
871
871
/// Check if two types are the same.
872
+ ///
873
+ /// This discards any lifetime annotations, too.
872
874
// FIXME: this works correctly for lifetimes bounds (`for <'a> Foo<'a>` == `for
873
875
// <'b> Foo<'b>` but
874
876
// not for type parameters.
875
877
pub fn same_tys < ' a , ' tcx > ( cx : & LateContext < ' a , ' tcx > , a : Ty < ' tcx > , b : Ty < ' tcx > ) -> bool {
878
+ let a = cx. tcx . erase_late_bound_regions ( & Binder :: bind ( a) ) ;
879
+ let b = cx. tcx . erase_late_bound_regions ( & Binder :: bind ( b) ) ;
876
880
cx. tcx
877
881
. infer_ctxt ( )
878
882
. enter ( |infcx| infcx. can_eq ( cx. param_env , a, b) . is_ok ( ) )
0 commit comments