-
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
Try to point out when edition 2024 lifetime capture rules cause borrowck issues #131186
Try to point out when edition 2024 lifetime capture rules cause borrowck issues #131186
Conversation
fd49086
to
5ade2ea
Compare
Applicability::MaybeIncorrect, | ||
); | ||
} else { | ||
diag.span_help( |
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.
Why isn't this a structured suggestion? Edit: because it's checking if it's not the current crate, got it.
5ade2ea
to
3b98411
Compare
r? @estebank, would you be willing to help out with the wording/etc. here? Otherwise, please feel free to reassign. I know the lifetime logic is kinda sketchy, but after all it's a diagnostic so 🤷 |
HIR ty lowering was modified cc @fmease |
Let's see the cost of the cross-crate encoding of opaque origin. @bors try @rust-timer |
…rrowck, r=<try> Try to point out when edition 2024 lifetime capture rules cause borrowck issues Lifetime capture rules in 2024 are modified to capture more lifetimes, which sometimes lead to some non-local borrowck errors. This PR attempts to link these back together with a useful note pointing out the capture rule changes. This is not a blocking concern, but I'd appreciate feedback (though, again, I'd like to stress that I don't want to block this PR on this): I'm worried about this note drowning in the sea of other diagnostics that borrowck emits. I was tempted to change the level of the note to `.span_warn` just so it would show up in a different color. Thoughts? Fixes rust-lang#130545 Opening as a draft first since it's stacked on rust-lang#131183. r? `@ghost`
☀️ Try build successful - checks-actions |
ugh lol @rust-timer build 17a60f6 |
This comment has been minimized.
This comment has been minimized.
Finished benchmarking commit (17a60f6): comparison URL. Overall result: no relevant changes - no action neededBenchmarking this pull request likely means that it is perf-sensitive, so we're automatically marking it as not fit for rolling up. While you can manually mark this PR as fit for rollup, we strongly recommend not doing so since this PR may lead to changes in compiler perf. @bors rollup=never Instruction countThis benchmark run did not return any relevant results for this metric. Max RSS (memory usage)Results (secondary -2.4%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesResults (secondary 3.9%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Binary sizeResults (primary 0.1%, secondary 0.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 774.169s -> 772.785s (-0.18%) |
3b98411
to
66e10ed
Compare
This comment has been minimized.
This comment has been minimized.
☔ The latest upstream changes (presumably #131985) made this pull request unmergeable. Please resolve the merge conflicts. |
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.
r=me after rebase
LL | println!("{a}"); | ||
| --- immutable borrow later used here | ||
| | ||
note: this call may capture more lifetimes since Rust 2024 has adjusted `impl Trait` lifetime capture rules |
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.
What do you think of the following?
note: this call may capture more lifetimes since Rust 2024 has adjusted `impl Trait` lifetime capture rules | |
note: this call may be capturing more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules |
| | ||
LL | let a = display_len(&x); | ||
| ^^^^^^^^^^^^^^^ | ||
help: add a `use<..>` precise capturing bound to avoid overcapturing |
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.
I'd let the suggestion show the syntax and leave the text easier to read
help: add a `use<..>` precise capturing bound to avoid overcapturing | |
help: add a precise capturing bound to avoid overcapturing in Rust 2024 edition |
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.
I think saying "in Rust 2024" is redundant (that's the current edition enabled) and also going to be wrong as soon as we bump the edition further. I'll leave out the use<..>
part tho.
66e10ed
to
b2fa80e
Compare
@bors r=estebank |
…rrowck, r=estebank Try to point out when edition 2024 lifetime capture rules cause borrowck issues Lifetime capture rules in 2024 are modified to capture more lifetimes, which sometimes lead to some non-local borrowck errors. This PR attempts to link these back together with a useful note pointing out the capture rule changes. This is not a blocking concern, but I'd appreciate feedback (though, again, I'd like to stress that I don't want to block this PR on this): I'm worried about this note drowning in the sea of other diagnostics that borrowck emits. I was tempted to change the level of the note to `.span_warn` just so it would show up in a different color. Thoughts? Fixes rust-lang#130545 Opening as a draft first since it's stacked on rust-lang#131183. r? `@ghost`
This comment has been minimized.
This comment has been minimized.
💔 Test failed - checks-actions |
@bors retry |
☔ The latest upstream changes (presumably #132371) made this pull request unmergeable. Please resolve the merge conflicts. |
b2fa80e
to
c145779
Compare
@bors r=estebank |
☀️ Test successful - checks-actions |
Finished benchmarking commit (c8b8378): comparison URL. Overall result: ✅ improvements - no action needed@rustbot label: -perf-regression Instruction countThis is the most reliable metric that we have; it was used to determine the overall result at the top of this comment. However, even this metric can sometimes exhibit noise.
Max RSS (memory usage)Results (secondary -1.8%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
CyclesThis benchmark run did not return any relevant results for this metric. Binary sizeResults (primary 0.1%, secondary 0.2%)This is a less reliable metric that may be of interest but was not used to determine the overall result at the top of this comment.
Bootstrap: 782.954s -> 783.744s (0.10%) |
Dont suggest `use<impl Trait>` when we have an edition-2024-related borrowck issue rust-lang#131186 implements some machinery to detect in borrowck when we may have RPIT overcaptures due to edition 2024, and suggests adding `+ use<'a, T>` to go back to the edition 2021 capture rules. However, we weren't filtering out cases when there are APITs in scope. This PR implements a more sophisticated diagnostic where we will suggest turning any APITs in scope into type parameters, and applies this to both the borrowck error note, and to the `impl_trait_overcaptures` migration lint. cc rust-lang#132809
Rollup merge of rust-lang#132816 - compiler-errors:2024-apit, r=jieyouxu Dont suggest `use<impl Trait>` when we have an edition-2024-related borrowck issue rust-lang#131186 implements some machinery to detect in borrowck when we may have RPIT overcaptures due to edition 2024, and suggests adding `+ use<'a, T>` to go back to the edition 2021 capture rules. However, we weren't filtering out cases when there are APITs in scope. This PR implements a more sophisticated diagnostic where we will suggest turning any APITs in scope into type parameters, and applies this to both the borrowck error note, and to the `impl_trait_overcaptures` migration lint. cc rust-lang#132809
Dont suggest `use<impl Trait>` when we have an edition-2024-related borrowck issue rust-lang#131186 implements some machinery to detect in borrowck when we may have RPIT overcaptures due to edition 2024, and suggests adding `+ use<'a, T>` to go back to the edition 2021 capture rules. However, we weren't filtering out cases when there are APITs in scope. This PR implements a more sophisticated diagnostic where we will suggest turning any APITs in scope into type parameters, and applies this to both the borrowck error note, and to the `impl_trait_overcaptures` migration lint. cc rust-lang#132809
Lifetime capture rules in 2024 are modified to capture more lifetimes, which sometimes lead to some non-local borrowck errors. This PR attempts to link these back together with a useful note pointing out the capture rule changes.
This is not a blocking concern, but I'd appreciate feedback (though, again, I'd like to stress that I don't want to block this PR on this): I'm worried about this note drowning in the sea of other diagnostics that borrowck emits. I was tempted to change the level of the note to
.span_warn
just so it would show up in a different color. Thoughts?Fixes #130545
Opening as a draft first since it's stacked on #131183.
r? @ghost