Always run tail_expr_drop_order lint on promoted MIR

This commit is contained in:
Michael Goulet 2024-12-19 04:13:28 +00:00
parent addbd001ec
commit b893221517
13 changed files with 92 additions and 38 deletions

View file

@ -437,6 +437,8 @@ fn mir_promoted(
Some(MirPhase::Analysis(AnalysisPhase::Initial)),
);
lint_tail_expr_drop_order::run_lint(tcx, def, &body);
let promoted = promote_pass.promoted_fragments.into_inner();
(tcx.alloc_steal_mir(body), tcx.alloc_steal_promoted(promoted))
}
@ -492,7 +494,6 @@ fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &
}
let (body, _) = tcx.mir_promoted(def);
lint_tail_expr_drop_order::run_lint(tcx, def, &body.borrow());
let mut body = body.steal();
if let Some(error_reported) = tainted_by_errors {

View file

@ -2,7 +2,6 @@
// This lint is to capture potential change in program semantics
// due to implementation of RFC 3606 <https://github.com/rust-lang/rfcs/pull/3606>
//@ edition: 2021
//@ build-fail
#![deny(tail_expr_drop_order)] //~ NOTE: the lint level is defined here
#![allow(dropping_copy_types)]

View file

@ -1,5 +1,5 @@
error: relative drop order changing in Rust 2024
--> $DIR/lint-tail-expr-drop-order.rs:42:15
--> $DIR/lint-tail-expr-drop-order.rs:41:15
|
LL | let x = LoudDropper;
| -
@ -19,14 +19,14 @@ LL | }
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
note: `#1` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:11:1
--> $DIR/lint-tail-expr-drop-order.rs:10:1
|
LL | / impl Drop for LoudDropper {
... |
LL | | }
| |_^
note: `x` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:11:1
--> $DIR/lint-tail-expr-drop-order.rs:10:1
|
LL | / impl Drop for LoudDropper {
... |
@ -34,13 +34,13 @@ LL | | }
| |_^
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
note: the lint level is defined here
--> $DIR/lint-tail-expr-drop-order.rs:7:9
--> $DIR/lint-tail-expr-drop-order.rs:6:9
|
LL | #![deny(tail_expr_drop_order)]
| ^^^^^^^^^^^^^^^^^^^^
error: relative drop order changing in Rust 2024
--> $DIR/lint-tail-expr-drop-order.rs:67:19
--> $DIR/lint-tail-expr-drop-order.rs:66:19
|
LL | let x = LoudDropper;
| -
@ -60,14 +60,14 @@ LL | }
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
note: `#1` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:11:1
--> $DIR/lint-tail-expr-drop-order.rs:10:1
|
LL | / impl Drop for LoudDropper {
... |
LL | | }
| |_^
note: `x` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:11:1
--> $DIR/lint-tail-expr-drop-order.rs:10:1
|
LL | / impl Drop for LoudDropper {
... |
@ -76,7 +76,7 @@ LL | | }
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
error: relative drop order changing in Rust 2024
--> $DIR/lint-tail-expr-drop-order.rs:94:7
--> $DIR/lint-tail-expr-drop-order.rs:93:7
|
LL | let x = LoudDropper;
| -
@ -96,14 +96,14 @@ LL | }
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
note: `#1` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:11:1
--> $DIR/lint-tail-expr-drop-order.rs:10:1
|
LL | / impl Drop for LoudDropper {
... |
LL | | }
| |_^
note: `x` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:11:1
--> $DIR/lint-tail-expr-drop-order.rs:10:1
|
LL | / impl Drop for LoudDropper {
... |
@ -112,7 +112,7 @@ LL | | }
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
error: relative drop order changing in Rust 2024
--> $DIR/lint-tail-expr-drop-order.rs:147:5
--> $DIR/lint-tail-expr-drop-order.rs:146:5
|
LL | let future = f();
| ------
@ -132,14 +132,14 @@ LL | }
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
note: `#1` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:11:1
--> $DIR/lint-tail-expr-drop-order.rs:10:1
|
LL | / impl Drop for LoudDropper {
... |
LL | | }
| |_^
note: `future` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:11:1
--> $DIR/lint-tail-expr-drop-order.rs:10:1
|
LL | / impl Drop for LoudDropper {
... |
@ -148,7 +148,7 @@ LL | | }
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
error: relative drop order changing in Rust 2024
--> $DIR/lint-tail-expr-drop-order.rs:164:14
--> $DIR/lint-tail-expr-drop-order.rs:163:14
|
LL | let x = T::default();
| -
@ -170,7 +170,7 @@ LL | }
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
error: relative drop order changing in Rust 2024
--> $DIR/lint-tail-expr-drop-order.rs:178:5
--> $DIR/lint-tail-expr-drop-order.rs:177:5
|
LL | let x: Result<LoudDropper, ()> = Ok(LoudDropper);
| -
@ -190,14 +190,14 @@ LL | }
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
note: `#1` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:11:1
--> $DIR/lint-tail-expr-drop-order.rs:10:1
|
LL | / impl Drop for LoudDropper {
... |
LL | | }
| |_^
note: `x` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:11:1
--> $DIR/lint-tail-expr-drop-order.rs:10:1
|
LL | / impl Drop for LoudDropper {
... |
@ -206,7 +206,7 @@ LL | | }
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
error: relative drop order changing in Rust 2024
--> $DIR/lint-tail-expr-drop-order.rs:222:5
--> $DIR/lint-tail-expr-drop-order.rs:221:5
|
LL | let x = LoudDropper2;
| -
@ -226,7 +226,7 @@ LL | }
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
note: `#1` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:195:5
--> $DIR/lint-tail-expr-drop-order.rs:194:5
|
LL | / impl Drop for LoudDropper3 {
LL | |
@ -236,7 +236,7 @@ LL | | }
LL | | }
| |_____^
note: `x` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:207:5
--> $DIR/lint-tail-expr-drop-order.rs:206:5
|
LL | / impl Drop for LoudDropper2 {
LL | |
@ -248,7 +248,7 @@ LL | | }
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
error: relative drop order changing in Rust 2024
--> $DIR/lint-tail-expr-drop-order.rs:235:13
--> $DIR/lint-tail-expr-drop-order.rs:234:13
|
LL | LoudDropper.get()
| ^^^^^^^^^^^
@ -268,14 +268,14 @@ LL | ));
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
note: `#1` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:11:1
--> $DIR/lint-tail-expr-drop-order.rs:10:1
|
LL | / impl Drop for LoudDropper {
... |
LL | | }
| |_^
note: `_x` invokes this custom destructor
--> $DIR/lint-tail-expr-drop-order.rs:11:1
--> $DIR/lint-tail-expr-drop-order.rs:10:1
|
LL | / impl Drop for LoudDropper {
... |

View file

@ -1,5 +1,4 @@
//@ edition: 2021
//@ build-fail
// Make sure we don't ICE when emitting the "lint" drop statement
// used for tail_expr_drop_order.

View file

@ -1,5 +1,5 @@
error: relative drop order changing in Rust 2024
--> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:20:15
--> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:19:15
|
LL | match func().await {
| ^^^^^^^-----
@ -21,21 +21,21 @@ LL | }
= warning: this changes meaning in Rust 2024
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
note: `#2` invokes this custom destructor
--> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:10:1
--> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:9:1
|
LL | / impl std::ops::Drop for Drop {
LL | | fn drop(&mut self) {}
LL | | }
| |_^
note: `#1` invokes this custom destructor
--> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:10:1
--> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:9:1
|
LL | / impl std::ops::Drop for Drop {
LL | | fn drop(&mut self) {}
LL | | }
| |_^
note: `e` invokes this custom destructor
--> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:10:1
--> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:9:1
|
LL | / impl std::ops::Drop for Drop {
LL | | fn drop(&mut self) {}
@ -43,7 +43,7 @@ LL | | }
| |_^
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
note: the lint level is defined here
--> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:7:9
--> $DIR/tail_expr_drop_order-on-coroutine-unwind.rs:6:9
|
LL | #![deny(tail_expr_drop_order)]
| ^^^^^^^^^^^^^^^^^^^^

View file

@ -2,5 +2,7 @@
//~| ERROR E0452
//~| ERROR E0452
//~| ERROR E0452
//~| ERROR E0452
//~| ERROR E0452
fn main() {
}

View file

@ -28,6 +28,22 @@ LL | #![allow(foo = "")]
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 4 previous errors
error[E0452]: malformed lint attribute input
--> $DIR/E0452.rs:1:10
|
LL | #![allow(foo = "")]
| ^^^^^^^^ bad attribute argument
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0452]: malformed lint attribute input
--> $DIR/E0452.rs:1:10
|
LL | #![allow(foo = "")]
| ^^^^^^^^ bad attribute argument
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 6 previous errors
For more information about this error, try `rustc --explain E0452`.

View file

@ -7,6 +7,11 @@ error[E0602]: unknown lint tool: `unknown_tool`
= note: requested on the command line with `-A unknown_tool::foo`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
error[E0602]: unknown lint tool: `unknown_tool`
|
= note: requested on the command line with `-A unknown_tool::foo`
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0602`.

View file

@ -4,6 +4,10 @@ error[E0602]: `warnings` lint group is not supported with ´--force-warn´
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 2 previous errors
error[E0602]: `warnings` lint group is not supported with ´--force-warn´
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 3 previous errors
For more information about this error, try `rustc --explain E0602`.

View file

@ -3,4 +3,6 @@
//~| ERROR malformed lint attribute
//~| ERROR malformed lint attribute
//~| ERROR malformed lint attribute
//~| ERROR malformed lint attribute
//~| ERROR malformed lint attribute
fn main() { }

View file

@ -34,6 +34,22 @@ LL | #![allow(bar = "baz")]
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 5 previous errors
error[E0452]: malformed lint attribute input
--> $DIR/lint-malformed.rs:2:10
|
LL | #![allow(bar = "baz")]
| ^^^^^^^^^^^ bad attribute argument
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0452]: malformed lint attribute input
--> $DIR/lint-malformed.rs:2:10
|
LL | #![allow(bar = "baz")]
| ^^^^^^^^^^^ bad attribute argument
|
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 7 previous errors
For more information about this error, try `rustc --explain E0452`.

View file

@ -1,5 +1,6 @@
#![deny(foo::bar)] //~ ERROR unknown tool name `foo` found in scoped lint: `foo::bar`
//~| ERROR unknown tool name `foo` found in scoped lint: `foo::bar`
//~| ERROR unknown tool name `foo` found in scoped lint: `foo::bar`
#[allow(foo::bar)] //~ ERROR unknown tool name `foo` found in scoped lint: `foo::bar`
//~| ERROR unknown tool name `foo` found in scoped lint: `foo::bar`

View file

@ -7,7 +7,7 @@ LL | #![deny(foo::bar)]
= help: add `#![register_tool(foo)]` to the crate root
error[E0710]: unknown tool name `foo` found in scoped lint: `foo::bar`
--> $DIR/unknown-lint-tool-name.rs:4:9
--> $DIR/unknown-lint-tool-name.rs:5:9
|
LL | #[allow(foo::bar)]
| ^^^
@ -24,7 +24,7 @@ LL | #![deny(foo::bar)]
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error[E0710]: unknown tool name `foo` found in scoped lint: `foo::bar`
--> $DIR/unknown-lint-tool-name.rs:4:9
--> $DIR/unknown-lint-tool-name.rs:5:9
|
LL | #[allow(foo::bar)]
| ^^^
@ -32,6 +32,15 @@ LL | #[allow(foo::bar)]
= help: add `#![register_tool(foo)]` to the crate root
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 4 previous errors
error[E0710]: unknown tool name `foo` found in scoped lint: `foo::bar`
--> $DIR/unknown-lint-tool-name.rs:1:9
|
LL | #![deny(foo::bar)]
| ^^^
|
= help: add `#![register_tool(foo)]` to the crate root
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
error: aborting due to 5 previous errors
For more information about this error, try `rustc --explain E0710`.