Skip to content

Commit eb07369

Browse files
committed
update most tests to 2021 edition
1 parent df65291 commit eb07369

25 files changed

+91
-55
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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
//edition:2015
12
// https://github.com/rust-lang/rust-clippy/issues/3969
23
// used to crash: error: internal compiler error:
34
// src/librustc_traits/normalize_erasing_regions.rs:43: could not fully normalize `<i32 as
@@ -7,7 +8,6 @@
78
// in type inference.
89
#![feature(trivial_bounds)]
910
#![allow(unused)]
10-
1111
trait A {}
1212

1313
impl A for i32 {}

tests/ui/crashes/ice-6252.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
//edition:2015
12
// originally from glacier fixed/77919.rs
23
// encountered errors resolving bounds after type-checking
3-
44
trait TypeVal<T> {
55
const VAL: T;
66
}

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: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
//edition:2015
12
#![warn(clippy::diverging_sub_expression)]
23
#![allow(clippy::match_same_arms, clippy::logic_bug)]
3-
44
#[allow(clippy::empty_loop)]
55
fn diverge() -> ! {
66
loop {}

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:36: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:54: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/if_then_panic.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::if_then_panic)]
34

tests/ui/if_then_panic.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::if_then_panic)]
34

tests/ui/if_then_panic.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/if_then_panic.rs:19:5
2+
--> $DIR/if_then_panic.rs:20:5
33
|
44
LL | / if !a.is_empty() {
55
LL | | panic!("qaqaq{:?}", a);
@@ -9,47 +9,47 @@ LL | | }
99
= note: `-D clippy::if-then-panic` implied by `-D warnings`
1010

1111
error: only a `panic!` in `if`-then statement
12-
--> $DIR/if_then_panic.rs:22:5
12+
--> $DIR/if_then_panic.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/if_then_panic.rs:39:5
20+
--> $DIR/if_then_panic.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/if_then_panic.rs:42:5
28+
--> $DIR/if_then_panic.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/if_then_panic.rs:45:5
36+
--> $DIR/if_then_panic.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/if_then_panic.rs:48:5
44+
--> $DIR/if_then_panic.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/if_then_panic.rs:51:5
52+
--> $DIR/if_then_panic.rs:52:5
5353
|
5454
LL | / if a.is_empty() || !b.is_empty() {
5555
LL | | panic!("panic5");

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/match_wild_err_arm.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,10 +1,10 @@
1+
//edition:2015
12
#![feature(exclusive_range_pattern)]
23
#![allow(clippy::match_same_arms)]
34
#![warn(clippy::match_wild_err_arm)]
45

56
fn match_wild_err_arm() {
67
let x: Result<i32, &str> = Ok(3);
7-
88
match x {
99
Ok(3) => println!("ok"),
1010
Ok(_) => println!("ok"),

tests/ui/missing-doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,9 +1,9 @@
1+
//edition:2015
12
#![warn(clippy::missing_docs_in_private_items)]
23
// When denying at the crate level, be sure to not get random warnings from the
34
// injected intrinsics by the compiler.
45
#![allow(dead_code)]
56
#![feature(global_asm)]
6-
77
//! Some garbage docs for the crate here
88
#![doc = "More garbage"]
99

tests/ui/missing_panics_doc.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
//edition:2015
12
#![warn(clippy::missing_panics_doc)]
23
#![allow(clippy::option_map_unit_fn)]
3-
44
fn main() {}
55

66
/// This needs to be documented

tests/ui/non_expressive_names.rs

Lines changed: 2 additions & 2 deletions
Original file line numberDiff line numberDiff line change
@@ -15,8 +15,8 @@ struct InstSplit {
1515
impl MaybeInst {
1616
fn fill(&mut self) {
1717
let filled = match *self {
18-
MaybeInst::Split1(goto1) => panic!(1),
19-
MaybeInst::Split2(goto2) => panic!(2),
18+
MaybeInst::Split1(goto1) => panic!("1"),
19+
MaybeInst::Split2(goto2) => panic!("2"),
2020
_ => unimplemented!(),
2121
};
2222
unimplemented!()

tests/ui/panic_in_result_fn.rs

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -1,6 +1,6 @@
1+
//edition:2015
12
#![warn(clippy::panic_in_result_fn)]
23
#![allow(clippy::unnecessary_wraps)]
3-
44
struct A;
55

66
impl A {

tests/ui/redundant_clone.fixed

Lines changed: 1 addition & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -196,7 +196,7 @@ fn clone_then_move_cloned() {
196196
fn foo<F: Fn()>(_: &Alpha, _: F) {}
197197
let x = Alpha;
198198
// ok, data is moved while the clone is in use.
199-
foo(&x.clone(), move || {
199+
foo(&x, move || {
200200
let _ = x;
201201
});
202202

tests/ui/redundant_clone.stderr

Lines changed: 13 additions & 1 deletion
Original file line numberDiff line numberDiff line change
@@ -167,5 +167,17 @@ note: cloned value is neither consumed nor mutated
167167
LL | let y = x.clone().join("matthias");
168168
| ^^^^^^^^^
169169

170-
error: aborting due to 14 previous errors
170+
error: redundant clone
171+
--> $DIR/redundant_clone.rs:199:11
172+
|
173+
LL | foo(&x.clone(), move || {
174+
| ^^^^^^^^ help: remove this
175+
|
176+
note: this value is dropped without further use
177+
--> $DIR/redundant_clone.rs:199:10
178+
|
179+
LL | foo(&x.clone(), move || {
180+
| ^
181+
182+
error: aborting due to 15 previous errors
171183

tests/ui/wildcard_imports.fixed

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// edition:2015
12
// run-rustfix
23
// aux-build:wildcard_imports_helper.rs
34

tests/ui/wildcard_imports.rs

Lines changed: 1 addition & 0 deletions
Original file line numberDiff line numberDiff line change
@@ -1,3 +1,4 @@
1+
// edition:2015
12
// run-rustfix
23
// aux-build:wildcard_imports_helper.rs
34

0 commit comments

Comments
 (0)