@@ -3315,9 +3315,27 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
33153315 tcx. mk_existential_predicates ( iter)
33163316 } ) ;
33173317 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
33183336 let InferOk { obligations, .. } = self . infcx
33193337 . at ( & obligation. cause , obligation. param_env )
3320- . sup ( target, source_trait)
3338+ . eq ( target, source_trait) // FIXME -- see below
33213339 . map_err ( |_| Unimplemented ) ?;
33223340 nested. extend ( obligations) ;
33233341
0 commit comments