@@ -6,15 +6,14 @@ use rustc_hir::{GenericParamKind, ImplItemKind, TraitItemKind};
66use rustc_infer:: infer:: { self , InferOk , TyCtxtInferExt } ;
77use rustc_middle:: ty;
88use rustc_middle:: ty:: error:: { ExpectedFound , TypeError } ;
9- use rustc_middle:: ty:: subst:: { InternalSubsts , Subst , SubstsRef } ;
9+ use rustc_middle:: ty:: subst:: { InternalSubsts , Subst } ;
1010use rustc_middle:: ty:: util:: ExplicitSelf ;
11- use rustc_middle:: ty:: { GenericParamDefKind , ToPredicate , TyCtxt , WithConstness } ;
11+ use rustc_middle:: ty:: { GenericParamDefKind , ToPredicate , TyCtxt } ;
1212use rustc_span:: Span ;
1313use rustc_trait_selection:: traits:: error_reporting:: InferCtxtExt ;
1414use rustc_trait_selection:: traits:: { self , ObligationCause , ObligationCauseCode , Reveal } ;
1515
1616use super :: { potentially_plural_count, FnCtxt , Inherited } ;
17- use std:: iter;
1817
1918/// Checks that a method from an impl conforms to the signature of
2019/// the same method as declared in the trait.
@@ -1240,22 +1239,6 @@ fn compare_projection_bounds<'tcx>(
12401239 ty:: ParamEnv :: new ( tcx. intern_predicates ( & predicates) , Reveal :: UserFacing , None )
12411240 } ;
12421241
1243- // Map the predicate from the trait to the corresponding one for the impl.
1244- // For example:
1245- //
1246- // trait X<A> { type Y<'a>: PartialEq<A> } impl X for T { type Y<'a> = &'a S; }
1247- // impl<'x> X<&'x u32> for () { type Y<'c> = &'c u32; }
1248- //
1249- // For the `for<'a> <<Self as X<A>>::Y<'a>: PartialEq<A>` bound, this
1250- // function would translate and partially normalize
1251- // `[<Self as X<A>>::Y<'a>, A]` to `[&'a u32, &'x u32]`.
1252- let translate_predicate_substs = move |predicate_substs : SubstsRef < ' tcx > | {
1253- tcx. mk_substs (
1254- iter:: once ( impl_ty_value. into ( ) )
1255- . chain ( predicate_substs[ 1 ..] . iter ( ) . map ( |s| s. subst ( tcx, rebased_substs) ) ) ,
1256- )
1257- } ;
1258-
12591242 tcx. infer_ctxt ( ) . enter ( move |infcx| {
12601243 let inh = Inherited :: new ( infcx, impl_ty. def_id . expect_local ( ) ) ;
12611244 let infcx = & inh. infcx ;
@@ -1270,39 +1253,10 @@ fn compare_projection_bounds<'tcx>(
12701253 ) ;
12711254
12721255 let predicates = tcx. projection_predicates ( trait_ty. def_id ) ;
1273-
12741256 debug ! ( "compare_projection_bounds: projection_predicates={:?}" , predicates) ;
12751257
12761258 for predicate in predicates {
1277- let concrete_ty_predicate = match predicate. kind ( ) {
1278- ty:: PredicateKind :: Trait ( poly_tr, c) => poly_tr
1279- . map_bound ( |tr| {
1280- let trait_substs = translate_predicate_substs ( tr. trait_ref . substs ) ;
1281- ty:: TraitRef { def_id : tr. def_id ( ) , substs : trait_substs }
1282- } )
1283- . with_constness ( * c)
1284- . to_predicate ( tcx) ,
1285- ty:: PredicateKind :: Projection ( poly_projection) => poly_projection
1286- . map_bound ( |projection| {
1287- let projection_substs =
1288- translate_predicate_substs ( projection. projection_ty . substs ) ;
1289- ty:: ProjectionPredicate {
1290- projection_ty : ty:: ProjectionTy {
1291- substs : projection_substs,
1292- item_def_id : projection. projection_ty . item_def_id ,
1293- } ,
1294- ty : projection. ty . subst ( tcx, rebased_substs) ,
1295- }
1296- } )
1297- . to_predicate ( tcx) ,
1298- ty:: PredicateKind :: TypeOutlives ( poly_outlives) => poly_outlives
1299- . map_bound ( |outlives| {
1300- ty:: OutlivesPredicate ( impl_ty_value, outlives. 1 . subst ( tcx, rebased_substs) )
1301- } )
1302- . to_predicate ( tcx) ,
1303- _ => bug ! ( "unexepected projection predicate kind: `{:?}`" , predicate) ,
1304- } ;
1305-
1259+ let concrete_ty_predicate = predicate. subst ( tcx, rebased_substs) ;
13061260 debug ! ( "compare_projection_bounds: concrete predicate = {:?}" , concrete_ty_predicate) ;
13071261
13081262 let traits:: Normalized { value : normalized_predicate, obligations } = traits:: normalize (
@@ -1311,7 +1265,6 @@ fn compare_projection_bounds<'tcx>(
13111265 normalize_cause. clone ( ) ,
13121266 & concrete_ty_predicate,
13131267 ) ;
1314-
13151268 debug ! ( "compare_projection_bounds: normalized predicate = {:?}" , normalized_predicate) ;
13161269
13171270 inh. register_predicates ( obligations) ;
0 commit comments