Unnormalized migration: assert_fully_normalized and struct_tail#156224
Unnormalized migration: assert_fully_normalized and struct_tail#156224khyperia wants to merge 2 commits intorust-lang:mainfrom
Conversation
This comment has been minimized.
This comment has been minimized.
906e38e to
d618d7a
Compare
|
The GCC codegen subtree was changed |
| let mut normalize = |ty| self.normalize(ty, location); | ||
| let tail = tcx.struct_tail_raw(ty, &cause, &mut normalize, || {}); | ||
| normalize(tail) | ||
| normalize(Unnormalized::new_wip(tail)) |
There was a problem hiding this comment.
that normalize call can be removed or struct_tail_raw has to return Unnormalized 🤔
| @@ -461,7 +461,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { | |||
| let projected_ty = curr_projected_ty.projection_ty_core( | |||
There was a problem hiding this comment.
projection_ty_core should also have its normalization closure take Unnormalized<Ty>, unless u want to do that in a later PR
| // Need to renormalize `a` as typecheck may have failed to normalize | ||
| // higher-ranked aliases if normalization was ambiguous due to inference. | ||
| let a = self.normalize(a, locations); | ||
| let ty = self.normalize(curr_projected_ty.ty, locations); | ||
| let a = self.normalize(ty::Unnormalized::new_wip(a), locations); | ||
| let ty = self.normalize(ty::Unnormalized::new_wip(curr_projected_ty.ty), locations); |
There was a problem hiding this comment.
| // Need to renormalize `a` as typecheck may have failed to normalize | |
| // higher-ranked aliases if normalization was ambiguous due to inference. | |
| let a = self.normalize(a, locations); | |
| let ty = self.normalize(curr_projected_ty.ty, locations); | |
| let a = self.normalize(ty::Unnormalized::new_wip(a), locations); | |
| let ty = self.normalize(ty::Unnormalized::new_wip(curr_projected_ty.ty), locations); | |
| // Need to renormalize `a` in the old solver as typecheck may have failed | |
| // to normalize higher-ranked aliases if normalization was ambiguous due | |
| // to inference. | |
| // | |
| // We properly normalize higher-ranked aliases during writeback with the | |
| // new solver, so this is no longer necessary. | |
| let mut a = a; | |
| let mut ty = curr_projected_ty.ty; | |
| if !self.infcx.next_trait_solver() { | |
| a = self.normalize(ty::Unnormalized::new_wip(a), locations); | |
| ty = self.normalize(ty::Unnormalized::new_wip(curr_projected_ty.ty), locations); | |
| } |
| layout.ty, | ||
| &ObligationCause::dummy(), | ||
| |ty| ty, | ||
| |ty| ty.skip_normalization(), |
There was a problem hiding this comment.
what are we doing here 😭 that'a broken, please add a "FIXME(#155345): Missing normalization call" here
| // Even if `ty` is normalized, the search for the unsized tail will project | ||
| // to fields, which can yield non-normalized types. So we need to provide a | ||
| // normalization function. | ||
| let normalize = |ty| { | ||
| self.tcx.normalize_erasing_regions(self.typing_env, Unnormalized::new_wip(ty)) | ||
| }; | ||
| let normalize = |ty| self.tcx.normalize_erasing_regions(self.typing_env, ty); | ||
| ty.ptr_metadata_ty(*self.tcx, normalize) |
There was a problem hiding this comment.
remove that comment and maybe inline the comment. I don't think that comment is useful as this holds for all uses of ptr_metadata_ty, so it should be on that function if anywhere
There was a problem hiding this comment.
I added the comment because I can never remember when one has to normalize what and we had a bunch of bugs due to that.
| @@ -81,7 +81,7 @@ impl<'a, 'tcx> Expectation<'tcx> { | |||
| let cause = ObligationCause::misc(span, fcx.body_id); | |||
|
|
|||
| // FIXME: This is not right, even in the old solver... | |||
There was a problem hiding this comment.
| // FIXME: This is not right, even in the old solver... | |
| // FIXME(#155345): Missing normalization call |
| tcx.types.unit | ||
| } else { | ||
| match pointee_ty.ptr_metadata_ty_or_tail(tcx, |x| x) { | ||
| match pointee_ty.ptr_metadata_ty_or_tail(tcx, |x| x.skip_normalization()) { |
There was a problem hiding this comment.
aaaaaaaaaaaaaaaa xd
| match pointee_ty.ptr_metadata_ty_or_tail(tcx, |x| x.skip_normalization()) { | |
| // FIXME(#155345): Missing normalization call | |
| match pointee_ty.ptr_metadata_ty_or_tail(tcx, |x| x.skip_normalization()) { |
|
|
||
| ty::Alias(..) => { | ||
| let normalized = normalize(ty); | ||
| let normalized = normalize(Unnormalized::new(ty)); |
There was a problem hiding this comment.
| let normalized = normalize(Unnormalized::new(ty)); | |
| let normalized = normalize(Unnormalized::new_wip(ty)); |
we should remove this as all the inputs should already be normalized
| pointee, | ||
| &ObligationCause::dummy(), | ||
| |ty| ty, | ||
| |ty| ty.skip_norm_wip(), |
There was a problem hiding this comment.
that...
why are we not matching on try_normalize_erasing_regions inside of struct_tail_raw
ah well, not necessarily for your PR. would keep that as is for now
tracking issue: #155345 (first checkbox, and partial second checkbox, of that issue)
I'm going a bit slower than expected (less free time than I'd hope, lots of GCA work that I'm doing instead), and figured I'd just submit what I have now rather than building up a big batch of changes. Slow and steady!
r? @lcnr