Skip to content

Commit 7cd9bf5

Browse files
committed
Auto merge of #7866 - rust-lang:edition-2021-tests, r=Manishearth
update most tests to 2021 edition Some tests would no longer work at all, so I added `edition:2015` or `edition:2018` to them. Notably 2021 panics are not yet detected correctly. Once ready, this closes #7842. --- changelog: none
2 parents 310ecb0 + a4ede72 commit 7cd9bf5

File tree

109 files changed

+525
-530
lines changed

Some content is hidden

Large Commits have some content hidden by default. Use the searchbox below for content that may be hidden.

109 files changed

+525
-530
lines changed

Cargo.toml

+1-1
Original file line numberDiff line numberDiff line change
@@ -28,7 +28,7 @@ tempfile = { version = "3.2", optional = true }
2828

2929
[dev-dependencies]
3030
cargo_metadata = "0.12"
31-
compiletest_rs = { version = "0.7", features = ["tmp"] }
31+
compiletest_rs = { version = "0.7.1", features = ["tmp"] }
3232
tester = "0.9"
3333
regex = "1.5"
3434
# This is used by the `collect-metadata` alias.

tests/compile-test.rs

+4-1
Original file line numberDiff line numberDiff line change
@@ -104,7 +104,10 @@ fn extern_flags() -> String {
104104
}
105105

106106
fn default_config() -> compiletest::Config {
107-
let mut config = compiletest::Config::default();
107+
let mut config = compiletest::Config {
108+
edition: Some("2021".into()),
109+
..compiletest::Config::default()
110+
};
108111

109112
if let Ok(filters) = env::var("TESTNAME") {
110113
config.filters = filters.split(',').map(std::string::ToString::to_string).collect();

tests/ui-toml/functions_maxlines/test.rs

-2
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,3 @@
1-
// edition:2018
2-
31
#![warn(clippy::too_many_lines)]
42

53
// This function should be considered one line.

tests/ui-toml/functions_maxlines/test.stderr

+4-4
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: this function has too many lines (2/1)
2-
--> $DIR/test.rs:20:1
2+
--> $DIR/test.rs:18:1
33
|
44
LL | / fn too_many_lines() {
55
LL | | println!("This is bad.");
@@ -10,7 +10,7 @@ LL | | }
1010
= note: `-D clippy::too-many-lines` implied by `-D warnings`
1111

1212
error: this function has too many lines (4/1)
13-
--> $DIR/test.rs:26:1
13+
--> $DIR/test.rs:24:1
1414
|
1515
LL | / async fn async_too_many_lines() {
1616
LL | | println!("This is bad.");
@@ -19,7 +19,7 @@ LL | | }
1919
| |_^
2020

2121
error: this function has too many lines (4/1)
22-
--> $DIR/test.rs:32:1
22+
--> $DIR/test.rs:30:1
2323
|
2424
LL | / fn closure_too_many_lines() {
2525
LL | | let _ = {
@@ -30,7 +30,7 @@ LL | | }
3030
| |_^
3131

3232
error: this function has too many lines (2/1)
33-
--> $DIR/test.rs:54:1
33+
--> $DIR/test.rs:52:1
3434
|
3535
LL | / fn comment_before_code() {
3636
LL | | let _ = "test";

tests/ui/assertions_on_constants.rs

+2-2
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//FIXME: suggestions are wrongly expanded, this should be fixed along with #7843
12
#![allow(non_fmt_panics)]
23

34
macro_rules! assert_const {
@@ -6,15 +7,14 @@ macro_rules! assert_const {
67
debug_assert!($len < 0);
78
};
89
}
9-
1010
fn main() {
1111
assert!(true);
1212
assert!(false);
1313
assert!(true, "true message");
1414
assert!(false, "false message");
1515

1616
let msg = "panic message";
17-
assert!(false, msg.to_uppercase());
17+
assert!(false, "{}", msg.to_uppercase());
1818

1919
const B: bool = true;
2020
assert!(B);

tests/ui/assertions_on_constants.stderr

+5-14
Original file line numberDiff line numberDiff line change
@@ -26,22 +26,13 @@ LL | assert!(true, "true message");
2626
= help: remove it
2727
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
2828

29-
error: `assert!(false, "false message")` should probably be replaced
29+
error: `assert!(false, $crate::const_format_args!($($t)+))` should probably be replaced
3030
--> $DIR/assertions_on_constants.rs:14:5
3131
|
3232
LL | assert!(false, "false message");
3333
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
3434
|
35-
= help: use `panic!("false message")` or `unreachable!("false message")`
36-
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
37-
38-
error: `assert!(false, msg.to_uppercase())` should probably be replaced
39-
--> $DIR/assertions_on_constants.rs:17:5
40-
|
41-
LL | assert!(false, msg.to_uppercase());
42-
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
43-
|
44-
= help: use `panic!(msg.to_uppercase())` or `unreachable!(msg.to_uppercase())`
35+
= help: use `panic!($crate::const_format_args!($($t)+))` or `unreachable!($crate::const_format_args!($($t)+))`
4536
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
4637

4738
error: `assert!(true)` will be optimized out by the compiler
@@ -62,13 +53,13 @@ LL | assert!(C);
6253
= help: use `panic!()` or `unreachable!()`
6354
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
6455

65-
error: `assert!(false, "C message")` should probably be replaced
56+
error: `assert!(false, $crate::const_format_args!($($t)+))` should probably be replaced
6657
--> $DIR/assertions_on_constants.rs:24:5
6758
|
6859
LL | assert!(C, "C message");
6960
| ^^^^^^^^^^^^^^^^^^^^^^^
7061
|
71-
= help: use `panic!("C message")` or `unreachable!("C message")`
62+
= help: use `panic!($crate::const_format_args!($($t)+))` or `unreachable!($crate::const_format_args!($($t)+))`
7263
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)
7364

7465
error: `debug_assert!(true)` will be optimized out by the compiler
@@ -80,5 +71,5 @@ LL | debug_assert!(true);
8071
= help: remove it
8172
= note: this error originates in the macro `$crate::assert` (in Nightly builds, run with -Z macro-backtrace for more info)
8273

83-
error: aborting due to 9 previous errors
74+
error: aborting due to 8 previous errors
8475

tests/ui/async_yields_async.fixed

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-rustfix
2-
// edition:2018
32

43
#![feature(async_closure)]
54
#![warn(clippy::async_yields_async)]

tests/ui/async_yields_async.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,4 @@
11
// run-rustfix
2-
// edition:2018
32

43
#![feature(async_closure)]
54
#![warn(clippy::async_yields_async)]

tests/ui/async_yields_async.stderr

+6-6
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: an async construct yields a type which is itself awaitable
2-
--> $DIR/async_yields_async.rs:40:9
2+
--> $DIR/async_yields_async.rs:39:9
33
|
44
LL | let _h = async {
55
| ____________________-
@@ -20,7 +20,7 @@ LL + }.await
2020
|
2121

2222
error: an async construct yields a type which is itself awaitable
23-
--> $DIR/async_yields_async.rs:45:9
23+
--> $DIR/async_yields_async.rs:44:9
2424
|
2525
LL | let _i = async {
2626
| ____________________-
@@ -33,7 +33,7 @@ LL | | };
3333
| |_____- outer async construct
3434

3535
error: an async construct yields a type which is itself awaitable
36-
--> $DIR/async_yields_async.rs:51:9
36+
--> $DIR/async_yields_async.rs:50:9
3737
|
3838
LL | let _j = async || {
3939
| _______________________-
@@ -53,7 +53,7 @@ LL + }.await
5353
|
5454

5555
error: an async construct yields a type which is itself awaitable
56-
--> $DIR/async_yields_async.rs:56:9
56+
--> $DIR/async_yields_async.rs:55:9
5757
|
5858
LL | let _k = async || {
5959
| _______________________-
@@ -66,7 +66,7 @@ LL | | };
6666
| |_____- outer async construct
6767

6868
error: an async construct yields a type which is itself awaitable
69-
--> $DIR/async_yields_async.rs:58:23
69+
--> $DIR/async_yields_async.rs:57:23
7070
|
7171
LL | let _l = async || CustomFutureType;
7272
| ^^^^^^^^^^^^^^^^
@@ -76,7 +76,7 @@ LL | let _l = async || CustomFutureType;
7676
| help: consider awaiting this value: `CustomFutureType.await`
7777

7878
error: an async construct yields a type which is itself awaitable
79-
--> $DIR/async_yields_async.rs:64:9
79+
--> $DIR/async_yields_async.rs:63:9
8080
|
8181
LL | let _m = async || {
8282
| _______________________-

tests/ui/await_holding_lock.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// edition:2018
21
#![warn(clippy::await_holding_lock)]
32

43
use std::sync::Mutex;

tests/ui/await_holding_lock.stderr

+8-8
Original file line numberDiff line numberDiff line change
@@ -1,26 +1,26 @@
11
error: this MutexGuard is held across an 'await' point. Consider using an async-aware Mutex type or ensuring the MutexGuard is dropped before calling await
2-
--> $DIR/await_holding_lock.rs:7:9
2+
--> $DIR/await_holding_lock.rs:6:9
33
|
44
LL | let guard = x.lock().unwrap();
55
| ^^^^^
66
|
77
= note: `-D clippy::await-holding-lock` implied by `-D warnings`
88
note: these are all the await points this lock is held through
9-
--> $DIR/await_holding_lock.rs:7:5
9+
--> $DIR/await_holding_lock.rs:6:5
1010
|
1111
LL | / let guard = x.lock().unwrap();
1212
LL | | baz().await
1313
LL | | }
1414
| |_^
1515

1616
error: this MutexGuard is held across an 'await' point. Consider using an async-aware Mutex type or ensuring the MutexGuard is dropped before calling await
17-
--> $DIR/await_holding_lock.rs:28:9
17+
--> $DIR/await_holding_lock.rs:27:9
1818
|
1919
LL | let guard = x.lock().unwrap();
2020
| ^^^^^
2121
|
2222
note: these are all the await points this lock is held through
23-
--> $DIR/await_holding_lock.rs:28:5
23+
--> $DIR/await_holding_lock.rs:27:5
2424
|
2525
LL | / let guard = x.lock().unwrap();
2626
LL | |
@@ -32,27 +32,27 @@ LL | | }
3232
| |_^
3333

3434
error: this MutexGuard is held across an 'await' point. Consider using an async-aware Mutex type or ensuring the MutexGuard is dropped before calling await
35-
--> $DIR/await_holding_lock.rs:41:13
35+
--> $DIR/await_holding_lock.rs:40:13
3636
|
3737
LL | let guard = x.lock().unwrap();
3838
| ^^^^^
3939
|
4040
note: these are all the await points this lock is held through
41-
--> $DIR/await_holding_lock.rs:41:9
41+
--> $DIR/await_holding_lock.rs:40:9
4242
|
4343
LL | / let guard = x.lock().unwrap();
4444
LL | | baz().await
4545
LL | | };
4646
| |_____^
4747

4848
error: this MutexGuard is held across an 'await' point. Consider using an async-aware Mutex type or ensuring the MutexGuard is dropped before calling await
49-
--> $DIR/await_holding_lock.rs:53:13
49+
--> $DIR/await_holding_lock.rs:52:13
5050
|
5151
LL | let guard = x.lock().unwrap();
5252
| ^^^^^
5353
|
5454
note: these are all the await points this lock is held through
55-
--> $DIR/await_holding_lock.rs:53:9
55+
--> $DIR/await_holding_lock.rs:52:9
5656
|
5757
LL | / let guard = x.lock().unwrap();
5858
LL | | baz().await

tests/ui/await_holding_refcell_ref.rs

-1
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// edition:2018
21
#![warn(clippy::await_holding_refcell_ref)]
32

43
use std::cell::RefCell;

tests/ui/await_holding_refcell_ref.stderr

+12-12
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,40 @@
11
error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await
2-
--> $DIR/await_holding_refcell_ref.rs:7:9
2+
--> $DIR/await_holding_refcell_ref.rs:6:9
33
|
44
LL | let b = x.borrow();
55
| ^
66
|
77
= note: `-D clippy::await-holding-refcell-ref` implied by `-D warnings`
88
note: these are all the await points this ref is held through
9-
--> $DIR/await_holding_refcell_ref.rs:7:5
9+
--> $DIR/await_holding_refcell_ref.rs:6:5
1010
|
1111
LL | / let b = x.borrow();
1212
LL | | baz().await
1313
LL | | }
1414
| |_^
1515

1616
error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await
17-
--> $DIR/await_holding_refcell_ref.rs:12:9
17+
--> $DIR/await_holding_refcell_ref.rs:11:9
1818
|
1919
LL | let b = x.borrow_mut();
2020
| ^
2121
|
2222
note: these are all the await points this ref is held through
23-
--> $DIR/await_holding_refcell_ref.rs:12:5
23+
--> $DIR/await_holding_refcell_ref.rs:11:5
2424
|
2525
LL | / let b = x.borrow_mut();
2626
LL | | baz().await
2727
LL | | }
2828
| |_^
2929

3030
error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await
31-
--> $DIR/await_holding_refcell_ref.rs:33:9
31+
--> $DIR/await_holding_refcell_ref.rs:32:9
3232
|
3333
LL | let b = x.borrow_mut();
3434
| ^
3535
|
3636
note: these are all the await points this ref is held through
37-
--> $DIR/await_holding_refcell_ref.rs:33:5
37+
--> $DIR/await_holding_refcell_ref.rs:32:5
3838
|
3939
LL | / let b = x.borrow_mut();
4040
LL | |
@@ -46,13 +46,13 @@ LL | | }
4646
| |_^
4747

4848
error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await
49-
--> $DIR/await_holding_refcell_ref.rs:45:9
49+
--> $DIR/await_holding_refcell_ref.rs:44:9
5050
|
5151
LL | let b = x.borrow_mut();
5252
| ^
5353
|
5454
note: these are all the await points this ref is held through
55-
--> $DIR/await_holding_refcell_ref.rs:45:5
55+
--> $DIR/await_holding_refcell_ref.rs:44:5
5656
|
5757
LL | / let b = x.borrow_mut();
5858
LL | |
@@ -64,27 +64,27 @@ LL | | }
6464
| |_^
6565

6666
error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await
67-
--> $DIR/await_holding_refcell_ref.rs:60:13
67+
--> $DIR/await_holding_refcell_ref.rs:59:13
6868
|
6969
LL | let b = x.borrow_mut();
7070
| ^
7171
|
7272
note: these are all the await points this ref is held through
73-
--> $DIR/await_holding_refcell_ref.rs:60:9
73+
--> $DIR/await_holding_refcell_ref.rs:59:9
7474
|
7575
LL | / let b = x.borrow_mut();
7676
LL | | baz().await
7777
LL | | };
7878
| |_____^
7979

8080
error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await
81-
--> $DIR/await_holding_refcell_ref.rs:72:13
81+
--> $DIR/await_holding_refcell_ref.rs:71:13
8282
|
8383
LL | let b = x.borrow_mut();
8484
| ^
8585
|
8686
note: these are all the await points this ref is held through
87-
--> $DIR/await_holding_refcell_ref.rs:72:9
87+
--> $DIR/await_holding_refcell_ref.rs:71:9
8888
|
8989
LL | / let b = x.borrow_mut();
9090
LL | | baz().await

tests/ui/crashes/ice-3969.rs

+2-3
Original file line numberDiff line numberDiff line change
@@ -7,7 +7,6 @@
77
// in type inference.
88
#![feature(trivial_bounds)]
99
#![allow(unused)]
10-
1110
trait A {}
1211

1312
impl A for i32 {}
@@ -22,9 +21,9 @@ where
2221

2322
fn unsized_local()
2423
where
25-
for<'a> Dst<A + 'a>: Sized,
24+
for<'a> Dst<dyn A + 'a>: Sized,
2625
{
27-
let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>);
26+
let x: Dst<dyn A> = *(Box::new(Dst { x: 1 }) as Box<Dst<dyn A>>);
2827
}
2928

3029
fn return_str() -> str

0 commit comments

Comments
 (0)