@@ -3315,9 +3315,27 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
3315
3315
tcx. mk_existential_predicates ( iter)
3316
3316
} ) ;
3317
3317
let source_trait = tcx. mk_dynamic ( existential_predicates, r_b) ;
3318
+
3319
+ // Require that the traits involved in this upcast are **equal**;
3320
+ // only the **lifetime bound** is changed.
3321
+ //
3322
+ // FIXME: This condition is arguably too strong -- it
3323
+ // would suffice for the source trait to be a
3324
+ // *subtype* of the target trait. In particular
3325
+ // changing from something like `for<'a, 'b> Foo<'a,
3326
+ // 'b>` to `for<'a> Foo<'a, 'a>` should be
3327
+ // permitted. And, indeed, in the in commit
3328
+ // 904a0bde93f0348f69914ee90b1f8b6e4e0d7cbc, this
3329
+ // condition was loosened. However, when the leak check was added
3330
+ // back, using subtype here actually guies the coercion code in
3331
+ // such a way that it accepts `old-lub-glb-object.rs`. This is probably
3332
+ // a good thing, but I've modified this to `.eq` because I want
3333
+ // to continue rejecting that test (as we have done for quite some time)
3334
+ // before we are firmly comfortable with what our behavior
3335
+ // should be there. -nikomatsakis
3318
3336
let InferOk { obligations, .. } = self . infcx
3319
3337
. at ( & obligation. cause , obligation. param_env )
3320
- . sup ( target, source_trait)
3338
+ . eq ( target, source_trait) // FIXME -- see below
3321
3339
. map_err ( |_| Unimplemented ) ?;
3322
3340
nested. extend ( obligations) ;
3323
3341
0 commit comments