- // Enforce the region bound (e.g., `usize: 'static`, in our example).
- .chain([Obligation::new(
+ .chain([
+ // Enforce the region bound (e.g., `usize: 'static`, in our example).
+ Obligation::new(
+ self.tcx,
+ self.cause.clone(),
+ self.param_env,
+ ty::Binder::dummy(ty::PredicateKind::TypeOutlives(ty::OutlivesPredicate(
+ a, b_region,
+ ))),
+ ),
+ ])
+ .collect();
+
+ // Enforce that the type is `usize`/pointer-sized. For now, only those
+ // can be coerced to `dyn*`, except for `dyn* -> dyn*` upcasts.
+ if !a.is_dyn_star() {
+ obligations.push(Obligation::new(