-
Notifications
You must be signed in to change notification settings - Fork 12.8k
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
Register wf obligation before normalizing in wfcheck #100046
Register wf obligation before normalizing in wfcheck #100046
Conversation
if obligation.predicate.has_projections() { | ||
// Normalizing WellFormed predicates is not sound, see #100041 | ||
if obligation.predicate.has_projections() | ||
&& !matches!( |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
145eff2
to
8f16b02
Compare
anything that's not wf checking pretty much expects normalized inputs 😅 without lazy norm having unnormalized projections tends to be bad™️. we do normalize in Footnotes
|
@lcnr yeah, I'm more curious about whether it's correct/important to have normalized types before we add them to the implied bounds list, like here: https://github.com/rust-lang/rust/blob/master/compiler/rustc_typeck/src/check/wfcheck.rs#L1523 This PR doesn't affect that, for example (just moves the WF obligation on that fn sig's types to before they get normalized). Should we be normalizing types there at all? |
With the changes to normalization in fulfill, and maybe some other ones of #99217, we are allowed to (and should) add both. We do need to add the normalized ones as we currently don't elaborate implied bounds. If you have |
Alright. That makes sense, thanks for the explanation. As a first step I can cherry-pick #99217 onto this branch so we can do another crater run of the merged code. I'll think a bit more about the best way that we can collect both the normalized and un-normalized forms of those types in wfcheck. |
8f16b02
to
854a9eb
Compare
@bors try |
⌛ Trying commit 854a9eb2d1feaa755ed9827216f314bd29cd7854 with merge d76952bc2a74b981479554f7e1e2c6f8a8c3e3bf... |
☀️ Try build successful - checks-actions |
@craterbot check |
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🚧 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
🎉 Experiment
|
ok crater shows clearly that yeah i need to do this then |
@rfcbot reviewed Agreed we should be checking WF before normalization. |
🔔 This is now entering its final comment period, as per the review above. 🔔 |
The final comment period, with a disposition to merge, as per the review above, is now complete. As the automated representative of the governance process, I would like to thank the author for their work and everyone else who contributed. This will be merged soon. |
Lol, so this PR cannot land as-is anymore because of #100676 and a few other PRs. I need to rework this now. |
e6b8a21
to
2dd6666
Compare
2dd6666
to
1634023
Compare
@lcnr I think this is blocked on your work to get both the unnormalized and normalized versions of a type to be considered implied wf types, correct? Since e6b8a2129fdfe4fcde1e418a8b3ec479a23c87f1 is obsolete (we don't collect implied wf tys here anymore). |
☔ The latest upstream changes (presumably #101225) made this pull request unmergeable. Please resolve the merge conflicts. |
// Normalizing WellFormed predicates is not sound, see #100041 | ||
if obligation.predicate.has_projections() && obligation.predicate.allow_normalization() { |
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
already dealt with by try_normalize_with_depth_to
, no need to check for allow_normalization
here
There was a problem hiding this comment.
Choose a reason for hiding this comment
The reason will be displayed to describe this comment to others. Learn more.
Oh cool
blocked on implied bounds for unnormalized types, should hopefully implement this over the next few weeks |
#105948 should probably be fixed first. Otherwise this will break the following arguably correct code: trait Trait { type Ty; }
impl<T> Trait for T { type Ty = (); }
fn pass<T>(_: <&'static T as Trait>::Ty) {} |
closing this PR as #100046 (comment) is blocked on |
It is not clear to me why this is blocked on the next trait solver. Is it because of the regression in this ui test? If so it can be simply unblocked by fixing #105948 first. |
we need the unnormalized implied bounds for impl headers as well. Fixing #105948 would only fix it in function signatures 🤔 I think the following test breaks with this PR: trait Trait {}
trait ToUnit {
type Assoc;
}
impl<T> ToUnit for T {
type Assoc = ();
}
impl<'a, 'b> Trait for <&'a &'b () as ToUnit>::Assoc {} |
Add newly required bound due to rust-lang/rust#100046
Fixes #100041.
Why are we normalizing in wfcheck at all? Should we just be dealing w unnormalized types? I guess whether we normalize or not at all has effects on implied bounds...
cc @rust-lang/types
r? types