Skip to content

Commit a3c147b

Browse files
Rollup merge of #113018 - asquared31415:test_fix, r=TaKO8Ki
Fix test for #96258 #98644 did not properly test enabling the problematic lint as a warning due to improper use of `compile-flags:` (missing `:`). This makes it use `#![warn]` instead, like in the reproducer. cc #96258
2 parents 758adf6 + 9dd655f commit a3c147b

2 files changed

+28
-3
lines changed

tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,4 @@
1-
// compile-flags -Wrust-2021-incompatible-closure-captures
1+
#![warn(rust_2021_incompatible_closure_captures)]
22

33
fn main() {}
44

@@ -9,7 +9,7 @@ impl Numberer {
99
//~^ ERROR `async fn` is not permitted in Rust 2015
1010
interval: Duration,
1111
//~^ ERROR cannot find type `Duration` in this scope
12-
) -> Numberer {
12+
) -> Numberer { //~WARN: changes to closure capture in Rust 2021
1313
Numberer {}
1414
}
1515
}

tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr

+26-1
Original file line numberDiff line numberDiff line change
@@ -18,7 +18,32 @@ help: consider importing this struct
1818
LL + use std::time::Duration;
1919
|
2020

21-
error: aborting due to 2 previous errors
21+
warning: changes to closure capture in Rust 2021 will affect drop order
22+
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs:12:19
23+
|
24+
LL | interval: Duration,
25+
| -------- in Rust 2018, this causes the closure to capture `interval`, but in Rust 2021, it has no effect
26+
LL |
27+
LL | ) -> Numberer {
28+
| _________________-_^
29+
| | |
30+
| | in Rust 2018, `interval` is dropped here along with the closure, but in Rust 2021 `interval` is not part of the closure
31+
LL | | Numberer {}
32+
LL | | }
33+
| |_____^
34+
|
35+
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/disjoint-capture-in-closures.html>
36+
note: the lint level is defined here
37+
--> $DIR/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.rs:1:9
38+
|
39+
LL | #![warn(rust_2021_incompatible_closure_captures)]
40+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
41+
help: add a dummy let to cause `interval` to be fully captured
42+
|
43+
LL | ) -> Numberer { let _ = &interval;
44+
| ++++++++++++++++++
45+
46+
error: aborting due to 2 previous errors; 1 warning emitted
2247

2348
Some errors have detailed explanations: E0412, E0670.
2449
For more information about an error, try `rustc --explain E0412`.

0 commit comments

Comments
 (0)