-
Notifications
You must be signed in to change notification settings - Fork 12.9k
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
Reduce false positives of tail-expr-drop-order from consumed values (attempt #2) #131326
Reduce false positives of tail-expr-drop-order from consumed values (attempt #2) #131326
Conversation
Some changes occurred to the CTFE / Miri interpreter cc @rust-lang/miri Some changes occurred in src/tools/clippy cc @rust-lang/clippy Some changes occurred to MIR optimizations cc @rust-lang/wg-mir-opt Some changes occurred in coverage instrumentation. cc @Zalathar This PR changes Stable MIR cc @oli-obk, @celinval, @ouz-a Some changes occurred in compiler/rustc_codegen_cranelift cc @bjorn3 This PR changes MIR cc @oli-obk, @RalfJung, @JakobDegen, @davidtwco, @celinval, @vakaras Some changes occurred in match lowering cc @Nadrieril |
31f4a7f
to
39b18f4
Compare
I still have two issues.
About the futuresTake the crate
|
This comment has been minimized.
This comment has been minimized.
39b18f4
to
e6641cf
Compare
This comment has been minimized.
This comment has been minimized.
e6641cf
to
0c227e9
Compare
This comment has been minimized.
This comment has been minimized.
@rustbot labels +A-edition-2024 |
This comment has been minimized.
This comment has been minimized.
@bors try |
…t-2, r=<try> Reduce false positives of tail-expr-drop-order from consumed values (attempt #2) r? `@nikomatsakis` Related to rust-lang#129864 but not replacing, yet. Related to rust-lang#130836. This is an implementation of the approach suggested in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/temporary.20drop.20order.20changes). A new MIR statement `BackwardsIncompatibleDrop` is added to the MIR syntax. The lint now works by inspecting possibly live move paths before at the `BackwardsIncompatibleDrop` location and the actual drop under the current edition, which should be one before Edition 2024 in practice.
☀️ Try build successful - checks-actions |
@bors try |
…t-2, r=<try> Reduce false positives of tail-expr-drop-order from consumed values (attempt #2) r? `@nikomatsakis` Related to rust-lang#129864 but not replacing, yet. Related to rust-lang#130836. This is an implementation of the approach suggested in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/temporary.20drop.20order.20changes). A new MIR statement `BackwardsIncompatibleDrop` is added to the MIR syntax. The lint now works by inspecting possibly live move paths before at the `BackwardsIncompatibleDrop` location and the actual drop under the current edition, which should be one before Edition 2024 in practice.
This comment has been minimized.
This comment has been minimized.
☀️ Try build successful - checks-actions |
@compiler-errors Shall we give it a crater run with |
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.
Overall this seems much better than before! Minimally invasive, which is good.
{ | ||
visitor.terminating_scopes.insert(tail_expr.hir_id.local_id); | ||
// Note: we are unconditionally adding this information so that we can run |
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.
The word "unconditionally" is confusing here, since clearly this insert call is conditioned on several things (edition, lint level, etc). I think I know what you mean by it, perhaps rewrite to
// If this temporary scope will be changing once the codebase adopts Rust 2024,
// and we are linting about possible semantic changes that would result,
// then record this node-id in the field `backwards_incompatible_scope`
// for future reference.
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.
Applied. The original comment was added when I thought it was right to insert the linting info under all circumstances. Given that we only want to lint when edition migration is run, I changed the condition when the linting info is inserted.
compiler/rustc_middle/src/thir.rs
Outdated
/// Lifetime for temporaries as expected. | ||
/// This should be `None` in a constant context. | ||
pub temp_lifetime: Option<region::Scope>, | ||
/// Backward-incompatible lifetime for future editions |
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 would say:
/// If `Some(lt)`, indicates that the lifetime of this temporary will change to `lt` in a future edition.
/// If `None`, then no changes are expected, or lints are disabled.
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.
Applied
cc @traviscross for visibility |
@bors try |
…t-2, r=<try> Reduce false positives of tail-expr-drop-order from consumed values (attempt #2) r? `@nikomatsakis` Tracked by rust-lang#123739. Related to rust-lang#129864 but not replacing, yet. Related to rust-lang#130836. This is an implementation of the approach suggested in the [Zulip stream](https://rust-lang.zulipchat.com/#narrow/stream/213817-t-lang/topic/temporary.20drop.20order.20changes). A new MIR statement `BackwardsIncompatibleDrop` is added to the MIR syntax. The lint now works by inspecting possibly live move paths before at the `BackwardsIncompatibleDrop` location and the actual drop under the current edition, which should be one before Edition 2024 in practice.
@bors r- Looks like there are merge conflicts. |
take 2 open up coroutines tweak the wordings the lint works up until 2021 We were missing one case, for ADTs, which was causing `Result` to yield incorrect results. only include field spans with significant types deduplicate and eliminate field spans switch to emit spans to impl Drops Co-authored-by: Niko Matsakis <[email protected]> collect drops instead of taking liveness diff apply some suggestions and add explantory notes small fix on the cache let the query recurse through coroutine new suggestion format with extracted variable name fine-tune the drop span and messages bugfix on runtime borrows tweak message wording filter out ecosystem types earlier apply suggestions clippy check lint level at session level further restrict applicability of the lint translate bid into nop for stable mir detect cycle in type structure
bfb48b7
to
297b618
Compare
@rustbot ready Updates:
|
Before this starts attracting new conflicts... @bors r=nikomatsakis p=1 |
@bors p=10 so this is put in front of my rollup |
☀️ Test successful - checks-actions |
Finished benchmarking commit (3fee0f1): comparison URL. Overall result: ❌✅ regressions and improvements - please read the text belowOur benchmarks found a performance regression caused by this PR. Next Steps:
@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 (primary -1.6%, secondary 1.6%)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 (primary -2.4%, secondary 5.0%)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 sizeThis benchmark run did not return any relevant results for this metric. Bootstrap: 794.285s -> 797.74s (0.43%) |
@dingxiangfei2009: I just stumbled across this PR because it caused a conflict with one of my changes. (Which is fine; the conflict was easy to fix.) It looks like you originally had a lot of separate commits and the squashed them together? As a result, the commit log message is incomprehensible. Next time, could you rewrite the commit log so it's more readable to someone not familiar with the PR? Thanks. |
Sorry! I will take care of the commit message in squashing. Most of them are just describing back-and-forth changes and they indeed need some sorting. |
This was actually a small perf. win on primary benchmarks, and the largest secondary regression was just noise. Marking as triaged. @rustbot label: +perf-regression-triaged |
Fix required due to the following changes to Rust's internal API: - rust-lang/rust#132460 - rust-lang/rust#133212 - rust-lang/rust#131326 Resolves #3731 By submitting this pull request, I confirm that my contribution is made under the terms of the Apache 2.0 and MIT licenses. --------- Co-authored-by: Zyad Hassan <[email protected]>
r? @nikomatsakis
Tracked by #123739.
Related to #129864 but not replacing, yet.
Related to #130836.
This is an implementation of the approach suggested in the Zulip stream. A new MIR statement
BackwardsIncompatibleDrop
is added to the MIR syntax. The lint now works by inspecting possibly live move paths before at theBackwardsIncompatibleDrop
location and the actual drop under the current edition, which should be one before Edition 2024 in practice.