Skip to content

Commit e801bfe

Browse files
committed
Auto merge of rust-lang#134493 - compiler-errors:drops-elaborated, r=oli-obk
Always run `tail_expr_drop_order` lint in promoted MIR query Rather than running the lint at the beginning of `mir_drops_elaborated_and_const_checked`, run it at the end of `mir_promoted`. This should ensure that the lint gets picked up when running `cargo fix`, which runs with `--emit metadata` and therefore doesn't actually query `mir_drops_elaborated_and_const_checked`. We could probably push this down into `mir_built` too? but I don't really see a good reason to do so. rust-lang#132861 (comment) cc `@ehuss`
2 parents 54dcff1 + 8ccdd12 commit e801bfe

11 files changed

+87
-32
lines changed

Diff for: compiler/rustc_mir_transform/src/lib.rs

+2-1
Original file line numberDiff line numberDiff line change
@@ -437,6 +437,8 @@ fn mir_promoted(
437437
Some(MirPhase::Analysis(AnalysisPhase::Initial)),
438438
);
439439

440+
lint_tail_expr_drop_order::run_lint(tcx, def, &body);
441+
440442
let promoted = promote_pass.promoted_fragments.into_inner();
441443
(tcx.alloc_steal_mir(body), tcx.alloc_steal_promoted(promoted))
442444
}
@@ -492,7 +494,6 @@ fn mir_drops_elaborated_and_const_checked(tcx: TyCtxt<'_>, def: LocalDefId) -> &
492494
}
493495

494496
let (body, _) = tcx.mir_promoted(def);
495-
lint_tail_expr_drop_order::run_lint(tcx, def, &body.borrow());
496497
let mut body = body.steal();
497498

498499
if let Some(error_reported) = tainted_by_errors {

Diff for: tests/ui/drop/lint-tail-expr-drop-order.rs

-1
Original file line numberDiff line numberDiff line change
@@ -2,7 +2,6 @@
22
// This lint is to capture potential change in program semantics
33
// due to implementation of RFC 3606 <https://github.com/rust-lang/rfcs/pull/3606>
44
//@ edition: 2021
5-
//@ build-fail
65

76
#![deny(tail_expr_drop_order)] //~ NOTE: the lint level is defined here
87
#![allow(dropping_copy_types)]

Diff for: tests/ui/drop/lint-tail-expr-drop-order.stderr

+23-23
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: relative drop order changing in Rust 2024
2-
--> $DIR/lint-tail-expr-drop-order.rs:42:15
2+
--> $DIR/lint-tail-expr-drop-order.rs:41:15
33
|
44
LL | let x = LoudDropper;
55
| -
@@ -19,28 +19,28 @@ LL | }
1919
= warning: this changes meaning in Rust 2024
2020
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
2121
note: `#1` invokes this custom destructor
22-
--> $DIR/lint-tail-expr-drop-order.rs:11:1
22+
--> $DIR/lint-tail-expr-drop-order.rs:10:1
2323
|
2424
LL | / impl Drop for LoudDropper {
2525
... |
2626
LL | | }
2727
| |_^
2828
note: `x` invokes this custom destructor
29-
--> $DIR/lint-tail-expr-drop-order.rs:11:1
29+
--> $DIR/lint-tail-expr-drop-order.rs:10:1
3030
|
3131
LL | / impl Drop for LoudDropper {
3232
... |
3333
LL | | }
3434
| |_^
3535
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
3636
note: the lint level is defined here
37-
--> $DIR/lint-tail-expr-drop-order.rs:7:9
37+
--> $DIR/lint-tail-expr-drop-order.rs:6:9
3838
|
3939
LL | #![deny(tail_expr_drop_order)]
4040
| ^^^^^^^^^^^^^^^^^^^^
4141

4242
error: relative drop order changing in Rust 2024
43-
--> $DIR/lint-tail-expr-drop-order.rs:67:19
43+
--> $DIR/lint-tail-expr-drop-order.rs:66:19
4444
|
4545
LL | let x = LoudDropper;
4646
| -
@@ -60,14 +60,14 @@ LL | }
6060
= warning: this changes meaning in Rust 2024
6161
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
6262
note: `#1` invokes this custom destructor
63-
--> $DIR/lint-tail-expr-drop-order.rs:11:1
63+
--> $DIR/lint-tail-expr-drop-order.rs:10:1
6464
|
6565
LL | / impl Drop for LoudDropper {
6666
... |
6767
LL | | }
6868
| |_^
6969
note: `x` invokes this custom destructor
70-
--> $DIR/lint-tail-expr-drop-order.rs:11:1
70+
--> $DIR/lint-tail-expr-drop-order.rs:10:1
7171
|
7272
LL | / impl Drop for LoudDropper {
7373
... |
@@ -76,7 +76,7 @@ LL | | }
7676
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
7777

7878
error: relative drop order changing in Rust 2024
79-
--> $DIR/lint-tail-expr-drop-order.rs:94:7
79+
--> $DIR/lint-tail-expr-drop-order.rs:93:7
8080
|
8181
LL | let x = LoudDropper;
8282
| -
@@ -96,14 +96,14 @@ LL | }
9696
= warning: this changes meaning in Rust 2024
9797
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
9898
note: `#1` invokes this custom destructor
99-
--> $DIR/lint-tail-expr-drop-order.rs:11:1
99+
--> $DIR/lint-tail-expr-drop-order.rs:10:1
100100
|
101101
LL | / impl Drop for LoudDropper {
102102
... |
103103
LL | | }
104104
| |_^
105105
note: `x` invokes this custom destructor
106-
--> $DIR/lint-tail-expr-drop-order.rs:11:1
106+
--> $DIR/lint-tail-expr-drop-order.rs:10:1
107107
|
108108
LL | / impl Drop for LoudDropper {
109109
... |
@@ -112,7 +112,7 @@ LL | | }
112112
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
113113

114114
error: relative drop order changing in Rust 2024
115-
--> $DIR/lint-tail-expr-drop-order.rs:147:5
115+
--> $DIR/lint-tail-expr-drop-order.rs:146:5
116116
|
117117
LL | let future = f();
118118
| ------
@@ -132,14 +132,14 @@ LL | }
132132
= warning: this changes meaning in Rust 2024
133133
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
134134
note: `#1` invokes this custom destructor
135-
--> $DIR/lint-tail-expr-drop-order.rs:11:1
135+
--> $DIR/lint-tail-expr-drop-order.rs:10:1
136136
|
137137
LL | / impl Drop for LoudDropper {
138138
... |
139139
LL | | }
140140
| |_^
141141
note: `future` invokes this custom destructor
142-
--> $DIR/lint-tail-expr-drop-order.rs:11:1
142+
--> $DIR/lint-tail-expr-drop-order.rs:10:1
143143
|
144144
LL | / impl Drop for LoudDropper {
145145
... |
@@ -148,7 +148,7 @@ LL | | }
148148
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
149149

150150
error: relative drop order changing in Rust 2024
151-
--> $DIR/lint-tail-expr-drop-order.rs:164:14
151+
--> $DIR/lint-tail-expr-drop-order.rs:163:14
152152
|
153153
LL | let x = T::default();
154154
| -
@@ -170,7 +170,7 @@ LL | }
170170
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
171171

172172
error: relative drop order changing in Rust 2024
173-
--> $DIR/lint-tail-expr-drop-order.rs:178:5
173+
--> $DIR/lint-tail-expr-drop-order.rs:177:5
174174
|
175175
LL | let x: Result<LoudDropper, ()> = Ok(LoudDropper);
176176
| -
@@ -190,14 +190,14 @@ LL | }
190190
= warning: this changes meaning in Rust 2024
191191
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
192192
note: `#1` invokes this custom destructor
193-
--> $DIR/lint-tail-expr-drop-order.rs:11:1
193+
--> $DIR/lint-tail-expr-drop-order.rs:10:1
194194
|
195195
LL | / impl Drop for LoudDropper {
196196
... |
197197
LL | | }
198198
| |_^
199199
note: `x` invokes this custom destructor
200-
--> $DIR/lint-tail-expr-drop-order.rs:11:1
200+
--> $DIR/lint-tail-expr-drop-order.rs:10:1
201201
|
202202
LL | / impl Drop for LoudDropper {
203203
... |
@@ -206,7 +206,7 @@ LL | | }
206206
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
207207

208208
error: relative drop order changing in Rust 2024
209-
--> $DIR/lint-tail-expr-drop-order.rs:222:5
209+
--> $DIR/lint-tail-expr-drop-order.rs:221:5
210210
|
211211
LL | let x = LoudDropper2;
212212
| -
@@ -226,7 +226,7 @@ LL | }
226226
= warning: this changes meaning in Rust 2024
227227
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
228228
note: `#1` invokes this custom destructor
229-
--> $DIR/lint-tail-expr-drop-order.rs:195:5
229+
--> $DIR/lint-tail-expr-drop-order.rs:194:5
230230
|
231231
LL | / impl Drop for LoudDropper3 {
232232
LL | |
@@ -236,7 +236,7 @@ LL | | }
236236
LL | | }
237237
| |_____^
238238
note: `x` invokes this custom destructor
239-
--> $DIR/lint-tail-expr-drop-order.rs:207:5
239+
--> $DIR/lint-tail-expr-drop-order.rs:206:5
240240
|
241241
LL | / impl Drop for LoudDropper2 {
242242
LL | |
@@ -248,7 +248,7 @@ LL | | }
248248
= note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages
249249

250250
error: relative drop order changing in Rust 2024
251-
--> $DIR/lint-tail-expr-drop-order.rs:235:13
251+
--> $DIR/lint-tail-expr-drop-order.rs:234:13
252252
|
253253
LL | LoudDropper.get()
254254
| ^^^^^^^^^^^
@@ -268,14 +268,14 @@ LL | ));
268268
= warning: this changes meaning in Rust 2024
269269
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html>
270270
note: `#1` invokes this custom destructor
271-
--> $DIR/lint-tail-expr-drop-order.rs:11:1
271+
--> $DIR/lint-tail-expr-drop-order.rs:10:1
272272
|
273273
LL | / impl Drop for LoudDropper {
274274
... |
275275
LL | | }
276276
| |_^
277277
note: `_x` invokes this custom destructor
278-
--> $DIR/lint-tail-expr-drop-order.rs:11:1
278+
--> $DIR/lint-tail-expr-drop-order.rs:10:1
279279
|
280280
LL | / impl Drop for LoudDropper {
281281
... |

Diff for: tests/ui/error-codes/E0452.rs

+2
Original file line numberDiff line numberDiff line change
@@ -2,5 +2,7 @@
22
//~| ERROR E0452
33
//~| ERROR E0452
44
//~| ERROR E0452
5+
//~| ERROR E0452
6+
//~| ERROR E0452
57
fn main() {
68
}

Diff for: tests/ui/error-codes/E0452.stderr

+17-1
Original file line numberDiff line numberDiff line change
@@ -28,6 +28,22 @@ LL | #![allow(foo = "")]
2828
|
2929
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3030

31-
error: aborting due to 4 previous errors
31+
error[E0452]: malformed lint attribute input
32+
--> $DIR/E0452.rs:1:10
33+
|
34+
LL | #![allow(foo = "")]
35+
| ^^^^^^^^ bad attribute argument
36+
|
37+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
38+
39+
error[E0452]: malformed lint attribute input
40+
--> $DIR/E0452.rs:1:10
41+
|
42+
LL | #![allow(foo = "")]
43+
| ^^^^^^^^ bad attribute argument
44+
|
45+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
46+
47+
error: aborting due to 6 previous errors
3248

3349
For more information about this error, try `rustc --explain E0452`.

Diff for: tests/ui/lint/command-line-register-unknown-lint-tool.stderr

+6-1
Original file line numberDiff line numberDiff line change
@@ -7,6 +7,11 @@ error[E0602]: unknown lint tool: `unknown_tool`
77
= note: requested on the command line with `-A unknown_tool::foo`
88
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
99

10-
error: aborting due to 2 previous errors
10+
error[E0602]: unknown lint tool: `unknown_tool`
11+
|
12+
= note: requested on the command line with `-A unknown_tool::foo`
13+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
14+
15+
error: aborting due to 3 previous errors
1116

1217
For more information about this error, try `rustc --explain E0602`.

Diff for: tests/ui/lint/force-warn/warnings-lint-group.stderr

+5-1
Original file line numberDiff line numberDiff line change
@@ -4,6 +4,10 @@ error[E0602]: `warnings` lint group is not supported with ´--force-warn´
44
|
55
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
66

7-
error: aborting due to 2 previous errors
7+
error[E0602]: `warnings` lint group is not supported with ´--force-warn´
8+
|
9+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
10+
11+
error: aborting due to 3 previous errors
812

913
For more information about this error, try `rustc --explain E0602`.

Diff for: tests/ui/lint/lint-malformed.rs

+2
Original file line numberDiff line numberDiff line change
@@ -3,4 +3,6 @@
33
//~| ERROR malformed lint attribute
44
//~| ERROR malformed lint attribute
55
//~| ERROR malformed lint attribute
6+
//~| ERROR malformed lint attribute
7+
//~| ERROR malformed lint attribute
68
fn main() { }

Diff for: tests/ui/lint/lint-malformed.stderr

+17-1
Original file line numberDiff line numberDiff line change
@@ -34,6 +34,22 @@ LL | #![allow(bar = "baz")]
3434
|
3535
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3636

37-
error: aborting due to 5 previous errors
37+
error[E0452]: malformed lint attribute input
38+
--> $DIR/lint-malformed.rs:2:10
39+
|
40+
LL | #![allow(bar = "baz")]
41+
| ^^^^^^^^^^^ bad attribute argument
42+
|
43+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
44+
45+
error[E0452]: malformed lint attribute input
46+
--> $DIR/lint-malformed.rs:2:10
47+
|
48+
LL | #![allow(bar = "baz")]
49+
| ^^^^^^^^^^^ bad attribute argument
50+
|
51+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
52+
53+
error: aborting due to 7 previous errors
3854

3955
For more information about this error, try `rustc --explain E0452`.

Diff for: tests/ui/tool-attributes/unknown-lint-tool-name.rs

+1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,6 @@
11
#![deny(foo::bar)] //~ ERROR unknown tool name `foo` found in scoped lint: `foo::bar`
22
//~| ERROR unknown tool name `foo` found in scoped lint: `foo::bar`
3+
//~| ERROR unknown tool name `foo` found in scoped lint: `foo::bar`
34

45
#[allow(foo::bar)] //~ ERROR unknown tool name `foo` found in scoped lint: `foo::bar`
56
//~| ERROR unknown tool name `foo` found in scoped lint: `foo::bar`

Diff for: tests/ui/tool-attributes/unknown-lint-tool-name.stderr

+12-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,7 @@ LL | #![deny(foo::bar)]
77
= help: add `#![register_tool(foo)]` to the crate root
88

99
error[E0710]: unknown tool name `foo` found in scoped lint: `foo::bar`
10-
--> $DIR/unknown-lint-tool-name.rs:4:9
10+
--> $DIR/unknown-lint-tool-name.rs:5:9
1111
|
1212
LL | #[allow(foo::bar)]
1313
| ^^^
@@ -24,14 +24,23 @@ LL | #![deny(foo::bar)]
2424
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
2525

2626
error[E0710]: unknown tool name `foo` found in scoped lint: `foo::bar`
27-
--> $DIR/unknown-lint-tool-name.rs:4:9
27+
--> $DIR/unknown-lint-tool-name.rs:5:9
2828
|
2929
LL | #[allow(foo::bar)]
3030
| ^^^
3131
|
3232
= help: add `#![register_tool(foo)]` to the crate root
3333
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
3434

35-
error: aborting due to 4 previous errors
35+
error[E0710]: unknown tool name `foo` found in scoped lint: `foo::bar`
36+
--> $DIR/unknown-lint-tool-name.rs:1:9
37+
|
38+
LL | #![deny(foo::bar)]
39+
| ^^^
40+
|
41+
= help: add `#![register_tool(foo)]` to the crate root
42+
= note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no`
43+
44+
error: aborting due to 5 previous errors
3645

3746
For more information about this error, try `rustc --explain E0710`.

0 commit comments

Comments
 (0)