@@ -6,15 +6,14 @@ use rustc_hir::{GenericParamKind, ImplItemKind, TraitItemKind};
6
6
use rustc_infer:: infer:: { self , InferOk , TyCtxtInferExt } ;
7
7
use rustc_middle:: ty;
8
8
use rustc_middle:: ty:: error:: { ExpectedFound , TypeError } ;
9
- use rustc_middle:: ty:: subst:: { InternalSubsts , Subst , SubstsRef } ;
9
+ use rustc_middle:: ty:: subst:: { InternalSubsts , Subst } ;
10
10
use rustc_middle:: ty:: util:: ExplicitSelf ;
11
- use rustc_middle:: ty:: { GenericParamDefKind , ToPredicate , TyCtxt , WithConstness } ;
11
+ use rustc_middle:: ty:: { GenericParamDefKind , ToPredicate , TyCtxt } ;
12
12
use rustc_span:: Span ;
13
13
use rustc_trait_selection:: traits:: error_reporting:: InferCtxtExt ;
14
14
use rustc_trait_selection:: traits:: { self , ObligationCause , ObligationCauseCode , Reveal } ;
15
15
16
16
use super :: { potentially_plural_count, FnCtxt , Inherited } ;
17
- use std:: iter;
18
17
19
18
/// Checks that a method from an impl conforms to the signature of
20
19
/// the same method as declared in the trait.
@@ -1240,22 +1239,6 @@ fn compare_projection_bounds<'tcx>(
1240
1239
ty:: ParamEnv :: new ( tcx. intern_predicates ( & predicates) , Reveal :: UserFacing , None )
1241
1240
} ;
1242
1241
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
-
1259
1242
tcx. infer_ctxt ( ) . enter ( move |infcx| {
1260
1243
let inh = Inherited :: new ( infcx, impl_ty. def_id . expect_local ( ) ) ;
1261
1244
let infcx = & inh. infcx ;
@@ -1270,39 +1253,10 @@ fn compare_projection_bounds<'tcx>(
1270
1253
) ;
1271
1254
1272
1255
let predicates = tcx. projection_predicates ( trait_ty. def_id ) ;
1273
-
1274
1256
debug ! ( "compare_projection_bounds: projection_predicates={:?}" , predicates) ;
1275
1257
1276
1258
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) ;
1306
1260
debug ! ( "compare_projection_bounds: concrete predicate = {:?}" , concrete_ty_predicate) ;
1307
1261
1308
1262
let traits:: Normalized { value : normalized_predicate, obligations } = traits:: normalize (
@@ -1311,7 +1265,6 @@ fn compare_projection_bounds<'tcx>(
1311
1265
normalize_cause. clone ( ) ,
1312
1266
& concrete_ty_predicate,
1313
1267
) ;
1314
-
1315
1268
debug ! ( "compare_projection_bounds: normalized predicate = {:?}" , normalized_predicate) ;
1316
1269
1317
1270
inh. register_predicates ( obligations) ;
0 commit comments