-
-
Notifications
You must be signed in to change notification settings - Fork 14.2k
WF check lifetime bounds for locals with type params #149389
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?
Conversation
|
@bors try |
This comment has been minimized.
This comment has been minimized.
WF check lifetime bounds for locals with type params
This comment has been minimized.
This comment has been minimized.
a99bb12 to
4f2261f
Compare
|
@bors try |
WF check lifetime bounds for locals with type params
This comment has been minimized.
This comment has been minimized.
|
@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
Footnotes
|
|
👌 Experiment ℹ️ Crater is a tool to run experiments across parts of the Rust ecosystem. Learn more |
|
@craterbot p=11 |
|
📝 Configuration of the ℹ️ 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
Footnotes
|
|
I expected lots of breakages but seems not |
| fn test<T>() { | ||
| let _ = None::<Static<T>>; | ||
| //~^ ERROR the parameter type `T` may not live long enough | ||
| } |
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.
can you also add a test for the unsoundness?
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.
Added a test with the code from #148854
4f2261f to
223927a
Compare
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.
| // This has to error due to an unsatisfied outlives bound on | |
| // `Inner<T: 'static>` as its implicit drop relies on that | |
| // bound. |
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.
writing an FCP for this rn
223927a to
5441562
Compare
|
@rfcbot fcp merge types MIR typeck needs to check that all used types are well-formed. While one could imagine checking all locals for well-formedness, we don't. We only check types which flow into the body and assuming that most expressions and subtyping maintain well-formedness. As part of this FCP proposal I took some time to look through everything chcked for WF in borrowck, it should be the following:
Notably, we only check that the type of locals is well-formed if we explicitly track the fact that the user provided type information for them. As a performance optimization, we only track that fact if checking well-formedness may result in lifetime constraints. This previously didn't add user type annotations for types which involve type params but no regions. This meant the following incorrectly compiles struct Static<T: 'static>(T);
fn test<T>() {
let _ = None::<Static<T>>;
}@theemathas was then able to weaponize this in #148854 by adding a This PR changes us to weaken the perf optimization so that we now also check user type annotations if they have type parameters in them. There are no crater regressions from this change. |
|
Team member @lcnr has proposed to merge this. The next step is review by the rest of the tagged team members: No concerns currently listed. Once a majority of reviewers approve (and at most 2 approvals are outstanding), this will enter its final comment period. If you spot a major issue that hasn't been raised at any point in this process, please speak up! See this document for info about what commands tagged team members can give me. |
|
@rust-timer build f70ee28 |
This comment has been minimized.
This comment has been minimized.
|
Finished benchmarking commit (f70ee28): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowBenchmarking this pull request means it may be perf-sensitive – we'll automatically label it not fit for rolling up. You can override this, but we strongly advise not to, due to possible changes in compiler perf. Next Steps: If you can justify the regressions found in this try perf run, please do so in sufficient writing along with @bors rollup=never Instruction countOur most reliable metric. Used to determine the overall result above. However, even this metric can be noisy.
Max RSS (memory usage)Results (primary -5.4%)A less reliable metric. May be of interest, but not used to determine the overall result above.
CyclesResults (primary -1.3%, secondary -1.2%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Binary sizeResults (primary -0.1%, secondary -0.1%)A less reliable metric. May be of interest, but not used to determine the overall result above.
Bootstrap: 470.335s -> 475.664s (1.13%) |
|
Is it expected that changing WF has diffs in mir-opts tests? |
|
It looks like there are query differences in metadata. Maybe the wf checks cause some difference but I wouldn't know how or why. I'd say noise (even if reproducible, any other change could cause it, too) |
Fixes #115175
Fixes #148854