You signed in with another tab or window. Reload to refresh your session.You signed out in another tab or window. Reload to refresh your session.You switched accounts on another tab or window. Reload to refresh your session.Dismiss alert
traitTrait{}implTraitforu32{}fnhello() -> Box<implTrait>{iftrue{let x = hello();//[next]~^ ERROR: the size for values of type `dyn Trait` cannot be known at compilation timelet y:Box<dynTrait> = x;}Box::new(1u32)}fnmain(){}
Assignig dyn Trait to the opaque should cause the existing ?hidden_ty: Sized obligation to fail, at least after proving Subtype obligations as well. We may want to check obligations before committing to coercions/equality in typeck.
The text was updated successfully, but these errors were encountered:
We may want to check obligations before committing to coercions/equality in typeck.
I don't think this idea makes sense, since coercions falling back to equality is the last choice we have in coercion, namely after we've tried and failed to do an unsizing coercion first.
In the old solver, we see that we're trying to coerce Box<?0> to Box<dyn Trait>, and also see that ?0: Sized via an item bound of the opaque. But that doesn't work in the new solver since we have Box<impl Trait> being unsized to Box<dyn Trait>, but since we don't know the hidden type we just bail with ambiguity and fail to do the unsizing coercion.
edit: My analysis of how this succeeds in the old trait solver may be wrong too -- it may be due to the fact that we can rely on opaque item bounds holding in the defining scope even if we don't know the hidden type. That would allow impl Trait: Sized to hold, which is required for the unsize goal.
We probably could special-case this behavior in a new way if we turned this coercion loop into a proper proof tree visitor in the new solver, but this is also somewhat dissatisfying.
affected test
Assignig
dyn Trait
to the opaque should cause the existing?hidden_ty: Sized
obligation to fail, at least after provingSubtype
obligations as well. We may want to check obligations before committing to coercions/equality in typeck.The text was updated successfully, but these errors were encountered: