Fix ICE when projecting DiscriminantKind through unsafe binders#158856
Fix ICE when projecting DiscriminantKind through unsafe binders#158856lapla-cogito wants to merge 1 commit into
Conversation
|
r? @fee1-dead rustbot has assigned @fee1-dead. Use Why was this reviewer chosen?The reviewer was selected based on:
|
This comment has been minimized.
This comment has been minimized.
0429ea0 to
bb383cb
Compare
| ty::Coroutine(_, args) => args.as_coroutine().discr_ty(tcx), | ||
|
|
||
| ty::Param(_) | ty::Alias(..) | ty::Infer(ty::TyVar(_)) => { | ||
| ty::Param(_) | ty::Placeholder(_) | ty::Alias(..) | ty::Infer(ty::TyVar(_)) => { |
There was a problem hiding this comment.
Hmm. Is this needed and correct? The UnsafeBinder arm below just instantiates with erased. Placeholders have discriminants question mark? cc @rust-lang/types
There was a problem hiding this comment.
Note that this is for the next solver. IIUC, placeholders don't have a known concrete discriminant type, so we return <!0 as DiscriminantKind>::Discriminant rather than inventing u8. Same pattern as other unknown types in this function.
There was a problem hiding this comment.
we are instantiating the binder with erased regions here, which feels wrong in the trait solver 🤔
we probably want to instantiate them with placeholders?
It's also weird to me that discriminant_ty for unsafe binders doesn't just return instantiated_inner_ty::DiscriminantKind and instead recursively call discriminant_ty.
do we ever encounter the ty::Param(_) | ty::Alias(..) | ty::Infer(ty::TyVar(_)) branch of discriminant_ty outside of the trait solver? Because if so, I would prefer to change it to a panic and have both the old and new solver handle that branch manually.
|
☔ The latest upstream changes (presumably #159246) made this pull request unmergeable. Please resolve the merge conflicts by rebasing. |
Ty::discriminant_tyalready forwards throughUnsafeBinderto the erased inner type (see 35693778e81). The old and new trait solvers still hittodo!s when assembling/normalizing<unsafe<> T as DiscriminantKind>::Discriminant.Fixes #158839