-
-
Notifications
You must be signed in to change notification settings - Fork 14.8k
Introduce Unnormalized wrapper
#155083
New issue
Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.
By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.
Already on GitHub? Sign in to your account
base: main
Are you sure you want to change the base?
Introduce Unnormalized wrapper
#155083
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change | ||||
|---|---|---|---|---|---|---|
|
|
@@ -5,7 +5,7 @@ use rustc_infer::infer::canonical::Canonical; | |||||
| use rustc_infer::infer::outlives::env::RegionBoundPairs; | ||||||
| use rustc_middle::bug; | ||||||
| use rustc_middle::mir::{Body, ConstraintCategory}; | ||||||
| use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, Upcast}; | ||||||
| use rustc_middle::ty::{self, Ty, TyCtxt, TypeFoldable, Unnormalized, Upcast}; | ||||||
| use rustc_span::Span; | ||||||
| use rustc_span::def_id::DefId; | ||||||
| use rustc_trait_selection::solve::NoSolution; | ||||||
|
|
@@ -189,7 +189,11 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { | |||||
| where | ||||||
| T: type_op::normalize::Normalizable<'tcx> + fmt::Display + Copy + 'tcx, | ||||||
| { | ||||||
| self.normalize_with_category(value, location, ConstraintCategory::Boring) | ||||||
| self.normalize_with_category( | ||||||
| Unnormalized::new_wip(value), | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. not propagating this one out? |
||||||
| location, | ||||||
| ConstraintCategory::Boring, | ||||||
| ) | ||||||
| } | ||||||
|
|
||||||
| pub(super) fn deeply_normalize<T>(&mut self, value: T, location: impl NormalizeLocation) -> T | ||||||
|
|
@@ -207,13 +211,14 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { | |||||
| #[instrument(skip(self), level = "debug")] | ||||||
| pub(super) fn normalize_with_category<T>( | ||||||
| &mut self, | ||||||
| value: T, | ||||||
| value: Unnormalized<'tcx, T>, | ||||||
| location: impl NormalizeLocation, | ||||||
| category: ConstraintCategory<'tcx>, | ||||||
| ) -> T | ||||||
| where | ||||||
| T: type_op::normalize::Normalizable<'tcx> + fmt::Display + Copy + 'tcx, | ||||||
| { | ||||||
| let value = value.inside_norm(); | ||||||
|
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more.
Suggested change
would want us to propagate the |
||||||
| let param_env = self.infcx.param_env; | ||||||
| let result: Result<_, ErrorGuaranteed> = self.fully_perform_op( | ||||||
| location.to_locations(), | ||||||
|
|
@@ -246,11 +251,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { | |||||
| CustomTypeOp::new( | ||||||
| |ocx| { | ||||||
| let structurally_normalize = |ty| { | ||||||
| ocx.structurally_normalize_ty( | ||||||
| &cause, | ||||||
| param_env, | ||||||
| ty, | ||||||
| ) | ||||||
| ocx.structurally_normalize_ty(&cause, param_env, Unnormalized::new_wip(ty)) | ||||||
| .unwrap_or_else(|_| bug!("struct tail should have been computable, since we computed it in HIR")) | ||||||
| }; | ||||||
|
|
||||||
|
|
@@ -295,7 +296,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { | |||||
| body.source.def_id().expect_local(), | ||||||
| ), | ||||||
| param_env, | ||||||
| ty, | ||||||
| Unnormalized::new_wip(ty), | ||||||
| ) | ||||||
| .map_err(|_| NoSolution) | ||||||
| }, | ||||||
|
|
@@ -364,7 +365,7 @@ impl<'a, 'tcx> TypeChecker<'a, 'tcx> { | |||||
| // obligation for the unnormalized user_ty here. This is | ||||||
| // where the "incorrectly skips the WF checks we normally do" | ||||||
| // happens | ||||||
| let user_ty = ocx.normalize(&cause, param_env, user_ty); | ||||||
| let user_ty = ocx.normalize(&cause, param_env, Unnormalized::new_wip(user_ty)); | ||||||
| ocx.eq(&cause, param_env, user_ty, mir_ty)?; | ||||||
| Ok(()) | ||||||
| }, | ||||||
|
|
||||||
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -1759,7 +1759,8 @@ impl<'a, 'tcx> Visitor<'tcx> for TypeChecker<'a, 'tcx> { | |
| ); | ||
| } | ||
| } else if let Some(static_def_id) = constant.check_static_ptr(tcx) { | ||
| let unnormalized_ty = tcx.type_of(static_def_id).instantiate_identity(); | ||
| let unnormalized_ty = | ||
| tcx.type_of(static_def_id).instantiate_identity().skip_norm_wip(); | ||
| let normalized_ty = self.normalize(unnormalized_ty, locations); | ||
|
Comment on lines
+1762
to
1764
Contributor
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. hmm, want to change |
||
| let literal_ty = constant.const_.ty().builtin_deref(true).unwrap(); | ||
|
|
||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.