-
Notifications
You must be signed in to change notification settings - Fork 13.2k
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
Lint on tail expr drop order change in Edition 2024 #128662
Lint on tail expr drop order change in Edition 2024 #128662
Conversation
7bf7921
to
9441d83
Compare
This comment has been minimized.
This comment has been minimized.
a7c38d1
to
f5043b7
Compare
This comment has been minimized.
This comment has been minimized.
f5043b7
to
dc79461
Compare
This comment has been minimized.
This comment has been minimized.
dc79461
to
3b8f154
Compare
This comment has been minimized.
This comment has been minimized.
3b8f154
to
cf843a3
Compare
This comment has been minimized.
This comment has been minimized.
cf843a3
to
6e34720
Compare
r? compiler This is an edition item. |
Thanks for the PR. I'm taking a look at this now, but I'm going to read back some of the context first. |
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 implementation looks good to me in general. I have some discussions / questions and suggestions (for doc clarity and test coverage).
/// The `tail_expr_drop_order` lint looks for those values generated at the tail expression location, that of type | ||
/// with a significant `Drop` implementation, such as locks. | ||
/// In case there are also local variables of type with significant `Drop` implementation as well, | ||
/// this lint warns you of a potential transposition in the drop order. | ||
/// Your discretion on the new drop order introduced by Edition 2024 is required. |
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.
Discussion: this wording is a bit unclear to me. Maybe something to the effect of:
The
tail_expr_drop_order
lint looks for potential transposition of the drop order before and after Edition 2024 between:
- values whose types have significant
Drop
implementations, which are generated at tail expression positions, and- local variables whose types have significant
Drop
implementation as well.The transposition of drop order introduced in Edition 2024 warrants your attention,
as it may change observable behavior and thus your intention.
(Or some better wording to that effect)
I think we also want to clarify or define what "significant Drop
implementation" means here as well, does this mean "Drop implementation with side effects", or is there a more technically accurate description that would align with e.g. the reference?
AFAICT, the "significant" terminology comes from the internal has_significant_drop
method on Ty (please correct me if this is well-defined elsewhere like in the reference), but it's not super obvious what this means even looking at the impl in rustc_middle
, let alone for regular users.
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 is not a blocking concern, we can always fine-tune the wording later.)
@rustbot author |
3ec54c4
to
28d804e
Compare
Thanks, the rest looks good to me now, just the edition/feature double-gating that needs to be addressed. |
28d804e
to
2c80b68
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.
The rest looks good to me, but I just realized one thing: we should add an ui test with three revisions for negative gating checks //@ revisions: neither no_feature_gate edition_less_than_2024
:
neither
://@[neither] edition: 2021
and#![cfg_attr(neither, shorter_tail_lifetimes)]
; check lint does not fireno_feature_gate
://@[no_feature_gate] edition: 2024
; check lint does not fireedition_less_than_2024
://@[edition_less_than_2024] edition: 2021
and#![cfg_attr(edition_less_than_2024, shorter_tail_lifetimes)]
; check lint does not fire
2c80b68
to
ef25fbd
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.
Thanks for the updates! Let me double-check if we're missing anything from previous review comments, then we can send this off to the merge queue ^^
Ok this LGTM now, r=me once PR CI is green. |
@bors r+ |
(Not tagging relnotes as I expect this to be announced alongside Edition 2024.) |
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#128662 (Lint on tail expr drop order change in Edition 2024) - rust-lang#128932 (skip updating when external binding is existed) - rust-lang#129270 (Don't consider locals to shadow inner items' generics) - rust-lang#129277 (Update annotate-snippets to 0.11) - rust-lang#129294 (Stabilize `iter::repeat_n`) - rust-lang#129308 (fix: simple typo in compiler directory) - rust-lang#129309 (ctfe: make CompileTimeInterpCx type alias public) - rust-lang#129314 (fix a broken link in `mir/mod.rs`) - rust-lang#129318 (Remove unneeded conversion to `DefId` for `ExtraInfo`) r? `@ghost` `@rustbot` modify labels: rollup
…iaskrgr Rollup of 9 pull requests Successful merges: - rust-lang#128662 (Lint on tail expr drop order change in Edition 2024) - rust-lang#128932 (skip updating when external binding is existed) - rust-lang#129270 (Don't consider locals to shadow inner items' generics) - rust-lang#129277 (Update annotate-snippets to 0.11) - rust-lang#129294 (Stabilize `iter::repeat_n`) - rust-lang#129308 (fix: simple typo in compiler directory) - rust-lang#129309 (ctfe: make CompileTimeInterpCx type alias public) - rust-lang#129314 (fix a broken link in `mir/mod.rs`) - rust-lang#129318 (Remove unneeded conversion to `DefId` for `ExtraInfo`) r? `@ghost` `@rustbot` modify labels: rollup
Rollup merge of rust-lang#128662 - dingxiangfei2009:lint-tail-expr-drop-order, r=jieyouxu Lint on tail expr drop order change in Edition 2024 This lint warns users to consider extra discretion on the effect of a transposed drop order arising from Edition 2024, which involves temporaries in tail expression location with significant drop implementation. cc `@traviscross` Tracking: - rust-lang#123739
This lint warns users to consider extra discretion on the effect of a transposed drop order arising from Edition 2024, which involves temporaries in tail expression location with significant drop implementation.
cc @traviscross
Tracking: