Skip to content

Commit

Permalink
Auto merge of #7866 - rust-lang:edition-2021-tests, r=Manishearth
Browse files Browse the repository at this point in the history
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
  • Loading branch information
bors committed Nov 1, 2021
2 parents 310ecb0 + a4ede72 commit 7cd9bf5
Show file tree
Hide file tree
Showing 109 changed files with 525 additions and 530 deletions.
2 changes: 1 addition & 1 deletion Cargo.toml
Original file line number Diff line number Diff line change
Expand Up @@ -28,7 +28,7 @@ tempfile = { version = "3.2", optional = true }

[dev-dependencies]
cargo_metadata = "0.12"
compiletest_rs = { version = "0.7", features = ["tmp"] }
compiletest_rs = { version = "0.7.1", features = ["tmp"] }
tester = "0.9"
regex = "1.5"
# This is used by the `collect-metadata` alias.
Expand Down
5 changes: 4 additions & 1 deletion tests/compile-test.rs
Original file line number Diff line number Diff line change
Expand Up @@ -104,7 +104,10 @@ fn extern_flags() -> String {
}

fn default_config() -> compiletest::Config {
let mut config = compiletest::Config::default();
let mut config = compiletest::Config {
edition: Some("2021".into()),
..compiletest::Config::default()
};

if let Ok(filters) = env::var("TESTNAME") {
config.filters = filters.split(',').map(std::string::ToString::to_string).collect();
Expand Down
2 changes: 0 additions & 2 deletions tests/ui-toml/functions_maxlines/test.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,3 @@
// edition:2018

#![warn(clippy::too_many_lines)]

// This function should be considered one line.
Expand Down
8 changes: 4 additions & 4 deletions tests/ui-toml/functions_maxlines/test.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: this function has too many lines (2/1)
--> $DIR/test.rs:20:1
--> $DIR/test.rs:18:1
|
LL | / fn too_many_lines() {
LL | | println!("This is bad.");
Expand All @@ -10,7 +10,7 @@ LL | | }
= note: `-D clippy::too-many-lines` implied by `-D warnings`

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

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

error: this function has too many lines (2/1)
--> $DIR/test.rs:54:1
--> $DIR/test.rs:52:1
|
LL | / fn comment_before_code() {
LL | | let _ = "test";
Expand Down
4 changes: 2 additions & 2 deletions tests/ui/assertions_on_constants.rs
Original file line number Diff line number Diff line change
@@ -1,3 +1,4 @@
//FIXME: suggestions are wrongly expanded, this should be fixed along with #7843
#![allow(non_fmt_panics)]

macro_rules! assert_const {
Expand All @@ -6,15 +7,14 @@ macro_rules! assert_const {
debug_assert!($len < 0);
};
}

fn main() {
assert!(true);
assert!(false);
assert!(true, "true message");
assert!(false, "false message");

let msg = "panic message";
assert!(false, msg.to_uppercase());
assert!(false, "{}", msg.to_uppercase());

const B: bool = true;
assert!(B);
Expand Down
19 changes: 5 additions & 14 deletions tests/ui/assertions_on_constants.stderr
Original file line number Diff line number Diff line change
Expand Up @@ -26,22 +26,13 @@ LL | assert!(true, "true message");
= help: remove it
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `assert!(false, "false message")` should probably be replaced
error: `assert!(false, $crate::const_format_args!($($t)+))` should probably be replaced
--> $DIR/assertions_on_constants.rs:14:5
|
LL | assert!(false, "false message");
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: use `panic!("false message")` or `unreachable!("false message")`
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)

error: `assert!(false, msg.to_uppercase())` should probably be replaced
--> $DIR/assertions_on_constants.rs:17:5
|
LL | assert!(false, msg.to_uppercase());
| ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^
|
= help: use `panic!(msg.to_uppercase())` or `unreachable!(msg.to_uppercase())`
= help: use `panic!($crate::const_format_args!($($t)+))` or `unreachable!($crate::const_format_args!($($t)+))`
= note: this error originates in the macro `assert` (in Nightly builds, run with -Z macro-backtrace for more info)

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

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

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

error: aborting due to 9 previous errors
error: aborting due to 8 previous errors

1 change: 0 additions & 1 deletion tests/ui/async_yields_async.fixed
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// run-rustfix
// edition:2018

#![feature(async_closure)]
#![warn(clippy::async_yields_async)]
Expand Down
1 change: 0 additions & 1 deletion tests/ui/async_yields_async.rs
Original file line number Diff line number Diff line change
@@ -1,5 +1,4 @@
// run-rustfix
// edition:2018

#![feature(async_closure)]
#![warn(clippy::async_yields_async)]
Expand Down
12 changes: 6 additions & 6 deletions tests/ui/async_yields_async.stderr
Original file line number Diff line number Diff line change
@@ -1,5 +1,5 @@
error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:40:9
--> $DIR/async_yields_async.rs:39:9
|
LL | let _h = async {
| ____________________-
Expand All @@ -20,7 +20,7 @@ LL + }.await
|

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

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

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

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

error: an async construct yields a type which is itself awaitable
--> $DIR/async_yields_async.rs:64:9
--> $DIR/async_yields_async.rs:63:9
|
LL | let _m = async || {
| _______________________-
Expand Down
1 change: 0 additions & 1 deletion tests/ui/await_holding_lock.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// edition:2018
#![warn(clippy::await_holding_lock)]

use std::sync::Mutex;
Expand Down
16 changes: 8 additions & 8 deletions tests/ui/await_holding_lock.stderr
Original file line number Diff line number Diff line change
@@ -1,26 +1,26 @@
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
--> $DIR/await_holding_lock.rs:7:9
--> $DIR/await_holding_lock.rs:6:9
|
LL | let guard = x.lock().unwrap();
| ^^^^^
|
= note: `-D clippy::await-holding-lock` implied by `-D warnings`
note: these are all the await points this lock is held through
--> $DIR/await_holding_lock.rs:7:5
--> $DIR/await_holding_lock.rs:6:5
|
LL | / let guard = x.lock().unwrap();
LL | | baz().await
LL | | }
| |_^

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
--> $DIR/await_holding_lock.rs:28:9
--> $DIR/await_holding_lock.rs:27:9
|
LL | let guard = x.lock().unwrap();
| ^^^^^
|
note: these are all the await points this lock is held through
--> $DIR/await_holding_lock.rs:28:5
--> $DIR/await_holding_lock.rs:27:5
|
LL | / let guard = x.lock().unwrap();
LL | |
Expand All @@ -32,27 +32,27 @@ LL | | }
| |_^

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
--> $DIR/await_holding_lock.rs:41:13
--> $DIR/await_holding_lock.rs:40:13
|
LL | let guard = x.lock().unwrap();
| ^^^^^
|
note: these are all the await points this lock is held through
--> $DIR/await_holding_lock.rs:41:9
--> $DIR/await_holding_lock.rs:40:9
|
LL | / let guard = x.lock().unwrap();
LL | | baz().await
LL | | };
| |_____^

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
--> $DIR/await_holding_lock.rs:53:13
--> $DIR/await_holding_lock.rs:52:13
|
LL | let guard = x.lock().unwrap();
| ^^^^^
|
note: these are all the await points this lock is held through
--> $DIR/await_holding_lock.rs:53:9
--> $DIR/await_holding_lock.rs:52:9
|
LL | / let guard = x.lock().unwrap();
LL | | baz().await
Expand Down
1 change: 0 additions & 1 deletion tests/ui/await_holding_refcell_ref.rs
Original file line number Diff line number Diff line change
@@ -1,4 +1,3 @@
// edition:2018
#![warn(clippy::await_holding_refcell_ref)]

use std::cell::RefCell;
Expand Down
24 changes: 12 additions & 12 deletions tests/ui/await_holding_refcell_ref.stderr
Original file line number Diff line number Diff line change
@@ -1,40 +1,40 @@
error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await
--> $DIR/await_holding_refcell_ref.rs:7:9
--> $DIR/await_holding_refcell_ref.rs:6:9
|
LL | let b = x.borrow();
| ^
|
= note: `-D clippy::await-holding-refcell-ref` implied by `-D warnings`
note: these are all the await points this ref is held through
--> $DIR/await_holding_refcell_ref.rs:7:5
--> $DIR/await_holding_refcell_ref.rs:6:5
|
LL | / let b = x.borrow();
LL | | baz().await
LL | | }
| |_^

error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await
--> $DIR/await_holding_refcell_ref.rs:12:9
--> $DIR/await_holding_refcell_ref.rs:11:9
|
LL | let b = x.borrow_mut();
| ^
|
note: these are all the await points this ref is held through
--> $DIR/await_holding_refcell_ref.rs:12:5
--> $DIR/await_holding_refcell_ref.rs:11:5
|
LL | / let b = x.borrow_mut();
LL | | baz().await
LL | | }
| |_^

error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await
--> $DIR/await_holding_refcell_ref.rs:33:9
--> $DIR/await_holding_refcell_ref.rs:32:9
|
LL | let b = x.borrow_mut();
| ^
|
note: these are all the await points this ref is held through
--> $DIR/await_holding_refcell_ref.rs:33:5
--> $DIR/await_holding_refcell_ref.rs:32:5
|
LL | / let b = x.borrow_mut();
LL | |
Expand All @@ -46,13 +46,13 @@ LL | | }
| |_^

error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await
--> $DIR/await_holding_refcell_ref.rs:45:9
--> $DIR/await_holding_refcell_ref.rs:44:9
|
LL | let b = x.borrow_mut();
| ^
|
note: these are all the await points this ref is held through
--> $DIR/await_holding_refcell_ref.rs:45:5
--> $DIR/await_holding_refcell_ref.rs:44:5
|
LL | / let b = x.borrow_mut();
LL | |
Expand All @@ -64,27 +64,27 @@ LL | | }
| |_^

error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await
--> $DIR/await_holding_refcell_ref.rs:60:13
--> $DIR/await_holding_refcell_ref.rs:59:13
|
LL | let b = x.borrow_mut();
| ^
|
note: these are all the await points this ref is held through
--> $DIR/await_holding_refcell_ref.rs:60:9
--> $DIR/await_holding_refcell_ref.rs:59:9
|
LL | / let b = x.borrow_mut();
LL | | baz().await
LL | | };
| |_____^

error: this RefCell Ref is held across an 'await' point. Consider ensuring the Ref is dropped before calling await
--> $DIR/await_holding_refcell_ref.rs:72:13
--> $DIR/await_holding_refcell_ref.rs:71:13
|
LL | let b = x.borrow_mut();
| ^
|
note: these are all the await points this ref is held through
--> $DIR/await_holding_refcell_ref.rs:72:9
--> $DIR/await_holding_refcell_ref.rs:71:9
|
LL | / let b = x.borrow_mut();
LL | | baz().await
Expand Down
5 changes: 2 additions & 3 deletions tests/ui/crashes/ice-3969.rs
Original file line number Diff line number Diff line change
Expand Up @@ -7,7 +7,6 @@
// in type inference.
#![feature(trivial_bounds)]
#![allow(unused)]

trait A {}

impl A for i32 {}
Expand All @@ -22,9 +21,9 @@ where

fn unsized_local()
where
for<'a> Dst<A + 'a>: Sized,
for<'a> Dst<dyn A + 'a>: Sized,
{
let x: Dst<A> = *(Box::new(Dst { x: 1 }) as Box<Dst<A>>);
let x: Dst<dyn A> = *(Box::new(Dst { x: 1 }) as Box<Dst<dyn A>>);
}

fn return_str() -> str
Expand Down
Loading

0 comments on commit 7cd9bf5

Please sign in to comment.