@@ -3254,9 +3254,27 @@ impl<'cx, 'gcx, 'tcx> SelectionContext<'cx, 'gcx, 'tcx> {
32543254 tcx. mk_existential_predicates ( iter)
32553255 } ) ;
32563256 let source_trait = tcx. mk_dynamic ( existential_predicates, r_b) ;
3257+
3258+ // Require that the traits involved in this upcast are **equal**;
3259+ // only the **lifetime bound** is changed.
3260+ //
3261+ // FIXME: This condition is arguably too strong -- it
3262+ // would suffice for the source trait to be a
3263+ // *subtype* of the target trait. In particular
3264+ // changing from something like `for<'a, 'b> Foo<'a,
3265+ // 'b>` to `for<'a> Foo<'a, 'a>` should be
3266+ // permitted. And, indeed, in the in commit
3267+ // 904a0bde93f0348f69914ee90b1f8b6e4e0d7cbc, this
3268+ // condition was loosened. However, when the leak check was added
3269+ // back, using subtype here actually guies the coercion code in
3270+ // such a way that it accepts `old-lub-glb-object.rs`. This is probably
3271+ // a good thing, but I've modified this to `.eq` because I want
3272+ // to continue rejecting that test (as we have done for quite some time)
3273+ // before we are firmly comfortable with what our behavior
3274+ // should be there. -nikomatsakis
32573275 let InferOk { obligations, .. } = self . infcx
32583276 . at ( & obligation. cause , obligation. param_env )
3259- . sup ( target, source_trait)
3277+ . eq ( target, source_trait) // FIXME -- see below
32603278 . map_err ( |_| Unimplemented ) ?;
32613279 nested. extend ( obligations) ;
32623280
0 commit comments