From b7b0291147c3897fe2619e2069bb828b059f44f1 Mon Sep 17 00:00:00 2001 From: Yuki Okushi Date: Fri, 30 Jul 2021 02:36:57 +0900 Subject: Move some UI tests to more suitable subdirs --- src/test/ui/consts/issue-37222.rs | 17 +++ src/test/ui/deref-suggestion.rs | 74 ------------- src/test/ui/deref-suggestion.stderr | 144 -------------------------- src/test/ui/derives/issue-43023.rs | 20 ++++ src/test/ui/derives/issue-43023.stderr | 29 ++++++ src/test/ui/estr-subtyping.rs | 15 --- src/test/ui/estr-subtyping.stderr | 11 -- src/test/ui/inference/deref-suggestion.rs | 74 +++++++++++++ src/test/ui/inference/deref-suggestion.stderr | 144 ++++++++++++++++++++++++++ src/test/ui/issues/issue-13641.rs | 13 --- src/test/ui/issues/issue-13641.stderr | 27 ----- src/test/ui/issues/issue-37222.rs | 17 --- src/test/ui/issues/issue-43023.rs | 20 ---- src/test/ui/issues/issue-43023.stderr | 29 ------ src/test/ui/privacy/issue-13641.rs | 13 +++ src/test/ui/privacy/issue-13641.stderr | 27 +++++ src/tools/tidy/src/ui_tests.rs | 2 +- 17 files changed, 325 insertions(+), 351 deletions(-) create mode 100644 src/test/ui/consts/issue-37222.rs delete mode 100644 src/test/ui/deref-suggestion.rs delete mode 100644 src/test/ui/deref-suggestion.stderr create mode 100644 src/test/ui/derives/issue-43023.rs create mode 100644 src/test/ui/derives/issue-43023.stderr delete mode 100644 src/test/ui/estr-subtyping.rs delete mode 100644 src/test/ui/estr-subtyping.stderr create mode 100644 src/test/ui/inference/deref-suggestion.rs create mode 100644 src/test/ui/inference/deref-suggestion.stderr delete mode 100644 src/test/ui/issues/issue-13641.rs delete mode 100644 src/test/ui/issues/issue-13641.stderr delete mode 100644 src/test/ui/issues/issue-37222.rs delete mode 100644 src/test/ui/issues/issue-43023.rs delete mode 100644 src/test/ui/issues/issue-43023.stderr create mode 100644 src/test/ui/privacy/issue-13641.rs create mode 100644 src/test/ui/privacy/issue-13641.stderr (limited to 'src') diff --git a/src/test/ui/consts/issue-37222.rs b/src/test/ui/consts/issue-37222.rs new file mode 100644 index 00000000000..8ea5f6b7a27 --- /dev/null +++ b/src/test/ui/consts/issue-37222.rs @@ -0,0 +1,17 @@ +// run-pass +#![allow(dead_code)] +#[derive(Debug, PartialEq)] +enum Bar { + A(i64), + B(i32), + C, +} + +#[derive(Debug, PartialEq)] +struct Foo(Bar, u8); + +static FOO: [Foo; 2] = [Foo(Bar::C, 0), Foo(Bar::C, 0xFF)]; + +fn main() { + assert_eq!(&FOO[1], &Foo(Bar::C, 0xFF)); +} diff --git a/src/test/ui/deref-suggestion.rs b/src/test/ui/deref-suggestion.rs deleted file mode 100644 index 4fd695585ba..00000000000 --- a/src/test/ui/deref-suggestion.rs +++ /dev/null @@ -1,74 +0,0 @@ -macro_rules! borrow { - ($x:expr) => { &$x } //~ ERROR mismatched types -} - -fn foo(_: String) {} - -fn foo2(s: &String) { - foo(s); - //~^ ERROR mismatched types -} - -fn foo3(_: u32) {} -fn foo4(u: &u32) { - foo3(u); - //~^ ERROR mismatched types -} - -struct S<'a> { - u: &'a u32, -} - -struct R { - i: u32, -} - -fn main() { - let s = String::new(); - let r_s = &s; - foo2(r_s); - foo(&"aaa".to_owned()); - //~^ ERROR mismatched types - foo(&mut "aaa".to_owned()); - //~^ ERROR mismatched types - foo3(borrow!(0)); - foo4(&0); - assert_eq!(3i32, &3i32); - //~^ ERROR mismatched types - let u = 3; - let s = S { u }; - //~^ ERROR mismatched types - let s = S { u: u }; - //~^ ERROR mismatched types - let i = &4; - let r = R { i }; - //~^ ERROR mismatched types - let r = R { i: i }; - //~^ ERROR mismatched types - - - let a = &1; - let b = &2; - let val: i32 = if true { - a + 1 - } else { - b - //~^ ERROR mismatched types - }; - let val: i32 = if true { - let _ = 2; - a + 1 - } else { - let _ = 2; - b - //~^ ERROR mismatched types - }; - let val = if true { - *a - } else if true { - //~^ ERROR incompatible types - b - } else { - &0 - }; -} diff --git a/src/test/ui/deref-suggestion.stderr b/src/test/ui/deref-suggestion.stderr deleted file mode 100644 index 8c004148a5d..00000000000 --- a/src/test/ui/deref-suggestion.stderr +++ /dev/null @@ -1,144 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:8:9 - | -LL | foo(s); - | ^- help: try using a conversion method: `.to_string()` - | | - | expected struct `String`, found `&String` - -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:14:10 - | -LL | foo3(u); - | ^ expected `u32`, found `&u32` - | -help: consider dereferencing the borrow - | -LL | foo3(*u); - | ^ - -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:30:9 - | -LL | foo(&"aaa".to_owned()); - | ^^^^^^^^^^^^^^^^^ expected struct `String`, found `&String` - | -help: consider removing the borrow - | -LL | foo("aaa".to_owned()); - | -- - -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:32:9 - | -LL | foo(&mut "aaa".to_owned()); - | ^^^^^^^^^^^^^^^^^^^^^ expected struct `String`, found `&mut String` - | -help: consider removing the borrow - | -LL | foo("aaa".to_owned()); - | -- - -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:2:20 - | -LL | ($x:expr) => { &$x } - | ^^^ expected `u32`, found `&{integer}` -... -LL | foo3(borrow!(0)); - | ---------- in this macro invocation - | - = note: this error originates in the macro `borrow` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:36:5 - | -LL | assert_eq!(3i32, &3i32); - | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `&i32` - | - = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:39:17 - | -LL | let s = S { u }; - | ^ - | | - | expected `&u32`, found integer - | help: consider borrowing here: `u: &u` - -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:41:20 - | -LL | let s = S { u: u }; - | ^ - | | - | expected `&u32`, found integer - | help: consider borrowing here: `&u` - -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:44:17 - | -LL | let r = R { i }; - | ^ expected `u32`, found `&{integer}` - | -help: consider dereferencing the borrow - | -LL | let r = R { i: *i }; - | ^^^^^ - -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:46:20 - | -LL | let r = R { i: i }; - | ^ expected `u32`, found `&{integer}` - | -help: consider dereferencing the borrow - | -LL | let r = R { i: *i }; - | ^ - -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:55:9 - | -LL | b - | ^ expected `i32`, found `&{integer}` - | -help: consider dereferencing the borrow - | -LL | *b - | ^ - -error[E0308]: mismatched types - --> $DIR/deref-suggestion.rs:63:9 - | -LL | b - | ^ expected `i32`, found `&{integer}` - | -help: consider dereferencing the borrow - | -LL | *b - | ^ - -error[E0308]: `if` and `else` have incompatible types - --> $DIR/deref-suggestion.rs:68:12 - | -LL | let val = if true { - | _______________- -LL | | *a - | | -- expected because of this -LL | | } else if true { - | |____________^ -LL | || -LL | || b -LL | || } else { -LL | || &0 -LL | || }; - | || ^ - | ||_____| - | |______`if` and `else` have incompatible types - | expected `i32`, found `&{integer}` - -error: aborting due to 13 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/derives/issue-43023.rs b/src/test/ui/derives/issue-43023.rs new file mode 100644 index 00000000000..c0208e68084 --- /dev/null +++ b/src/test/ui/derives/issue-43023.rs @@ -0,0 +1,20 @@ +struct S; + +impl S { + #[derive(Debug)] //~ ERROR `derive` may only be applied to `struct`s, `enum`s and `union`s + fn f() { + file!(); + } +} + +trait Tr1 { + #[derive(Debug)] //~ ERROR `derive` may only be applied to `struct`s, `enum`s and `union`s + fn f(); +} + +trait Tr2 { + #[derive(Debug)] //~ ERROR `derive` may only be applied to `struct`s, `enum`s and `union`s + type F; +} + +fn main() {} diff --git a/src/test/ui/derives/issue-43023.stderr b/src/test/ui/derives/issue-43023.stderr new file mode 100644 index 00000000000..007eb259594 --- /dev/null +++ b/src/test/ui/derives/issue-43023.stderr @@ -0,0 +1,29 @@ +error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s + --> $DIR/issue-43023.rs:4:5 + | +LL | #[derive(Debug)] + | ^^^^^^^^^^^^^^^^ not applicable here +LL | / fn f() { +LL | | file!(); +LL | | } + | |_____- not a `struct`, `enum` or `union` + +error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s + --> $DIR/issue-43023.rs:11:5 + | +LL | #[derive(Debug)] + | ^^^^^^^^^^^^^^^^ not applicable here +LL | fn f(); + | ------- not a `struct`, `enum` or `union` + +error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s + --> $DIR/issue-43023.rs:16:5 + | +LL | #[derive(Debug)] + | ^^^^^^^^^^^^^^^^ not applicable here +LL | type F; + | ------- not a `struct`, `enum` or `union` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0774`. diff --git a/src/test/ui/estr-subtyping.rs b/src/test/ui/estr-subtyping.rs deleted file mode 100644 index 9c5825fff85..00000000000 --- a/src/test/ui/estr-subtyping.rs +++ /dev/null @@ -1,15 +0,0 @@ -fn wants_uniq(x: String) { } -fn wants_slice(x: &str) { } - -fn has_uniq(x: String) { - wants_uniq(x); - wants_slice(&*x); -} - -fn has_slice(x: &str) { - wants_uniq(x); //~ ERROR mismatched types - wants_slice(x); -} - -fn main() { -} diff --git a/src/test/ui/estr-subtyping.stderr b/src/test/ui/estr-subtyping.stderr deleted file mode 100644 index d929c32633a..00000000000 --- a/src/test/ui/estr-subtyping.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/estr-subtyping.rs:10:15 - | -LL | wants_uniq(x); - | ^- help: try using a conversion method: `.to_string()` - | | - | expected struct `String`, found `&str` - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/inference/deref-suggestion.rs b/src/test/ui/inference/deref-suggestion.rs new file mode 100644 index 00000000000..4fd695585ba --- /dev/null +++ b/src/test/ui/inference/deref-suggestion.rs @@ -0,0 +1,74 @@ +macro_rules! borrow { + ($x:expr) => { &$x } //~ ERROR mismatched types +} + +fn foo(_: String) {} + +fn foo2(s: &String) { + foo(s); + //~^ ERROR mismatched types +} + +fn foo3(_: u32) {} +fn foo4(u: &u32) { + foo3(u); + //~^ ERROR mismatched types +} + +struct S<'a> { + u: &'a u32, +} + +struct R { + i: u32, +} + +fn main() { + let s = String::new(); + let r_s = &s; + foo2(r_s); + foo(&"aaa".to_owned()); + //~^ ERROR mismatched types + foo(&mut "aaa".to_owned()); + //~^ ERROR mismatched types + foo3(borrow!(0)); + foo4(&0); + assert_eq!(3i32, &3i32); + //~^ ERROR mismatched types + let u = 3; + let s = S { u }; + //~^ ERROR mismatched types + let s = S { u: u }; + //~^ ERROR mismatched types + let i = &4; + let r = R { i }; + //~^ ERROR mismatched types + let r = R { i: i }; + //~^ ERROR mismatched types + + + let a = &1; + let b = &2; + let val: i32 = if true { + a + 1 + } else { + b + //~^ ERROR mismatched types + }; + let val: i32 = if true { + let _ = 2; + a + 1 + } else { + let _ = 2; + b + //~^ ERROR mismatched types + }; + let val = if true { + *a + } else if true { + //~^ ERROR incompatible types + b + } else { + &0 + }; +} diff --git a/src/test/ui/inference/deref-suggestion.stderr b/src/test/ui/inference/deref-suggestion.stderr new file mode 100644 index 00000000000..8c004148a5d --- /dev/null +++ b/src/test/ui/inference/deref-suggestion.stderr @@ -0,0 +1,144 @@ +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:8:9 + | +LL | foo(s); + | ^- help: try using a conversion method: `.to_string()` + | | + | expected struct `String`, found `&String` + +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:14:10 + | +LL | foo3(u); + | ^ expected `u32`, found `&u32` + | +help: consider dereferencing the borrow + | +LL | foo3(*u); + | ^ + +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:30:9 + | +LL | foo(&"aaa".to_owned()); + | ^^^^^^^^^^^^^^^^^ expected struct `String`, found `&String` + | +help: consider removing the borrow + | +LL | foo("aaa".to_owned()); + | -- + +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:32:9 + | +LL | foo(&mut "aaa".to_owned()); + | ^^^^^^^^^^^^^^^^^^^^^ expected struct `String`, found `&mut String` + | +help: consider removing the borrow + | +LL | foo("aaa".to_owned()); + | -- + +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:2:20 + | +LL | ($x:expr) => { &$x } + | ^^^ expected `u32`, found `&{integer}` +... +LL | foo3(borrow!(0)); + | ---------- in this macro invocation + | + = note: this error originates in the macro `borrow` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:36:5 + | +LL | assert_eq!(3i32, &3i32); + | ^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `&i32` + | + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:39:17 + | +LL | let s = S { u }; + | ^ + | | + | expected `&u32`, found integer + | help: consider borrowing here: `u: &u` + +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:41:20 + | +LL | let s = S { u: u }; + | ^ + | | + | expected `&u32`, found integer + | help: consider borrowing here: `&u` + +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:44:17 + | +LL | let r = R { i }; + | ^ expected `u32`, found `&{integer}` + | +help: consider dereferencing the borrow + | +LL | let r = R { i: *i }; + | ^^^^^ + +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:46:20 + | +LL | let r = R { i: i }; + | ^ expected `u32`, found `&{integer}` + | +help: consider dereferencing the borrow + | +LL | let r = R { i: *i }; + | ^ + +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:55:9 + | +LL | b + | ^ expected `i32`, found `&{integer}` + | +help: consider dereferencing the borrow + | +LL | *b + | ^ + +error[E0308]: mismatched types + --> $DIR/deref-suggestion.rs:63:9 + | +LL | b + | ^ expected `i32`, found `&{integer}` + | +help: consider dereferencing the borrow + | +LL | *b + | ^ + +error[E0308]: `if` and `else` have incompatible types + --> $DIR/deref-suggestion.rs:68:12 + | +LL | let val = if true { + | _______________- +LL | | *a + | | -- expected because of this +LL | | } else if true { + | |____________^ +LL | || +LL | || b +LL | || } else { +LL | || &0 +LL | || }; + | || ^ + | ||_____| + | |______`if` and `else` have incompatible types + | expected `i32`, found `&{integer}` + +error: aborting due to 13 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/src/test/ui/issues/issue-13641.rs b/src/test/ui/issues/issue-13641.rs deleted file mode 100644 index 198cea4289c..00000000000 --- a/src/test/ui/issues/issue-13641.rs +++ /dev/null @@ -1,13 +0,0 @@ -mod a { - struct Foo; - impl Foo { pub fn new() {} } - enum Bar {} - impl Bar { pub fn new() {} } -} - -fn main() { - a::Foo::new(); - //~^ ERROR: struct `Foo` is private - a::Bar::new(); - //~^ ERROR: enum `Bar` is private -} diff --git a/src/test/ui/issues/issue-13641.stderr b/src/test/ui/issues/issue-13641.stderr deleted file mode 100644 index cdd0772d39f..00000000000 --- a/src/test/ui/issues/issue-13641.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0603]: struct `Foo` is private - --> $DIR/issue-13641.rs:9:8 - | -LL | a::Foo::new(); - | ^^^ private struct - | -note: the struct `Foo` is defined here - --> $DIR/issue-13641.rs:2:5 - | -LL | struct Foo; - | ^^^^^^^^^^^ - -error[E0603]: enum `Bar` is private - --> $DIR/issue-13641.rs:11:8 - | -LL | a::Bar::new(); - | ^^^ private enum - | -note: the enum `Bar` is defined here - --> $DIR/issue-13641.rs:4:5 - | -LL | enum Bar {} - | ^^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0603`. diff --git a/src/test/ui/issues/issue-37222.rs b/src/test/ui/issues/issue-37222.rs deleted file mode 100644 index 8ea5f6b7a27..00000000000 --- a/src/test/ui/issues/issue-37222.rs +++ /dev/null @@ -1,17 +0,0 @@ -// run-pass -#![allow(dead_code)] -#[derive(Debug, PartialEq)] -enum Bar { - A(i64), - B(i32), - C, -} - -#[derive(Debug, PartialEq)] -struct Foo(Bar, u8); - -static FOO: [Foo; 2] = [Foo(Bar::C, 0), Foo(Bar::C, 0xFF)]; - -fn main() { - assert_eq!(&FOO[1], &Foo(Bar::C, 0xFF)); -} diff --git a/src/test/ui/issues/issue-43023.rs b/src/test/ui/issues/issue-43023.rs deleted file mode 100644 index c0208e68084..00000000000 --- a/src/test/ui/issues/issue-43023.rs +++ /dev/null @@ -1,20 +0,0 @@ -struct S; - -impl S { - #[derive(Debug)] //~ ERROR `derive` may only be applied to `struct`s, `enum`s and `union`s - fn f() { - file!(); - } -} - -trait Tr1 { - #[derive(Debug)] //~ ERROR `derive` may only be applied to `struct`s, `enum`s and `union`s - fn f(); -} - -trait Tr2 { - #[derive(Debug)] //~ ERROR `derive` may only be applied to `struct`s, `enum`s and `union`s - type F; -} - -fn main() {} diff --git a/src/test/ui/issues/issue-43023.stderr b/src/test/ui/issues/issue-43023.stderr deleted file mode 100644 index 007eb259594..00000000000 --- a/src/test/ui/issues/issue-43023.stderr +++ /dev/null @@ -1,29 +0,0 @@ -error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s - --> $DIR/issue-43023.rs:4:5 - | -LL | #[derive(Debug)] - | ^^^^^^^^^^^^^^^^ not applicable here -LL | / fn f() { -LL | | file!(); -LL | | } - | |_____- not a `struct`, `enum` or `union` - -error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s - --> $DIR/issue-43023.rs:11:5 - | -LL | #[derive(Debug)] - | ^^^^^^^^^^^^^^^^ not applicable here -LL | fn f(); - | ------- not a `struct`, `enum` or `union` - -error[E0774]: `derive` may only be applied to `struct`s, `enum`s and `union`s - --> $DIR/issue-43023.rs:16:5 - | -LL | #[derive(Debug)] - | ^^^^^^^^^^^^^^^^ not applicable here -LL | type F; - | ------- not a `struct`, `enum` or `union` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0774`. diff --git a/src/test/ui/privacy/issue-13641.rs b/src/test/ui/privacy/issue-13641.rs new file mode 100644 index 00000000000..198cea4289c --- /dev/null +++ b/src/test/ui/privacy/issue-13641.rs @@ -0,0 +1,13 @@ +mod a { + struct Foo; + impl Foo { pub fn new() {} } + enum Bar {} + impl Bar { pub fn new() {} } +} + +fn main() { + a::Foo::new(); + //~^ ERROR: struct `Foo` is private + a::Bar::new(); + //~^ ERROR: enum `Bar` is private +} diff --git a/src/test/ui/privacy/issue-13641.stderr b/src/test/ui/privacy/issue-13641.stderr new file mode 100644 index 00000000000..cdd0772d39f --- /dev/null +++ b/src/test/ui/privacy/issue-13641.stderr @@ -0,0 +1,27 @@ +error[E0603]: struct `Foo` is private + --> $DIR/issue-13641.rs:9:8 + | +LL | a::Foo::new(); + | ^^^ private struct + | +note: the struct `Foo` is defined here + --> $DIR/issue-13641.rs:2:5 + | +LL | struct Foo; + | ^^^^^^^^^^^ + +error[E0603]: enum `Bar` is private + --> $DIR/issue-13641.rs:11:8 + | +LL | a::Bar::new(); + | ^^^ private enum + | +note: the enum `Bar` is defined here + --> $DIR/issue-13641.rs:4:5 + | +LL | enum Bar {} + | ^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0603`. diff --git a/src/tools/tidy/src/ui_tests.rs b/src/tools/tidy/src/ui_tests.rs index 66d05d9f00e..46b5b877b4c 100644 --- a/src/tools/tidy/src/ui_tests.rs +++ b/src/tools/tidy/src/ui_tests.rs @@ -8,7 +8,7 @@ use std::path::Path; const ENTRY_LIMIT: usize = 1000; // FIXME: The following limits should be reduced eventually. const ROOT_ENTRY_LIMIT: usize = 1345; -const ISSUES_ENTRY_LIMIT: usize = 2530; +const ISSUES_ENTRY_LIMIT: usize = 2525; fn check_entries(path: &Path, bad: &mut bool) { let dirs = walkdir::WalkDir::new(&path.join("test/ui")) -- cgit 1.4.1-3-g733a5