-
-
Notifications
You must be signed in to change notification settings - Fork 15k
Fix variable deallocation order in panic unwinding paths #149435
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?
Changes from all commits
File filter
Filter by extension
Conversations
Jump to
Diff view
Diff view
There are no files selected for viewing
| Original file line number | Diff line number | Diff line change |
|---|---|---|
|
|
@@ -150,6 +150,7 @@ pub mod hardwired { | |
| UNUSED_UNSAFE, | ||
| UNUSED_VARIABLES, | ||
| UNUSED_VISIBILITIES, | ||
| UNWIND_DROP_ORDER, | ||
| USELESS_DEPRECATED, | ||
| VARARGS_WITHOUT_PATTERN, | ||
| WARNINGS, | ||
|
|
@@ -5233,6 +5234,47 @@ declare_lint! { | |
| }; | ||
| } | ||
|
|
||
| declare_lint! { | ||
| /// The `unwind_drop_order` lint detects values whose relative drop order on | ||
| /// panic unwind paths will change in a future release. | ||
| /// | ||
| /// ### Example | ||
| /// ```rust,no_run | ||
| /// #![warn(unwind_drop_order)] | ||
| /// | ||
| /// struct Wrap<T>(T); | ||
| /// | ||
| /// impl<T> Drop for Wrap<T> { | ||
| /// fn drop(&mut self) {} | ||
| /// } | ||
| /// | ||
| /// fn main() { | ||
| /// let x; | ||
| /// { | ||
| /// let y = 1; | ||
| /// x = Wrap(&y); | ||
| /// panic!(); | ||
| /// } | ||
| /// } | ||
| /// ``` | ||
| /// | ||
| /// {{produces}} | ||
| /// | ||
| /// ### Explanation | ||
| /// | ||
| /// During panic unwinding, Rust currently does not mark locals as dead at | ||
| /// the same program points as normal control flow. A future release may | ||
| /// make unwind paths use the same storage-dead points as normal paths. This | ||
| /// lint reports code where that change can affect relative drop order | ||
| /// checking. | ||
| pub UNWIND_DROP_ORDER, | ||
| Allow, | ||
|
Member
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. Do we want this to warn by default? It seems like this would be a T-lang decision.
Contributor
Author
There was a problem hiding this comment. Choose a reason for hiding this commentThe reason will be displayed to describe this comment to others. Learn more. I kept this allow-by-default. It is only surfaced as a future-incompat lint via |
||
| "detects future changes to drop order during panic unwinding", | ||
| @future_incompatible = FutureIncompatibleInfo { | ||
| reason: fcw!(FutureReleaseSemanticsChange #147875), | ||
| }; | ||
| } | ||
|
|
||
| declare_lint! { | ||
| /// The `rust_2024_guarded_string_incompatible_syntax` lint detects `#` tokens | ||
| /// that will be parsed as part of a guarded string literal in Rust 2024. | ||
|
|
||
Uh oh!
There was an error while loading. Please reload this page.