Skip to content

Commit c1dc00d

Browse files
committed
update most tests to 2021 edition
1 parent dbe167d commit c1dc00d

30 files changed

+166
-108
lines changed

Cargo.toml

Lines changed: 1 addition & 1 deletion
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

Lines changed: 4 additions & 1 deletion
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/assertions_on_constants.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//edition:2015
12
#![allow(non_fmt_panics)]
23

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

tests/ui/crashes/ice-3969.rs

Lines changed: 2 additions & 3 deletions
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

tests/ui/crashes/ice-3969.stderr

Lines changed: 24 additions & 20 deletions
Original file line numberDiff line numberDiff line change
@@ -1,30 +1,34 @@
1-
error: trait objects without an explicit `dyn` are deprecated
2-
--> $DIR/ice-3969.rs:25:17
1+
error: trait bound str: std::marker::Sized does not depend on any type or lifetime parameters
2+
--> $DIR/ice-3969.rs:20:10
33
|
4-
LL | for<'a> Dst<A + 'a>: Sized,
5-
| ^^^^^^ help: use `dyn`: `dyn A + 'a`
4+
LL | str: Sized;
5+
| ^^^^^
66
|
7-
= note: `-D bare-trait-objects` implied by `-D warnings`
8-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
9-
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
7+
= note: `-D trivial-bounds` implied by `-D warnings`
108

11-
error: trait objects without an explicit `dyn` are deprecated
12-
--> $DIR/ice-3969.rs:27:16
9+
error: trait bound for<'a> Dst<(dyn A + 'a)>: std::marker::Sized does not depend on any type or lifetime parameters
10+
--> $DIR/ice-3969.rs:24:30
1311
|
14-
LL | let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>);
15-
| ^ help: use `dyn`: `dyn A`
12+
LL | for<'a> Dst<dyn A + 'a>: Sized,
13+
| ^^^^^
14+
15+
error: trait bound str: std::marker::Sized does not depend on any type or lifetime parameters
16+
--> $DIR/ice-3969.rs:31:10
1617
|
17-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
18-
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
18+
LL | str: Sized,
19+
| ^^^^^
1920

20-
error: trait objects without an explicit `dyn` are deprecated
21-
--> $DIR/ice-3969.rs:27:57
21+
error: trait bound std::string::String: std::ops::Neg does not depend on any type or lifetime parameters
22+
--> $DIR/ice-3969.rs:38:13
2223
|
23-
LL | let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>);
24-
| ^ help: use `dyn`: `dyn A`
24+
LL | String: ::std::ops::Neg<Output = String>,
25+
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
26+
27+
error: trait bound i32: std::iter::Iterator does not depend on any type or lifetime parameters
28+
--> $DIR/ice-3969.rs:45:10
2529
|
26-
= warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021!
27-
= note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2021/warnings-promoted-to-error.html>
30+
LL | i32: Iterator,
31+
| ^^^^^^^^
2832

29-
error: aborting due to 3 previous errors
33+
error: aborting due to 5 previous errors
3034

tests/ui/crashes/ice-6252.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
// originally from glacier fixed/77919.rs
22
// encountered errors resolving bounds after type-checking
3-
43
trait TypeVal<T> {
54
const VAL: T;
65
}

tests/ui/crashes/ice-6252.stderr

Lines changed: 8 additions & 4 deletions
Original file line numberDiff line numberDiff line change
@@ -1,24 +1,28 @@
11
error[E0412]: cannot find type `PhantomData` in this scope
2-
--> $DIR/ice-6252.rs:9:9
2+
--> $DIR/ice-6252.rs:8:9
33
|
44
LL | _n: PhantomData,
55
| ^^^^^^^^^^^ not found in this scope
66
|
7-
help: consider importing this struct
7+
help: consider importing one of these items
8+
|
9+
LL | use serde::export::PhantomData;
810
|
911
LL | use std::marker::PhantomData;
1012
|
13+
LL | use core::marker::PhantomData;
14+
|
1115

1216
error[E0412]: cannot find type `VAL` in this scope
13-
--> $DIR/ice-6252.rs:11:63
17+
--> $DIR/ice-6252.rs:10:63
1418
|
1519
LL | impl<N, M> TypeVal<usize> for Multiply<N, M> where N: TypeVal<VAL> {}
1620
| - ^^^ not found in this scope
1721
| |
1822
| help: you might be missing a type parameter: `, VAL`
1923

2024
error[E0046]: not all trait items implemented, missing: `VAL`
21-
--> $DIR/ice-6252.rs:11:1
25+
--> $DIR/ice-6252.rs:10:1
2226
|
2327
LL | const VAL: T;
2428
| ------------- `VAL` from trait

tests/ui/debug_assert_with_mut_call.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1-
// compile-flags: --edition=2018
21
#![feature(custom_inner_attributes)]
32
#![rustfmt::skip]
43
#![warn(clippy::debug_assert_with_mut_call)]
54
#![allow(clippy::redundant_closure_call)]
65

6+
77
struct S;
88

99
impl S {

tests/ui/diverging_sub_expression.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,5 @@
11
#![warn(clippy::diverging_sub_expression)]
22
#![allow(clippy::match_same_arms, clippy::logic_bug)]
3-
43
#[allow(clippy::empty_loop)]
54
fn diverge() -> ! {
65
loop {}
Lines changed: 15 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,40 +1,48 @@
11
error: sub-expression diverges
2-
--> $DIR/diverging_sub_expression.rs:20:10
2+
--> $DIR/diverging_sub_expression.rs:19:10
33
|
44
LL | b || diverge();
55
| ^^^^^^^^^
66
|
77
= note: `-D clippy::diverging-sub-expression` implied by `-D warnings`
88

99
error: sub-expression diverges
10-
--> $DIR/diverging_sub_expression.rs:21:10
10+
--> $DIR/diverging_sub_expression.rs:20:10
1111
|
1212
LL | b || A.foo();
1313
| ^^^^^^^
1414

1515
error: sub-expression diverges
16-
--> $DIR/diverging_sub_expression.rs:30:26
16+
--> $DIR/diverging_sub_expression.rs:29:26
1717
|
1818
LL | 6 => true || return,
1919
| ^^^^^^
2020

2121
error: sub-expression diverges
22-
--> $DIR/diverging_sub_expression.rs:31:26
22+
--> $DIR/diverging_sub_expression.rs:30:26
2323
|
2424
LL | 7 => true || continue,
2525
| ^^^^^^^^
2626

2727
error: sub-expression diverges
28-
--> $DIR/diverging_sub_expression.rs:34:26
28+
--> $DIR/diverging_sub_expression.rs:33:26
2929
|
3030
LL | 3 => true || diverge(),
3131
| ^^^^^^^^^
3232

3333
error: sub-expression diverges
34-
--> $DIR/diverging_sub_expression.rs:39:26
34+
--> $DIR/diverging_sub_expression.rs:36:30
35+
|
36+
LL | _ => true || panic!("boo"),
37+
| ^^^^^^^^^^^^^
38+
|
39+
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
40+
41+
error: sub-expression diverges
42+
--> $DIR/diverging_sub_expression.rs:38:26
3543
|
3644
LL | _ => true || break,
3745
| ^^^^^
3846

39-
error: aborting due to 6 previous errors
47+
error: aborting due to 7 previous errors
4048

tests/ui/fallible_impl_from.stderr

Lines changed: 3 additions & 3 deletions
Original file line numberDiff line numberDiff line change
@@ -38,7 +38,7 @@ note: potential failure(s)
3838
|
3939
LL | panic!();
4040
| ^^^^^^^^
41-
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
41+
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
4242

4343
error: consider implementing `TryFrom` instead
4444
--> $DIR/fallible_impl_from.rs:35:1
@@ -65,7 +65,7 @@ LL | } else if s.parse::<u32>().unwrap() != 42 {
6565
| ^^^^^^^^^^^^^^^^^^^^^^^^^
6666
LL | panic!("{:?}", s);
6767
| ^^^^^^^^^^^^^^^^^
68-
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
68+
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
6969

7070
error: consider implementing `TryFrom` instead
7171
--> $DIR/fallible_impl_from.rs:53:1
@@ -87,7 +87,7 @@ LL | if s.parse::<u32>().ok().unwrap() != 42 {
8787
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
8888
LL | panic!("{:?}", s);
8989
| ^^^^^^^^^^^^^^^^^
90-
= note: this error originates in the macro `$crate::panic::panic_2015` (in Nightly builds, run with -Z macro-backtrace for more info)
90+
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
9191

9292
error: aborting due to 4 previous errors
9393

tests/ui/issue-7447.stderr

Lines changed: 19 additions & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -0,0 +1,19 @@
1+
error: sub-expression diverges
2+
--> $DIR/issue-7447.rs:23:15
3+
|
4+
LL | byte_view(panic!());
5+
| ^^^^^^^^
6+
|
7+
= note: `-D clippy::diverging-sub-expression` implied by `-D warnings`
8+
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
9+
10+
error: sub-expression diverges
11+
--> $DIR/issue-7447.rs:24:19
12+
|
13+
LL | group_entries(panic!());
14+
| ^^^^^^^^
15+
|
16+
= note: this error originates in the macro `$crate::panic::panic_2021` (in Nightly builds, run with -Z macro-backtrace for more info)
17+
18+
error: aborting due to 2 previous errors
19+

tests/ui/macro_use_imports.fixed

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// compile-flags: --edition 2018
21
// aux-build:macro_rules.rs
32
// aux-build:macro_use_helper.rs
43
// aux-build:proc_macro_derive.rs

tests/ui/macro_use_imports.rs

Lines changed: 0 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,4 +1,3 @@
1-
// compile-flags: --edition 2018
21
// aux-build:macro_rules.rs
32
// aux-build:macro_use_helper.rs
43
// aux-build:proc_macro_derive.rs

tests/ui/macro_use_imports.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,28 +1,28 @@
11
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
2-
--> $DIR/macro_use_imports.rs:19:5
2+
--> $DIR/macro_use_imports.rs:18:5
33
|
44
LL | #[macro_use]
55
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{pub_macro, inner_mod_macro, function_macro, ty_macro, pub_in_private_macro};`
66
|
77
= note: `-D clippy::macro-use-imports` implied by `-D warnings`
88

99
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
10-
--> $DIR/macro_use_imports.rs:25:5
10+
--> $DIR/macro_use_imports.rs:20:5
1111
|
1212
LL | #[macro_use]
13-
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;`
13+
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;`
1414

1515
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
16-
--> $DIR/macro_use_imports.rs:21:5
16+
--> $DIR/macro_use_imports.rs:22:5
1717
|
1818
LL | #[macro_use]
19-
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mini_mac::ClippyMiniMacroTest;`
19+
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::foofoo, inner::try_err};`
2020

2121
error: `macro_use` attributes are no longer needed in the Rust 2018 edition
22-
--> $DIR/macro_use_imports.rs:23:5
22+
--> $DIR/macro_use_imports.rs:24:5
2323
|
2424
LL | #[macro_use]
25-
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::{inner::foofoo, inner::try_err};`
25+
| ^^^^^^^^^^^^ help: remove the attribute and import the macro directly, try: `use mac::inner::nested::string_add;`
2626

2727
error: aborting due to 4 previous errors
2828

tests/ui/manual_assert.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// edition:2018
12
// run-rustfix
23
#![warn(clippy::manual_assert)]
34

tests/ui/manual_assert.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// edition:2018
12
// run-rustfix
23
#![warn(clippy::manual_assert)]
34

tests/ui/manual_assert.stderr

Lines changed: 7 additions & 7 deletions
Original file line numberDiff line numberDiff line change
@@ -1,5 +1,5 @@
11
error: only a `panic!` in `if`-then statement
2-
--> $DIR/manual_assert.rs:19:5
2+
--> $DIR/manual_assert.rs:20:5
33
|
44
LL | / if !a.is_empty() {
55
LL | | panic!("qaqaq{:?}", a);
@@ -9,47 +9,47 @@ LL | | }
99
= note: `-D clippy::manual-assert` implied by `-D warnings`
1010

1111
error: only a `panic!` in `if`-then statement
12-
--> $DIR/manual_assert.rs:22:5
12+
--> $DIR/manual_assert.rs:23:5
1313
|
1414
LL | / if !a.is_empty() {
1515
LL | | panic!("qwqwq");
1616
LL | | }
1717
| |_____^ help: try: `assert!(a.is_empty(), "qwqwq");`
1818

1919
error: only a `panic!` in `if`-then statement
20-
--> $DIR/manual_assert.rs:39:5
20+
--> $DIR/manual_assert.rs:40:5
2121
|
2222
LL | / if b.is_empty() {
2323
LL | | panic!("panic1");
2424
LL | | }
2525
| |_____^ help: try: `assert!(!b.is_empty(), "panic1");`
2626

2727
error: only a `panic!` in `if`-then statement
28-
--> $DIR/manual_assert.rs:42:5
28+
--> $DIR/manual_assert.rs:43:5
2929
|
3030
LL | / if b.is_empty() && a.is_empty() {
3131
LL | | panic!("panic2");
3232
LL | | }
3333
| |_____^ help: try: `assert!(!(b.is_empty() && a.is_empty()), "panic2");`
3434

3535
error: only a `panic!` in `if`-then statement
36-
--> $DIR/manual_assert.rs:45:5
36+
--> $DIR/manual_assert.rs:46:5
3737
|
3838
LL | / if a.is_empty() && !b.is_empty() {
3939
LL | | panic!("panic3");
4040
LL | | }
4141
| |_____^ help: try: `assert!(!(a.is_empty() && !b.is_empty()), "panic3");`
4242

4343
error: only a `panic!` in `if`-then statement
44-
--> $DIR/manual_assert.rs:48:5
44+
--> $DIR/manual_assert.rs:49:5
4545
|
4646
LL | / if b.is_empty() || a.is_empty() {
4747
LL | | panic!("panic4");
4848
LL | | }
4949
| |_____^ help: try: `assert!(!(b.is_empty() || a.is_empty()), "panic4");`
5050

5151
error: only a `panic!` in `if`-then statement
52-
--> $DIR/manual_assert.rs:51:5
52+
--> $DIR/manual_assert.rs:52:5
5353
|
5454
LL | / if a.is_empty() || !b.is_empty() {
5555
LL | | panic!("panic5");

0 commit comments

Comments
 (0)