diff options
Diffstat (limited to 'tests/ui')
1468 files changed, 14918 insertions, 5101 deletions
diff --git a/tests/ui/abi/stack-probes-lto.rs b/tests/ui/abi/stack-probes-lto.rs index a455eef42..039507d51 100644 --- a/tests/ui/abi/stack-probes-lto.rs +++ b/tests/ui/abi/stack-probes-lto.rs @@ -9,7 +9,6 @@ // ignore-emscripten no processes // ignore-sgx no processes // ignore-musl FIXME #31506 -// ignore-pretty // ignore-fuchsia no exception handler registered for segfault // compile-flags: -C lto // no-prefer-dynamic diff --git a/tests/ui/argument-suggestions/issue-109425.fixed b/tests/ui/argument-suggestions/issue-109425.fixed new file mode 100644 index 000000000..143ddf995 --- /dev/null +++ b/tests/ui/argument-suggestions/issue-109425.fixed @@ -0,0 +1,20 @@ +// run-rustfix + +fn f() {} +fn i(_: u32) {} +fn is(_: u32, _: &str) {} +fn s(_: &str) {} + +fn main() { + // code expected suggestion + f(); // f() + //~^ error: this function takes 0 arguments but 2 arguments were supplied + i(0,); // i(0,) + //~^ error: this function takes 1 argument but 3 arguments were supplied + i(0); // i(0) + //~^ error: this function takes 1 argument but 3 arguments were supplied + is(0, ""); // is(0, "") + //~^ error: this function takes 2 arguments but 4 arguments were supplied + s(""); // s("") + //~^ error: this function takes 1 argument but 3 arguments were supplied +} diff --git a/tests/ui/argument-suggestions/issue-109425.rs b/tests/ui/argument-suggestions/issue-109425.rs new file mode 100644 index 000000000..a845c4195 --- /dev/null +++ b/tests/ui/argument-suggestions/issue-109425.rs @@ -0,0 +1,20 @@ +// run-rustfix + +fn f() {} +fn i(_: u32) {} +fn is(_: u32, _: &str) {} +fn s(_: &str) {} + +fn main() { + // code expected suggestion + f(0, 1,); // f() + //~^ error: this function takes 0 arguments but 2 arguments were supplied + i(0, 1, 2,); // i(0,) + //~^ error: this function takes 1 argument but 3 arguments were supplied + i(0, 1, 2); // i(0) + //~^ error: this function takes 1 argument but 3 arguments were supplied + is(0, 1, 2, ""); // is(0, "") + //~^ error: this function takes 2 arguments but 4 arguments were supplied + s(0, 1, ""); // s("") + //~^ error: this function takes 1 argument but 3 arguments were supplied +} diff --git a/tests/ui/argument-suggestions/issue-109425.stderr b/tests/ui/argument-suggestions/issue-109425.stderr new file mode 100644 index 000000000..1514f1cb4 --- /dev/null +++ b/tests/ui/argument-suggestions/issue-109425.stderr @@ -0,0 +1,98 @@ +error[E0061]: this function takes 0 arguments but 2 arguments were supplied + --> $DIR/issue-109425.rs:10:5 + | +LL | f(0, 1,); // f() + | ^ - - unexpected argument of type `{integer}` + | | + | unexpected argument of type `{integer}` + | +note: function defined here + --> $DIR/issue-109425.rs:3:4 + | +LL | fn f() {} + | ^ +help: remove the extra arguments + | +LL - f(0, 1,); // f() +LL + f(); // f() + | + +error[E0061]: this function takes 1 argument but 3 arguments were supplied + --> $DIR/issue-109425.rs:12:5 + | +LL | i(0, 1, 2,); // i(0,) + | ^ - - unexpected argument of type `{integer}` + | | + | unexpected argument of type `{integer}` + | +note: function defined here + --> $DIR/issue-109425.rs:4:4 + | +LL | fn i(_: u32) {} + | ^ ------ +help: remove the extra arguments + | +LL - i(0, 1, 2,); // i(0,) +LL + i(0,); // i(0,) + | + +error[E0061]: this function takes 1 argument but 3 arguments were supplied + --> $DIR/issue-109425.rs:14:5 + | +LL | i(0, 1, 2); // i(0) + | ^ - - unexpected argument of type `{integer}` + | | + | unexpected argument of type `{integer}` + | +note: function defined here + --> $DIR/issue-109425.rs:4:4 + | +LL | fn i(_: u32) {} + | ^ ------ +help: remove the extra arguments + | +LL - i(0, 1, 2); // i(0) +LL + i(0); // i(0) + | + +error[E0061]: this function takes 2 arguments but 4 arguments were supplied + --> $DIR/issue-109425.rs:16:5 + | +LL | is(0, 1, 2, ""); // is(0, "") + | ^^ - - unexpected argument of type `{integer}` + | | + | unexpected argument of type `{integer}` + | +note: function defined here + --> $DIR/issue-109425.rs:5:4 + | +LL | fn is(_: u32, _: &str) {} + | ^^ ------ ------- +help: remove the extra arguments + | +LL - is(0, 1, 2, ""); // is(0, "") +LL + is(0, ""); // is(0, "") + | + +error[E0061]: this function takes 1 argument but 3 arguments were supplied + --> $DIR/issue-109425.rs:18:5 + | +LL | s(0, 1, ""); // s("") + | ^ - - unexpected argument of type `{integer}` + | | + | unexpected argument of type `{integer}` + | +note: function defined here + --> $DIR/issue-109425.rs:6:4 + | +LL | fn s(_: &str) {} + | ^ ------- +help: remove the extra arguments + | +LL - s(0, 1, ""); // s("") +LL + s(""); // s("") + | + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/argument-suggestions/issue-109831.rs b/tests/ui/argument-suggestions/issue-109831.rs new file mode 100644 index 000000000..2e8ae40f6 --- /dev/null +++ b/tests/ui/argument-suggestions/issue-109831.rs @@ -0,0 +1,9 @@ +struct A; +struct B; + +fn f(b1: B, b2: B, a2: C) {} //~ ERROR E0412 + +fn main() { + f(A, A, B, C); //~ ERROR E0425 + //~^ ERROR E0061 +} diff --git a/tests/ui/argument-suggestions/issue-109831.stderr b/tests/ui/argument-suggestions/issue-109831.stderr new file mode 100644 index 000000000..7b9a3c9ef --- /dev/null +++ b/tests/ui/argument-suggestions/issue-109831.stderr @@ -0,0 +1,51 @@ +error[E0412]: cannot find type `C` in this scope + --> $DIR/issue-109831.rs:4:24 + | +LL | struct A; + | --------- similarly named struct `A` defined here +... +LL | fn f(b1: B, b2: B, a2: C) {} + | ^ + | +help: a struct with a similar name exists + | +LL | fn f(b1: B, b2: B, a2: A) {} + | ~ +help: you might be missing a type parameter + | +LL | fn f<C>(b1: B, b2: B, a2: C) {} + | +++ + +error[E0425]: cannot find value `C` in this scope + --> $DIR/issue-109831.rs:7:16 + | +LL | struct A; + | --------- similarly named unit struct `A` defined here +... +LL | f(A, A, B, C); + | ^ help: a unit struct with a similar name exists: `A` + +error[E0061]: this function takes 3 arguments but 4 arguments were supplied + --> $DIR/issue-109831.rs:7:5 + | +LL | f(A, A, B, C); + | ^ - - - unexpected argument + | | | + | | expected `B`, found `A` + | expected `B`, found `A` + | +note: function defined here + --> $DIR/issue-109831.rs:4:4 + | +LL | fn f(b1: B, b2: B, a2: C) {} + | ^ ----- ----- ----- +help: remove the extra argument + | +LL - f(A, A, B, C); +LL + f(/* B */, /* B */, B); + | + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0061, E0412, E0425. +For more information about an error, try `rustc --explain E0061`. diff --git a/tests/ui/array-slice-vec/repeat_empty_ok.stderr b/tests/ui/array-slice-vec/repeat_empty_ok.stderr index 724bdcd92..e8bac04ac 100644 --- a/tests/ui/array-slice-vec/repeat_empty_ok.stderr +++ b/tests/ui/array-slice-vec/repeat_empty_ok.stderr @@ -7,7 +7,8 @@ LL | let headers = [Header{value: &[]}; 128]; = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Header<'_>` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | pub struct Header<'a> { | error[E0277]: the trait bound `Header<'_>: Copy` is not satisfied @@ -19,7 +20,8 @@ LL | let headers = [Header{value: &[0]}; 128]; = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Header<'_>` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | pub struct Header<'a> { | error: aborting due to 2 previous errors diff --git a/tests/ui/asm/aarch64/parse-error.rs b/tests/ui/asm/aarch64/parse-error.rs index cbc93cd3f..9b8170840 100644 --- a/tests/ui/asm/aarch64/parse-error.rs +++ b/tests/ui/asm/aarch64/parse-error.rs @@ -37,8 +37,7 @@ fn main() { asm!("", options(nomem, foo)); //~^ ERROR expected one of asm!("{}", options(), const foo); - //~^ ERROR arguments are not allowed after options - //~^^ ERROR attempt to use a non-constant value in a constant + //~^ ERROR attempt to use a non-constant value in a constant asm!("", clobber_abi(foo)); //~^ ERROR expected string literal asm!("", clobber_abi("C" foo)); @@ -46,12 +45,10 @@ fn main() { asm!("", clobber_abi("C", foo)); //~^ ERROR expected string literal asm!("{}", clobber_abi("C"), const foo); - //~^ ERROR arguments are not allowed after clobber_abi - //~^^ ERROR attempt to use a non-constant value in a constant + //~^ ERROR attempt to use a non-constant value in a constant asm!("", options(), clobber_abi("C")); - //~^ ERROR clobber_abi is not allowed after options asm!("{}", options(), clobber_abi("C"), const foo); - //~^ ERROR clobber_abi is not allowed after options + //~^ ERROR attempt to use a non-constant value in a constant asm!("{a}", a = const foo, a = const bar); //~^ ERROR duplicate argument named `a` //~^^ ERROR argument never used @@ -60,11 +57,9 @@ fn main() { asm!("", a = in("x0") foo); //~^ ERROR explicit register arguments cannot have names asm!("{a}", in("x0") foo, a = const bar); - //~^ ERROR named arguments cannot follow explicit register arguments - //~^^ ERROR attempt to use a non-constant value in a constant + //~^ ERROR attempt to use a non-constant value in a constant asm!("{a}", in("x0") foo, a = const bar); - //~^ ERROR named arguments cannot follow explicit register arguments - //~^^ ERROR attempt to use a non-constant value in a constant + //~^ ERROR attempt to use a non-constant value in a constant asm!("{1}", in("x0") foo, const bar); //~^ ERROR positional arguments cannot follow named arguments or explicit register arguments //~^^ ERROR attempt to use a non-constant value in a constant @@ -106,7 +101,6 @@ global_asm!("", options(nomem FOO)); global_asm!("", options(nomem, FOO)); //~^ ERROR expected one of global_asm!("{}", options(), const FOO); -//~^ ERROR arguments are not allowed after options global_asm!("", clobber_abi(FOO)); //~^ ERROR expected string literal global_asm!("", clobber_abi("C" FOO)); @@ -114,12 +108,11 @@ global_asm!("", clobber_abi("C" FOO)); global_asm!("", clobber_abi("C", FOO)); //~^ ERROR expected string literal global_asm!("{}", clobber_abi("C"), const FOO); -//~^ ERROR arguments are not allowed after clobber_abi -//~^^ ERROR `clobber_abi` cannot be used with `global_asm!` +//~^ ERROR `clobber_abi` cannot be used with `global_asm!` global_asm!("", options(), clobber_abi("C")); -//~^ ERROR clobber_abi is not allowed after options +//~^ ERROR `clobber_abi` cannot be used with `global_asm!` global_asm!("{}", options(), clobber_abi("C"), const FOO); -//~^ ERROR clobber_abi is not allowed after options +//~^ ERROR `clobber_abi` cannot be used with `global_asm!` global_asm!("{a}", a = const FOO, a = const BAR); //~^ ERROR duplicate argument named `a` //~^^ ERROR argument never used diff --git a/tests/ui/asm/aarch64/parse-error.stderr b/tests/ui/asm/aarch64/parse-error.stderr index 804966b06..46984a1fe 100644 --- a/tests/ui/asm/aarch64/parse-error.stderr +++ b/tests/ui/asm/aarch64/parse-error.stderr @@ -82,58 +82,26 @@ error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `no LL | asm!("", options(nomem, foo)); | ^^^ expected one of 10 possible tokens -error: arguments are not allowed after options - --> $DIR/parse-error.rs:39:31 - | -LL | asm!("{}", options(), const foo); - | --------- ^^^^^^^^^ argument - | | - | previous options - error: expected string literal - --> $DIR/parse-error.rs:42:30 + --> $DIR/parse-error.rs:41:30 | LL | asm!("", clobber_abi(foo)); | ^^^ not a string literal error: expected one of `)` or `,`, found `foo` - --> $DIR/parse-error.rs:44:34 + --> $DIR/parse-error.rs:43:34 | LL | asm!("", clobber_abi("C" foo)); | ^^^ expected one of `)` or `,` error: expected string literal - --> $DIR/parse-error.rs:46:35 + --> $DIR/parse-error.rs:45:35 | LL | asm!("", clobber_abi("C", foo)); | ^^^ not a string literal -error: arguments are not allowed after clobber_abi - --> $DIR/parse-error.rs:48:38 - | -LL | asm!("{}", clobber_abi("C"), const foo); - | ---------------- ^^^^^^^^^ argument - | | - | clobber_abi - -error: clobber_abi is not allowed after options - --> $DIR/parse-error.rs:51:29 - | -LL | asm!("", options(), clobber_abi("C")); - | --------- ^^^^^^^^^^^^^^^^ - | | - | options - -error: clobber_abi is not allowed after options - --> $DIR/parse-error.rs:53:31 - | -LL | asm!("{}", options(), clobber_abi("C"), const foo); - | --------- ^^^^^^^^^^^^^^^^ - | | - | options - error: duplicate argument named `a` - --> $DIR/parse-error.rs:55:36 + --> $DIR/parse-error.rs:52:36 | LL | asm!("{a}", a = const foo, a = const bar); | ------------- ^^^^^^^^^^^^^ duplicate argument @@ -141,7 +109,7 @@ LL | asm!("{a}", a = const foo, a = const bar); | previously here error: argument never used - --> $DIR/parse-error.rs:55:36 + --> $DIR/parse-error.rs:52:36 | LL | asm!("{a}", a = const foo, a = const bar); | ^^^^^^^^^^^^^ argument never used @@ -149,29 +117,13 @@ LL | asm!("{a}", a = const foo, a = const bar); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: explicit register arguments cannot have names - --> $DIR/parse-error.rs:60:18 + --> $DIR/parse-error.rs:57:18 | LL | asm!("", a = in("x0") foo); | ^^^^^^^^^^^^^^^^ -error: named arguments cannot follow explicit register arguments - --> $DIR/parse-error.rs:62:35 - | -LL | asm!("{a}", in("x0") foo, a = const bar); - | ------------ ^^^^^^^^^^^^^ named argument - | | - | explicit register argument - -error: named arguments cannot follow explicit register arguments - --> $DIR/parse-error.rs:65:35 - | -LL | asm!("{a}", in("x0") foo, a = const bar); - | ------------ ^^^^^^^^^^^^^ named argument - | | - | explicit register argument - error: positional arguments cannot follow named arguments or explicit register arguments - --> $DIR/parse-error.rs:68:35 + --> $DIR/parse-error.rs:63:35 | LL | asm!("{1}", in("x0") foo, const bar); | ------------ ^^^^^^^^^ positional argument @@ -179,19 +131,19 @@ LL | asm!("{1}", in("x0") foo, const bar); | explicit register argument error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `""` - --> $DIR/parse-error.rs:71:29 + --> $DIR/parse-error.rs:66:29 | LL | asm!("", options(), ""); | ^^ expected one of 9 possible tokens error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `"{}"` - --> $DIR/parse-error.rs:73:33 + --> $DIR/parse-error.rs:68:33 | LL | asm!("{}", in(reg) foo, "{}", out(reg) foo); | ^^^^ expected one of 9 possible tokens error: asm template must be a string literal - --> $DIR/parse-error.rs:75:14 + --> $DIR/parse-error.rs:70:14 | LL | asm!(format!("{{{}}}", 0), in(reg) foo); | ^^^^^^^^^^^^^^^^^^^^ @@ -199,7 +151,7 @@ LL | asm!(format!("{{{}}}", 0), in(reg) foo); = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: asm template must be a string literal - --> $DIR/parse-error.rs:77:21 + --> $DIR/parse-error.rs:72:21 | LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar); | ^^^^^^^^^^^^^^^^^^^^ @@ -207,135 +159,115 @@ LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar); = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: _ cannot be used for input operands - --> $DIR/parse-error.rs:79:28 + --> $DIR/parse-error.rs:74:28 | LL | asm!("{}", in(reg) _); | ^ error: _ cannot be used for input operands - --> $DIR/parse-error.rs:81:31 + --> $DIR/parse-error.rs:76:31 | LL | asm!("{}", inout(reg) _); | ^ error: _ cannot be used for input operands - --> $DIR/parse-error.rs:83:35 + --> $DIR/parse-error.rs:78:35 | LL | asm!("{}", inlateout(reg) _); | ^ error: requires at least a template string argument - --> $DIR/parse-error.rs:90:1 + --> $DIR/parse-error.rs:85:1 | LL | global_asm!(); | ^^^^^^^^^^^^^ error: asm template must be a string literal - --> $DIR/parse-error.rs:92:13 + --> $DIR/parse-error.rs:87:13 | LL | global_asm!(FOO); | ^^^ error: expected token: `,` - --> $DIR/parse-error.rs:94:18 + --> $DIR/parse-error.rs:89:18 | LL | global_asm!("{}" FOO); | ^^^ expected `,` error: expected operand, options, or additional template string - --> $DIR/parse-error.rs:96:19 + --> $DIR/parse-error.rs:91:19 | LL | global_asm!("{}", FOO); | ^^^ expected operand, options, or additional template string error: expected expression, found end of macro arguments - --> $DIR/parse-error.rs:98:24 + --> $DIR/parse-error.rs:93:24 | LL | global_asm!("{}", const); | ^ expected expression error: expected one of `,`, `.`, `?`, or an operator, found `FOO` - --> $DIR/parse-error.rs:100:30 + --> $DIR/parse-error.rs:95:30 | LL | global_asm!("{}", const(reg) FOO); | ^^^ expected one of `,`, `.`, `?`, or an operator error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` - --> $DIR/parse-error.rs:102:25 + --> $DIR/parse-error.rs:97:25 | LL | global_asm!("", options(FOO)); | ^^^ expected one of `)`, `att_syntax`, or `raw` error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` - --> $DIR/parse-error.rs:104:25 + --> $DIR/parse-error.rs:99:25 | LL | global_asm!("", options(nomem FOO)); | ^^^^^ expected one of `)`, `att_syntax`, or `raw` error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` - --> $DIR/parse-error.rs:106:25 + --> $DIR/parse-error.rs:101:25 | LL | global_asm!("", options(nomem, FOO)); | ^^^^^ expected one of `)`, `att_syntax`, or `raw` -error: arguments are not allowed after options - --> $DIR/parse-error.rs:108:30 - | -LL | global_asm!("{}", options(), const FOO); - | --------- ^^^^^^^^^ argument - | | - | previous options - error: expected string literal - --> $DIR/parse-error.rs:110:29 + --> $DIR/parse-error.rs:104:29 | LL | global_asm!("", clobber_abi(FOO)); | ^^^ not a string literal error: expected one of `)` or `,`, found `FOO` - --> $DIR/parse-error.rs:112:33 + --> $DIR/parse-error.rs:106:33 | LL | global_asm!("", clobber_abi("C" FOO)); | ^^^ expected one of `)` or `,` error: expected string literal - --> $DIR/parse-error.rs:114:34 + --> $DIR/parse-error.rs:108:34 | LL | global_asm!("", clobber_abi("C", FOO)); | ^^^ not a string literal -error: arguments are not allowed after clobber_abi - --> $DIR/parse-error.rs:116:37 - | -LL | global_asm!("{}", clobber_abi("C"), const FOO); - | ---------------- ^^^^^^^^^ argument - | | - | clobber_abi - error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:116:19 + --> $DIR/parse-error.rs:110:19 | LL | global_asm!("{}", clobber_abi("C"), const FOO); | ^^^^^^^^^^^^^^^^ -error: clobber_abi is not allowed after options - --> $DIR/parse-error.rs:119:28 +error: `clobber_abi` cannot be used with `global_asm!` + --> $DIR/parse-error.rs:112:28 | LL | global_asm!("", options(), clobber_abi("C")); - | --------- ^^^^^^^^^^^^^^^^ - | | - | options + | ^^^^^^^^^^^^^^^^ -error: clobber_abi is not allowed after options - --> $DIR/parse-error.rs:121:30 +error: `clobber_abi` cannot be used with `global_asm!` + --> $DIR/parse-error.rs:114:30 | LL | global_asm!("{}", options(), clobber_abi("C"), const FOO); - | --------- ^^^^^^^^^^^^^^^^ - | | - | options + | ^^^^^^^^^^^^^^^^ error: duplicate argument named `a` - --> $DIR/parse-error.rs:123:35 + --> $DIR/parse-error.rs:116:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ------------- ^^^^^^^^^^^^^ duplicate argument @@ -343,7 +275,7 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); | previously here error: argument never used - --> $DIR/parse-error.rs:123:35 + --> $DIR/parse-error.rs:116:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ^^^^^^^^^^^^^ argument never used @@ -351,19 +283,19 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""` - --> $DIR/parse-error.rs:126:28 + --> $DIR/parse-error.rs:119:28 | LL | global_asm!("", options(), ""); | ^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"` - --> $DIR/parse-error.rs:128:30 + --> $DIR/parse-error.rs:121:30 | LL | global_asm!("{}", const FOO, "{}", const FOO); | ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: asm template must be a string literal - --> $DIR/parse-error.rs:130:13 + --> $DIR/parse-error.rs:123:13 | LL | global_asm!(format!("{{{}}}", 0), const FOO); | ^^^^^^^^^^^^^^^^^^^^ @@ -371,7 +303,7 @@ LL | global_asm!(format!("{{{}}}", 0), const FOO); = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: asm template must be a string literal - --> $DIR/parse-error.rs:132:20 + --> $DIR/parse-error.rs:125:20 | LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); | ^^^^^^^^^^^^^^^^^^^^ @@ -388,7 +320,7 @@ LL | asm!("{}", options(), const foo); | ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:48:44 + --> $DIR/parse-error.rs:47:44 | LL | let mut foo = 0; | ----------- help: consider using `const` instead of `let`: `const foo` @@ -397,7 +329,16 @@ LL | asm!("{}", clobber_abi("C"), const foo); | ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:55:31 + --> $DIR/parse-error.rs:50:55 + | +LL | let mut foo = 0; + | ----------- help: consider using `const` instead of `let`: `const foo` +... +LL | asm!("{}", options(), clobber_abi("C"), const foo); + | ^^^ non-constant value + +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/parse-error.rs:52:31 | LL | let mut foo = 0; | ----------- help: consider using `const` instead of `let`: `const foo` @@ -406,7 +347,7 @@ LL | asm!("{a}", a = const foo, a = const bar); | ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:55:46 + --> $DIR/parse-error.rs:52:46 | LL | let mut bar = 0; | ----------- help: consider using `const` instead of `let`: `const bar` @@ -415,7 +356,7 @@ LL | asm!("{a}", a = const foo, a = const bar); | ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:62:45 + --> $DIR/parse-error.rs:59:45 | LL | let mut bar = 0; | ----------- help: consider using `const` instead of `let`: `const bar` @@ -424,7 +365,7 @@ LL | asm!("{a}", in("x0") foo, a = const bar); | ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:65:45 + --> $DIR/parse-error.rs:61:45 | LL | let mut bar = 0; | ----------- help: consider using `const` instead of `let`: `const bar` @@ -433,7 +374,7 @@ LL | asm!("{a}", in("x0") foo, a = const bar); | ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:68:41 + --> $DIR/parse-error.rs:63:41 | LL | let mut bar = 0; | ----------- help: consider using `const` instead of `let`: `const bar` @@ -441,6 +382,6 @@ LL | let mut bar = 0; LL | asm!("{1}", in("x0") foo, const bar); | ^^^ non-constant value -error: aborting due to 64 previous errors +error: aborting due to 57 previous errors For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/asm/bad-template.aarch64_mirunsafeck.stderr b/tests/ui/asm/bad-template.aarch64_mirunsafeck.stderr index bb6a222b2..b16f9a06c 100644 --- a/tests/ui/asm/bad-template.aarch64_mirunsafeck.stderr +++ b/tests/ui/asm/bad-template.aarch64_mirunsafeck.stderr @@ -81,6 +81,11 @@ note: explicit register arguments cannot be used in the asm template | LL | asm!("{}", in("x0") foo); | ^^^^^^^^^^^^ +help: use the register name directly in the assembly code + --> $DIR/bad-template.rs:48:20 + | +LL | asm!("{}", in("x0") foo); + | ^^^^^^^^^^^^ error: asm template modifier must be a single character --> $DIR/bad-template.rs:50:17 diff --git a/tests/ui/asm/bad-template.aarch64_thirunsafeck.stderr b/tests/ui/asm/bad-template.aarch64_thirunsafeck.stderr index bb6a222b2..b16f9a06c 100644 --- a/tests/ui/asm/bad-template.aarch64_thirunsafeck.stderr +++ b/tests/ui/asm/bad-template.aarch64_thirunsafeck.stderr @@ -81,6 +81,11 @@ note: explicit register arguments cannot be used in the asm template | LL | asm!("{}", in("x0") foo); | ^^^^^^^^^^^^ +help: use the register name directly in the assembly code + --> $DIR/bad-template.rs:48:20 + | +LL | asm!("{}", in("x0") foo); + | ^^^^^^^^^^^^ error: asm template modifier must be a single character --> $DIR/bad-template.rs:50:17 diff --git a/tests/ui/asm/bad-template.x86_64_mirunsafeck.stderr b/tests/ui/asm/bad-template.x86_64_mirunsafeck.stderr index 903b5e959..41ac37c33 100644 --- a/tests/ui/asm/bad-template.x86_64_mirunsafeck.stderr +++ b/tests/ui/asm/bad-template.x86_64_mirunsafeck.stderr @@ -81,6 +81,11 @@ note: explicit register arguments cannot be used in the asm template | LL | asm!("{}", in("eax") foo); | ^^^^^^^^^^^^^ +help: use the register name directly in the assembly code + --> $DIR/bad-template.rs:45:20 + | +LL | asm!("{}", in("eax") foo); + | ^^^^^^^^^^^^^ error: asm template modifier must be a single character --> $DIR/bad-template.rs:50:17 diff --git a/tests/ui/asm/bad-template.x86_64_thirunsafeck.stderr b/tests/ui/asm/bad-template.x86_64_thirunsafeck.stderr index 903b5e959..41ac37c33 100644 --- a/tests/ui/asm/bad-template.x86_64_thirunsafeck.stderr +++ b/tests/ui/asm/bad-template.x86_64_thirunsafeck.stderr @@ -81,6 +81,11 @@ note: explicit register arguments cannot be used in the asm template | LL | asm!("{}", in("eax") foo); | ^^^^^^^^^^^^^ +help: use the register name directly in the assembly code + --> $DIR/bad-template.rs:45:20 + | +LL | asm!("{}", in("eax") foo); + | ^^^^^^^^^^^^^ error: asm template modifier must be a single character --> $DIR/bad-template.rs:50:17 diff --git a/tests/ui/asm/x86_64/issue-89875.rs b/tests/ui/asm/x86_64/issue-89875.rs index 669fd7e7e..39c645640 100644 --- a/tests/ui/asm/x86_64/issue-89875.rs +++ b/tests/ui/asm/x86_64/issue-89875.rs @@ -7,7 +7,7 @@ use std::arch::asm; #[target_feature(enable = "avx")] -fn main() { +fn foo() { unsafe { asm!( "/* {} */", @@ -15,3 +15,5 @@ fn main() { ); } } + +fn main() {} diff --git a/tests/ui/asm/x86_64/parse-error.rs b/tests/ui/asm/x86_64/parse-error.rs index 9aeb6b285..2e714d464 100644 --- a/tests/ui/asm/x86_64/parse-error.rs +++ b/tests/ui/asm/x86_64/parse-error.rs @@ -37,8 +37,7 @@ fn main() { asm!("", options(nomem, foo)); //~^ ERROR expected one of asm!("{}", options(), const foo); - //~^ ERROR arguments are not allowed after options - //~^^ ERROR attempt to use a non-constant value in a constant + //~^ ERROR attempt to use a non-constant value in a constant asm!("", clobber_abi()); //~^ ERROR at least one abi must be provided asm!("", clobber_abi(foo)); @@ -48,12 +47,10 @@ fn main() { asm!("", clobber_abi("C", foo)); //~^ ERROR expected string literal asm!("{}", clobber_abi("C"), const foo); - //~^ ERROR arguments are not allowed after clobber_abi - //~^^ ERROR attempt to use a non-constant value in a constant + //~^ ERROR attempt to use a non-constant value in a constant asm!("", options(), clobber_abi("C")); - //~^ ERROR clobber_abi is not allowed after options asm!("{}", options(), clobber_abi("C"), const foo); - //~^ ERROR clobber_abi is not allowed after options + //~^ ERROR attempt to use a non-constant value in a constant asm!("{a}", a = const foo, a = const bar); //~^ ERROR duplicate argument named `a` //~^^ ERROR argument never used @@ -62,11 +59,9 @@ fn main() { asm!("", a = in("eax") foo); //~^ ERROR explicit register arguments cannot have names asm!("{a}", in("eax") foo, a = const bar); - //~^ ERROR named arguments cannot follow explicit register arguments - //~^^ ERROR attempt to use a non-constant value in a constant + //~^ ERROR attempt to use a non-constant value in a constant asm!("{a}", in("eax") foo, a = const bar); - //~^ ERROR named arguments cannot follow explicit register arguments - //~^^ ERROR attempt to use a non-constant value in a constant + //~^ ERROR attempt to use a non-constant value in a constant asm!("{1}", in("eax") foo, const bar); //~^ ERROR positional arguments cannot follow named arguments or explicit register arguments //~^^ ERROR attempt to use a non-constant value in a constant @@ -108,7 +103,6 @@ global_asm!("", options(nomem FOO)); global_asm!("", options(nomem, FOO)); //~^ ERROR expected one of global_asm!("{}", options(), const FOO); -//~^ ERROR arguments are not allowed after options global_asm!("", clobber_abi(FOO)); //~^ ERROR expected string literal global_asm!("", clobber_abi("C" FOO)); @@ -116,12 +110,11 @@ global_asm!("", clobber_abi("C" FOO)); global_asm!("", clobber_abi("C", FOO)); //~^ ERROR expected string literal global_asm!("{}", clobber_abi("C"), const FOO); -//~^ ERROR arguments are not allowed after clobber_abi -//~^^ ERROR `clobber_abi` cannot be used with `global_asm!` +//~^ ERROR `clobber_abi` cannot be used with `global_asm!` global_asm!("", options(), clobber_abi("C")); -//~^ ERROR clobber_abi is not allowed after options +//~^ ERROR `clobber_abi` cannot be used with `global_asm!` global_asm!("{}", options(), clobber_abi("C"), const FOO); -//~^ ERROR clobber_abi is not allowed after options +//~^ ERROR `clobber_abi` cannot be used with `global_asm!` global_asm!("", clobber_abi("C"), clobber_abi("C")); //~^ ERROR `clobber_abi` cannot be used with `global_asm!` global_asm!("{a}", a = const FOO, a = const BAR); diff --git a/tests/ui/asm/x86_64/parse-error.stderr b/tests/ui/asm/x86_64/parse-error.stderr index 57702c37b..0c9d6f715 100644 --- a/tests/ui/asm/x86_64/parse-error.stderr +++ b/tests/ui/asm/x86_64/parse-error.stderr @@ -82,64 +82,32 @@ error: expected one of `)`, `att_syntax`, `may_unwind`, `nomem`, `noreturn`, `no LL | asm!("", options(nomem, foo)); | ^^^ expected one of 10 possible tokens -error: arguments are not allowed after options - --> $DIR/parse-error.rs:39:31 - | -LL | asm!("{}", options(), const foo); - | --------- ^^^^^^^^^ argument - | | - | previous options - error: at least one abi must be provided as an argument to `clobber_abi` - --> $DIR/parse-error.rs:42:30 + --> $DIR/parse-error.rs:41:30 | LL | asm!("", clobber_abi()); | ^ error: expected string literal - --> $DIR/parse-error.rs:44:30 + --> $DIR/parse-error.rs:43:30 | LL | asm!("", clobber_abi(foo)); | ^^^ not a string literal error: expected one of `)` or `,`, found `foo` - --> $DIR/parse-error.rs:46:34 + --> $DIR/parse-error.rs:45:34 | LL | asm!("", clobber_abi("C" foo)); | ^^^ expected one of `)` or `,` error: expected string literal - --> $DIR/parse-error.rs:48:35 + --> $DIR/parse-error.rs:47:35 | LL | asm!("", clobber_abi("C", foo)); | ^^^ not a string literal -error: arguments are not allowed after clobber_abi - --> $DIR/parse-error.rs:50:38 - | -LL | asm!("{}", clobber_abi("C"), const foo); - | ---------------- ^^^^^^^^^ argument - | | - | clobber_abi - -error: clobber_abi is not allowed after options - --> $DIR/parse-error.rs:53:29 - | -LL | asm!("", options(), clobber_abi("C")); - | --------- ^^^^^^^^^^^^^^^^ - | | - | options - -error: clobber_abi is not allowed after options - --> $DIR/parse-error.rs:55:31 - | -LL | asm!("{}", options(), clobber_abi("C"), const foo); - | --------- ^^^^^^^^^^^^^^^^ - | | - | options - error: duplicate argument named `a` - --> $DIR/parse-error.rs:57:36 + --> $DIR/parse-error.rs:54:36 | LL | asm!("{a}", a = const foo, a = const bar); | ------------- ^^^^^^^^^^^^^ duplicate argument @@ -147,7 +115,7 @@ LL | asm!("{a}", a = const foo, a = const bar); | previously here error: argument never used - --> $DIR/parse-error.rs:57:36 + --> $DIR/parse-error.rs:54:36 | LL | asm!("{a}", a = const foo, a = const bar); | ^^^^^^^^^^^^^ argument never used @@ -155,29 +123,13 @@ LL | asm!("{a}", a = const foo, a = const bar); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: explicit register arguments cannot have names - --> $DIR/parse-error.rs:62:18 + --> $DIR/parse-error.rs:59:18 | LL | asm!("", a = in("eax") foo); | ^^^^^^^^^^^^^^^^^ -error: named arguments cannot follow explicit register arguments - --> $DIR/parse-error.rs:64:36 - | -LL | asm!("{a}", in("eax") foo, a = const bar); - | ------------- ^^^^^^^^^^^^^ named argument - | | - | explicit register argument - -error: named arguments cannot follow explicit register arguments - --> $DIR/parse-error.rs:67:36 - | -LL | asm!("{a}", in("eax") foo, a = const bar); - | ------------- ^^^^^^^^^^^^^ named argument - | | - | explicit register argument - error: positional arguments cannot follow named arguments or explicit register arguments - --> $DIR/parse-error.rs:70:36 + --> $DIR/parse-error.rs:65:36 | LL | asm!("{1}", in("eax") foo, const bar); | ------------- ^^^^^^^^^ positional argument @@ -185,19 +137,19 @@ LL | asm!("{1}", in("eax") foo, const bar); | explicit register argument error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `""` - --> $DIR/parse-error.rs:73:29 + --> $DIR/parse-error.rs:68:29 | LL | asm!("", options(), ""); | ^^ expected one of 9 possible tokens error: expected one of `clobber_abi`, `const`, `in`, `inlateout`, `inout`, `lateout`, `options`, `out`, or `sym`, found `"{}"` - --> $DIR/parse-error.rs:75:33 + --> $DIR/parse-error.rs:70:33 | LL | asm!("{}", in(reg) foo, "{}", out(reg) foo); | ^^^^ expected one of 9 possible tokens error: asm template must be a string literal - --> $DIR/parse-error.rs:77:14 + --> $DIR/parse-error.rs:72:14 | LL | asm!(format!("{{{}}}", 0), in(reg) foo); | ^^^^^^^^^^^^^^^^^^^^ @@ -205,7 +157,7 @@ LL | asm!(format!("{{{}}}", 0), in(reg) foo); = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: asm template must be a string literal - --> $DIR/parse-error.rs:79:21 + --> $DIR/parse-error.rs:74:21 | LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar); | ^^^^^^^^^^^^^^^^^^^^ @@ -213,141 +165,121 @@ LL | asm!("{1}", format!("{{{}}}", 0), in(reg) foo, out(reg) bar); = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: _ cannot be used for input operands - --> $DIR/parse-error.rs:81:28 + --> $DIR/parse-error.rs:76:28 | LL | asm!("{}", in(reg) _); | ^ error: _ cannot be used for input operands - --> $DIR/parse-error.rs:83:31 + --> $DIR/parse-error.rs:78:31 | LL | asm!("{}", inout(reg) _); | ^ error: _ cannot be used for input operands - --> $DIR/parse-error.rs:85:35 + --> $DIR/parse-error.rs:80:35 | LL | asm!("{}", inlateout(reg) _); | ^ error: requires at least a template string argument - --> $DIR/parse-error.rs:92:1 + --> $DIR/parse-error.rs:87:1 | LL | global_asm!(); | ^^^^^^^^^^^^^ error: asm template must be a string literal - --> $DIR/parse-error.rs:94:13 + --> $DIR/parse-error.rs:89:13 | LL | global_asm!(FOO); | ^^^ error: expected token: `,` - --> $DIR/parse-error.rs:96:18 + --> $DIR/parse-error.rs:91:18 | LL | global_asm!("{}" FOO); | ^^^ expected `,` error: expected operand, options, or additional template string - --> $DIR/parse-error.rs:98:19 + --> $DIR/parse-error.rs:93:19 | LL | global_asm!("{}", FOO); | ^^^ expected operand, options, or additional template string error: expected expression, found end of macro arguments - --> $DIR/parse-error.rs:100:24 + --> $DIR/parse-error.rs:95:24 | LL | global_asm!("{}", const); | ^ expected expression error: expected one of `,`, `.`, `?`, or an operator, found `FOO` - --> $DIR/parse-error.rs:102:30 + --> $DIR/parse-error.rs:97:30 | LL | global_asm!("{}", const(reg) FOO); | ^^^ expected one of `,`, `.`, `?`, or an operator error: expected one of `)`, `att_syntax`, or `raw`, found `FOO` - --> $DIR/parse-error.rs:104:25 + --> $DIR/parse-error.rs:99:25 | LL | global_asm!("", options(FOO)); | ^^^ expected one of `)`, `att_syntax`, or `raw` error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` - --> $DIR/parse-error.rs:106:25 + --> $DIR/parse-error.rs:101:25 | LL | global_asm!("", options(nomem FOO)); | ^^^^^ expected one of `)`, `att_syntax`, or `raw` error: expected one of `)`, `att_syntax`, or `raw`, found `nomem` - --> $DIR/parse-error.rs:108:25 + --> $DIR/parse-error.rs:103:25 | LL | global_asm!("", options(nomem, FOO)); | ^^^^^ expected one of `)`, `att_syntax`, or `raw` -error: arguments are not allowed after options - --> $DIR/parse-error.rs:110:30 - | -LL | global_asm!("{}", options(), const FOO); - | --------- ^^^^^^^^^ argument - | | - | previous options - error: expected string literal - --> $DIR/parse-error.rs:112:29 + --> $DIR/parse-error.rs:106:29 | LL | global_asm!("", clobber_abi(FOO)); | ^^^ not a string literal error: expected one of `)` or `,`, found `FOO` - --> $DIR/parse-error.rs:114:33 + --> $DIR/parse-error.rs:108:33 | LL | global_asm!("", clobber_abi("C" FOO)); | ^^^ expected one of `)` or `,` error: expected string literal - --> $DIR/parse-error.rs:116:34 + --> $DIR/parse-error.rs:110:34 | LL | global_asm!("", clobber_abi("C", FOO)); | ^^^ not a string literal -error: arguments are not allowed after clobber_abi - --> $DIR/parse-error.rs:118:37 - | -LL | global_asm!("{}", clobber_abi("C"), const FOO); - | ---------------- ^^^^^^^^^ argument - | | - | clobber_abi - error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:118:19 + --> $DIR/parse-error.rs:112:19 | LL | global_asm!("{}", clobber_abi("C"), const FOO); | ^^^^^^^^^^^^^^^^ -error: clobber_abi is not allowed after options - --> $DIR/parse-error.rs:121:28 +error: `clobber_abi` cannot be used with `global_asm!` + --> $DIR/parse-error.rs:114:28 | LL | global_asm!("", options(), clobber_abi("C")); - | --------- ^^^^^^^^^^^^^^^^ - | | - | options + | ^^^^^^^^^^^^^^^^ -error: clobber_abi is not allowed after options - --> $DIR/parse-error.rs:123:30 +error: `clobber_abi` cannot be used with `global_asm!` + --> $DIR/parse-error.rs:116:30 | LL | global_asm!("{}", options(), clobber_abi("C"), const FOO); - | --------- ^^^^^^^^^^^^^^^^ - | | - | options + | ^^^^^^^^^^^^^^^^ error: `clobber_abi` cannot be used with `global_asm!` - --> $DIR/parse-error.rs:125:17 + --> $DIR/parse-error.rs:118:17 | LL | global_asm!("", clobber_abi("C"), clobber_abi("C")); | ^^^^^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^ error: duplicate argument named `a` - --> $DIR/parse-error.rs:127:35 + --> $DIR/parse-error.rs:120:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ------------- ^^^^^^^^^^^^^ duplicate argument @@ -355,7 +287,7 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); | previously here error: argument never used - --> $DIR/parse-error.rs:127:35 + --> $DIR/parse-error.rs:120:35 | LL | global_asm!("{a}", a = const FOO, a = const BAR); | ^^^^^^^^^^^^^ argument never used @@ -363,19 +295,19 @@ LL | global_asm!("{a}", a = const FOO, a = const BAR); = help: if this argument is intentionally unused, consider using it in an asm comment: `"/* {1} */"` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `""` - --> $DIR/parse-error.rs:130:28 + --> $DIR/parse-error.rs:123:28 | LL | global_asm!("", options(), ""); | ^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: expected one of `clobber_abi`, `const`, `options`, or `sym`, found `"{}"` - --> $DIR/parse-error.rs:132:30 + --> $DIR/parse-error.rs:125:30 | LL | global_asm!("{}", const FOO, "{}", const FOO); | ^^^^ expected one of `clobber_abi`, `const`, `options`, or `sym` error: asm template must be a string literal - --> $DIR/parse-error.rs:134:13 + --> $DIR/parse-error.rs:127:13 | LL | global_asm!(format!("{{{}}}", 0), const FOO); | ^^^^^^^^^^^^^^^^^^^^ @@ -383,7 +315,7 @@ LL | global_asm!(format!("{{{}}}", 0), const FOO); = note: this error originates in the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: asm template must be a string literal - --> $DIR/parse-error.rs:136:20 + --> $DIR/parse-error.rs:129:20 | LL | global_asm!("{1}", format!("{{{}}}", 0), const FOO, const BAR); | ^^^^^^^^^^^^^^^^^^^^ @@ -400,7 +332,7 @@ LL | asm!("{}", options(), const foo); | ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:50:44 + --> $DIR/parse-error.rs:49:44 | LL | let mut foo = 0; | ----------- help: consider using `const` instead of `let`: `const foo` @@ -409,7 +341,16 @@ LL | asm!("{}", clobber_abi("C"), const foo); | ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:57:31 + --> $DIR/parse-error.rs:52:55 + | +LL | let mut foo = 0; + | ----------- help: consider using `const` instead of `let`: `const foo` +... +LL | asm!("{}", options(), clobber_abi("C"), const foo); + | ^^^ non-constant value + +error[E0435]: attempt to use a non-constant value in a constant + --> $DIR/parse-error.rs:54:31 | LL | let mut foo = 0; | ----------- help: consider using `const` instead of `let`: `const foo` @@ -418,7 +359,7 @@ LL | asm!("{a}", a = const foo, a = const bar); | ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:57:46 + --> $DIR/parse-error.rs:54:46 | LL | let mut bar = 0; | ----------- help: consider using `const` instead of `let`: `const bar` @@ -427,7 +368,7 @@ LL | asm!("{a}", a = const foo, a = const bar); | ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:64:46 + --> $DIR/parse-error.rs:61:46 | LL | let mut bar = 0; | ----------- help: consider using `const` instead of `let`: `const bar` @@ -436,7 +377,7 @@ LL | asm!("{a}", in("eax") foo, a = const bar); | ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:67:46 + --> $DIR/parse-error.rs:63:46 | LL | let mut bar = 0; | ----------- help: consider using `const` instead of `let`: `const bar` @@ -445,7 +386,7 @@ LL | asm!("{a}", in("eax") foo, a = const bar); | ^^^ non-constant value error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/parse-error.rs:70:42 + --> $DIR/parse-error.rs:65:42 | LL | let mut bar = 0; | ----------- help: consider using `const` instead of `let`: `const bar` @@ -453,6 +394,6 @@ LL | let mut bar = 0; LL | asm!("{1}", in("eax") foo, const bar); | ^^^ non-constant value -error: aborting due to 66 previous errors +error: aborting due to 59 previous errors For more information about this error, try `rustc --explain E0435`. diff --git a/tests/ui/associated-consts/associated-const-dead-code.stderr b/tests/ui/associated-consts/associated-const-dead-code.stderr index cc701cc4b..7e485a314 100644 --- a/tests/ui/associated-consts/associated-const-dead-code.stderr +++ b/tests/ui/associated-consts/associated-const-dead-code.stderr @@ -1,6 +1,8 @@ error: associated constant `BAR` is never used --> $DIR/associated-const-dead-code.rs:6:11 | +LL | impl MyFoo { + | ---------- associated constant in this implementation LL | const BAR: u32 = 1; | ^^^ | diff --git a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr index fb7159e40..9b761b006 100644 --- a/tests/ui/associated-consts/defaults-not-assumed-fail.stderr +++ b/tests/ui/associated-consts/defaults-not-assumed-fail.stderr @@ -26,14 +26,6 @@ LL | assert_eq!(<() as Tr>::B, 0); // causes the error above | = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) -note: erroneous constant used - --> $DIR/defaults-not-assumed-fail.rs:33:5 - | -LL | assert_eq!(<() as Tr>::B, 0); // causes the error above - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this note originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) - error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/associated-consts/issue-93775.rs b/tests/ui/associated-consts/issue-93775.rs index 7a007b732..db788fe6e 100644 --- a/tests/ui/associated-consts/issue-93775.rs +++ b/tests/ui/associated-consts/issue-93775.rs @@ -3,7 +3,7 @@ // Regression for #93775, needs build-pass to test it. -#![recursion_limit = "1000"] +#![recursion_limit = "1001"] use std::marker::PhantomData; diff --git a/tests/ui/associated-inherent-types/issue-109299-1.rs b/tests/ui/associated-inherent-types/issue-109299-1.rs new file mode 100644 index 000000000..6f9527311 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-109299-1.rs @@ -0,0 +1,12 @@ +#![feature(inherent_associated_types, non_lifetime_binders, type_alias_impl_trait)] +#![allow(incomplete_features)] + +struct Lexer<T>(T); + +impl Lexer<i32> { + type Cursor = (); +} + +type X = impl for<T> Fn() -> Lexer<T>::Cursor; //~ ERROR associated type `Cursor` not found for `Lexer<T>` in the current scope + +fn main() {} diff --git a/tests/ui/associated-inherent-types/issue-109299-1.stderr b/tests/ui/associated-inherent-types/issue-109299-1.stderr new file mode 100644 index 000000000..dc59b56ee --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-109299-1.stderr @@ -0,0 +1,15 @@ +error[E0220]: associated type `Cursor` not found for `Lexer<T>` in the current scope + --> $DIR/issue-109299-1.rs:10:40 + | +LL | struct Lexer<T>(T); + | --------------- associated item `Cursor` not found for this struct +... +LL | type X = impl for<T> Fn() -> Lexer<T>::Cursor; + | ^^^^^^ associated item not found in `Lexer<T>` + | + = note: the associated type was found for + - `Lexer<i32>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0220`. diff --git a/tests/ui/associated-inherent-types/issue-109299.rs b/tests/ui/associated-inherent-types/issue-109299.rs new file mode 100644 index 000000000..84e4f9e72 --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-109299.rs @@ -0,0 +1,12 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] + +struct Lexer<'d>(&'d ()); + +impl Lexer<'d> { //~ ERROR use of undeclared lifetime name `'d` + type Cursor = (); +} + +fn test(_: Lexer::Cursor) {} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/issue-109299.stderr b/tests/ui/associated-inherent-types/issue-109299.stderr new file mode 100644 index 000000000..63f50732d --- /dev/null +++ b/tests/ui/associated-inherent-types/issue-109299.stderr @@ -0,0 +1,11 @@ +error[E0261]: use of undeclared lifetime name `'d` + --> $DIR/issue-109299.rs:6:12 + | +LL | impl Lexer<'d> { + | - ^^ undeclared lifetime + | | + | help: consider introducing lifetime `'d` here: `<'d>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0261`. diff --git a/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr b/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr index 4162cdaa8..575b00e09 100644 --- a/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr +++ b/tests/ui/associated-type-bounds/ambiguous-associated-type2.stderr @@ -5,7 +5,7 @@ LL | trait Baz: Foo + Bar<Self::Item> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: ...which immediately requires computing the super traits of `Baz` with associated type name `Item` again -note: cycle used when computing the super traits of `Baz` +note: cycle used when computing the super predicates of `Baz` --> $DIR/ambiguous-associated-type2.rs:7:1 | LL | trait Baz: Foo + Bar<Self::Item> {} diff --git a/tests/ui/associated-type-bounds/issue-104916.rs b/tests/ui/associated-type-bounds/issue-104916.rs new file mode 100644 index 000000000..3361fa011 --- /dev/null +++ b/tests/ui/associated-type-bounds/issue-104916.rs @@ -0,0 +1,14 @@ +#![feature(associated_type_bounds)] + +trait B { + type AssocType; +} + +fn f() +where + dyn for<'j> B<AssocType: 'j>:, + //~^ ERROR: associated type bounds are only allowed in where clauses and function signatures +{ +} + +fn main() {} diff --git a/tests/ui/associated-type-bounds/issue-104916.stderr b/tests/ui/associated-type-bounds/issue-104916.stderr new file mode 100644 index 000000000..35435962f --- /dev/null +++ b/tests/ui/associated-type-bounds/issue-104916.stderr @@ -0,0 +1,8 @@ +error: associated type bounds are only allowed in where clauses and function signatures, not in bounds + --> $DIR/issue-104916.rs:9:19 + | +LL | dyn for<'j> B<AssocType: 'j>:, + | ^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs new file mode 100644 index 000000000..79cee5517 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.rs @@ -0,0 +1,22 @@ +// edition: 2021 + +#![feature(return_type_notation, async_fn_in_trait)] +//~^ WARN the feature `return_type_notation` is incomplete +//~| WARN the feature `async_fn_in_trait` is incomplete + +trait Trait { + async fn method() {} +} + +fn foo<T: Trait<method(i32): Send>>() {} +//~^ ERROR argument types not allowed with return type notation +//~| ERROR associated type bounds are unstable + +fn bar<T: Trait<method() -> (): Send>>() {} +//~^ ERROR return type not allowed with return type notation +//~| ERROR associated type bounds are unstable + +fn baz<T: Trait<method(..): Send>>() {} +//~^ ERROR return type notation uses `()` instead of `(..)` for elided arguments + +fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr new file mode 100644 index 000000000..b23e0f791 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/bad-inputs-and-output.stderr @@ -0,0 +1,56 @@ +error: return type notation uses `()` instead of `(..)` for elided arguments + --> $DIR/bad-inputs-and-output.rs:19:24 + | +LL | fn baz<T: Trait<method(..): Send>>() {} + | ^^ help: remove the `..` + +error[E0658]: associated type bounds are unstable + --> $DIR/bad-inputs-and-output.rs:11:17 + | +LL | fn foo<T: Trait<method(i32): Send>>() {} + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error[E0658]: associated type bounds are unstable + --> $DIR/bad-inputs-and-output.rs:15:17 + | +LL | fn bar<T: Trait<method() -> (): Send>>() {} + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/bad-inputs-and-output.rs:3:12 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/bad-inputs-and-output.rs:3:34 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + +error: argument types not allowed with return type notation + --> $DIR/bad-inputs-and-output.rs:11:23 + | +LL | fn foo<T: Trait<method(i32): Send>>() {} + | ^^^^^ help: remove the input types: `()` + +error: return type not allowed with return type notation + --> $DIR/bad-inputs-and-output.rs:15:25 + | +LL | fn bar<T: Trait<method() -> (): Send>>() {} + | ^^^^^^ help: remove the return type + +error: aborting due to 5 previous errors; 2 warnings emitted + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.rs b/tests/ui/associated-type-bounds/return-type-notation/basic.rs new file mode 100644 index 000000000..0b7530b65 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.rs @@ -0,0 +1,28 @@ +// revisions: with without +// edition: 2021 +//[with] check-pass + +#![feature(return_type_notation, async_fn_in_trait)] +//~^ WARN the feature `return_type_notation` is incomplete +//~| WARN the feature `async_fn_in_trait` is incomplete + +trait Foo { + async fn method() -> Result<(), ()>; +} + +async fn foo<T: Foo>() -> Result<(), ()> { + T::method().await?; + Ok(()) +} + +fn is_send(_: impl Send) {} + +fn test< + #[cfg(with)] T: Foo<method(): Send>, + #[cfg(without)] T: Foo, +>() { + is_send(foo::<T>()); + //[without]~^ ERROR future cannot be sent between threads safely +} + +fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr new file mode 100644 index 000000000..722c774cb --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.with.stderr @@ -0,0 +1,19 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/basic.rs:5:12 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/basic.rs:5:34 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + +warning: 2 warnings emitted + diff --git a/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr new file mode 100644 index 000000000..1645d8c26 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/basic.without.stderr @@ -0,0 +1,37 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/basic.rs:5:12 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/basic.rs:5:34 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + +error: future cannot be sent between threads safely + --> $DIR/basic.rs:24:13 + | +LL | is_send(foo::<T>()); + | ^^^^^^^^^^ future returned by `foo` is not `Send` + | + = help: within `impl Future<Output = Result<(), ()>>`, the trait `Send` is not implemented for `impl Future<Output = Result<(), ()>>` +note: future is not `Send` as it awaits another future which is not `Send` + --> $DIR/basic.rs:14:5 + | +LL | T::method().await?; + | ^^^^^^^^^^^ await occurs here on type `impl Future<Output = Result<(), ()>>`, which is not `Send` +note: required by a bound in `is_send` + --> $DIR/basic.rs:18:20 + | +LL | fn is_send(_: impl Send) {} + | ^^^^ required by this bound in `is_send` + +error: aborting due to previous error; 2 warnings emitted + diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.rs b/tests/ui/associated-type-bounds/return-type-notation/equality.rs new file mode 100644 index 000000000..75f757e90 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.rs @@ -0,0 +1,16 @@ +// edition: 2021 + +#![feature(return_type_notation, async_fn_in_trait)] +//~^ WARN the feature `return_type_notation` is incomplete +//~| WARN the feature `async_fn_in_trait` is incomplete + +use std::future::Future; + +trait Trait { + async fn method() {} +} + +fn test<T: Trait<method() = Box<dyn Future<Output = ()>>>>() {} +//~^ ERROR return type notation is not allowed to use type equality + +fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/equality.stderr b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr new file mode 100644 index 000000000..c5b2e5710 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/equality.stderr @@ -0,0 +1,25 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/equality.rs:3:12 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/equality.rs:3:34 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + +error: return type notation is not allowed to use type equality + --> $DIR/equality.rs:13:18 + | +LL | fn test<T: Trait<method() = Box<dyn Future<Output = ()>>>>() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error; 2 warnings emitted + diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.rs b/tests/ui/associated-type-bounds/return-type-notation/missing.rs new file mode 100644 index 000000000..7b98a5cda --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/missing.rs @@ -0,0 +1,14 @@ +// edition: 2021 + +#![feature(return_type_notation, async_fn_in_trait)] +//~^ WARN the feature `return_type_notation` is incomplete +//~| WARN the feature `async_fn_in_trait` is incomplete + +trait Trait { + async fn method() {} +} + +fn bar<T: Trait<methid(): Send>>() {} +//~^ ERROR cannot find associated function `methid` in trait `Trait` + +fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/missing.stderr b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr new file mode 100644 index 000000000..34f5bda88 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/missing.stderr @@ -0,0 +1,25 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/missing.rs:3:12 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/missing.rs:3:34 + | +LL | #![feature(return_type_notation, async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + +error: cannot find associated function `methid` in trait `Trait` + --> $DIR/missing.rs:11:17 + | +LL | fn bar<T: Trait<methid(): Send>>() {} + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error; 2 warnings emitted + diff --git a/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs new file mode 100644 index 000000000..db5f6fe38 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.rs @@ -0,0 +1,11 @@ +#![feature(return_type_notation)] +//~^ WARN the feature `return_type_notation` is incomplete + +trait Trait { + fn method() {} +} + +fn test<T: Trait<method(): Send>>() {} +//~^ ERROR return type notation used on function that is not `async` and does not return `impl Trait` + +fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr new file mode 100644 index 000000000..31b793995 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/non-rpitit.stderr @@ -0,0 +1,22 @@ +warning: the feature `return_type_notation` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/non-rpitit.rs:1:12 + | +LL | #![feature(return_type_notation)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: return type notation used on function that is not `async` and does not return `impl Trait` + --> $DIR/non-rpitit.rs:8:18 + | +LL | fn method() {} + | ----------- this function must be `async` or return `impl Trait` +... +LL | fn test<T: Trait<method(): Send>>() {} + | ^^^^^^^^^^^^^^ + | + = note: function returns `()`, which is not compatible with associated type return bounds + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.rs b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.rs new file mode 100644 index 000000000..9129f37e0 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.rs @@ -0,0 +1,11 @@ +// edition: 2021 +// compile-flags: -Zunpretty=expanded + +trait Trait { + async fn method() {} +} + +fn foo<T: Trait<method(i32): Send>>() {} +//~^ ERROR associated type bounds are unstable + +fn main() {} diff --git a/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stderr b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stderr new file mode 100644 index 000000000..77e015b41 --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stderr @@ -0,0 +1,12 @@ +error[E0658]: associated type bounds are unstable + --> $DIR/unpretty-parenthesized.rs:8:17 + | +LL | fn foo<T: Trait<method(i32): Send>>() {} + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #52662 <https://github.com/rust-lang/rust/issues/52662> for more information + = help: add `#![feature(associated_type_bounds)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout new file mode 100644 index 000000000..b3dea8f6e --- /dev/null +++ b/tests/ui/associated-type-bounds/return-type-notation/unpretty-parenthesized.stdout @@ -0,0 +1,15 @@ +#![feature(prelude_import)] +#[prelude_import] +use std::prelude::rust_2021::*; +#[macro_use] +extern crate std; +// edition: 2021 +// compile-flags: -Zunpretty=expanded + +trait Trait { + async fn method() {} +} + +fn foo<T: Trait<method(i32) : Send>>() {} + +fn main() {} diff --git a/tests/ui/associated-types/associated-types-in-ambiguous-context.rs b/tests/ui/associated-types/associated-types-in-ambiguous-context.rs index 51b53908f..5d6b1b591 100644 --- a/tests/ui/associated-types/associated-types-in-ambiguous-context.rs +++ b/tests/ui/associated-types/associated-types-in-ambiguous-context.rs @@ -1,3 +1,5 @@ +// normalize-stderr-test: "and \d+ other candidates" -> "and N other candidates" + trait Get { type Value; fn get(&self) -> <Self as Get>::Value; diff --git a/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr b/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr index 00856b55d..1ff6fd4b8 100644 --- a/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr +++ b/tests/ui/associated-types/associated-types-in-ambiguous-context.stderr @@ -1,5 +1,5 @@ error[E0223]: ambiguous associated type - --> $DIR/associated-types-in-ambiguous-context.rs:6:36 + --> $DIR/associated-types-in-ambiguous-context.rs:8:36 | LL | fn get<T:Get,U:Get>(x: T, y: U) -> Get::Value {} | ^^^^^^^^^^ @@ -10,30 +10,37 @@ LL | fn get<T:Get,U:Get>(x: T, y: U) -> <Example as Get>::Value {} | ~~~~~~~~~~~~~~~~~~~~~~~ error[E0223]: ambiguous associated type - --> $DIR/associated-types-in-ambiguous-context.rs:20:17 + --> $DIR/associated-types-in-ambiguous-context.rs:22:17 | LL | trait Foo where Foo::Assoc: Bar { | ^^^^^^^^^^ help: use the fully-qualified path: `<Self as Foo>::Assoc` error[E0223]: ambiguous associated type - --> $DIR/associated-types-in-ambiguous-context.rs:25:10 + --> $DIR/associated-types-in-ambiguous-context.rs:27:10 | LL | type X = std::ops::Deref::Target; | ^^^^^^^^^^^^^^^^^^^^^^^ | -help: if there were a type named `Example` that implemented `Deref`, you could use the fully-qualified path +help: use the fully-qualified path | -LL | type X = <Example as Deref>::Target; +LL | type X = <CString as Deref>::Target; | ~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | type X = <IoSlice<'_> as Deref>::Target; + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | type X = <IoSliceMut<'_> as Deref>::Target; + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | type X = <OsString as Deref>::Target; + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~ + and N other candidates error[E0223]: ambiguous associated type - --> $DIR/associated-types-in-ambiguous-context.rs:11:23 + --> $DIR/associated-types-in-ambiguous-context.rs:13:23 | LL | fn grab(&self) -> Grab::Value; | ^^^^^^^^^^^ help: use the fully-qualified path: `<Self as Grab>::Value` error[E0223]: ambiguous associated type - --> $DIR/associated-types-in-ambiguous-context.rs:14:22 + --> $DIR/associated-types-in-ambiguous-context.rs:16:22 | LL | fn get(&self) -> Get::Value; | ^^^^^^^^^^ diff --git a/tests/ui/associated-types/defaults-suitability.stderr b/tests/ui/associated-types/defaults-suitability.stderr index 248575875..4b2094691 100644 --- a/tests/ui/associated-types/defaults-suitability.stderr +++ b/tests/ui/associated-types/defaults-suitability.stderr @@ -11,7 +11,8 @@ LL | type Ty: Clone = NotClone; | ^^^^^ required by this bound in `Tr::Ty` help: consider annotating `NotClone` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct NotClone; | error[E0277]: the trait bound `NotClone: Clone` is not satisfied @@ -30,7 +31,8 @@ LL | type Ty = NotClone; | -- required by a bound in this associated type help: consider annotating `NotClone` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct NotClone; | error[E0277]: the trait bound `T: Clone` is not satisfied diff --git a/tests/ui/associated-types/issue-20825.stderr b/tests/ui/associated-types/issue-20825.stderr index be2bbd448..c4dea68b8 100644 --- a/tests/ui/associated-types/issue-20825.stderr +++ b/tests/ui/associated-types/issue-20825.stderr @@ -5,7 +5,7 @@ LL | pub trait Processor: Subscriber<Input = Self::Input> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: ...which immediately requires computing the super traits of `Processor` with associated type name `Input` again -note: cycle used when computing the super traits of `Processor` +note: cycle used when computing the super predicates of `Processor` --> $DIR/issue-20825.rs:5:1 | LL | pub trait Processor: Subscriber<Input = Self::Input> { diff --git a/tests/ui/associated-types/issue-63591.rs b/tests/ui/associated-types/issue-63591.rs index 4d2e39f4d..d07c12349 100644 --- a/tests/ui/associated-types/issue-63591.rs +++ b/tests/ui/associated-types/issue-63591.rs @@ -1,11 +1,13 @@ // check-pass #![feature(associated_type_bounds)] -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] fn main() {} -trait Bar { type Assoc; } +trait Bar { + type Assoc; +} trait Thing { type Out; @@ -13,7 +15,9 @@ trait Thing { } struct AssocIsCopy; -impl Bar for AssocIsCopy { type Assoc = u8; } +impl Bar for AssocIsCopy { + type Assoc = u8; +} impl Thing for AssocIsCopy { type Out = impl Bar<Assoc: Copy>; diff --git a/tests/ui/associated-types/issue-67684.rs b/tests/ui/associated-types/issue-67684.rs index 49efe8a1b..c6920cf8d 100644 --- a/tests/ui/associated-types/issue-67684.rs +++ b/tests/ui/associated-types/issue-67684.rs @@ -1,4 +1,10 @@ -// check-pass +// revisions: check build +// [check]check-pass +// +// This second configuration aims to verify that we do not ICE in ConstProp because of +// normalization failure. +// [build]build-pass +// [build]compile-flags: -Zmir-opt-level=3 --emit=mir #![allow(dead_code)] diff --git a/tests/ui/async-await/async-trait-fn.current.stderr b/tests/ui/async-await/async-trait-fn.current.stderr new file mode 100644 index 000000000..7ccf2f230 --- /dev/null +++ b/tests/ui/async-await/async-trait-fn.current.stderr @@ -0,0 +1,42 @@ +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/async-trait-fn.rs:6:5 + | +LL | async fn foo() {} + | -----^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable + +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/async-trait-fn.rs:7:5 + | +LL | async fn bar(&self) {} + | -----^^^^^^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable + +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/async-trait-fn.rs:8:5 + | +LL | async fn baz() { + | -----^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0706`. diff --git a/tests/ui/async-await/async-trait-fn.next.stderr b/tests/ui/async-await/async-trait-fn.next.stderr new file mode 100644 index 000000000..7ccf2f230 --- /dev/null +++ b/tests/ui/async-await/async-trait-fn.next.stderr @@ -0,0 +1,42 @@ +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/async-trait-fn.rs:6:5 + | +LL | async fn foo() {} + | -----^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable + +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/async-trait-fn.rs:7:5 + | +LL | async fn bar(&self) {} + | -----^^^^^^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable + +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/async-trait-fn.rs:8:5 + | +LL | async fn baz() { + | -----^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0706`. diff --git a/tests/ui/async-await/async-trait-fn.rs b/tests/ui/async-await/async-trait-fn.rs index e2062e827..04123badb 100644 --- a/tests/ui/async-await/async-trait-fn.rs +++ b/tests/ui/async-await/async-trait-fn.rs @@ -1,4 +1,5 @@ // edition:2018 + trait T { async fn foo() {} //~ ERROR functions in traits cannot be declared `async` async fn bar(&self) {} //~ ERROR functions in traits cannot be declared `async` diff --git a/tests/ui/async-await/async-trait-fn.stderr b/tests/ui/async-await/async-trait-fn.stderr index afbe25cf7..68ebe3507 100644 --- a/tests/ui/async-await/async-trait-fn.stderr +++ b/tests/ui/async-await/async-trait-fn.stderr @@ -1,5 +1,5 @@ error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:3:5 + --> $DIR/async-trait-fn.rs:4:5 | LL | async fn foo() {} | -----^^^^^^^^^ @@ -12,7 +12,7 @@ LL | async fn foo() {} = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:4:5 + --> $DIR/async-trait-fn.rs:5:5 | LL | async fn bar(&self) {} | -----^^^^^^^^^^^^^^ @@ -25,7 +25,7 @@ LL | async fn bar(&self) {} = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` - --> $DIR/async-trait-fn.rs:5:5 + --> $DIR/async-trait-fn.rs:6:5 | LL | async fn baz() { | -----^^^^^^^^^ diff --git a/tests/ui/async-await/edition-deny-async-fns-2015.stderr b/tests/ui/async-await/edition-deny-async-fns-2015.current.stderr index ba918eb28..c47b99e65 100644 --- a/tests/ui/async-await/edition-deny-async-fns-2015.stderr +++ b/tests/ui/async-await/edition-deny-async-fns-2015.current.stderr @@ -1,5 +1,5 @@ error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:3:1 + --> $DIR/edition-deny-async-fns-2015.rs:5:1 | LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -8,7 +8,7 @@ LL | async fn foo() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:5:12 + --> $DIR/edition-deny-async-fns-2015.rs:7:12 | LL | fn baz() { async fn foo() {} } | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -17,7 +17,7 @@ LL | fn baz() { async fn foo() {} } = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:7:1 + --> $DIR/edition-deny-async-fns-2015.rs:9:1 | LL | async fn async_baz() { | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -26,7 +26,7 @@ LL | async fn async_baz() { = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:8:5 + --> $DIR/edition-deny-async-fns-2015.rs:10:5 | LL | async fn bar() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -35,7 +35,7 @@ LL | async fn bar() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:14:5 + --> $DIR/edition-deny-async-fns-2015.rs:16:5 | LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -44,7 +44,7 @@ LL | async fn foo() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:18:5 + --> $DIR/edition-deny-async-fns-2015.rs:20:5 | LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -53,7 +53,7 @@ LL | async fn foo() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:36:9 + --> $DIR/edition-deny-async-fns-2015.rs:38:9 | LL | async fn bar() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -62,7 +62,7 @@ LL | async fn bar() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:26:9 + --> $DIR/edition-deny-async-fns-2015.rs:28:9 | LL | async fn foo() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -71,7 +71,7 @@ LL | async fn foo() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0670]: `async fn` is not permitted in Rust 2015 - --> $DIR/edition-deny-async-fns-2015.rs:31:13 + --> $DIR/edition-deny-async-fns-2015.rs:33:13 | LL | async fn bar() {} | ^^^^^ to use `async fn`, switch to Rust 2018 or later @@ -80,7 +80,7 @@ LL | async fn bar() {} = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0706]: functions in traits cannot be declared `async` - --> $DIR/edition-deny-async-fns-2015.rs:18:5 + --> $DIR/edition-deny-async-fns-2015.rs:20:5 | LL | async fn foo() {} | -----^^^^^^^^^ diff --git a/tests/ui/async-await/edition-deny-async-fns-2015.next.stderr b/tests/ui/async-await/edition-deny-async-fns-2015.next.stderr new file mode 100644 index 000000000..c47b99e65 --- /dev/null +++ b/tests/ui/async-await/edition-deny-async-fns-2015.next.stderr @@ -0,0 +1,98 @@ +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:5:1 + | +LL | async fn foo() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:7:12 + | +LL | fn baz() { async fn foo() {} } + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:9:1 + | +LL | async fn async_baz() { + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:10:5 + | +LL | async fn bar() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:16:5 + | +LL | async fn foo() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:20:5 + | +LL | async fn foo() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:38:9 + | +LL | async fn bar() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:28:9 + | +LL | async fn foo() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0670]: `async fn` is not permitted in Rust 2015 + --> $DIR/edition-deny-async-fns-2015.rs:33:13 + | +LL | async fn bar() {} + | ^^^^^ to use `async fn`, switch to Rust 2018 or later + | + = help: pass `--edition 2021` to `rustc` + = note: for more on editions, read https://doc.rust-lang.org/edition-guide + +error[E0706]: functions in traits cannot be declared `async` + --> $DIR/edition-deny-async-fns-2015.rs:20:5 + | +LL | async fn foo() {} + | -----^^^^^^^^^ + | | + | `async` because of this + | + = note: `async` trait functions are not currently supported + = note: consider using the `async-trait` crate: https://crates.io/crates/async-trait + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable + +error: aborting due to 10 previous errors + +Some errors have detailed explanations: E0670, E0706. +For more information about an error, try `rustc --explain E0670`. diff --git a/tests/ui/async-await/edition-deny-async-fns-2015.rs b/tests/ui/async-await/edition-deny-async-fns-2015.rs index 6bd6d879a..d4c30dc9d 100644 --- a/tests/ui/async-await/edition-deny-async-fns-2015.rs +++ b/tests/ui/async-await/edition-deny-async-fns-2015.rs @@ -1,4 +1,6 @@ // edition:2015 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next async fn foo() {} //~ ERROR `async fn` is not permitted in Rust 2015 diff --git a/tests/ui/async-await/generator-desc.stderr b/tests/ui/async-await/generator-desc.stderr index 51ac9d86b..042766f19 100644 --- a/tests/ui/async-await/generator-desc.stderr +++ b/tests/ui/async-await/generator-desc.stderr @@ -2,16 +2,18 @@ error[E0308]: mismatched types --> $DIR/generator-desc.rs:10:19 | LL | fun(async {}, async {}); - | -------- ^^^^^^^^ - | | | - | | expected `async` block, found a different `async` block - | | arguments to this function are incorrect - | the expected `async` block + | --- -------- ^^^^^^^^ expected `async` block, found a different `async` block + | | | + | | the expected `async` block + | arguments to this function are incorrect | = note: expected `async` block `[async block@$DIR/generator-desc.rs:10:9: 10:17]` found `async` block `[async block@$DIR/generator-desc.rs:10:19: 10:27]` note: function defined here - --> $SRC_DIR/core/src/future/mod.rs:LL:COL + --> $DIR/generator-desc.rs:8:4 + | +LL | fn fun<F: Future<Output = ()>>(f1: F, f2: F) {} + | ^^^ ----- error[E0308]: mismatched types --> $DIR/generator-desc.rs:12:16 diff --git a/tests/ui/async-await/in-trait/async-associated-types.rs b/tests/ui/async-await/in-trait/async-associated-types.rs index 974f5aaff..89ca4039b 100644 --- a/tests/ui/async-await/in-trait/async-associated-types.rs +++ b/tests/ui/async-await/in-trait/async-associated-types.rs @@ -1,5 +1,7 @@ // check-pass // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![feature(impl_trait_projections)] diff --git a/tests/ui/async-await/in-trait/async-associated-types2.rs b/tests/ui/async-await/in-trait/async-associated-types2.rs index e546a0579..b889f616a 100644 --- a/tests/ui/async-await/in-trait/async-associated-types2.rs +++ b/tests/ui/async-await/in-trait/async-associated-types2.rs @@ -1,8 +1,10 @@ // check-pass // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] #![allow(incomplete_features)] use std::future::Future; @@ -21,9 +23,7 @@ impl MyTrait for i32 { Self: 'a; fn foo<'a>(&'a self) -> Self::Fut<'a> { - async { - *self - } + async { *self } } } diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.stderr b/tests/ui/async-await/in-trait/async-default-fn-overridden.current.stderr index 61a826258..2142ee232 100644 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.stderr +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.current.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/async-default-fn-overridden.rs:4:12 + --> $DIR/async-default-fn-overridden.rs:6:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.next.stderr b/tests/ui/async-await/in-trait/async-default-fn-overridden.next.stderr new file mode 100644 index 000000000..2142ee232 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.next.stderr @@ -0,0 +1,11 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/async-default-fn-overridden.rs:6:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs index 0fd1a2703..dd1af93d7 100644 --- a/tests/ui/async-await/in-trait/async-default-fn-overridden.rs +++ b/tests/ui/async-await/in-trait/async-default-fn-overridden.rs @@ -1,5 +1,7 @@ // run-pass // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] //~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.current.stderr index 168ef8e9e..b5ace9ada 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.current.stderr @@ -1,11 +1,11 @@ error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:15:28 + --> $DIR/async-example-desugared-boxed-in-trait.rs:17:28 | LL | async fn foo(&self) -> i32 { | ^^^ expected `Pin<Box<dyn Future<Output = i32>>>`, found future | note: type in trait - --> $DIR/async-example-desugared-boxed-in-trait.rs:11:22 + --> $DIR/async-example-desugared-boxed-in-trait.rs:13:22 | LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.next.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.next.stderr new file mode 100644 index 000000000..b5ace9ada --- /dev/null +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.next.stderr @@ -0,0 +1,17 @@ +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/async-example-desugared-boxed-in-trait.rs:17:28 + | +LL | async fn foo(&self) -> i32 { + | ^^^ expected `Pin<Box<dyn Future<Output = i32>>>`, found future + | +note: type in trait + --> $DIR/async-example-desugared-boxed-in-trait.rs:13:22 + | +LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: expected signature `fn(&i32) -> Pin<Box<dyn Future<Output = i32>>>` + found signature `fn(&i32) -> impl Future<Output = i32>` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs index 38ba29718..7b53379b2 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed-in-trait.rs @@ -1,4 +1,6 @@ // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed.current.stderr index 60fa534a6..6c0b58591 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.current.stderr @@ -1,5 +1,5 @@ error: method `foo` should be async because the method from the trait is async - --> $DIR/async-example-desugared-boxed.rs:15:5 + --> $DIR/async-example-desugared-boxed.rs:17:5 | LL | async fn foo(&self) -> i32; | --------------------------- required because the trait method is async diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.next.stderr b/tests/ui/async-await/in-trait/async-example-desugared-boxed.next.stderr new file mode 100644 index 000000000..6c0b58591 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.next.stderr @@ -0,0 +1,11 @@ +error: method `foo` should be async because the method from the trait is async + --> $DIR/async-example-desugared-boxed.rs:17:5 + | +LL | async fn foo(&self) -> i32; + | --------------------------- required because the trait method is async +... +LL | fn foo(&self) -> Pin<Box<dyn Future<Output = i32> + '_>> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs b/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs index 1b1b3cffd..916488ffa 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-boxed.rs @@ -1,4 +1,6 @@ // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-example-desugared-extra.rs b/tests/ui/async-await/in-trait/async-example-desugared-extra.rs index 81e1e59a3..edac0b374 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-extra.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-extra.rs @@ -1,5 +1,7 @@ // check-pass // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs b/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs index feeda719e..934f7643d 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-in-trait.rs @@ -1,5 +1,7 @@ // check-pass // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr b/tests/ui/async-await/in-trait/async-example-desugared-manual.current.stderr index 567a36a86..0d2551ab8 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-manual.stderr +++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.current.stderr @@ -1,5 +1,5 @@ error: method `foo` should be async because the method from the trait is async - --> $DIR/async-example-desugared-manual.rs:23:5 + --> $DIR/async-example-desugared-manual.rs:25:5 | LL | async fn foo(&self) -> i32; | --------------------------- required because the trait method is async diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.next.stderr b/tests/ui/async-await/in-trait/async-example-desugared-manual.next.stderr new file mode 100644 index 000000000..0d2551ab8 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.next.stderr @@ -0,0 +1,11 @@ +error: method `foo` should be async because the method from the trait is async + --> $DIR/async-example-desugared-manual.rs:25:5 + | +LL | async fn foo(&self) -> i32; + | --------------------------- required because the trait method is async +... +LL | fn foo(&self) -> MyFuture { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/async-await/in-trait/async-example-desugared-manual.rs b/tests/ui/async-await/in-trait/async-example-desugared-manual.rs index 71473e745..4883828d3 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared-manual.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared-manual.rs @@ -1,4 +1,6 @@ // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-example-desugared.rs b/tests/ui/async-await/in-trait/async-example-desugared.rs index fb92ec786..214171b2e 100644 --- a/tests/ui/async-await/in-trait/async-example-desugared.rs +++ b/tests/ui/async-await/in-trait/async-example-desugared.rs @@ -1,5 +1,7 @@ // check-pass // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.current.stderr index f1f0d7e59..780da0689 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.stderr +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.current.stderr @@ -1,33 +1,33 @@ error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics-and-bounds.rs:12:28 + --> $DIR/async-generics-and-bounds.rs:14:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ | note: the parameter type `U` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics-and-bounds.rs:12:18 + --> $DIR/async-generics-and-bounds.rs:14:18 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics-and-bounds.rs:12:28 + --> $DIR/async-generics-and-bounds.rs:14:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics-and-bounds.rs:12:28 + --> $DIR/async-generics-and-bounds.rs:14:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ | note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics-and-bounds.rs:12:18 + --> $DIR/async-generics-and-bounds.rs:14:18 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics-and-bounds.rs:12:28 + --> $DIR/async-generics-and-bounds.rs:14:28 | LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; | ^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.next.stderr b/tests/ui/async-await/in-trait/async-generics-and-bounds.next.stderr new file mode 100644 index 000000000..780da0689 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.next.stderr @@ -0,0 +1,37 @@ +error[E0311]: the parameter type `U` may not live long enough + --> $DIR/async-generics-and-bounds.rs:14:28 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^^^ + | +note: the parameter type `U` must be valid for the anonymous lifetime defined here... + --> $DIR/async-generics-and-bounds.rs:14:18 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^ +note: ...so that the reference type `&(T, U)` does not outlive the data it points at + --> $DIR/async-generics-and-bounds.rs:14:28 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^^^ + +error[E0311]: the parameter type `T` may not live long enough + --> $DIR/async-generics-and-bounds.rs:14:28 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^^^ + | +note: the parameter type `T` must be valid for the anonymous lifetime defined here... + --> $DIR/async-generics-and-bounds.rs:14:18 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^ +note: ...so that the reference type `&(T, U)` does not outlive the data it points at + --> $DIR/async-generics-and-bounds.rs:14:28 + | +LL | async fn foo(&self) -> &(T, U) where T: Debug + Sized, U: Hash; + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0311`. diff --git a/tests/ui/async-await/in-trait/async-generics-and-bounds.rs b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs index a73d55adf..146e74ec2 100644 --- a/tests/ui/async-await/in-trait/async-generics-and-bounds.rs +++ b/tests/ui/async-await/in-trait/async-generics-and-bounds.rs @@ -1,6 +1,8 @@ // check-fail // known-bug: #102682 // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/async-generics.stderr b/tests/ui/async-await/in-trait/async-generics.current.stderr index 2f0556456..04e1ab6d7 100644 --- a/tests/ui/async-await/in-trait/async-generics.stderr +++ b/tests/ui/async-await/in-trait/async-generics.current.stderr @@ -1,33 +1,33 @@ error[E0311]: the parameter type `U` may not live long enough - --> $DIR/async-generics.rs:9:28 + --> $DIR/async-generics.rs:11:28 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ | note: the parameter type `U` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics.rs:9:18 + --> $DIR/async-generics.rs:11:18 | LL | async fn foo(&self) -> &(T, U); | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics.rs:9:28 + --> $DIR/async-generics.rs:11:28 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ error[E0311]: the parameter type `T` may not live long enough - --> $DIR/async-generics.rs:9:28 + --> $DIR/async-generics.rs:11:28 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ | note: the parameter type `T` must be valid for the anonymous lifetime defined here... - --> $DIR/async-generics.rs:9:18 + --> $DIR/async-generics.rs:11:18 | LL | async fn foo(&self) -> &(T, U); | ^^^^^ note: ...so that the reference type `&(T, U)` does not outlive the data it points at - --> $DIR/async-generics.rs:9:28 + --> $DIR/async-generics.rs:11:28 | LL | async fn foo(&self) -> &(T, U); | ^^^^^^^ diff --git a/tests/ui/async-await/in-trait/async-generics.next.stderr b/tests/ui/async-await/in-trait/async-generics.next.stderr new file mode 100644 index 000000000..04e1ab6d7 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-generics.next.stderr @@ -0,0 +1,37 @@ +error[E0311]: the parameter type `U` may not live long enough + --> $DIR/async-generics.rs:11:28 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^^^ + | +note: the parameter type `U` must be valid for the anonymous lifetime defined here... + --> $DIR/async-generics.rs:11:18 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^ +note: ...so that the reference type `&(T, U)` does not outlive the data it points at + --> $DIR/async-generics.rs:11:28 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^^^ + +error[E0311]: the parameter type `T` may not live long enough + --> $DIR/async-generics.rs:11:28 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^^^ + | +note: the parameter type `T` must be valid for the anonymous lifetime defined here... + --> $DIR/async-generics.rs:11:18 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^ +note: ...so that the reference type `&(T, U)` does not outlive the data it points at + --> $DIR/async-generics.rs:11:28 + | +LL | async fn foo(&self) -> &(T, U); + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0311`. diff --git a/tests/ui/async-await/in-trait/async-generics.rs b/tests/ui/async-await/in-trait/async-generics.rs index 67000e577..507500abf 100644 --- a/tests/ui/async-await/in-trait/async-generics.rs +++ b/tests/ui/async-await/in-trait/async-generics.rs @@ -1,6 +1,8 @@ // check-fail // known-bug: #102682 // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/async-recursive-generic.stderr b/tests/ui/async-await/in-trait/async-recursive-generic.current.stderr index cab173bdd..67b491f19 100644 --- a/tests/ui/async-await/in-trait/async-recursive-generic.stderr +++ b/tests/ui/async-await/in-trait/async-recursive-generic.current.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/async-recursive-generic.rs:11:48 + --> $DIR/async-recursive-generic.rs:13:48 | LL | async fn foo_recursive(&self, n: usize) -> T { | ^ recursive `async fn` diff --git a/tests/ui/async-await/in-trait/async-recursive-generic.next.stderr b/tests/ui/async-await/in-trait/async-recursive-generic.next.stderr new file mode 100644 index 000000000..67b491f19 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-recursive-generic.next.stderr @@ -0,0 +1,12 @@ +error[E0733]: recursion in an `async fn` requires boxing + --> $DIR/async-recursive-generic.rs:13:48 + | +LL | async fn foo_recursive(&self, n: usize) -> T { + | ^ recursive `async fn` + | + = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` + = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/in-trait/async-recursive-generic.rs b/tests/ui/async-await/in-trait/async-recursive-generic.rs index 6839abd38..64c6ba15c 100644 --- a/tests/ui/async-await/in-trait/async-recursive-generic.rs +++ b/tests/ui/async-await/in-trait/async-recursive-generic.rs @@ -1,4 +1,6 @@ // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/async-recursive.stderr b/tests/ui/async-await/in-trait/async-recursive.current.stderr index 9feff37b3..85af27e37 100644 --- a/tests/ui/async-await/in-trait/async-recursive.stderr +++ b/tests/ui/async-await/in-trait/async-recursive.current.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in an `async fn` requires boxing - --> $DIR/async-recursive.rs:11:48 + --> $DIR/async-recursive.rs:13:48 | LL | async fn foo_recursive(&self, n: usize) -> i32 { | ^^^ recursive `async fn` diff --git a/tests/ui/async-await/in-trait/async-recursive.next.stderr b/tests/ui/async-await/in-trait/async-recursive.next.stderr new file mode 100644 index 000000000..85af27e37 --- /dev/null +++ b/tests/ui/async-await/in-trait/async-recursive.next.stderr @@ -0,0 +1,12 @@ +error[E0733]: recursion in an `async fn` requires boxing + --> $DIR/async-recursive.rs:13:48 + | +LL | async fn foo_recursive(&self, n: usize) -> i32 { + | ^^^ recursive `async fn` + | + = note: a recursive `async fn` must be rewritten to return a boxed `dyn Future` + = note: consider using the `async_recursion` crate: https://crates.io/crates/async_recursion + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0733`. diff --git a/tests/ui/async-await/in-trait/async-recursive.rs b/tests/ui/async-await/in-trait/async-recursive.rs index 61119f809..d928909e3 100644 --- a/tests/ui/async-await/in-trait/async-recursive.rs +++ b/tests/ui/async-await/in-trait/async-recursive.rs @@ -1,4 +1,6 @@ // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/bad-signatures.stderr b/tests/ui/async-await/in-trait/bad-signatures.current.stderr index e0ba7b53e..5a05b080c 100644 --- a/tests/ui/async-await/in-trait/bad-signatures.stderr +++ b/tests/ui/async-await/in-trait/bad-signatures.current.stderr @@ -1,11 +1,11 @@ error: expected identifier, found keyword `self` - --> $DIR/bad-signatures.rs:7:23 + --> $DIR/bad-signatures.rs:9:23 | LL | async fn bar(&abc self); | ^^^^ expected identifier, found keyword error: expected one of `:`, `@`, or `|`, found keyword `self` - --> $DIR/bad-signatures.rs:7:23 + --> $DIR/bad-signatures.rs:9:23 | LL | async fn bar(&abc self); | -----^^^^ @@ -14,7 +14,7 @@ LL | async fn bar(&abc self); | help: declare the type after the parameter binding: `<identifier>: <type>` warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/bad-signatures.rs:3:12 + --> $DIR/bad-signatures.rs:5:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/bad-signatures.next.stderr b/tests/ui/async-await/in-trait/bad-signatures.next.stderr new file mode 100644 index 000000000..5a05b080c --- /dev/null +++ b/tests/ui/async-await/in-trait/bad-signatures.next.stderr @@ -0,0 +1,26 @@ +error: expected identifier, found keyword `self` + --> $DIR/bad-signatures.rs:9:23 + | +LL | async fn bar(&abc self); + | ^^^^ expected identifier, found keyword + +error: expected one of `:`, `@`, or `|`, found keyword `self` + --> $DIR/bad-signatures.rs:9:23 + | +LL | async fn bar(&abc self); + | -----^^^^ + | | | + | | expected one of `:`, `@`, or `|` + | help: declare the type after the parameter binding: `<identifier>: <type>` + +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/bad-signatures.rs:5:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: aborting due to 2 previous errors; 1 warning emitted + diff --git a/tests/ui/async-await/in-trait/bad-signatures.rs b/tests/ui/async-await/in-trait/bad-signatures.rs index b86f1d1c1..e0093be8c 100644 --- a/tests/ui/async-await/in-trait/bad-signatures.rs +++ b/tests/ui/async-await/in-trait/bad-signatures.rs @@ -1,4 +1,6 @@ // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] //~^ WARN the feature `async_fn_in_trait` is incomplete diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr index f71fd9980..1e67cdca2 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.current.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dont-project-to-specializable-projection.rs:4:12 + --> $DIR/dont-project-to-specializable-projection.rs:6:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #![feature(async_fn_in_trait)] = note: `#[warn(incomplete_features)]` on by default error: async associated function in trait cannot be specialized - --> $DIR/dont-project-to-specializable-projection.rs:14:5 + --> $DIR/dont-project-to-specializable-projection.rs:16:5 | LL | default async fn foo(_: T) -> &'static str { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr new file mode 100644 index 000000000..fa89c6b77 --- /dev/null +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.next.stderr @@ -0,0 +1,34 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/dont-project-to-specializable-projection.rs:6:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0053]: method `foo` has an incompatible type for trait + --> $DIR/dont-project-to-specializable-projection.rs:16:35 + | +LL | default async fn foo(_: T) -> &'static str { + | ^^^^^^^^^^^^ expected associated type, found future + | +note: type in trait + --> $DIR/dont-project-to-specializable-projection.rs:12:27 + | +LL | async fn foo(_: T) -> &'static str; + | ^^^^^^^^^^^^ + = note: expected signature `fn(_) -> impl Future<Output = &'static str>` + found signature `fn(_) -> impl Future<Output = &'static str>` + +error: async associated function in trait cannot be specialized + --> $DIR/dont-project-to-specializable-projection.rs:16:5 + | +LL | default async fn foo(_: T) -> &'static str { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: specialization behaves in inconsistent and surprising ways with `#![feature(async_fn_in_trait)]`, and for now is disallowed + +error: aborting due to 2 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs index afd3db5e0..7183eaccc 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.rs @@ -1,5 +1,7 @@ // edition: 2021 // known-bug: #108309 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![feature(min_specialization)] diff --git a/tests/ui/async-await/in-trait/early-bound-1.rs b/tests/ui/async-await/in-trait/early-bound-1.rs index 6b3b14201..30843473d 100644 --- a/tests/ui/async-await/in-trait/early-bound-1.rs +++ b/tests/ui/async-await/in-trait/early-bound-1.rs @@ -1,5 +1,7 @@ // check-pass // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/early-bound-2.rs b/tests/ui/async-await/in-trait/early-bound-2.rs index 270443229..1c5a68c2a 100644 --- a/tests/ui/async-await/in-trait/early-bound-2.rs +++ b/tests/ui/async-await/in-trait/early-bound-2.rs @@ -1,5 +1,7 @@ // check-pass // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/fn-not-async-err2.stderr b/tests/ui/async-await/in-trait/fn-not-async-err2.current.stderr index 37d9669c0..1a7495149 100644 --- a/tests/ui/async-await/in-trait/fn-not-async-err2.stderr +++ b/tests/ui/async-await/in-trait/fn-not-async-err2.current.stderr @@ -1,5 +1,5 @@ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types - --> $DIR/fn-not-async-err2.rs:13:22 + --> $DIR/fn-not-async-err2.rs:15:22 | LL | fn foo(&self) -> impl Future<Output = i32> { | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/async-await/in-trait/fn-not-async-err2.next.stderr b/tests/ui/async-await/in-trait/fn-not-async-err2.next.stderr new file mode 100644 index 000000000..1a7495149 --- /dev/null +++ b/tests/ui/async-await/in-trait/fn-not-async-err2.next.stderr @@ -0,0 +1,12 @@ +error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types + --> $DIR/fn-not-async-err2.rs:15:22 + | +LL | fn foo(&self) -> impl Future<Output = i32> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0562`. diff --git a/tests/ui/async-await/in-trait/fn-not-async-err2.rs b/tests/ui/async-await/in-trait/fn-not-async-err2.rs index 78017429f..5fdb7296a 100644 --- a/tests/ui/async-await/in-trait/fn-not-async-err2.rs +++ b/tests/ui/async-await/in-trait/fn-not-async-err2.rs @@ -1,4 +1,6 @@ // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/generics-mismatch.current.stderr b/tests/ui/async-await/in-trait/generics-mismatch.current.stderr new file mode 100644 index 000000000..be23384e0 --- /dev/null +++ b/tests/ui/async-await/in-trait/generics-mismatch.current.stderr @@ -0,0 +1,16 @@ +error[E0053]: method `foo` has an incompatible generic parameter for trait `Foo` + --> $DIR/generics-mismatch.rs:13:18 + | +LL | trait Foo { + | --- +LL | async fn foo<T>(); + | - expected type parameter +... +LL | impl Foo for () { + | --------------- +LL | async fn foo<const N: usize>() {} + | ^^^^^^^^^^^^^^ found const parameter of type `usize` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/generics-mismatch.next.stderr b/tests/ui/async-await/in-trait/generics-mismatch.next.stderr new file mode 100644 index 000000000..be23384e0 --- /dev/null +++ b/tests/ui/async-await/in-trait/generics-mismatch.next.stderr @@ -0,0 +1,16 @@ +error[E0053]: method `foo` has an incompatible generic parameter for trait `Foo` + --> $DIR/generics-mismatch.rs:13:18 + | +LL | trait Foo { + | --- +LL | async fn foo<T>(); + | - expected type parameter +... +LL | impl Foo for () { + | --------------- +LL | async fn foo<const N: usize>() {} + | ^^^^^^^^^^^^^^ found const parameter of type `usize` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/generics-mismatch.rs b/tests/ui/async-await/in-trait/generics-mismatch.rs new file mode 100644 index 000000000..fc29783c0 --- /dev/null +++ b/tests/ui/async-await/in-trait/generics-mismatch.rs @@ -0,0 +1,15 @@ +// edition: 2021 + +#![feature(async_fn_in_trait)] +#![allow(incomplete_features)] + +trait Foo { + async fn foo<T>(); +} + +impl Foo for () { + async fn foo<const N: usize>() {} + //~^ ERROR: method `foo` has an incompatible generic parameter for trait `Foo` [E0053] +} + +fn main() {} diff --git a/tests/ui/async-await/in-trait/generics-mismatch.stderr b/tests/ui/async-await/in-trait/generics-mismatch.stderr new file mode 100644 index 000000000..3518aa05c --- /dev/null +++ b/tests/ui/async-await/in-trait/generics-mismatch.stderr @@ -0,0 +1,16 @@ +error[E0053]: method `foo` has an incompatible generic parameter for trait `Foo` + --> $DIR/generics-mismatch.rs:11:18 + | +LL | trait Foo { + | --- +LL | async fn foo<T>(); + | - expected type parameter +... +LL | impl Foo for () { + | --------------- +LL | async fn foo<const N: usize>() {} + | ^^^^^^^^^^^^^^ found const parameter of type `usize` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/async-await/in-trait/implied-bounds.rs b/tests/ui/async-await/in-trait/implied-bounds.rs index 52bceb3cc..45ada1d84 100644 --- a/tests/ui/async-await/in-trait/implied-bounds.rs +++ b/tests/ui/async-await/in-trait/implied-bounds.rs @@ -1,5 +1,7 @@ // check-pass // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/issue-102138.rs b/tests/ui/async-await/in-trait/issue-102138.rs index f61b34ed9..ced30b7e4 100644 --- a/tests/ui/async-await/in-trait/issue-102138.rs +++ b/tests/ui/async-await/in-trait/issue-102138.rs @@ -1,5 +1,7 @@ // check-pass // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/issue-102219.rs b/tests/ui/async-await/in-trait/issue-102219.rs index 9a35f6515..f3fdfa345 100644 --- a/tests/ui/async-await/in-trait/issue-102219.rs +++ b/tests/ui/async-await/in-trait/issue-102219.rs @@ -1,6 +1,8 @@ // compile-flags:--crate-type=lib // edition:2021 // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/issue-102310.rs b/tests/ui/async-await/in-trait/issue-102310.rs index 49c3e9fee..8e5dbd08e 100644 --- a/tests/ui/async-await/in-trait/issue-102310.rs +++ b/tests/ui/async-await/in-trait/issue-102310.rs @@ -1,5 +1,7 @@ // check-pass // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/issue-104678.rs b/tests/ui/async-await/in-trait/issue-104678.rs index e396df4e5..3d010f180 100644 --- a/tests/ui/async-await/in-trait/issue-104678.rs +++ b/tests/ui/async-await/in-trait/issue-104678.rs @@ -1,5 +1,7 @@ // edition:2021 // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr index d87adcc78..0e9477544 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.stderr +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.current.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/lifetime-mismatch.rs:3:12 + --> $DIR/lifetime-mismatch.rs:5:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #![feature(async_fn_in_trait)] = note: `#[warn(incomplete_features)]` on by default error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration - --> $DIR/lifetime-mismatch.rs:12:17 + --> $DIR/lifetime-mismatch.rs:14:17 | LL | async fn foo<'a>(&self); | ---- lifetimes in impl do not match this method in trait diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr b/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr new file mode 100644 index 000000000..0e9477544 --- /dev/null +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.next.stderr @@ -0,0 +1,21 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/lifetime-mismatch.rs:5:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0195]: lifetime parameters or bounds on method `foo` do not match the trait declaration + --> $DIR/lifetime-mismatch.rs:14:17 + | +LL | async fn foo<'a>(&self); + | ---- lifetimes in impl do not match this method in trait +... +LL | async fn foo(&self) {} + | ^ lifetimes do not match method in trait + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0195`. diff --git a/tests/ui/async-await/in-trait/lifetime-mismatch.rs b/tests/ui/async-await/in-trait/lifetime-mismatch.rs index 45ede193c..5ff5a01a1 100644 --- a/tests/ui/async-await/in-trait/lifetime-mismatch.rs +++ b/tests/ui/async-await/in-trait/lifetime-mismatch.rs @@ -1,4 +1,6 @@ // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] //~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes diff --git a/tests/ui/async-await/in-trait/missing-send-bound.stderr b/tests/ui/async-await/in-trait/missing-send-bound.current.stderr index 5cedf3ddb..319ed582e 100644 --- a/tests/ui/async-await/in-trait/missing-send-bound.stderr +++ b/tests/ui/async-await/in-trait/missing-send-bound.current.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/missing-send-bound.rs:3:12 + --> $DIR/missing-send-bound.rs:5:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ @@ -8,19 +8,19 @@ LL | #![feature(async_fn_in_trait)] = note: `#[warn(incomplete_features)]` on by default error: future cannot be sent between threads safely - --> $DIR/missing-send-bound.rs:15:20 + --> $DIR/missing-send-bound.rs:17:20 | LL | assert_is_send(test::<T>()); | ^^^^^^^^^^^ future returned by `test` is not `Send` | = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>` note: future is not `Send` as it awaits another future which is not `Send` - --> $DIR/missing-send-bound.rs:11:5 + --> $DIR/missing-send-bound.rs:13:5 | LL | T::bar().await; | ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send` note: required by a bound in `assert_is_send` - --> $DIR/missing-send-bound.rs:19:27 + --> $DIR/missing-send-bound.rs:21:27 | LL | fn assert_is_send(_: impl Send) {} | ^^^^ required by this bound in `assert_is_send` diff --git a/tests/ui/async-await/in-trait/missing-send-bound.next.stderr b/tests/ui/async-await/in-trait/missing-send-bound.next.stderr new file mode 100644 index 000000000..319ed582e --- /dev/null +++ b/tests/ui/async-await/in-trait/missing-send-bound.next.stderr @@ -0,0 +1,29 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/missing-send-bound.rs:5:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: future cannot be sent between threads safely + --> $DIR/missing-send-bound.rs:17:20 + | +LL | assert_is_send(test::<T>()); + | ^^^^^^^^^^^ future returned by `test` is not `Send` + | + = help: within `impl Future<Output = ()>`, the trait `Send` is not implemented for `impl Future<Output = ()>` +note: future is not `Send` as it awaits another future which is not `Send` + --> $DIR/missing-send-bound.rs:13:5 + | +LL | T::bar().await; + | ^^^^^^^^ await occurs here on type `impl Future<Output = ()>`, which is not `Send` +note: required by a bound in `assert_is_send` + --> $DIR/missing-send-bound.rs:21:27 + | +LL | fn assert_is_send(_: impl Send) {} + | ^^^^ required by this bound in `assert_is_send` + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/async-await/in-trait/missing-send-bound.rs b/tests/ui/async-await/in-trait/missing-send-bound.rs index 78922b59b..705fcf322 100644 --- a/tests/ui/async-await/in-trait/missing-send-bound.rs +++ b/tests/ui/async-await/in-trait/missing-send-bound.rs @@ -1,4 +1,6 @@ // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] //~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes diff --git a/tests/ui/async-await/in-trait/object-safety.stderr b/tests/ui/async-await/in-trait/object-safety.current.stderr index 0b318f71f..90e049a99 100644 --- a/tests/ui/async-await/in-trait/object-safety.stderr +++ b/tests/ui/async-await/in-trait/object-safety.current.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/object-safety.rs:3:12 + --> $DIR/object-safety.rs:5:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ @@ -8,13 +8,13 @@ LL | #![feature(async_fn_in_trait)] = note: `#[warn(incomplete_features)]` on by default error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:11:12 + --> $DIR/object-safety.rs:13:12 | LL | let x: &dyn Foo = todo!(); | ^^^^^^^^ `Foo` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/object-safety.rs:7:14 + --> $DIR/object-safety.rs:9:14 | LL | trait Foo { | --- this trait cannot be made into an object... diff --git a/tests/ui/async-await/in-trait/object-safety.next.stderr b/tests/ui/async-await/in-trait/object-safety.next.stderr new file mode 100644 index 000000000..90e049a99 --- /dev/null +++ b/tests/ui/async-await/in-trait/object-safety.next.stderr @@ -0,0 +1,27 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/object-safety.rs:5:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety.rs:13:12 + | +LL | let x: &dyn Foo = todo!(); + | ^^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/object-safety.rs:9:14 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | async fn foo(&self); + | ^^^ ...because method `foo` is `async` + = help: consider moving `foo` to another trait + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/async-await/in-trait/object-safety.rs b/tests/ui/async-await/in-trait/object-safety.rs index a8bc35f7e..f67286a20 100644 --- a/tests/ui/async-await/in-trait/object-safety.rs +++ b/tests/ui/async-await/in-trait/object-safety.rs @@ -1,4 +1,6 @@ // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] //~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr index b8d83d0f2..a5efc7571 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.stderr +++ b/tests/ui/async-await/in-trait/return-type-suggestion.current.stderr @@ -1,5 +1,5 @@ warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/return-type-suggestion.rs:3:12 + --> $DIR/return-type-suggestion.rs:5:12 | LL | #![feature(async_fn_in_trait)] | ^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | #![feature(async_fn_in_trait)] = note: `#[warn(incomplete_features)]` on by default error[E0308]: mismatched types - --> $DIR/return-type-suggestion.rs:8:9 + --> $DIR/return-type-suggestion.rs:10:9 | LL | Ok(()) | ^^^^^^- help: consider using a semicolon here: `;` diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr b/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr new file mode 100644 index 000000000..a5efc7571 --- /dev/null +++ b/tests/ui/async-await/in-trait/return-type-suggestion.next.stderr @@ -0,0 +1,23 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/return-type-suggestion.rs:5:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0308]: mismatched types + --> $DIR/return-type-suggestion.rs:10:9 + | +LL | Ok(()) + | ^^^^^^- help: consider using a semicolon here: `;` + | | + | expected `()`, found `Result<(), _>` + | + = note: expected unit type `()` + found enum `Result<(), _>` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/async-await/in-trait/return-type-suggestion.rs b/tests/ui/async-await/in-trait/return-type-suggestion.rs index 3446761d1..3de66306d 100644 --- a/tests/ui/async-await/in-trait/return-type-suggestion.rs +++ b/tests/ui/async-await/in-trait/return-type-suggestion.rs @@ -1,4 +1,6 @@ // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait)] //~^ WARN the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes diff --git a/tests/ui/async-await/issue-108572.rs b/tests/ui/async-await/issue-108572.rs new file mode 100644 index 000000000..efcb8b8eb --- /dev/null +++ b/tests/ui/async-await/issue-108572.rs @@ -0,0 +1,12 @@ +// edition: 2021 + +use std::future::Future; +fn foo() -> impl Future<Output=()> { + async { } +} + +fn main() { + let fut = foo(); + fut.poll(); + //~^ ERROR no method named `poll` found for opaque type `impl Future<Output = ()>` in the current scope [E0599] +} diff --git a/tests/ui/async-await/issue-108572.stderr b/tests/ui/async-await/issue-108572.stderr new file mode 100644 index 000000000..0dbcf4d66 --- /dev/null +++ b/tests/ui/async-await/issue-108572.stderr @@ -0,0 +1,12 @@ +error[E0599]: no method named `poll` found for opaque type `impl Future<Output = ()>` in the current scope + --> $DIR/issue-108572.rs:10:9 + | +LL | fut.poll(); + | ^^^^ method not found in `impl Future<Output = ()>` + | + = help: method `poll` found on `Pin<&mut impl Future<Output = ()>>`, see documentation for `std::pin::Pin` + = help: self type must be pinned to call `Future::poll`, see https://rust-lang.github.io/async-book/04_pinning/01_chapter.html#pinning-in-practice + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/async-await/large_moves.attribute.stderr b/tests/ui/async-await/large_moves.attribute.stderr index 0c5452475..94f61caa2 100644 --- a/tests/ui/async-await/large_moves.attribute.stderr +++ b/tests/ui/async-await/large_moves.attribute.stderr @@ -1,14 +1,8 @@ error: moving 10024 bytes - --> $DIR/large_moves.rs:13:13 + --> $DIR/large_moves.rs:19:14 | -LL | let x = async { - | _____________^ -LL | | let y = [0; 9999]; -LL | | dbg!(y); -LL | | thing(&y).await; -LL | | dbg!(y); -LL | | }; - | |_____^ value moved from here +LL | let z = (x, 42); + | ^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here @@ -18,14 +12,6 @@ LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ error: moving 10024 bytes - --> $DIR/large_moves.rs:19:14 - | -LL | let z = (x, 42); - | ^ value moved from here - | - = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` - -error: moving 10024 bytes --> $DIR/large_moves.rs:19:13 | LL | let z = (x, 42); @@ -41,5 +27,5 @@ LL | let a = z.0; | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/async-await/large_moves.option.stderr b/tests/ui/async-await/large_moves.option.stderr index 0c5452475..94f61caa2 100644 --- a/tests/ui/async-await/large_moves.option.stderr +++ b/tests/ui/async-await/large_moves.option.stderr @@ -1,14 +1,8 @@ error: moving 10024 bytes - --> $DIR/large_moves.rs:13:13 + --> $DIR/large_moves.rs:19:14 | -LL | let x = async { - | _____________^ -LL | | let y = [0; 9999]; -LL | | dbg!(y); -LL | | thing(&y).await; -LL | | dbg!(y); -LL | | }; - | |_____^ value moved from here +LL | let z = (x, 42); + | ^ value moved from here | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` note: the lint level is defined here @@ -18,14 +12,6 @@ LL | #![deny(large_assignments)] | ^^^^^^^^^^^^^^^^^ error: moving 10024 bytes - --> $DIR/large_moves.rs:19:14 - | -LL | let z = (x, 42); - | ^ value moved from here - | - = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` - -error: moving 10024 bytes --> $DIR/large_moves.rs:19:13 | LL | let z = (x, 42); @@ -41,5 +27,5 @@ LL | let a = z.0; | = note: The current maximum size is 1000, but it can be customized with the move_size_limit attribute: `#![move_size_limit = "..."]` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/async-await/large_moves.rs b/tests/ui/async-await/large_moves.rs index d43d0eec0..c8ed6bafe 100644 --- a/tests/ui/async-await/large_moves.rs +++ b/tests/ui/async-await/large_moves.rs @@ -10,7 +10,7 @@ // compile-flags: -Zmir-opt-level=0 fn main() { - let x = async { //~ ERROR large_assignments + let x = async { let y = [0; 9999]; dbg!(y); thing(&y).await; diff --git a/tests/ui/async-await/missed-capture-issue-107414.rs b/tests/ui/async-await/missed-capture-issue-107414.rs new file mode 100644 index 000000000..0ab4f5ade --- /dev/null +++ b/tests/ui/async-await/missed-capture-issue-107414.rs @@ -0,0 +1,24 @@ +// check-pass +// edition:2018 + +fn main() {} + +struct StructA {} +struct StructB {} + +impl StructA { + fn fn_taking_struct_b(&self, struct_b: &StructB) -> bool { + true + } +} + +async fn get_struct_a_async() -> StructA { + StructA {} +} + +async fn ice() { + match Some(StructB {}) { + Some(struct_b) if get_struct_a_async().await.fn_taking_struct_b(&struct_b) => {} + _ => {} + } +} diff --git a/tests/ui/async-await/no-const-async.rs b/tests/ui/async-await/no-const-async.rs index cfb0ef1b3..b3c59734e 100644 --- a/tests/ui/async-await/no-const-async.rs +++ b/tests/ui/async-await/no-const-async.rs @@ -3,4 +3,3 @@ pub const async fn x() {} //~^ ERROR functions cannot be both `const` and `async` -//~| ERROR cycle detected diff --git a/tests/ui/async-await/no-const-async.stderr b/tests/ui/async-await/no-const-async.stderr index 71c228958..90ec646c8 100644 --- a/tests/ui/async-await/no-const-async.stderr +++ b/tests/ui/async-await/no-const-async.stderr @@ -7,36 +7,5 @@ LL | pub const async fn x() {} | | `async` because of this | `const` because of this -error[E0391]: cycle detected when computing type of `x::{opaque#0}` - --> $DIR/no-const-async.rs:4:24 - | -LL | pub const async fn x() {} - | ^ - | -note: ...which requires borrow-checking `x`... - --> $DIR/no-const-async.rs:4:1 - | -LL | pub const async fn x() {} - | ^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `x`... - --> $DIR/no-const-async.rs:4:1 - | -LL | pub const async fn x() {} - | ^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `x`... - --> $DIR/no-const-async.rs:4:1 - | -LL | pub const async fn x() {} - | ^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `x::{opaque#0}` is freeze... - = note: ...which requires evaluating trait selection obligation `x::{opaque#0}: core::marker::Freeze`... - = note: ...which again requires computing type of `x::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/no-const-async.rs:4:1 - | -LL | pub const async fn x() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error -For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/async-await/pin-needed-to-poll-2.stderr b/tests/ui/async-await/pin-needed-to-poll-2.stderr index 0a6f705e2..61126faf8 100644 --- a/tests/ui/async-await/pin-needed-to-poll-2.stderr +++ b/tests/ui/async-await/pin-needed-to-poll-2.stderr @@ -6,7 +6,8 @@ LL | Pin::new(&mut self.sleep).poll(cx) | | | required by a bound introduced by this call | - = note: consider using `Box::pin` + = note: consider using the `pin!` macro + consider using `Box::pin` if you need to access the pinned value outside of the current scope note: required because it appears within the type `Sleep` --> $DIR/pin-needed-to-poll-2.rs:8:8 | diff --git a/tests/ui/async-await/task-context-arg.rs b/tests/ui/async-await/task-context-arg.rs new file mode 100644 index 000000000..937723ca7 --- /dev/null +++ b/tests/ui/async-await/task-context-arg.rs @@ -0,0 +1,25 @@ +// Checks that we don't get conflicting arguments in our debug info with a particular async function +// structure. + +// edition:2021 +// compile-flags: -Cdebuginfo=2 +// build-pass + +#![crate_type = "lib"] + +use std::future::Future; + +// The compiler produces a closure as part of this function. That closure initially takes an +// argument _task_context. Later, when the MIR for that closure is transformed into a generator +// state machine, _task_context is demoted to not be an argument, but just part of an unnamed +// argument. If we emit debug info saying that both _task_context and the unnamed argument are both +// argument number 2, then LLVM will fail with "conflicting debug info for argument". See +// https://github.com/rust-lang/rust/pull/109466#issuecomment-1500879195 for details. +async fn recv_unit() { + std::future::ready(()).await; +} + +pub fn poll_recv() { + // This box is necessary in order to reproduce the problem. + let _: Box<dyn Future<Output = ()>> = Box::new(recv_unit()); +} diff --git a/tests/ui/async-await/track-caller/async-block.rs b/tests/ui/async-await/track-caller/async-block.rs index 8e81387c3..8ddd4ab11 100644 --- a/tests/ui/async-await/track-caller/async-block.rs +++ b/tests/ui/async-await/track-caller/async-block.rs @@ -1,9 +1,9 @@ // edition:2021 -#![feature(closure_track_caller, stmt_expr_attributes)] +#![feature(stmt_expr_attributes)] fn main() { let _ = #[track_caller] async { - //~^ ERROR attribute should be applied to a function definition [E0739] + //~^ ERROR `#[track_caller]` on closures is currently unstable [E0658] }; } diff --git a/tests/ui/async-await/track-caller/async-block.stderr b/tests/ui/async-await/track-caller/async-block.stderr index 407439921..21d1054d2 100644 --- a/tests/ui/async-await/track-caller/async-block.stderr +++ b/tests/ui/async-await/track-caller/async-block.stderr @@ -1,12 +1,12 @@ -error[E0739]: attribute should be applied to a function definition +error[E0658]: `#[track_caller]` on closures is currently unstable --> $DIR/async-block.rs:6:13 | -LL | let _ = #[track_caller] async { - | _____________^^^^^^^^^^^^^^^_- -LL | | -LL | | }; - | |_____- not a function definition +LL | let _ = #[track_caller] async { + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable error: aborting due to previous error -For more information about this error, try `rustc --explain E0739`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/async-await/track-caller/panic-track-caller.rs b/tests/ui/async-await/track-caller/panic-track-caller.rs index f45243b0e..65bb23e0b 100644 --- a/tests/ui/async-await/track-caller/panic-track-caller.rs +++ b/tests/ui/async-await/track-caller/panic-track-caller.rs @@ -79,6 +79,16 @@ async fn foo_closure() { c().await } +// Since compilation is expected to fail for this fn when using +// `nofeat`, we test that separately in `async-block.rs` +#[cfg(feat)] +async fn foo_block() { + let a = #[track_caller] async { + panic!(); + }; + a.await +} + fn panicked_at(f: impl FnOnce() + panic::UnwindSafe) -> u32 { let loc = Arc::new(Mutex::new(None)); @@ -110,4 +120,7 @@ fn main() { #[cfg(feat)] assert_eq!(panicked_at(|| block_on(foo_closure())), 79); + + #[cfg(feat)] + assert_eq!(panicked_at(|| block_on(foo_block())), 89); } diff --git a/tests/ui/attributes/issue-105594-invalid-attr-validation.rs b/tests/ui/attributes/issue-105594-invalid-attr-validation.rs index 6c68e6b04..096ce97ab 100644 --- a/tests/ui/attributes/issue-105594-invalid-attr-validation.rs +++ b/tests/ui/attributes/issue-105594-invalid-attr-validation.rs @@ -1,7 +1,7 @@ // This checks that the attribute validation ICE in issue #105594 doesn't // recur. // -// ignore-thumbv8m.base +// ignore-thumbv8m.base-none-eabi #![feature(cmse_nonsecure_entry)] fn main() {} diff --git a/tests/ui/attributes/no-mangle-closure.rs b/tests/ui/attributes/no-mangle-closure.rs new file mode 100644 index 000000000..c76baa27f --- /dev/null +++ b/tests/ui/attributes/no-mangle-closure.rs @@ -0,0 +1,11 @@ +// Check that we do not ICE when `no_mangle` is applied to something that has no name. + +#![crate_type = "lib"] +#![feature(stmt_expr_attributes)] + +pub struct S([usize; 8]); + +pub fn outer_function(x: S, y: S) -> usize { + (#[no_mangle] || y.0[0])() + //~^ ERROR `#[no_mangle]` cannot be used on a closure as it has no name +} diff --git a/tests/ui/attributes/no-mangle-closure.stderr b/tests/ui/attributes/no-mangle-closure.stderr new file mode 100644 index 000000000..949eb7051 --- /dev/null +++ b/tests/ui/attributes/no-mangle-closure.stderr @@ -0,0 +1,8 @@ +error: `#[no_mangle]` cannot be used on a closure as it has no name + --> $DIR/no-mangle-closure.rs:9:6 + | +LL | (#[no_mangle] || y.0[0])() + | ^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/auto-traits/suspicious-negative-impls-lint.rs b/tests/ui/auto-traits/suspicious-negative-impls-lint.rs new file mode 100644 index 000000000..34842e594 --- /dev/null +++ b/tests/ui/auto-traits/suspicious-negative-impls-lint.rs @@ -0,0 +1,21 @@ +#![feature(negative_impls)] +#![deny(suspicious_auto_trait_impls)] + +use std::marker::PhantomData; + +struct ContainsVec<T>(Vec<T>); +impl !Send for ContainsVec<u32> {} +//~^ ERROR +//~| WARNING this will change its meaning + +pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U); +impl<T> !Send for WithPhantomDataSend<*const T, u8> {} +//~^ ERROR +//~| WARNING this will change its meaning + +pub struct WithLifetime<'a, T>(&'a (), T); +impl<T> !Sync for WithLifetime<'static, Option<T>> {} +//~^ ERROR +//~| WARNING this will change its meaning + +fn main() {} diff --git a/tests/ui/auto-traits/suspicious-negative-impls-lint.stderr b/tests/ui/auto-traits/suspicious-negative-impls-lint.stderr new file mode 100644 index 000000000..ee03ea125 --- /dev/null +++ b/tests/ui/auto-traits/suspicious-negative-impls-lint.stderr @@ -0,0 +1,52 @@ +error: cross-crate traits with a default impl, like `Send`, should not be specialized + --> $DIR/suspicious-negative-impls-lint.rs:7:1 + | +LL | impl !Send for ContainsVec<u32> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this will change its meaning in a future release! + = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367> + = note: `u32` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> $DIR/suspicious-negative-impls-lint.rs:6:1 + | +LL | struct ContainsVec<T>(Vec<T>); + | ^^^^^^^^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/suspicious-negative-impls-lint.rs:2:9 + | +LL | #![deny(suspicious_auto_trait_impls)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: cross-crate traits with a default impl, like `Send`, should not be specialized + --> $DIR/suspicious-negative-impls-lint.rs:12:1 + | +LL | impl<T> !Send for WithPhantomDataSend<*const T, u8> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this will change its meaning in a future release! + = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367> + = note: `*const T` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> $DIR/suspicious-negative-impls-lint.rs:11:1 + | +LL | pub struct WithPhantomDataSend<T, U>(PhantomData<T>, U); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: cross-crate traits with a default impl, like `Sync`, should not be specialized + --> $DIR/suspicious-negative-impls-lint.rs:17:1 + | +LL | impl<T> !Sync for WithLifetime<'static, Option<T>> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this will change its meaning in a future release! + = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367> + = note: `Option<T>` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> $DIR/suspicious-negative-impls-lint.rs:16:1 + | +LL | pub struct WithLifetime<'a, T>(&'a (), T); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/autoref-autoderef/issue-38940.rs b/tests/ui/autoref-autoderef/issue-38940.rs deleted file mode 100644 index d2f1c6e32..000000000 --- a/tests/ui/autoref-autoderef/issue-38940.rs +++ /dev/null @@ -1,52 +0,0 @@ -// issue-38940: error printed twice for deref recursion limit exceeded -// Test that the recursion limit can be changed. In this case, we have -// deeply nested types that will fail the `Send` check by overflow -// when the recursion limit is set very low. -// compile-flags: -Zdeduplicate-diagnostics=yes - -#![allow(dead_code)] -#![recursion_limit = "10"] -macro_rules! link { - ($outer:ident, $inner:ident) => { - struct $outer($inner); - impl $outer { - fn new() -> $outer { - $outer($inner::new()) - } - } - impl std::ops::Deref for $outer { - type Target = $inner; - fn deref(&self) -> &$inner { - &self.0 - } - } - }; -} - -struct Bottom; - -impl Bottom { - fn new() -> Bottom { - Bottom - } -} - -link!(Top, A); -link!(A, B); -link!(B, C); -link!(C, D); -link!(D, E); -link!(E, F); -link!(F, G); -link!(G, H); -link!(H, I); -link!(I, J); -link!(J, K); -link!(K, Bottom); - -fn main() { - let t = Top::new(); - let x: &Bottom = &t; - //~^ ERROR mismatched types - //~| ERROR reached the recursion limit while auto-dereferencing `J` -} diff --git a/tests/ui/autoref-autoderef/issue-38940.stderr b/tests/ui/autoref-autoderef/issue-38940.stderr deleted file mode 100644 index 8e98bfcd9..000000000 --- a/tests/ui/autoref-autoderef/issue-38940.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0055]: reached the recursion limit while auto-dereferencing `J` - --> $DIR/issue-38940.rs:49:22 - | -LL | let x: &Bottom = &t; - | ^^ deref recursion limit reached - | - = help: consider increasing the recursion limit by adding a `#![recursion_limit = "20"]` attribute to your crate (`issue_38940`) - -error[E0308]: mismatched types - --> $DIR/issue-38940.rs:49:22 - | -LL | let x: &Bottom = &t; - | ------- ^^ expected `&Bottom`, found `&Top` - | | - | expected due to this - | - = note: expected reference `&Bottom` - found reference `&Top` - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0055, E0308. -For more information about an error, try `rustc --explain E0055`. diff --git a/tests/ui/auxiliary/issue-13560-1.rs b/tests/ui/auxiliary/issue-13560-1.rs new file mode 100644 index 000000000..c3a2ae679 --- /dev/null +++ b/tests/ui/auxiliary/issue-13560-1.rs @@ -0,0 +1,3 @@ +// no-prefer-dynamic + +#![crate_type = "dylib"] diff --git a/tests/ui/auxiliary/issue-13560-2.rs b/tests/ui/auxiliary/issue-13560-2.rs new file mode 100644 index 000000000..39c261e11 --- /dev/null +++ b/tests/ui/auxiliary/issue-13560-2.rs @@ -0,0 +1,3 @@ +// no-prefer-dynamic + +#![crate_type = "rlib"] diff --git a/tests/ui/auxiliary/issue-13560-3.rs b/tests/ui/auxiliary/issue-13560-3.rs new file mode 100644 index 000000000..e991bcc1a --- /dev/null +++ b/tests/ui/auxiliary/issue-13560-3.rs @@ -0,0 +1,6 @@ +// no-prefer-dynamic + +#![crate_type = "rlib"] + +#[macro_use] #[no_link] extern crate issue_13560_1 as t1; +#[macro_use] extern crate issue_13560_2 as t2; diff --git a/tests/ui/auxiliary/issue-16822.rs b/tests/ui/auxiliary/issue-16822.rs new file mode 100644 index 000000000..9042dd391 --- /dev/null +++ b/tests/ui/auxiliary/issue-16822.rs @@ -0,0 +1,20 @@ +#![crate_type="lib"] + +use std::cell::RefCell; + +pub struct Window<Data>{ + pub data: RefCell<Data> +} + +impl<Data: Update> Window<Data> { + pub fn update(&self, e: i32) { + match e { + 1 => self.data.borrow_mut().update(), + _ => {} + } + } +} + +pub trait Update { + fn update(&mut self); +} diff --git a/tests/ui/auxiliary/issue-18502.rs b/tests/ui/auxiliary/issue-18502.rs new file mode 100644 index 000000000..4d4230607 --- /dev/null +++ b/tests/ui/auxiliary/issue-18502.rs @@ -0,0 +1,21 @@ +#![crate_type="lib"] + +struct Foo; +// This is the ICE trigger +struct Formatter; + +trait Show { + fn fmt(&self); +} + +impl Show for Foo { + fn fmt(&self) {} +} + +fn bar<T>(f: extern "Rust" fn(&T), t: &T) { } + +// ICE requirement: this has to be marked as inline +#[inline] +pub fn baz() { + bar(Show::fmt, &Foo); +} diff --git a/tests/ui/auxiliary/issue-24106.rs b/tests/ui/auxiliary/issue-24106.rs new file mode 100644 index 000000000..2c6a60348 --- /dev/null +++ b/tests/ui/auxiliary/issue-24106.rs @@ -0,0 +1,13 @@ +#![crate_type="lib"] + +enum E { E0 = 0, E1 = 1 } +const E0_U8: u8 = E::E0 as u8; +const E1_U8: u8 = E::E1 as u8; + +pub fn go<T>() { + match 0 { + E0_U8 => (), + E1_U8 => (), + _ => (), + } +} diff --git a/tests/ui/binding/issue-53114-safety-checks.rs b/tests/ui/binding/issue-53114-safety-checks.rs index e234db516..f4be2b482 100644 --- a/tests/ui/binding/issue-53114-safety-checks.rs +++ b/tests/ui/binding/issue-53114-safety-checks.rs @@ -21,7 +21,7 @@ fn let_wild_gets_unsafe_field() { let u2 = U { a: I(1) }; let p = P { a: &2, b: &3 }; let _ = &p.b; //~ ERROR reference to packed field - let _ = u1.a; // #53114: should eventually signal error as well + let _ = u1.a; //~ ERROR [E0133] let _ = &u2.a; //~ ERROR [E0133] // variation on above with `_` in substructure @@ -30,6 +30,20 @@ fn let_wild_gets_unsafe_field() { let (_,) = (&u2.a,); //~ ERROR [E0133] } +fn let_ascribe_gets_unsafe_field() { + let u1 = U { a: I(0) }; + let u2 = U { a: I(1) }; + let p = P { a: &2, b: &3 }; + let _: _ = &p.b; //~ ERROR reference to packed field + let _: _ = u1.a; //~ ERROR [E0133] + let _: _ = &u2.a; //~ ERROR [E0133] + + // variation on above with `_` in substructure + let (_,): _ = (&p.b,); //~ ERROR reference to packed field + let (_,): _ = (u1.a,); //~ ERROR [E0133] + let (_,): _ = (&u2.a,); //~ ERROR [E0133] +} + fn match_unsafe_field_to_wild() { let u1 = U { a: I(0) }; let u2 = U { a: I(1) }; diff --git a/tests/ui/binding/issue-53114-safety-checks.stderr b/tests/ui/binding/issue-53114-safety-checks.stderr index 5c9d78772..41318d0a3 100644 --- a/tests/ui/binding/issue-53114-safety-checks.stderr +++ b/tests/ui/binding/issue-53114-safety-checks.stderr @@ -17,7 +17,25 @@ LL | let (_,) = (&p.b,); = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned - --> $DIR/issue-53114-safety-checks.rs:37:11 + --> $DIR/issue-53114-safety-checks.rs:37:16 + | +LL | let _: _ = &p.b; + | ^^^^ + | + = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) + +error[E0793]: reference to packed field is unaligned + --> $DIR/issue-53114-safety-checks.rs:42:20 + | +LL | let (_,): _ = (&p.b,); + | ^^^^ + | + = note: fields of packed structs are not properly aligned, and creating a misaligned reference is undefined behavior (even if that reference is never dereferenced) + = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) + +error[E0793]: reference to packed field is unaligned + --> $DIR/issue-53114-safety-checks.rs:51:11 | LL | match &p.b { _ => { } } | ^^^^ @@ -26,7 +44,7 @@ LL | match &p.b { _ => { } } = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0793]: reference to packed field is unaligned - --> $DIR/issue-53114-safety-checks.rs:42:12 + --> $DIR/issue-53114-safety-checks.rs:56:12 | LL | match (&p.b,) { (_,) => { } } | ^^^^ @@ -35,6 +53,14 @@ LL | match (&p.b,) { (_,) => { } } = help: copy the field contents to a local variable, or replace the reference with a raw pointer and use `read_unaligned`/`write_unaligned` (loads and stores via `*p` must be properly aligned even when using raw pointers) error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/issue-53114-safety-checks.rs:24:13 + | +LL | let _ = u1.a; + | ^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block --> $DIR/issue-53114-safety-checks.rs:25:13 | LL | let _ = &u2.a; @@ -59,7 +85,39 @@ LL | let (_,) = (&u2.a,); = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/issue-53114-safety-checks.rs:38:11 + --> $DIR/issue-53114-safety-checks.rs:38:16 + | +LL | let _: _ = u1.a; + | ^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/issue-53114-safety-checks.rs:39:16 + | +LL | let _: _ = &u2.a; + | ^^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/issue-53114-safety-checks.rs:43:20 + | +LL | let (_,): _ = (u1.a,); + | ^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/issue-53114-safety-checks.rs:44:20 + | +LL | let (_,): _ = (&u2.a,); + | ^^^^^ access to union field + | + = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior + +error[E0133]: access to union field is unsafe and requires unsafe function or block + --> $DIR/issue-53114-safety-checks.rs:52:11 | LL | match u1.a { _ => { } } | ^^^^ access to union field @@ -67,7 +125,7 @@ LL | match u1.a { _ => { } } = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/issue-53114-safety-checks.rs:39:11 + --> $DIR/issue-53114-safety-checks.rs:53:11 | LL | match &u2.a { _ => { } } | ^^^^^ access to union field @@ -75,7 +133,7 @@ LL | match &u2.a { _ => { } } = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/issue-53114-safety-checks.rs:43:12 + --> $DIR/issue-53114-safety-checks.rs:57:12 | LL | match (u1.a,) { (_,) => { } } | ^^^^ access to union field @@ -83,14 +141,14 @@ LL | match (u1.a,) { (_,) => { } } = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior error[E0133]: access to union field is unsafe and requires unsafe function or block - --> $DIR/issue-53114-safety-checks.rs:44:12 + --> $DIR/issue-53114-safety-checks.rs:58:12 | LL | match (&u2.a,) { (_,) => { } } | ^^^^^ access to union field | = note: the field may not be properly initialized: using uninitialized data will cause undefined behavior -error: aborting due to 11 previous errors +error: aborting due to 18 previous errors Some errors have detailed explanations: E0133, E0793. For more information about an error, try `rustc --explain E0133`. diff --git a/tests/ui/binding/optional_comma_in_match_arm.rs b/tests/ui/binding/optional_comma_in_match_arm.rs index fc268bf2a..71e2f07bb 100644 --- a/tests/ui/binding/optional_comma_in_match_arm.rs +++ b/tests/ui/binding/optional_comma_in_match_arm.rs @@ -1,6 +1,5 @@ // run-pass #![allow(unused_unsafe)] -// ignore-pretty issue #37199 #![allow(while_true)] fn main() { diff --git a/tests/ui/binop/issue-28837.stderr b/tests/ui/binop/issue-28837.stderr index cca1da3b6..bb9f3b8af 100644 --- a/tests/ui/binop/issue-28837.stderr +++ b/tests/ui/binop/issue-28837.stderr @@ -157,7 +157,8 @@ LL | struct A; | ^^^^^^^^ must implement `PartialEq<_>` help: consider annotating `A` with `#[derive(PartialEq)]` | -LL | #[derive(PartialEq)] +LL + #[derive(PartialEq)] +LL | struct A; | error[E0369]: binary operation `!=` cannot be applied to type `A` @@ -175,7 +176,8 @@ LL | struct A; | ^^^^^^^^ must implement `PartialEq<_>` help: consider annotating `A` with `#[derive(PartialEq)]` | -LL | #[derive(PartialEq)] +LL + #[derive(PartialEq)] +LL | struct A; | error[E0369]: binary operation `<` cannot be applied to type `A` @@ -193,7 +195,8 @@ LL | struct A; | ^^^^^^^^ must implement `PartialOrd<_>` help: consider annotating `A` with `#[derive(PartialEq, PartialOrd)]` | -LL | #[derive(PartialEq, PartialOrd)] +LL + #[derive(PartialEq, PartialOrd)] +LL | struct A; | error[E0369]: binary operation `<=` cannot be applied to type `A` @@ -211,7 +214,8 @@ LL | struct A; | ^^^^^^^^ must implement `PartialOrd<_>` help: consider annotating `A` with `#[derive(PartialEq, PartialOrd)]` | -LL | #[derive(PartialEq, PartialOrd)] +LL + #[derive(PartialEq, PartialOrd)] +LL | struct A; | error[E0369]: binary operation `>` cannot be applied to type `A` @@ -229,7 +233,8 @@ LL | struct A; | ^^^^^^^^ must implement `PartialOrd<_>` help: consider annotating `A` with `#[derive(PartialEq, PartialOrd)]` | -LL | #[derive(PartialEq, PartialOrd)] +LL + #[derive(PartialEq, PartialOrd)] +LL | struct A; | error[E0369]: binary operation `>=` cannot be applied to type `A` @@ -247,7 +252,8 @@ LL | struct A; | ^^^^^^^^ must implement `PartialOrd<_>` help: consider annotating `A` with `#[derive(PartialEq, PartialOrd)]` | -LL | #[derive(PartialEq, PartialOrd)] +LL + #[derive(PartialEq, PartialOrd)] +LL | struct A; | error: aborting due to 15 previous errors diff --git a/tests/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr b/tests/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr index 5835f0675..0ca14c3f3 100644 --- a/tests/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr +++ b/tests/ui/borrowck/bindings-after-at-or-patterns-slice-patterns-box-patterns.stderr @@ -2,18 +2,16 @@ error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:36:9 | LL | ref foo @ [.., ref mut bar] => (), - | -------^^^^^^^^-----------^ - | | | - | | value is mutably borrowed by `bar` here + | ^^^^^^^ ----------- value is mutably borrowed by `bar` here + | | | value is borrowed by `foo` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/bindings-after-at-or-patterns-slice-patterns-box-patterns.rs:120:9 | LL | ref foo @ Some(box ref mut s) => (), - | -------^^^^^^^^^^^^---------^ - | | | - | | value is mutably borrowed by `s` here + | ^^^^^^^ --------- value is mutably borrowed by `s` here + | | | value is borrowed by `foo` here error[E0382]: borrow of moved value: `x` diff --git a/tests/ui/borrowck/borrowck-pat-enum.rs b/tests/ui/borrowck/borrowck-pat-enum.rs index 7f9c5544d..6e51a2b2e 100644 --- a/tests/ui/borrowck/borrowck-pat-enum.rs +++ b/tests/ui/borrowck/borrowck-pat-enum.rs @@ -1,6 +1,5 @@ // run-pass #![allow(dead_code)] -// ignore-pretty issue #37199 fn match_ref(v: Option<isize>) -> isize { match v { diff --git a/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs b/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs index 1bda7a497..127a3f5b2 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs +++ b/tests/ui/borrowck/borrowck-vec-pattern-nesting.rs @@ -8,6 +8,7 @@ fn a() { //~^ NOTE `vec[_]` is borrowed here vec[0] = Box::new(4); //~ ERROR cannot assign //~^ NOTE `vec[_]` is assigned to here + //~| NOTE in this expansion of desugaring of drop and replace _a.use_ref(); //~^ NOTE borrow later used here } @@ -22,6 +23,7 @@ fn b() { //~^ `vec[_]` is borrowed here vec[0] = Box::new(4); //~ ERROR cannot assign //~^ NOTE `vec[_]` is assigned to here + //~| NOTE in this expansion of desugaring of drop and replace _b.use_ref(); //~^ NOTE borrow later used here } diff --git a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr index 70b9e4f44..5e1251b05 100644 --- a/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr +++ b/tests/ui/borrowck/borrowck-vec-pattern-nesting.stderr @@ -6,24 +6,24 @@ LL | [box ref _a, _, _] => { LL | LL | vec[0] = Box::new(4); | ^^^^^^ `vec[_]` is assigned to here but it was already borrowed -LL | +... LL | _a.use_ref(); | ------------ borrow later used here error[E0506]: cannot assign to `vec[_]` because it is borrowed - --> $DIR/borrowck-vec-pattern-nesting.rs:23:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:24:13 | LL | &mut [ref _b @ ..] => { | ------ `vec[_]` is borrowed here LL | LL | vec[0] = Box::new(4); | ^^^^^^ `vec[_]` is assigned to here but it was already borrowed -LL | +... LL | _b.use_ref(); | ------------ borrow later used here error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:34:11 + --> $DIR/borrowck-vec-pattern-nesting.rs:36:11 | LL | match vec { | ^^^ cannot move out of here @@ -41,7 +41,7 @@ LL + [_a, | error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:46:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:48:13 | LL | let a = vec[0]; | ^^^^^^ @@ -55,7 +55,7 @@ LL | let a = &vec[0]; | + error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:55:11 + --> $DIR/borrowck-vec-pattern-nesting.rs:57:11 | LL | match vec { | ^^^ cannot move out of here @@ -73,7 +73,7 @@ LL + [ | error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:65:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:67:13 | LL | let a = vec[0]; | ^^^^^^ @@ -87,7 +87,7 @@ LL | let a = &vec[0]; | + error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:74:11 + --> $DIR/borrowck-vec-pattern-nesting.rs:76:11 | LL | match vec { | ^^^ cannot move out of here @@ -106,7 +106,7 @@ LL + [_a, _b, _c] => {} | error[E0508]: cannot move out of type `[Box<isize>]`, a non-copy slice - --> $DIR/borrowck-vec-pattern-nesting.rs:85:13 + --> $DIR/borrowck-vec-pattern-nesting.rs:87:13 | LL | let a = vec[0]; | ^^^^^^ diff --git a/tests/ui/borrowck/drop-in-loop.rs b/tests/ui/borrowck/drop-in-loop.rs new file mode 100644 index 000000000..866c27ef2 --- /dev/null +++ b/tests/ui/borrowck/drop-in-loop.rs @@ -0,0 +1,24 @@ +// A version of `issue-70919-drop-in-loop`, but without +// the necessary `drop` call. +// +// This should fail to compile, since the `Drop` impl +// for `WrapperWithDrop` could observe the changed +// `base` value. + +struct WrapperWithDrop<'a>(&'a mut bool); +impl<'a> Drop for WrapperWithDrop<'a> { + fn drop(&mut self) { + } +} + +fn drop_in_loop() { + let mut base = true; + let mut wrapper = WrapperWithDrop(&mut base); + loop { + base = false; //~ ERROR: cannot assign to `base` + wrapper = WrapperWithDrop(&mut base); + } +} + +fn main() { +} diff --git a/tests/ui/borrowck/drop-in-loop.stderr b/tests/ui/borrowck/drop-in-loop.stderr new file mode 100644 index 000000000..d5734e7ec --- /dev/null +++ b/tests/ui/borrowck/drop-in-loop.stderr @@ -0,0 +1,14 @@ +error[E0506]: cannot assign to `base` because it is borrowed + --> $DIR/drop-in-loop.rs:18:9 + | +LL | let mut wrapper = WrapperWithDrop(&mut base); + | --------- `base` is borrowed here +LL | loop { +LL | base = false; + | ^^^^^^^^^^^^ `base` is assigned to here but it was already borrowed +LL | wrapper = WrapperWithDrop(&mut base); + | ------- borrow might be used here, when `wrapper` is dropped and runs the `Drop` code for type `WrapperWithDrop` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0506`. diff --git a/tests/ui/borrowck/issue-45199.rs b/tests/ui/borrowck/issue-45199.rs index ded46e56e..6a6b25541 100644 --- a/tests/ui/borrowck/issue-45199.rs +++ b/tests/ui/borrowck/issue-45199.rs @@ -5,6 +5,7 @@ fn test_drop_replace() { b = Box::new(1); //~ NOTE first assignment b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` //~| NOTE cannot assign twice to immutable + //~| NOTE in this expansion of desugaring of drop and replace } fn test_call() { @@ -13,12 +14,14 @@ fn test_call() { //~| SUGGESTION mut b b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` //~| NOTE cannot assign twice to immutable + //~| NOTE in this expansion of desugaring of drop and replace } fn test_args(b: Box<i32>) { //~ HELP consider making this binding mutable //~| SUGGESTION mut b b = Box::new(2); //~ ERROR cannot assign to immutable argument `b` //~| NOTE cannot assign to immutable argument + //~| NOTE in this expansion of desugaring of drop and replace } fn main() {} diff --git a/tests/ui/borrowck/issue-45199.stderr b/tests/ui/borrowck/issue-45199.stderr index 47aa30908..163f2370b 100644 --- a/tests/ui/borrowck/issue-45199.stderr +++ b/tests/ui/borrowck/issue-45199.stderr @@ -10,7 +10,7 @@ LL | b = Box::new(2); | ^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/issue-45199.rs:14:5 + --> $DIR/issue-45199.rs:15:5 | LL | let b = Box::new(1); | - @@ -22,7 +22,7 @@ LL | b = Box::new(2); | ^ cannot assign twice to immutable variable error[E0384]: cannot assign to immutable argument `b` - --> $DIR/issue-45199.rs:20:5 + --> $DIR/issue-45199.rs:22:5 | LL | fn test_args(b: Box<i32>) { | - help: consider making this binding mutable: `mut b` diff --git a/tests/ui/borrowck/issue-58776-borrowck-scans-children.rs b/tests/ui/borrowck/issue-58776-borrowck-scans-children.rs index efa313a9d..0b2372d12 100644 --- a/tests/ui/borrowck/issue-58776-borrowck-scans-children.rs +++ b/tests/ui/borrowck/issue-58776-borrowck-scans-children.rs @@ -5,7 +5,6 @@ fn main() { greeting = "DEALLOCATED".to_string(); //~^ ERROR cannot assign drop(greeting); - //~^ ERROR cannot move println!("thread result: {:?}", res); } diff --git a/tests/ui/borrowck/issue-58776-borrowck-scans-children.stderr b/tests/ui/borrowck/issue-58776-borrowck-scans-children.stderr index 0870b4237..967451c68 100644 --- a/tests/ui/borrowck/issue-58776-borrowck-scans-children.stderr +++ b/tests/ui/borrowck/issue-58776-borrowck-scans-children.stderr @@ -12,21 +12,6 @@ LL | greeting = "DEALLOCATED".to_string(); LL | println!("thread result: {:?}", res); | --- borrow later used here -error[E0505]: cannot move out of `greeting` because it is borrowed - --> $DIR/issue-58776-borrowck-scans-children.rs:7:10 - | -LL | let res = (|| (|| &greeting)())(); - | -- -------- borrow occurs due to use in closure - | | - | borrow of `greeting` occurs here -... -LL | drop(greeting); - | ^^^^^^^^ move out of `greeting` occurs here -... -LL | println!("thread result: {:?}", res); - | --- borrow later used here - -error: aborting due to 2 previous errors +error: aborting due to previous error -Some errors have detailed explanations: E0505, E0506. -For more information about an error, try `rustc --explain E0505`. +For more information about this error, try `rustc --explain E0506`. diff --git a/tests/ui/borrowck/issue-64453.stderr b/tests/ui/borrowck/issue-64453.stderr index 245c3a40e..f032ea779 100644 --- a/tests/ui/borrowck/issue-64453.stderr +++ b/tests/ui/borrowck/issue-64453.stderr @@ -1,4 +1,4 @@ -error: `Arguments::<'a>::new_v1` is not yet stable as a const fn +error: `Arguments::<'a>::new_const` is not yet stable as a const fn --> $DIR/issue-64453.rs:4:31 | LL | static settings_dir: String = format!(""); diff --git a/tests/ui/borrowck/issue-70919-drop-in-loop.rs b/tests/ui/borrowck/issue-70919-drop-in-loop.rs new file mode 100644 index 000000000..a8d5849a3 --- /dev/null +++ b/tests/ui/borrowck/issue-70919-drop-in-loop.rs @@ -0,0 +1,25 @@ +// Regression test for issue #70919 +// Tests that we don't emit a spurious "borrow might be used" error +// when we have an explicit `drop` in a loop + +// check-pass + +struct WrapperWithDrop<'a>(&'a mut bool); +impl<'a> Drop for WrapperWithDrop<'a> { + fn drop(&mut self) { + } +} + +fn drop_in_loop() { + let mut base = true; + let mut wrapper = WrapperWithDrop(&mut base); + loop { + drop(wrapper); + + base = false; + wrapper = WrapperWithDrop(&mut base); + } +} + +fn main() { +} diff --git a/tests/ui/borrowck/let_underscore_temporary.rs b/tests/ui/borrowck/let_underscore_temporary.rs new file mode 100644 index 000000000..37b5c5d9d --- /dev/null +++ b/tests/ui/borrowck/let_underscore_temporary.rs @@ -0,0 +1,27 @@ +// check-pass + +fn let_underscore(string: &Option<&str>, mut num: Option<i32>) { + let _ = if let Some(s) = *string { s.len() } else { 0 }; + let _ = if let Some(s) = &num { s } else { &0 }; + let _ = if let Some(s) = &mut num { + *s += 1; + s + } else { + &mut 0 + }; + let _ = if let Some(ref s) = num { s } else { &0 }; + let _ = if let Some(mut s) = num { + s += 1; + s + } else { + 0 + }; + let _ = if let Some(ref mut s) = num { + *s += 1; + s + } else { + &mut 0 + }; +} + +fn main() {} diff --git a/tests/ui/expr-block-generic-unique1.rs b/tests/ui/box/unit/expr-block-generic-unique1.rs index 14603a2c7..14603a2c7 100644 --- a/tests/ui/expr-block-generic-unique1.rs +++ b/tests/ui/box/unit/expr-block-generic-unique1.rs diff --git a/tests/ui/expr-block-generic-unique2.rs b/tests/ui/box/unit/expr-block-generic-unique2.rs index 7879c144b..7879c144b 100644 --- a/tests/ui/expr-block-generic-unique2.rs +++ b/tests/ui/box/unit/expr-block-generic-unique2.rs diff --git a/tests/ui/expr-if-unique.rs b/tests/ui/box/unit/expr-if-unique.rs index 862326835..862326835 100644 --- a/tests/ui/expr-if-unique.rs +++ b/tests/ui/box/unit/expr-if-unique.rs diff --git a/tests/ui/unique/unique-assign-copy.rs b/tests/ui/box/unit/unique-assign-copy.rs index b742973ce..b742973ce 100644 --- a/tests/ui/unique/unique-assign-copy.rs +++ b/tests/ui/box/unit/unique-assign-copy.rs diff --git a/tests/ui/unique/unique-assign-drop.rs b/tests/ui/box/unit/unique-assign-drop.rs index e7685b589..e7685b589 100644 --- a/tests/ui/unique/unique-assign-drop.rs +++ b/tests/ui/box/unit/unique-assign-drop.rs diff --git a/tests/ui/unique/unique-assign-generic.rs b/tests/ui/box/unit/unique-assign-generic.rs index d4932d833..d4932d833 100644 --- a/tests/ui/unique/unique-assign-generic.rs +++ b/tests/ui/box/unit/unique-assign-generic.rs diff --git a/tests/ui/unique/unique-assign.rs b/tests/ui/box/unit/unique-assign.rs index d598744f1..d598744f1 100644 --- a/tests/ui/unique/unique-assign.rs +++ b/tests/ui/box/unit/unique-assign.rs diff --git a/tests/ui/unique/unique-autoderef-field.rs b/tests/ui/box/unit/unique-autoderef-field.rs index 64147e11f..64147e11f 100644 --- a/tests/ui/unique/unique-autoderef-field.rs +++ b/tests/ui/box/unit/unique-autoderef-field.rs diff --git a/tests/ui/unique/unique-autoderef-index.rs b/tests/ui/box/unit/unique-autoderef-index.rs index ea6598a7f..ea6598a7f 100644 --- a/tests/ui/unique/unique-autoderef-index.rs +++ b/tests/ui/box/unit/unique-autoderef-index.rs diff --git a/tests/ui/unique/unique-cmp.rs b/tests/ui/box/unit/unique-cmp.rs index ee05dd5a3..ee05dd5a3 100644 --- a/tests/ui/unique/unique-cmp.rs +++ b/tests/ui/box/unit/unique-cmp.rs diff --git a/tests/ui/unique/unique-containing-tag.rs b/tests/ui/box/unit/unique-containing-tag.rs index 6c31ae99b..6c31ae99b 100644 --- a/tests/ui/unique/unique-containing-tag.rs +++ b/tests/ui/box/unit/unique-containing-tag.rs diff --git a/tests/ui/unique/unique-create.rs b/tests/ui/box/unit/unique-create.rs index c566e7962..c566e7962 100644 --- a/tests/ui/unique/unique-create.rs +++ b/tests/ui/box/unit/unique-create.rs diff --git a/tests/ui/unique/unique-decl-init-copy.rs b/tests/ui/box/unit/unique-decl-init-copy.rs index 5b9576fcc..5b9576fcc 100644 --- a/tests/ui/unique/unique-decl-init-copy.rs +++ b/tests/ui/box/unit/unique-decl-init-copy.rs diff --git a/tests/ui/unique/unique-decl-init.rs b/tests/ui/box/unit/unique-decl-init.rs index 1d70860c7..1d70860c7 100644 --- a/tests/ui/unique/unique-decl-init.rs +++ b/tests/ui/box/unit/unique-decl-init.rs diff --git a/tests/ui/unique/unique-decl-move.rs b/tests/ui/box/unit/unique-decl-move.rs index 21187510f..21187510f 100644 --- a/tests/ui/unique/unique-decl-move.rs +++ b/tests/ui/box/unit/unique-decl-move.rs diff --git a/tests/ui/unique/unique-decl.rs b/tests/ui/box/unit/unique-decl.rs index 84a1b2a5b..84a1b2a5b 100644 --- a/tests/ui/unique/unique-decl.rs +++ b/tests/ui/box/unit/unique-decl.rs diff --git a/tests/ui/unique/unique-deref.rs b/tests/ui/box/unit/unique-deref.rs index 33a1e9932..33a1e9932 100644 --- a/tests/ui/unique/unique-deref.rs +++ b/tests/ui/box/unit/unique-deref.rs diff --git a/tests/ui/unique/unique-destructure.rs b/tests/ui/box/unit/unique-destructure.rs index 7207ac962..7207ac962 100644 --- a/tests/ui/unique/unique-destructure.rs +++ b/tests/ui/box/unit/unique-destructure.rs diff --git a/tests/ui/unique/unique-drop-complex.rs b/tests/ui/box/unit/unique-drop-complex.rs index 2324f1e1a..2324f1e1a 100644 --- a/tests/ui/unique/unique-drop-complex.rs +++ b/tests/ui/box/unit/unique-drop-complex.rs diff --git a/tests/ui/unique/unique-ffi-symbols.rs b/tests/ui/box/unit/unique-ffi-symbols.rs index 77b5ead26..77b5ead26 100644 --- a/tests/ui/unique/unique-ffi-symbols.rs +++ b/tests/ui/box/unit/unique-ffi-symbols.rs diff --git a/tests/ui/unique/unique-fn-arg-move.rs b/tests/ui/box/unit/unique-fn-arg-move.rs index 6d42df218..6d42df218 100644 --- a/tests/ui/unique/unique-fn-arg-move.rs +++ b/tests/ui/box/unit/unique-fn-arg-move.rs diff --git a/tests/ui/unique/unique-fn-arg-mut.rs b/tests/ui/box/unit/unique-fn-arg-mut.rs index 01510200b..01510200b 100644 --- a/tests/ui/unique/unique-fn-arg-mut.rs +++ b/tests/ui/box/unit/unique-fn-arg-mut.rs diff --git a/tests/ui/unique/unique-fn-arg.rs b/tests/ui/box/unit/unique-fn-arg.rs index b4f3bc4b2..b4f3bc4b2 100644 --- a/tests/ui/unique/unique-fn-arg.rs +++ b/tests/ui/box/unit/unique-fn-arg.rs diff --git a/tests/ui/unique/unique-fn-ret.rs b/tests/ui/box/unit/unique-fn-ret.rs index 773a9bce1..773a9bce1 100644 --- a/tests/ui/unique/unique-fn-ret.rs +++ b/tests/ui/box/unit/unique-fn-ret.rs diff --git a/tests/ui/unique/unique-generic-assign.rs b/tests/ui/box/unit/unique-generic-assign.rs index 9c4405aa8..9c4405aa8 100644 --- a/tests/ui/unique/unique-generic-assign.rs +++ b/tests/ui/box/unit/unique-generic-assign.rs diff --git a/tests/ui/unique/unique-in-tag.rs b/tests/ui/box/unit/unique-in-tag.rs index 6daa06fb1..6daa06fb1 100644 --- a/tests/ui/unique/unique-in-tag.rs +++ b/tests/ui/box/unit/unique-in-tag.rs diff --git a/tests/ui/unique/unique-in-vec-copy.rs b/tests/ui/box/unit/unique-in-vec-copy.rs index ce52d15ef..ce52d15ef 100644 --- a/tests/ui/unique/unique-in-vec-copy.rs +++ b/tests/ui/box/unit/unique-in-vec-copy.rs diff --git a/tests/ui/unique/unique-in-vec.rs b/tests/ui/box/unit/unique-in-vec.rs index 1e8d05e3d..1e8d05e3d 100644 --- a/tests/ui/unique/unique-in-vec.rs +++ b/tests/ui/box/unit/unique-in-vec.rs diff --git a/tests/ui/unique/unique-init.rs b/tests/ui/box/unit/unique-init.rs index d19605046..d19605046 100644 --- a/tests/ui/unique/unique-init.rs +++ b/tests/ui/box/unit/unique-init.rs diff --git a/tests/ui/unique/unique-kinds.rs b/tests/ui/box/unit/unique-kinds.rs index f02d0b507..f02d0b507 100644 --- a/tests/ui/unique/unique-kinds.rs +++ b/tests/ui/box/unit/unique-kinds.rs diff --git a/tests/ui/unique/unique-log.rs b/tests/ui/box/unit/unique-log.rs index 0715d1662..0715d1662 100644 --- a/tests/ui/unique/unique-log.rs +++ b/tests/ui/box/unit/unique-log.rs diff --git a/tests/ui/unique/unique-match-discrim.rs b/tests/ui/box/unit/unique-match-discrim.rs index 6e6d74322..6e6d74322 100644 --- a/tests/ui/unique/unique-match-discrim.rs +++ b/tests/ui/box/unit/unique-match-discrim.rs diff --git a/tests/ui/unique/unique-move-drop.rs b/tests/ui/box/unit/unique-move-drop.rs index c0f5d8f90..c0f5d8f90 100644 --- a/tests/ui/unique/unique-move-drop.rs +++ b/tests/ui/box/unit/unique-move-drop.rs diff --git a/tests/ui/unique/unique-move-temp.rs b/tests/ui/box/unit/unique-move-temp.rs index 103af8e1f..103af8e1f 100644 --- a/tests/ui/unique/unique-move-temp.rs +++ b/tests/ui/box/unit/unique-move-temp.rs diff --git a/tests/ui/unique/unique-move.rs b/tests/ui/box/unit/unique-move.rs index 40a2718e4..40a2718e4 100644 --- a/tests/ui/unique/unique-move.rs +++ b/tests/ui/box/unit/unique-move.rs diff --git a/tests/ui/unique/unique-mutable.rs b/tests/ui/box/unit/unique-mutable.rs index 0367c0809..0367c0809 100644 --- a/tests/ui/unique/unique-mutable.rs +++ b/tests/ui/box/unit/unique-mutable.rs diff --git a/tests/ui/unique/unique-object-move.rs b/tests/ui/box/unit/unique-object-move.rs index bb35a9b2d..bb35a9b2d 100644 --- a/tests/ui/unique/unique-object-move.rs +++ b/tests/ui/box/unit/unique-object-move.rs diff --git a/tests/ui/unique-object-noncopyable.rs b/tests/ui/box/unit/unique-object-noncopyable.rs index 2c40dfc7a..2c40dfc7a 100644 --- a/tests/ui/unique-object-noncopyable.rs +++ b/tests/ui/box/unit/unique-object-noncopyable.rs diff --git a/tests/ui/unique-object-noncopyable.stderr b/tests/ui/box/unit/unique-object-noncopyable.stderr index db42ed9ba..db42ed9ba 100644 --- a/tests/ui/unique-object-noncopyable.stderr +++ b/tests/ui/box/unit/unique-object-noncopyable.stderr diff --git a/tests/ui/unique/unique-pat-2.rs b/tests/ui/box/unit/unique-pat-2.rs index 9c73fd220..9c73fd220 100644 --- a/tests/ui/unique/unique-pat-2.rs +++ b/tests/ui/box/unit/unique-pat-2.rs diff --git a/tests/ui/unique/unique-pat-3.rs b/tests/ui/box/unit/unique-pat-3.rs index 2e81f898d..2e81f898d 100644 --- a/tests/ui/unique/unique-pat-3.rs +++ b/tests/ui/box/unit/unique-pat-3.rs diff --git a/tests/ui/unique/unique-pat.rs b/tests/ui/box/unit/unique-pat.rs index c2474d0e7..c2474d0e7 100644 --- a/tests/ui/unique/unique-pat.rs +++ b/tests/ui/box/unit/unique-pat.rs diff --git a/tests/ui/unique-pinned-nocopy.rs b/tests/ui/box/unit/unique-pinned-nocopy.rs index 8edaeef51..8edaeef51 100644 --- a/tests/ui/unique-pinned-nocopy.rs +++ b/tests/ui/box/unit/unique-pinned-nocopy.rs diff --git a/tests/ui/unique-pinned-nocopy.stderr b/tests/ui/box/unit/unique-pinned-nocopy.stderr index de6611324..2fd5b0d82 100644 --- a/tests/ui/unique-pinned-nocopy.stderr +++ b/tests/ui/box/unit/unique-pinned-nocopy.stderr @@ -19,7 +19,8 @@ LL | let _j = i.clone(); candidate #1: `Clone` help: consider annotating `R` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct R { | error: aborting due to previous error diff --git a/tests/ui/unique/unique-rec.rs b/tests/ui/box/unit/unique-rec.rs index 9f8ad9bb0..9f8ad9bb0 100644 --- a/tests/ui/unique/unique-rec.rs +++ b/tests/ui/box/unit/unique-rec.rs diff --git a/tests/ui/unique/unique-send-2.rs b/tests/ui/box/unit/unique-send-2.rs index 23ddd2cdc..23ddd2cdc 100644 --- a/tests/ui/unique/unique-send-2.rs +++ b/tests/ui/box/unit/unique-send-2.rs diff --git a/tests/ui/unique/unique-send.rs b/tests/ui/box/unit/unique-send.rs index 431cc2be5..431cc2be5 100644 --- a/tests/ui/unique/unique-send.rs +++ b/tests/ui/box/unit/unique-send.rs diff --git a/tests/ui/unique/unique-swap.rs b/tests/ui/box/unit/unique-swap.rs index 4f33ff9a8..4f33ff9a8 100644 --- a/tests/ui/unique/unique-swap.rs +++ b/tests/ui/box/unit/unique-swap.rs diff --git a/tests/ui/unwind-unique.rs b/tests/ui/box/unit/unwind-unique.rs index 50ecf751a..50ecf751a 100644 --- a/tests/ui/unwind-unique.rs +++ b/tests/ui/box/unit/unwind-unique.rs diff --git a/tests/ui/cfg/auxiliary/cfg_false_lib.rs b/tests/ui/cfg/auxiliary/cfg_false_lib.rs new file mode 100644 index 000000000..3c011d72b --- /dev/null +++ b/tests/ui/cfg/auxiliary/cfg_false_lib.rs @@ -0,0 +1,6 @@ +// It is unclear whether a fully unconfigured crate should link to standard library, +// or what its `no_std`/`no_core`/`compiler_builtins` status, more precisely. +// Currently the usual standard library prelude is added to such crates, +// and therefore they link to libstd. + +#![cfg(FALSE)] diff --git a/tests/ui/cfg/cfg-false-feature.rs b/tests/ui/cfg/cfg-false-feature.rs new file mode 100644 index 000000000..21ea3ec79 --- /dev/null +++ b/tests/ui/cfg/cfg-false-feature.rs @@ -0,0 +1,20 @@ +// It is unclear which features should be in effect in a fully unconfigured crate (issue #104633). +// Currently none on the features are in effect, so we get the feature gates reported. + +// check-pass +// compile-flags: --crate-type lib + +#![feature(decl_macro)] +#![cfg(FALSE)] +#![feature(box_syntax)] + +macro mac() {} //~ WARN `macro` is experimental + //~| WARN unstable syntax can change at any point in the future + +trait A = Clone; //~ WARN trait aliases are experimental + //~| WARN unstable syntax can change at any point in the future + +fn main() { + let box _ = Box::new(0); //~ WARN box pattern syntax is experimental + //~| WARN unstable syntax can change at any point in the future +} diff --git a/tests/ui/cfg/cfg-false-feature.stderr b/tests/ui/cfg/cfg-false-feature.stderr new file mode 100644 index 000000000..14673fbdb --- /dev/null +++ b/tests/ui/cfg/cfg-false-feature.stderr @@ -0,0 +1,35 @@ +warning: trait aliases are experimental + --> $DIR/cfg-false-feature.rs:14:1 + | +LL | trait A = Clone; + | ^^^^^^^^^^^^^^^^ + | + = note: see issue #41517 <https://github.com/rust-lang/rust/issues/41517> for more information + = help: add `#![feature(trait_alias)]` to the crate attributes to enable + = warning: unstable syntax can change at any point in the future, causing a hard error! + = note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860> + +warning: `macro` is experimental + --> $DIR/cfg-false-feature.rs:11:1 + | +LL | macro mac() {} + | ^^^^^^^^^^^^^^ + | + = note: see issue #39412 <https://github.com/rust-lang/rust/issues/39412> for more information + = help: add `#![feature(decl_macro)]` to the crate attributes to enable + = warning: unstable syntax can change at any point in the future, causing a hard error! + = note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860> + +warning: box pattern syntax is experimental + --> $DIR/cfg-false-feature.rs:18:9 + | +LL | let box _ = Box::new(0); + | ^^^^^ + | + = note: see issue #29641 <https://github.com/rust-lang/rust/issues/29641> for more information + = help: add `#![feature(box_patterns)]` to the crate attributes to enable + = warning: unstable syntax can change at any point in the future, causing a hard error! + = note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860> + +warning: 3 warnings emitted + diff --git a/tests/ui/cfg/cfg_false_no_std.rs b/tests/ui/cfg/cfg_false_no_std.rs new file mode 100644 index 000000000..319ea0781 --- /dev/null +++ b/tests/ui/cfg/cfg_false_no_std.rs @@ -0,0 +1,11 @@ +// Currently no error because the panic handler is supplied by libstd linked though the empty +// library, but the desirable behavior is unclear (see comments in cfg_false_lib.rs). + +// check-pass +// aux-build: cfg_false_lib.rs + +#![no_std] + +extern crate cfg_false_lib as _; + +fn main() {} diff --git a/tests/ui/chalkify/bugs/async.rs b/tests/ui/chalkify/bugs/async.rs index 3169e4781..a1ef4732b 100644 --- a/tests/ui/chalkify/bugs/async.rs +++ b/tests/ui/chalkify/bugs/async.rs @@ -4,7 +4,7 @@ // compile-flags:-Z trait-solver=chalk // error-pattern:internal compiler error // failure-status:101 -// normalize-stderr-test "DefId([^)]*)" -> "..." +// normalize-stderr-test "DefId\([^)]*\)" -> "..." // normalize-stderr-test "\nerror: internal compiler error.*\n\n" -> "" // normalize-stderr-test "note:.*unexpectedly panicked.*\n\n" -> "" // normalize-stderr-test "note: we would appreciate a bug report.*\n\n" -> "" diff --git a/tests/ui/chalkify/bugs/async.stderr b/tests/ui/chalkify/bugs/async.stderr index 8043f1e5a..36606fd49 100644 --- a/tests/ui/chalkify/bugs/async.stderr +++ b/tests/ui/chalkify/bugs/async.stderr @@ -1,34 +1,4 @@ error[E0277]: `[async fn body@$DIR/async.rs:23:29: 25:2]` is not a future - --> $DIR/async.rs:23:29 - | -LL | async fn foo(x: u32) -> u32 { - | _____________________________- -LL | | x -LL | | } - | | ^ - | | | - | |_`[async fn body@$DIR/async.rs:23:29: 25:2]` is not a future - | required by a bound introduced by this call - | - = help: the trait `Future` is not implemented for `[async fn body@$DIR/async.rs:23:29: 25:2]` - = note: [async fn body@$DIR/async.rs:23:29: 25:2] must be a future or must implement `IntoFuture` to be awaited -note: required by a bound in `identity_future` - --> $SRC_DIR/core/src/future/mod.rs:LL:COL - -error[E0277]: the size for values of type `<[async fn body@$DIR/async.rs:23:29: 25:2] as Future>::Output` cannot be known at compilation time - --> $DIR/async.rs:23:29 - | -LL | async fn foo(x: u32) -> u32 { - | _____________________________^ -LL | | x -LL | | } - | |_^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `<[async fn body@$DIR/async.rs:23:29: 25:2] as Future>::Output` -note: required by a bound in `identity_future` - --> $SRC_DIR/core/src/future/mod.rs:LL:COL - -error[E0277]: `[async fn body@$DIR/async.rs:23:29: 25:2]` is not a future --> $DIR/async.rs:23:25 | LL | async fn foo(x: u32) -> u32 { @@ -37,22 +7,23 @@ LL | async fn foo(x: u32) -> u32 { = help: the trait `Future` is not implemented for `[async fn body@$DIR/async.rs:23:29: 25:2]` = note: [async fn body@$DIR/async.rs:23:29: 25:2] must be a future or must implement `IntoFuture` to be awaited -error: internal compiler error: projection clauses should be implied from elsewhere. obligation: `Obligation(predicate=Binder(ProjectionPredicate(AliasTy { substs: [[async fn body@$DIR/async.rs:23:29: 25:2]], def_id: ...) }, Term::Ty(u32)), []), depth=0)` +error: internal compiler error: projection clauses should be implied from elsewhere. obligation: `Obligation(predicate=Binder(ProjectionPredicate(AliasTy { substs: [[async fn body@$DIR/async.rs:23:29: 25:2]], def_id: ... }, Term::Ty(u32)), []), depth=0)` --> $DIR/async.rs:23:25 | LL | async fn foo(x: u32) -> u32 { | ^^^query stack during panic: #0 [typeck] type-checking `foo` #1 [thir_body] building THIR for `foo` -#2 [mir_built] building MIR for `foo` -#3 [unsafety_check_result] unsafety-checking `foo` -#4 [mir_const] preparing `foo` for borrow checking -#5 [mir_promoted] processing MIR for `foo` -#6 [mir_borrowck] borrow-checking `foo` -#7 [type_of] computing type of `foo::{opaque#0}` -#8 [check_mod_item_types] checking item types in top-level module -#9 [analysis] running analysis passes on this crate +#2 [check_match] match-checking `foo` +#3 [mir_built] building MIR for `foo` +#4 [unsafety_check_result] unsafety-checking `foo` +#5 [mir_const] preparing `foo` for borrow checking +#6 [mir_promoted] processing MIR for `foo` +#7 [mir_borrowck] borrow-checking `foo` +#8 [type_of] computing type of `foo::{opaque#0}` +#9 [check_mod_item_types] checking item types in top-level module +#10 [analysis] running analysis passes on this crate end of query stack -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/check-cfg/compact-values.stderr b/tests/ui/check-cfg/compact-values.stderr index 9864aa385..5ca4d3b3d 100644 --- a/tests/ui/check-cfg/compact-values.stderr +++ b/tests/ui/check-cfg/compact-values.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition value LL | #[cfg(target(os = "linux", arch = "X"))] | ^^^^^^^^^^ | - = note: expected values for `target_arch` are: aarch64, arm, avr, bpf, hexagon, m68k, mips, mips64, msp430, nvptx64, powerpc, powerpc64, riscv32, riscv64, s390x, sparc, sparc64, wasm32, wasm64, x86, x86_64 + = note: expected values for `target_arch` are: aarch64, arm, avr, bpf, hexagon, loongarch64, m68k, mips, mips64, msp430, nvptx64, powerpc, powerpc64, riscv32, riscv64, s390x, sparc, sparc64, wasm32, wasm64, x86, x86_64 = note: `#[warn(unexpected_cfgs)]` on by default warning: 1 warning emitted diff --git a/tests/ui/check-cfg/my-awesome-platform.json b/tests/ui/check-cfg/my-awesome-platform.json new file mode 100644 index 000000000..5e9ab8f1a --- /dev/null +++ b/tests/ui/check-cfg/my-awesome-platform.json @@ -0,0 +1,12 @@ +{ + "llvm-target": "x86_64-unknown-none-gnu", + "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", + "arch": "x86_64", + "target-endian": "little", + "target-pointer-width": "64", + "target-c-int-width": "32", + "os": "ericos", + "linker-flavor": "ld.lld", + "linker": "rust-lld", + "executables": true +} diff --git a/tests/ui/check-cfg/values-target-json.rs b/tests/ui/check-cfg/values-target-json.rs new file mode 100644 index 000000000..2ef5a4459 --- /dev/null +++ b/tests/ui/check-cfg/values-target-json.rs @@ -0,0 +1,21 @@ +// This test checks that we don't lint values defined by a custom target (target json) +// +// check-pass +// needs-llvm-components: x86 +// compile-flags: --crate-type=lib --check-cfg=values() --target={{src-base}}/check-cfg/my-awesome-platform.json -Z unstable-options + +#![feature(lang_items, no_core, auto_traits)] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +#[cfg(target_os = "linuz")] +//~^ WARNING unexpected `cfg` condition value +fn target_os_linux_misspell() {} + +#[cfg(target_os = "linux")] +fn target_os_linux() {} + +#[cfg(target_os = "ericos")] +fn target_os_ericos() {} diff --git a/tests/ui/check-cfg/values-target-json.stderr b/tests/ui/check-cfg/values-target-json.stderr new file mode 100644 index 000000000..b58d29707 --- /dev/null +++ b/tests/ui/check-cfg/values-target-json.stderr @@ -0,0 +1,13 @@ +warning: unexpected `cfg` condition value + --> $DIR/values-target-json.rs:13:7 + | +LL | #[cfg(target_os = "linuz")] + | ^^^^^^^^^^^^------- + | | + | help: did you mean: `"linux"` + | + = note: expected values for `target_os` are: aix, android, cuda, dragonfly, emscripten, ericos, espidf, freebsd, fuchsia, haiku, hermit, horizon, illumos, ios, l4re, linux, macos, netbsd, none, nto, openbsd, psp, redox, solaris, solid_asp3, tvos, uefi, unknown, vita, vxworks, wasi, watchos, windows, xous + = note: `#[warn(unexpected_cfgs)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/check-static-values-constraints.rs b/tests/ui/check-static-values-constraints.rs index f6a577d0d..005a77988 100644 --- a/tests/ui/check-static-values-constraints.rs +++ b/tests/ui/check-static-values-constraints.rs @@ -1,7 +1,6 @@ // Verifies all possible restrictions for statics values. #![allow(warnings)] -#![feature(box_syntax)] use std::marker; @@ -19,7 +18,7 @@ enum SafeEnum { Variant1, Variant2(isize), Variant3(WithDtor), - Variant4(String) + Variant4(String), } // These should be ok @@ -29,42 +28,45 @@ static STATIC3: SafeEnum = SafeEnum::Variant3(WithDtor); enum UnsafeEnum { Variant5, - Variant6(isize) + Variant6(isize), } impl Drop for UnsafeEnum { fn drop(&mut self) {} } - static STATIC4: UnsafeEnum = UnsafeEnum::Variant5; static STATIC5: UnsafeEnum = UnsafeEnum::Variant6(0); - struct SafeStruct { field1: SafeEnum, field2: SafeEnum, } - // Struct fields are safe, hence this static should be safe -static STATIC6: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, field2: SafeEnum::Variant2(0)}; +static STATIC6: SafeStruct = + SafeStruct { field1: SafeEnum::Variant1, field2: SafeEnum::Variant2(0) }; -static STATIC7: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, - field2: SafeEnum::Variant3(WithDtor)}; +static STATIC7: SafeStruct = + SafeStruct { field1: SafeEnum::Variant1, field2: SafeEnum::Variant3(WithDtor) }; // Test variadic constructor for structs. The base struct should be examined // as well as every field present in the constructor. // This example shouldn't fail because all the fields are safe. -static STATIC8: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, - ..SafeStruct{field1: SafeEnum::Variant1, - field2: SafeEnum::Variant1}}; +static STATIC8: SafeStruct = SafeStruct { + field1: SafeEnum::Variant1, + ..SafeStruct { field1: SafeEnum::Variant1, field2: SafeEnum::Variant1 } +}; // This example should fail because field1 in the base struct is not safe -static STATIC9: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, - ..SafeStruct{field1: SafeEnum::Variant3(WithDtor), -//~^ ERROR destructor of - field2: SafeEnum::Variant1}}; +static STATIC9: SafeStruct = SafeStruct { + field1: SafeEnum::Variant1, + ..SafeStruct { + //~^ ERROR destructor of + field1: SafeEnum::Variant3(WithDtor), + field2: SafeEnum::Variant1, + } +}; struct UnsafeStruct; @@ -76,38 +78,45 @@ static STATIC10: UnsafeStruct = UnsafeStruct; struct MyOwned; -static STATIC11: Box<MyOwned> = box MyOwned; +static STATIC11: Vec<MyOwned> = vec![MyOwned]; //~^ ERROR allocations are not allowed in statics +//~^^ ERROR cannot call non-const static mut STATIC12: UnsafeStruct = UnsafeStruct; -static mut STATIC13: SafeStruct = SafeStruct{field1: SafeEnum::Variant1, - field2: SafeEnum::Variant3(WithDtor)}; +static mut STATIC13: SafeStruct = + SafeStruct { field1: SafeEnum::Variant1, field2: SafeEnum::Variant3(WithDtor) }; static mut STATIC14: SafeStruct = SafeStruct { field1: SafeEnum::Variant1, - field2: SafeEnum::Variant4("str".to_string()) -//~^ ERROR cannot call non-const fn + field2: SafeEnum::Variant4("str".to_string()), //~ ERROR cannot call non-const fn }; -static STATIC15: &'static [Box<MyOwned>] = &[ - box MyOwned, //~ ERROR allocations are not allowed in statics - box MyOwned, //~ ERROR allocations are not allowed in statics +static STATIC15: &'static [Vec<MyOwned>] = &[ + vec![MyOwned], //~ ERROR allocations are not allowed in statics + //~^ ERROR cannot call non-const + vec![MyOwned], //~ ERROR allocations are not allowed in statics + //~^ ERROR cannot call non-const ]; -static STATIC16: (&'static Box<MyOwned>, &'static Box<MyOwned>) = ( - &box MyOwned, //~ ERROR allocations are not allowed in statics - &box MyOwned, //~ ERROR allocations are not allowed in statics +static STATIC16: (&'static Vec<MyOwned>, &'static Vec<MyOwned>) = ( + &vec![MyOwned], //~ ERROR allocations are not allowed in statics + //~^ ERROR cannot call non-const + &vec![MyOwned], //~ ERROR allocations are not allowed in statics + //~^ ERROR cannot call non-const ); static mut STATIC17: SafeEnum = SafeEnum::Variant1; -static STATIC19: Box<isize> = - box 3; +static STATIC19: Vec<isize> = vec![3]; //~^ ERROR allocations are not allowed in statics +//~^^ ERROR cannot call non-const pub fn main() { - let y = { static x: Box<isize> = box 3; x }; - //~^ ERROR allocations are not allowed in statics - //~| ERROR cannot move out of static item + let y = { + static x: Vec<isize> = vec![3]; //~ ERROR allocations are not allowed in statics + //~^ ERROR cannot call non-const + x + //~^ ERROR cannot move out of static + }; } diff --git a/tests/ui/check-static-values-constraints.stderr b/tests/ui/check-static-values-constraints.stderr index 490566784..064eb4b8a 100644 --- a/tests/ui/check-static-values-constraints.stderr +++ b/tests/ui/check-static-values-constraints.stderr @@ -1,24 +1,38 @@ error[E0493]: destructor of `SafeStruct` cannot be evaluated at compile-time - --> $DIR/check-static-values-constraints.rs:65:43 + --> $DIR/check-static-values-constraints.rs:64:7 | -LL | ..SafeStruct{field1: SafeEnum::Variant3(WithDtor), - | ___________________________________________^ +LL | ..SafeStruct { + | _______^ LL | | -LL | | field2: SafeEnum::Variant1}}; - | | ^- value is dropped here - | |________________________________________________________________________________| - | the destructor for this type cannot be evaluated in statics +LL | | field1: SafeEnum::Variant3(WithDtor), +LL | | field2: SafeEnum::Variant1, +LL | | } + | |_____^ the destructor for this type cannot be evaluated in statics +LL | }; + | - value is dropped here error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:79:33 + --> $DIR/check-static-values-constraints.rs:81:33 | -LL | static STATIC11: Box<MyOwned> = box MyOwned; - | ^^^^^^^^^^^ allocation not allowed in statics +LL | static STATIC11: Vec<MyOwned> = vec![MyOwned]; + | ^^^^^^^^^^^^^ allocation not allowed in statics + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0015]: cannot call non-const fn `slice::<impl [MyOwned]>::into_vec::<std::alloc::Global>` in statics + --> $DIR/check-static-values-constraints.rs:81:33 + | +LL | static STATIC11: Vec<MyOwned> = vec![MyOwned]; + | ^^^^^^^^^^^^^ + | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const fn `<str as ToString>::to_string` in statics - --> $DIR/check-static-values-constraints.rs:89:38 + --> $DIR/check-static-values-constraints.rs:92:38 | -LL | field2: SafeEnum::Variant4("str".to_string()) +LL | field2: SafeEnum::Variant4("str".to_string()), | ^^^^^^^^^^^ | = note: calls in statics are limited to constant functions, tuple structs and tuple variants @@ -26,53 +40,125 @@ LL | field2: SafeEnum::Variant4("str".to_string()) = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:94:5 + --> $DIR/check-static-values-constraints.rs:96:5 | -LL | box MyOwned, - | ^^^^^^^^^^^ allocation not allowed in statics +LL | vec![MyOwned], + | ^^^^^^^^^^^^^ allocation not allowed in statics + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0015]: cannot call non-const fn `slice::<impl [MyOwned]>::into_vec::<std::alloc::Global>` in statics + --> $DIR/check-static-values-constraints.rs:96:5 + | +LL | vec![MyOwned], + | ^^^^^^^^^^^^^ + | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:95:5 + --> $DIR/check-static-values-constraints.rs:98:5 + | +LL | vec![MyOwned], + | ^^^^^^^^^^^^^ allocation not allowed in statics + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0015]: cannot call non-const fn `slice::<impl [MyOwned]>::into_vec::<std::alloc::Global>` in statics + --> $DIR/check-static-values-constraints.rs:98:5 + | +LL | vec![MyOwned], + | ^^^^^^^^^^^^^ | -LL | box MyOwned, - | ^^^^^^^^^^^ allocation not allowed in statics + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:99:6 + --> $DIR/check-static-values-constraints.rs:103:6 + | +LL | &vec![MyOwned], + | ^^^^^^^^^^^^^ allocation not allowed in statics + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0015]: cannot call non-const fn `slice::<impl [MyOwned]>::into_vec::<std::alloc::Global>` in statics + --> $DIR/check-static-values-constraints.rs:103:6 | -LL | &box MyOwned, - | ^^^^^^^^^^^ allocation not allowed in statics +LL | &vec![MyOwned], + | ^^^^^^^^^^^^^ + | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:100:6 + --> $DIR/check-static-values-constraints.rs:105:6 | -LL | &box MyOwned, - | ^^^^^^^^^^^ allocation not allowed in statics +LL | &vec![MyOwned], + | ^^^^^^^^^^^^^ allocation not allowed in statics + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0015]: cannot call non-const fn `slice::<impl [MyOwned]>::into_vec::<std::alloc::Global>` in statics + --> $DIR/check-static-values-constraints.rs:105:6 + | +LL | &vec![MyOwned], + | ^^^^^^^^^^^^^ + | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:106:5 + --> $DIR/check-static-values-constraints.rs:111:31 | -LL | box 3; - | ^^^^^ allocation not allowed in statics +LL | static STATIC19: Vec<isize> = vec![3]; + | ^^^^^^^ allocation not allowed in statics + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0015]: cannot call non-const fn `slice::<impl [isize]>::into_vec::<std::alloc::Global>` in statics + --> $DIR/check-static-values-constraints.rs:111:31 + | +LL | static STATIC19: Vec<isize> = vec![3]; + | ^^^^^^^ + | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0507]: cannot move out of static item `x` - --> $DIR/check-static-values-constraints.rs:110:45 + --> $DIR/check-static-values-constraints.rs:119:9 | -LL | let y = { static x: Box<isize> = box 3; x }; - | ^ move occurs because `x` has type `Box<isize>`, which does not implement the `Copy` trait +LL | x + | ^ move occurs because `x` has type `Vec<isize>`, which does not implement the `Copy` trait | help: consider borrowing here | -LL | let y = { static x: Box<isize> = box 3; &x }; - | + +LL | &x + | + error[E0010]: allocations are not allowed in statics - --> $DIR/check-static-values-constraints.rs:110:38 + --> $DIR/check-static-values-constraints.rs:117:32 + | +LL | static x: Vec<isize> = vec![3]; + | ^^^^^^^ allocation not allowed in statics | -LL | let y = { static x: Box<isize> = box 3; x }; - | ^^^^^ allocation not allowed in statics + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0015]: cannot call non-const fn `slice::<impl [isize]>::into_vec::<std::alloc::Global>` in statics + --> $DIR/check-static-values-constraints.rs:117:32 + | +LL | static x: Vec<isize> = vec![3]; + | ^^^^^^^ + | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 10 previous errors +error: aborting due to 17 previous errors Some errors have detailed explanations: E0010, E0015, E0493, E0507. For more information about an error, try `rustc --explain E0010`. diff --git a/tests/ui/closures/2229_closure_analysis/array_subslice.rs b/tests/ui/closures/2229_closure_analysis/array_subslice.rs new file mode 100644 index 000000000..5f244ea89 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/array_subslice.rs @@ -0,0 +1,13 @@ +// regression test for #109298 +// edition: 2021 + +pub fn subslice_array(x: [u8; 3]) { + let f = || { + let [_x @ ..] = x; + let [ref y, ref mut z @ ..] = x; //~ ERROR cannot borrow `x[..]` as mutable + }; + + f(); //~ ERROR cannot borrow `f` as mutable +} + +fn main() {} diff --git a/tests/ui/closures/2229_closure_analysis/array_subslice.stderr b/tests/ui/closures/2229_closure_analysis/array_subslice.stderr new file mode 100644 index 000000000..888c60d5e --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/array_subslice.stderr @@ -0,0 +1,26 @@ +error[E0596]: cannot borrow `x[..]` as mutable, as `x` is not declared as mutable + --> $DIR/array_subslice.rs:7:21 + | +LL | pub fn subslice_array(x: [u8; 3]) { + | - help: consider changing this to be mutable: `mut x` +... +LL | let [ref y, ref mut z @ ..] = x; + | ^^^^^^^^^ cannot borrow as mutable + +error[E0596]: cannot borrow `f` as mutable, as it is not declared as mutable + --> $DIR/array_subslice.rs:10:5 + | +LL | let [ref y, ref mut z @ ..] = x; + | - calling `f` requires mutable binding due to mutable borrow of `x` +... +LL | f(); + | ^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +LL | let mut f = || { + | +++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0596`. diff --git a/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-1.rs b/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-1.rs new file mode 100644 index 000000000..f21ef43fb --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-1.rs @@ -0,0 +1,18 @@ +// edition:2021 + +// regression test for #112056 + +fn extend_lifetime<'a, 'b>(x: &mut (&'a str,), y: &'b str) { + let mut closure = |input| x.0 = input; + //~^ ERROR: lifetime may not live long enough + closure(y); +} + +fn main() { + let mut tuple = ("static",); + { + let x = String::from("temporary"); + extend_lifetime(&mut tuple, &x); + } + println!("{}", tuple.0); +} diff --git a/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-1.stderr b/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-1.stderr new file mode 100644 index 000000000..730823281 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-1.stderr @@ -0,0 +1,14 @@ +error: lifetime may not live long enough + --> $DIR/unique-borrows-are-invariant-1.rs:6:31 + | +LL | fn extend_lifetime<'a, 'b>(x: &mut (&'a str,), y: &'b str) { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | let mut closure = |input| x.0 = input; + | ^^^^^^^^^^^ assignment requires that `'b` must outlive `'a` + | + = help: consider adding the following bound: `'b: 'a` + +error: aborting due to previous error + diff --git a/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-2.rs b/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-2.rs new file mode 100644 index 000000000..dd9d986c2 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-2.rs @@ -0,0 +1,31 @@ +// edition:2021 + +// regression test for #112056 + +struct Spooky<'b> { + owned: Option<&'static u32>, + borrowed: &'b &'static u32, +} + +impl<'b> Spooky<'b> { + fn create_self_reference<'a>(&'a mut self) { + let mut closure = || { + if let Some(owned) = &self.owned { + let borrow: &'a &'static u32 = owned; + self.borrowed = borrow; + //~^ ERROR: lifetime may not live long enough + } + }; + closure(); + } +} + +fn main() { + let mut spooky: Spooky<'static> = Spooky { + owned: Some(&1), + borrowed: &&1, + }; + spooky.create_self_reference(); + spooky.owned = None; + println!("{}", **spooky.borrowed); +} diff --git a/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-2.stderr b/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-2.stderr new file mode 100644 index 000000000..66ba0fe35 --- /dev/null +++ b/tests/ui/closures/2229_closure_analysis/unique-borrows-are-invariant-2.stderr @@ -0,0 +1,15 @@ +error: lifetime may not live long enough + --> $DIR/unique-borrows-are-invariant-2.rs:15:17 + | +LL | impl<'b> Spooky<'b> { + | -- lifetime `'b` defined here +LL | fn create_self_reference<'a>(&'a mut self) { + | -- lifetime `'a` defined here +... +LL | self.borrowed = borrow; + | ^^^^^^^^^^^^^^^^^^^^^^ assignment requires that `'a` must outlive `'b` + | + = help: consider adding the following bound: `'a: 'b` + +error: aborting due to previous error + diff --git a/tests/ui/closures/issue-109188.rs b/tests/ui/closures/issue-109188.rs new file mode 100644 index 000000000..cae1ced99 --- /dev/null +++ b/tests/ui/closures/issue-109188.rs @@ -0,0 +1,22 @@ +enum Either { + One(X), + Two(X), +} + +struct X(Y); + +struct Y; + +fn consume_fnmut(f: &dyn FnMut()) { + f(); +} + +fn move_into_fnmut() { + let x = move_into_fnmut(); + consume_fnmut(&|| { + let Either::One(_t) = x; //~ ERROR mismatched types + let Either::Two(_t) = x; //~ ERROR mismatched types + }); +} + +fn main() { } diff --git a/tests/ui/closures/issue-109188.stderr b/tests/ui/closures/issue-109188.stderr new file mode 100644 index 000000000..d52b51629 --- /dev/null +++ b/tests/ui/closures/issue-109188.stderr @@ -0,0 +1,19 @@ +error[E0308]: mismatched types + --> $DIR/issue-109188.rs:17:13 + | +LL | let Either::One(_t) = x; + | ^^^^^^^^^^^^^^^ - this expression has type `()` + | | + | expected `()`, found `Either` + +error[E0308]: mismatched types + --> $DIR/issue-109188.rs:18:13 + | +LL | let Either::Two(_t) = x; + | ^^^^^^^^^^^^^^^ - this expression has type `()` + | | + | expected `()`, found `Either` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/closures/self-supertrait-bounds.rs b/tests/ui/closures/self-supertrait-bounds.rs new file mode 100644 index 000000000..f4f1cea6b --- /dev/null +++ b/tests/ui/closures/self-supertrait-bounds.rs @@ -0,0 +1,14 @@ +// check-pass + +// Makes sure that we only consider `Self` supertrait predicates while +// elaborating during closure signature deduction. + +#![feature(trait_alias)] + +trait Confusing<F> = Fn(i32) where F: Fn(u32); + +fn alias<T: Confusing<F>, F>(_: T, _: F) {} + +fn main() { + alias(|_| {}, |_| {}); +} diff --git a/tests/ui/codegen/mono-impossible-2.rs b/tests/ui/codegen/mono-impossible-2.rs new file mode 100644 index 000000000..21eb2c9b2 --- /dev/null +++ b/tests/ui/codegen/mono-impossible-2.rs @@ -0,0 +1,19 @@ +//compile-flags: --crate-type=lib -Clink-dead-code=on +// build-pass + +// Make sure that we don't monomorphize the impossible method `<() as Visit>::visit`, +// which does not hold under a reveal-all param env. + +pub trait Visit { + fn visit() {} +} + +pub trait Array { + type Element; +} + +impl<'a> Visit for () where (): Array<Element = &'a ()> {} + +impl Array for () { + type Element = (); +} diff --git a/tests/ui/codegen/mono-impossible.rs b/tests/ui/codegen/mono-impossible.rs new file mode 100644 index 000000000..1ea32ed2c --- /dev/null +++ b/tests/ui/codegen/mono-impossible.rs @@ -0,0 +1,13 @@ +// compile-flags: -Clink-dead-code=on --crate-type=lib +// build-pass + +// Make sure that we don't monomorphize the impossible method `<() as Visit>::visit`, +// which does not hold under a reveal-all param env. + +pub trait Visit { + fn visit() {} +} + +pub trait Array<'a> {} + +impl Visit for () where (): for<'a> Array<'a> {} diff --git a/tests/ui/coercion/coerce-expect-unsized-ascribed.rs b/tests/ui/coercion/coerce-expect-unsized-ascribed.rs index d7b11317a..43b0b375a 100644 --- a/tests/ui/coercion/coerce-expect-unsized-ascribed.rs +++ b/tests/ui/coercion/coerce-expect-unsized-ascribed.rs @@ -1,18 +1,19 @@ // A version of coerce-expect-unsized that uses type ascription. // Doesn't work so far, but supposed to work eventually -#![feature(box_syntax, type_ascription)] +#![feature(type_ascription)] use std::fmt::Debug; pub fn main() { - let _ = type_ascribe!(box { [1, 2, 3] }, Box<[i32]>); //~ ERROR mismatched types - let _ = type_ascribe!(box if true { [1, 2, 3] } else { [1, 3, 4] }, Box<[i32]>); //~ ERROR mismatched types - let _ = type_ascribe!(box match true { true => [1, 2, 3], false => [1, 3, 4] }, Box<[i32]>); + let _ = type_ascribe!(Box::new({ [1, 2, 3] }), Box<[i32]>); //~ ERROR mismatched types + let _ = type_ascribe!(Box::new( if true { [1, 2, 3] } else { [1, 3, 4] }), Box<[i32]>); //~ ERROR mismatched types + let _ = type_ascribe!( + Box::new( match true { true => [1, 2, 3], false => [1, 3, 4] }), Box<[i32]>); //~^ ERROR mismatched types - let _ = type_ascribe!(box { |x| (x as u8) }, Box<dyn Fn(i32) -> _>); //~ ERROR mismatched types - let _ = type_ascribe!(box if true { false } else { true }, Box<dyn Debug>); //~ ERROR mismatched types - let _ = type_ascribe!(box match true { true => 'a', false => 'b' }, Box<dyn Debug>); //~ ERROR mismatched types + let _ = type_ascribe!(Box::new( { |x| (x as u8) }), Box<dyn Fn(i32) -> _>); //~ ERROR mismatched types + let _ = type_ascribe!(Box::new( if true { false } else { true }), Box<dyn Debug>); //~ ERROR mismatched types + let _ = type_ascribe!(Box::new( match true { true => 'a', false => 'b' }), Box<dyn Debug>); //~ ERROR mismatched types let _ = type_ascribe!(&{ [1, 2, 3] }, &[i32]); //~ ERROR mismatched types let _ = type_ascribe!(&if true { [1, 2, 3] } else { [1, 3, 4] }, &[i32]); //~ ERROR mismatched types @@ -27,6 +28,6 @@ pub fn main() { let _ = type_ascribe!(vec![ Box::new(|x| (x as u8)), - box |x| (x as i16 as u8), + Box::new(|x| (x as i16 as u8)), ], Vec<Box<dyn Fn(i32) -> _>>); } diff --git a/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr b/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr index f94422a92..aa5ec6b5a 100644 --- a/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr +++ b/tests/ui/coercion/coerce-expect-unsized-ascribed.stderr @@ -1,8 +1,8 @@ error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:9:27 | -LL | let _ = type_ascribe!(box { [1, 2, 3] }, Box<[i32]>); - | ^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>` +LL | let _ = type_ascribe!(Box::new({ [1, 2, 3] }), Box<[i32]>); + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>` | = note: expected struct `Box<[i32]>` found struct `Box<[i32; 3]>` @@ -10,50 +10,50 @@ LL | let _ = type_ascribe!(box { [1, 2, 3] }, Box<[i32]>); error[E0308]: mismatched types --> $DIR/coerce-expect-unsized-ascribed.rs:10:27 | -LL | let _ = type_ascribe!(box if true { [1, 2, 3] } else { [1, 3, 4] }, Box<[i32]>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>` +LL | let _ = type_ascribe!(Box::new( if true { [1, 2, 3] } else { [1, 3, 4] }), Box<[i32]>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>` | = note: expected struct `Box<[i32]>` found struct `Box<[i32; 3]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:11:27 + --> $DIR/coerce-expect-unsized-ascribed.rs:12:9 | -LL | let _ = type_ascribe!(box match true { true => [1, 2, 3], false => [1, 3, 4] }, Box<[i32]>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>` +LL | Box::new( match true { true => [1, 2, 3], false => [1, 3, 4] }), Box<[i32]>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>` | = note: expected struct `Box<[i32]>` found struct `Box<[i32; 3]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:13:27 + --> $DIR/coerce-expect-unsized-ascribed.rs:14:27 | -LL | let _ = type_ascribe!(box { |x| (x as u8) }, Box<dyn Fn(i32) -> _>); - | ^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Fn(i32) -> u8>`, found `Box<[closure@coerce-expect-unsized-ascribed.rs:13:33]>` +LL | let _ = type_ascribe!(Box::new( { |x| (x as u8) }), Box<dyn Fn(i32) -> _>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Fn(i32) -> u8>`, found `Box<[closure@coerce-expect-unsized-ascribed.rs:14:39]>` | = note: expected struct `Box<dyn Fn(i32) -> u8>` - found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:13:33: 13:36]>` + found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:14:39: 14:42]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:14:27 + --> $DIR/coerce-expect-unsized-ascribed.rs:15:27 | -LL | let _ = type_ascribe!(box if true { false } else { true }, Box<dyn Debug>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Debug>`, found `Box<bool>` +LL | let _ = type_ascribe!(Box::new( if true { false } else { true }), Box<dyn Debug>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Debug>`, found `Box<bool>` | = note: expected struct `Box<dyn Debug>` found struct `Box<bool>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:15:27 + --> $DIR/coerce-expect-unsized-ascribed.rs:16:27 | -LL | let _ = type_ascribe!(box match true { true => 'a', false => 'b' }, Box<dyn Debug>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Debug>`, found `Box<char>` +LL | let _ = type_ascribe!(Box::new( match true { true => 'a', false => 'b' }), Box<dyn Debug>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Debug>`, found `Box<char>` | = note: expected struct `Box<dyn Debug>` found struct `Box<char>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:17:27 + --> $DIR/coerce-expect-unsized-ascribed.rs:18:27 | LL | let _ = type_ascribe!(&{ [1, 2, 3] }, &[i32]); | ^^^^^^^^^^^^^^ expected `&[i32]`, found `&[i32; 3]` @@ -62,7 +62,7 @@ LL | let _ = type_ascribe!(&{ [1, 2, 3] }, &[i32]); found reference `&[i32; 3]` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:18:27 + --> $DIR/coerce-expect-unsized-ascribed.rs:19:27 | LL | let _ = type_ascribe!(&if true { [1, 2, 3] } else { [1, 3, 4] }, &[i32]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[i32]`, found `&[i32; 3]` @@ -71,7 +71,7 @@ LL | let _ = type_ascribe!(&if true { [1, 2, 3] } else { [1, 3, 4] }, &[i32] found reference `&[i32; 3]` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:19:27 + --> $DIR/coerce-expect-unsized-ascribed.rs:20:27 | LL | let _ = type_ascribe!(&match true { true => [1, 2, 3], false => [1, 3, 4] }, &[i32]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&[i32]`, found `&[i32; 3]` @@ -80,16 +80,16 @@ LL | let _ = type_ascribe!(&match true { true => [1, 2, 3], false => [1, 3, found reference `&[i32; 3]` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:21:27 + --> $DIR/coerce-expect-unsized-ascribed.rs:22:27 | LL | let _ = type_ascribe!(&{ |x| (x as u8) }, &dyn Fn(i32) -> _); - | ^^^^^^^^^^^^^^^^^^ expected `&dyn Fn(i32) -> u8`, found `&[closure@coerce-expect-unsized-ascribed.rs:21:30]` + | ^^^^^^^^^^^^^^^^^^ expected `&dyn Fn(i32) -> u8`, found `&[closure@coerce-expect-unsized-ascribed.rs:22:30]` | = note: expected reference `&dyn Fn(i32) -> u8` - found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:21:30: 21:33]` + found reference `&[closure@$DIR/coerce-expect-unsized-ascribed.rs:22:30: 22:33]` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:22:27 + --> $DIR/coerce-expect-unsized-ascribed.rs:23:27 | LL | let _ = type_ascribe!(&if true { false } else { true }, &dyn Debug); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&dyn Debug`, found `&bool` @@ -98,7 +98,7 @@ LL | let _ = type_ascribe!(&if true { false } else { true }, &dyn Debug); found reference `&bool` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:23:27 + --> $DIR/coerce-expect-unsized-ascribed.rs:24:27 | LL | let _ = type_ascribe!(&match true { true => 'a', false => 'b' }, &dyn Debug); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `&dyn Debug`, found `&char` @@ -107,7 +107,7 @@ LL | let _ = type_ascribe!(&match true { true => 'a', false => 'b' }, &dyn D found reference `&char` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:25:27 + --> $DIR/coerce-expect-unsized-ascribed.rs:26:27 | LL | let _ = type_ascribe!(Box::new([1, 2, 3]), Box<[i32]>); | ^^^^^^^^^^^^^^^^^^^ expected `Box<[i32]>`, found `Box<[i32; 3]>` @@ -116,13 +116,13 @@ LL | let _ = type_ascribe!(Box::new([1, 2, 3]), Box<[i32]>); found struct `Box<[i32; 3]>` error[E0308]: mismatched types - --> $DIR/coerce-expect-unsized-ascribed.rs:26:27 + --> $DIR/coerce-expect-unsized-ascribed.rs:27:27 | LL | let _ = type_ascribe!(Box::new(|x| (x as u8)), Box<dyn Fn(i32) -> _>); - | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Fn(i32) -> u8>`, found `Box<[closure@coerce-expect-unsized-ascribed.rs:26:36]>` + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `Box<dyn Fn(i32) -> u8>`, found `Box<[closure@coerce-expect-unsized-ascribed.rs:27:36]>` | = note: expected struct `Box<dyn Fn(i32) -> u8>` - found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:26:36: 26:39]>` + found struct `Box<[closure@$DIR/coerce-expect-unsized-ascribed.rs:27:36: 27:39]>` error: aborting due to 14 previous errors diff --git a/tests/ui/coherence/coherence-conflicting-negative-trait-impl.rs b/tests/ui/coherence/coherence-conflicting-negative-trait-impl.rs index 24b878927..76a57936e 100644 --- a/tests/ui/coherence/coherence-conflicting-negative-trait-impl.rs +++ b/tests/ui/coherence/coherence-conflicting-negative-trait-impl.rs @@ -13,5 +13,7 @@ impl<T: MyTrait> !Send for TestType<T> {} //~ ERROR found both positive and nega unsafe impl<T: 'static> Send for TestType<T> {} //~ ERROR conflicting implementations impl !Send for TestType<i32> {} +//~^ WARNING +//~| WARNING this will change its meaning fn main() {} diff --git a/tests/ui/coherence/coherence-conflicting-negative-trait-impl.stderr b/tests/ui/coherence/coherence-conflicting-negative-trait-impl.stderr index 2463f38a9..020199da9 100644 --- a/tests/ui/coherence/coherence-conflicting-negative-trait-impl.stderr +++ b/tests/ui/coherence/coherence-conflicting-negative-trait-impl.stderr @@ -16,7 +16,23 @@ LL | unsafe impl<T: MyTrait + 'static> Send for TestType<T> {} LL | unsafe impl<T: 'static> Send for TestType<T> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` -error: aborting due to 2 previous errors +warning: cross-crate traits with a default impl, like `Send`, should not be specialized + --> $DIR/coherence-conflicting-negative-trait-impl.rs:15:1 + | +LL | impl !Send for TestType<i32> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this will change its meaning in a future release! + = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367> + = note: `i32` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> $DIR/coherence-conflicting-negative-trait-impl.rs:7:1 + | +LL | struct TestType<T>(::std::marker::PhantomData<T>); + | ^^^^^^^^^^^^^^^^^^ + = note: `#[warn(suspicious_auto_trait_impls)]` on by default + +error: aborting due to 2 previous errors; 1 warning emitted Some errors have detailed explanations: E0119, E0751. For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/coherence/coherence-impls-copy.stderr b/tests/ui/coherence/coherence-impls-copy.stderr index d40ffc48a..21dbc6063 100644 --- a/tests/ui/coherence/coherence-impls-copy.stderr +++ b/tests/ui/coherence/coherence-impls-copy.stderr @@ -52,19 +52,19 @@ LL | impl Copy for [MyType] {} | = note: define and implement a trait or new type instead -error[E0206]: the trait `Copy` may not be implemented for this type +error[E0206]: the trait `Copy` cannot be implemented for this type --> $DIR/coherence-impls-copy.rs:21:15 | LL | impl Copy for &'static mut MyType {} | ^^^^^^^^^^^^^^^^^^^ type is not a structure or enumeration -error[E0206]: the trait `Copy` may not be implemented for this type +error[E0206]: the trait `Copy` cannot be implemented for this type --> $DIR/coherence-impls-copy.rs:25:15 | LL | impl Copy for (MyType, MyType) {} | ^^^^^^^^^^^^^^^^ type is not a structure or enumeration -error[E0206]: the trait `Copy` may not be implemented for this type +error[E0206]: the trait `Copy` cannot be implemented for this type --> $DIR/coherence-impls-copy.rs:30:15 | LL | impl Copy for [MyType] {} diff --git a/tests/ui/coherence/coherence-orphan.rs b/tests/ui/coherence/coherence-orphan.rs index 3beac04c7..bed782203 100644 --- a/tests/ui/coherence/coherence-orphan.rs +++ b/tests/ui/coherence/coherence-orphan.rs @@ -14,7 +14,8 @@ impl TheTrait<TheType> for isize { } impl TheTrait<isize> for TheType { } -impl !Send for Vec<isize> { } -//~^ ERROR E0117 +impl !Send for Vec<isize> { } //~ ERROR E0117 +//~^ WARNING +//~| WARNING this will change its meaning fn main() { } diff --git a/tests/ui/coherence/coherence-orphan.stderr b/tests/ui/coherence/coherence-orphan.stderr index 01f166a21..9ec1d0dc3 100644 --- a/tests/ui/coherence/coherence-orphan.stderr +++ b/tests/ui/coherence/coherence-orphan.stderr @@ -21,6 +21,19 @@ LL | impl !Send for Vec<isize> { } | = note: define and implement a trait or new type instead -error: aborting due to 2 previous errors +warning: cross-crate traits with a default impl, like `Send`, should not be specialized + --> $DIR/coherence-orphan.rs:17:1 + | +LL | impl !Send for Vec<isize> { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this will change its meaning in a future release! + = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367> + = note: `isize` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + = note: `#[warn(suspicious_auto_trait_impls)]` on by default + +error: aborting due to 2 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0117`. diff --git a/tests/ui/coherence/coherence_inherent.stderr b/tests/ui/coherence/coherence_inherent.stderr index 46b128c08..b381b0680 100644 --- a/tests/ui/coherence/coherence_inherent.stderr +++ b/tests/ui/coherence/coherence_inherent.stderr @@ -7,7 +7,7 @@ LL | s.the_fn(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use Lib::TheTrait; +LL + use Lib::TheTrait; | error: aborting due to previous error diff --git a/tests/ui/coherence/coherence_inherent_cc.stderr b/tests/ui/coherence/coherence_inherent_cc.stderr index af0ef3b69..7b6cb7d43 100644 --- a/tests/ui/coherence/coherence_inherent_cc.stderr +++ b/tests/ui/coherence/coherence_inherent_cc.stderr @@ -7,7 +7,7 @@ LL | s.the_fn(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use coherence_inherent_cc_lib::TheTrait; +LL + use coherence_inherent_cc_lib::TheTrait; | error: aborting due to previous error diff --git a/tests/ui/coherence/deep-bad-copy-reason.rs b/tests/ui/coherence/deep-bad-copy-reason.rs index 80bbe387a..97fd3f719 100644 --- a/tests/ui/coherence/deep-bad-copy-reason.rs +++ b/tests/ui/coherence/deep-bad-copy-reason.rs @@ -31,7 +31,7 @@ impl<'tcx, T> Clone for List<'tcx, T> { } impl<'tcx, T> Copy for List<'tcx, T> {} -//~^ ERROR the trait `Copy` may not be implemented for this type +//~^ ERROR the trait `Copy` cannot be implemented for this type fn assert_is_copy<T: Copy>() {} diff --git a/tests/ui/coherence/deep-bad-copy-reason.stderr b/tests/ui/coherence/deep-bad-copy-reason.stderr index 168ee5726..7b6dd4b38 100644 --- a/tests/ui/coherence/deep-bad-copy-reason.stderr +++ b/tests/ui/coherence/deep-bad-copy-reason.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/deep-bad-copy-reason.rs:33:24 | LL | pub struct List<'tcx, T>(Interned<'tcx, ListS<T>>); diff --git a/tests/ui/coherence/illegal-copy-bad-projection.rs b/tests/ui/coherence/illegal-copy-bad-projection.rs new file mode 100644 index 000000000..797443a0a --- /dev/null +++ b/tests/ui/coherence/illegal-copy-bad-projection.rs @@ -0,0 +1,16 @@ +trait AsPtr { + type Ptr; +} + +impl AsPtr for () { + type Ptr = *const void; + //~^ ERROR cannot find type `void` in this scope +} + +#[derive(Copy, Clone)] +struct Foo { + p: <() as AsPtr>::Ptr, + // Do not report a "`Copy` cannot be implemented" here. +} + +fn main() {} diff --git a/tests/ui/coherence/illegal-copy-bad-projection.stderr b/tests/ui/coherence/illegal-copy-bad-projection.stderr new file mode 100644 index 000000000..8fed9ba23 --- /dev/null +++ b/tests/ui/coherence/illegal-copy-bad-projection.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `void` in this scope + --> $DIR/illegal-copy-bad-projection.rs:6:23 + | +LL | type Ptr = *const void; + | ^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/command/command-exec.rs b/tests/ui/command/command-exec.rs index 032dad184..edc33446d 100644 --- a/tests/ui/command/command-exec.rs +++ b/tests/ui/command/command-exec.rs @@ -2,7 +2,6 @@ #![allow(stable_features)] // ignore-windows - this is a unix-specific test -// ignore-pretty issue #37199 // ignore-emscripten no processes // ignore-sgx no processes // ignore-fuchsia no execvp syscall provided diff --git a/tests/ui/conditional-compilation/cfg-attr-multi-true.stderr b/tests/ui/conditional-compilation/cfg-attr-multi-true.stderr index fbfcd4565..123ce7172 100644 --- a/tests/ui/conditional-compilation/cfg-attr-multi-true.stderr +++ b/tests/ui/conditional-compilation/cfg-attr-multi-true.stderr @@ -35,6 +35,10 @@ note: the lint level is defined here | LL | #![warn(unused_must_use)] | ^^^^^^^^^^^^^^^ +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = MustUseDeprecated::new(); + | +++++++ warning: 5 warnings emitted diff --git a/tests/ui/const-generics/bad-generic-in-copy-impl.rs b/tests/ui/const-generics/bad-generic-in-copy-impl.rs new file mode 100644 index 000000000..b5663464c --- /dev/null +++ b/tests/ui/const-generics/bad-generic-in-copy-impl.rs @@ -0,0 +1,9 @@ +#[derive(Copy, Clone)] +pub struct Foo { + x: [u8; SIZE], + //~^ ERROR mismatched types +} + +const SIZE: u32 = 1; + +fn main() {} diff --git a/tests/ui/const-generics/bad-generic-in-copy-impl.stderr b/tests/ui/const-generics/bad-generic-in-copy-impl.stderr new file mode 100644 index 000000000..25701ce68 --- /dev/null +++ b/tests/ui/const-generics/bad-generic-in-copy-impl.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/bad-generic-in-copy-impl.rs:3:13 + | +LL | x: [u8; SIZE], + | ^^^^ expected `usize`, found `u32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/bad-subst-const-kind.rs b/tests/ui/const-generics/bad-subst-const-kind.rs new file mode 100644 index 000000000..e13dfbacd --- /dev/null +++ b/tests/ui/const-generics/bad-subst-const-kind.rs @@ -0,0 +1,13 @@ +// incremental +#![crate_type = "lib"] + +trait Q { + const ASSOC: usize; +} + +impl<const N: u64> Q for [u8; N] { + //~^ ERROR mismatched types + const ASSOC: usize = 1; +} + +pub fn test() -> [u8; <[u8; 13] as Q>::ASSOC] { todo!() } diff --git a/tests/ui/const-generics/bad-subst-const-kind.stderr b/tests/ui/const-generics/bad-subst-const-kind.stderr new file mode 100644 index 000000000..bd24f9140 --- /dev/null +++ b/tests/ui/const-generics/bad-subst-const-kind.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/bad-subst-const-kind.rs:8:31 + | +LL | impl<const N: u64> Q for [u8; N] { + | ^ expected `usize`, found `u64` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/const-arg-in-const-arg.full.stderr b/tests/ui/const-generics/const-arg-in-const-arg.full.stderr index 8672e79b3..463a37d7e 100644 --- a/tests/ui/const-generics/const-arg-in-const-arg.full.stderr +++ b/tests/ui/const-generics/const-arg-in-const-arg.full.stderr @@ -1,4 +1,4 @@ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:18:23 | LL | let _: [u8; faz::<'a>(&())]; @@ -10,7 +10,7 @@ note: the late bound lifetime parameter is introduced here LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:21:23 | LL | let _: [u8; faz::<'b>(&())]; @@ -22,7 +22,7 @@ note: the late bound lifetime parameter is introduced here LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:41:24 | LL | let _: Foo<{ faz::<'a>(&()) }>; @@ -34,7 +34,7 @@ note: the late bound lifetime parameter is introduced here LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:44:24 | LL | let _: Foo<{ faz::<'b>(&()) }>; @@ -94,7 +94,7 @@ LL | let _ = [0; bar::<N>()]; | = help: try adding a `where` bound using this expression: `where [(); bar::<N>()]:` -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:30:23 | LL | let _ = [0; faz::<'a>(&())]; @@ -106,7 +106,7 @@ note: the late bound lifetime parameter is introduced here LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:33:23 | LL | let _ = [0; faz::<'b>(&())]; @@ -134,7 +134,7 @@ LL | let _ = Foo::<{ bar::<N>() }>; | = help: try adding a `where` bound using this expression: `where [(); { bar::<N>() }]:` -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:52:27 | LL | let _ = Foo::<{ faz::<'a>(&()) }>; @@ -146,7 +146,7 @@ note: the late bound lifetime parameter is introduced here LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:55:27 | LL | let _ = Foo::<{ faz::<'b>(&()) }>; @@ -160,3 +160,4 @@ LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } error: aborting due to 16 previous errors +For more information about this error, try `rustc --explain E0794`. diff --git a/tests/ui/const-generics/const-arg-in-const-arg.min.stderr b/tests/ui/const-generics/const-arg-in-const-arg.min.stderr index f1353aa99..a7bd9c62b 100644 --- a/tests/ui/const-generics/const-arg-in-const-arg.min.stderr +++ b/tests/ui/const-generics/const-arg-in-const-arg.min.stderr @@ -216,7 +216,7 @@ help: if this generic argument was intended as a const parameter, surround it wi LL | let _: [u8; bar::<{ N }>()]; | + + -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:18:23 | LL | let _: [u8; faz::<'a>(&())]; @@ -228,7 +228,7 @@ note: the late bound lifetime parameter is introduced here LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:21:23 | LL | let _: [u8; faz::<'b>(&())]; @@ -251,7 +251,7 @@ help: if this generic argument was intended as a const parameter, surround it wi LL | let _: Foo<{ bar::<{ N }>() }>; | + + -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:41:24 | LL | let _: Foo<{ faz::<'a>(&()) }>; @@ -263,7 +263,7 @@ note: the late bound lifetime parameter is introduced here LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:44:24 | LL | let _: Foo<{ faz::<'b>(&()) }>; @@ -294,7 +294,7 @@ help: if this generic argument was intended as a const parameter, surround it wi LL | let _ = [0; bar::<{ N }>()]; | + + -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:30:23 | LL | let _ = [0; faz::<'a>(&())]; @@ -306,7 +306,7 @@ note: the late bound lifetime parameter is introduced here LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:33:23 | LL | let _ = [0; faz::<'b>(&())]; @@ -329,7 +329,7 @@ help: if this generic argument was intended as a const parameter, surround it wi LL | let _ = Foo::<{ bar::<{ N }>() }>; | + + -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:52:27 | LL | let _ = Foo::<{ faz::<'a>(&()) }>; @@ -341,7 +341,7 @@ note: the late bound lifetime parameter is introduced here LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/const-arg-in-const-arg.rs:55:27 | LL | let _ = Foo::<{ faz::<'b>(&()) }>; @@ -355,5 +355,5 @@ LL | const fn faz<'a>(_: &'a ()) -> usize { 13 } error: aborting due to 36 previous errors -Some errors have detailed explanations: E0658, E0747. +Some errors have detailed explanations: E0658, E0747, E0794. For more information about an error, try `rustc --explain E0658`. diff --git a/tests/ui/const-generics/defaults/doesnt_infer.stderr b/tests/ui/const-generics/defaults/doesnt_infer.stderr index 227b2f402..a61411d6e 100644 --- a/tests/ui/const-generics/defaults/doesnt_infer.stderr +++ b/tests/ui/const-generics/defaults/doesnt_infer.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed for `Foo<N>` LL | let foo = Foo::foo(); | ^^^ | -help: consider giving `foo` an explicit type, where the the value of const parameter `N` is specified +help: consider giving `foo` an explicit type, where the value of const parameter `N` is specified | LL | let foo: Foo<N> = Foo::foo(); | ++++++++ diff --git a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr index 7b4d46b82..6b3396a25 100644 --- a/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr +++ b/tests/ui/const-generics/generic_const_exprs/cross_crate_predicate.stderr @@ -1,8 +1,8 @@ error: unconstrained generic constant - --> $DIR/cross_crate_predicate.rs:7:13 + --> $DIR/cross_crate_predicate.rs:7:44 | LL | let _ = const_evaluatable_lib::test1::<T>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<T>() - 1]:` note: required by a bound in `test1` @@ -12,10 +12,10 @@ LL | [u8; std::mem::size_of::<T>() - 1]: Sized, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `test1` error: unconstrained generic constant - --> $DIR/cross_crate_predicate.rs:7:13 + --> $DIR/cross_crate_predicate.rs:7:44 | LL | let _ = const_evaluatable_lib::test1::<T>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ | = help: try adding a `where` bound using this expression: `where [(); std::mem::size_of::<T>() - 1]:` note: required by a bound in `test1` diff --git a/tests/ui/const-generics/generic_const_exprs/issue-94287.stderr b/tests/ui/const-generics/generic_const_exprs/issue-94287.stderr index 7390a0077..dc7d0c54f 100644 --- a/tests/ui/const-generics/generic_const_exprs/issue-94287.stderr +++ b/tests/ui/const-generics/generic_const_exprs/issue-94287.stderr @@ -8,7 +8,7 @@ LL | If<{ FRAC <= 32 }>: True, help: consider enabling this feature --> $DIR/issue-94287.rs:1:1 | -LL | #![feature(generic_const_exprs)] +LL + #![feature(generic_const_exprs)] | error: aborting due to previous error diff --git a/tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.rs b/tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.rs new file mode 100644 index 000000000..734a37862 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.rs @@ -0,0 +1,11 @@ +#![feature(generic_const_exprs)] +//~^ WARN the feature `generic_const_exprs` is incomplete + +trait B { + type U<T>; +} + +fn f<T: B<U<1i32> = ()>>() {} +//~^ ERROR constant provided when a type was expected + +fn main() {} diff --git a/tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.stderr b/tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.stderr new file mode 100644 index 000000000..8b6eb5b75 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/mismatched-gat-subst-kind.stderr @@ -0,0 +1,18 @@ +warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/mismatched-gat-subst-kind.rs:1:12 + | +LL | #![feature(generic_const_exprs)] + | ^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0747]: constant provided when a type was expected + --> $DIR/mismatched-gat-subst-kind.rs:8:13 + | +LL | fn f<T: B<U<1i32> = ()>>() {} + | ^^^^ + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0747`. diff --git a/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs new file mode 100644 index 000000000..85345d65c --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/typeid-equality-by-subtyping.rs @@ -0,0 +1,52 @@ +// check-pass +// known-bug: #97156 + +#![feature(const_type_id, generic_const_exprs)] +#![allow(incomplete_features)] + +use std::any::TypeId; +// `One` and `Two` are currently considered equal types, as both +// `One <: Two` and `One :> Two` holds. +type One = for<'a> fn(&'a (), &'a ()); +type Two = for<'a, 'b> fn(&'a (), &'b ()); +trait AssocCt { + const ASSOC: usize; +} +const fn to_usize<T: 'static>() -> usize { + const WHAT_A_TYPE: TypeId = TypeId::of::<One>(); + match TypeId::of::<T>() { + WHAT_A_TYPE => 0, + _ => 1000, + } +} +impl<T: 'static> AssocCt for T { + const ASSOC: usize = to_usize::<T>(); +} + +trait WithAssoc<U> { + type Assoc; +} +impl<T: 'static> WithAssoc<()> for T where [(); <T as AssocCt>::ASSOC]: { + type Assoc = [u8; <T as AssocCt>::ASSOC]; +} + +fn generic<T: 'static, U>(x: <T as WithAssoc<U>>::Assoc) -> <T as WithAssoc<U>>::Assoc +where + [(); <T as AssocCt>::ASSOC]:, + T: WithAssoc<U>, +{ + x +} + + +fn unsound<T>(x: <One as WithAssoc<T>>::Assoc) -> <Two as WithAssoc<T>>::Assoc +where + One: WithAssoc<T>, +{ + let x: <Two as WithAssoc<T>>::Assoc = generic::<One, T>(x); + x +} + +fn main() { + println!("{:?}", unsound::<()>([])); +} diff --git a/tests/ui/const-generics/issue-93647.rs b/tests/ui/const-generics/issue-93647.rs index 806540e17..a0083a0c6 100644 --- a/tests/ui/const-generics/issue-93647.rs +++ b/tests/ui/const-generics/issue-93647.rs @@ -1,6 +1,7 @@ struct X<const N: usize = { (||1usize)() //~^ ERROR cannot call non-const closure + //~| ERROR the trait bound }>; fn main() {} diff --git a/tests/ui/const-generics/issue-93647.stderr b/tests/ui/const-generics/issue-93647.stderr index 18370eea5..20a6af5c5 100644 --- a/tests/ui/const-generics/issue-93647.stderr +++ b/tests/ui/const-generics/issue-93647.stderr @@ -1,3 +1,17 @@ +error[E0277]: the trait bound `[closure@$DIR/issue-93647.rs:2:6: 2:8]: Fn<()>` is not satisfied + --> $DIR/issue-93647.rs:2:5 + | +LL | (||1usize)() + | ^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-93647.rs:2:6: 2:8]` + | + = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-93647.rs:2:6: 2:8]` +note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-93647.rs:2:6: 2:8]`, but that implementation is not `const` + --> $DIR/issue-93647.rs:2:5 + | +LL | (||1usize)() + | ^^^^^^^^^^^^ + = note: wrap the `[closure@$DIR/issue-93647.rs:2:6: 2:8]` in a closure with no arguments: `|| { /* code */ }` + error[E0015]: cannot call non-const closure in constants --> $DIR/issue-93647.rs:2:5 | @@ -8,6 +22,7 @@ LL | (||1usize)() = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0015`. +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/const-generics/issues/issue-82956.stderr b/tests/ui/const-generics/issues/issue-82956.stderr index d2320293e..d70c8d0bf 100644 --- a/tests/ui/const-generics/issues/issue-82956.stderr +++ b/tests/ui/const-generics/issues/issue-82956.stderr @@ -6,13 +6,13 @@ LL | let mut iter = IntoIter::new(self); | help: consider importing one of these items | -LL | use std::array::IntoIter; +LL + use std::array::IntoIter; | -LL | use std::collections::binary_heap::IntoIter; +LL + use std::collections::binary_heap::IntoIter; | -LL | use std::collections::btree_map::IntoIter; +LL + use std::collections::btree_map::IntoIter; | -LL | use std::collections::btree_set::IntoIter; +LL + use std::collections::btree_set::IntoIter; | and 8 other candidates diff --git a/tests/ui/const-generics/transmute-fail.rs b/tests/ui/const-generics/transmute-fail.rs new file mode 100644 index 000000000..d7bf1b47f --- /dev/null +++ b/tests/ui/const-generics/transmute-fail.rs @@ -0,0 +1,35 @@ +#![feature(transmute_generic_consts)] +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +fn foo<const W: usize, const H: usize>(v: [[u32;H+1]; W]) -> [[u32; W+1]; H] { + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute + } +} + +fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] { + //~^ ERROR mismatched types + //~| ERROR mismatched types + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute between types + } +} + +fn baz<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [u32; W * H * H] { + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute + } +} + +fn overflow(v: [[[u32; 8888888]; 9999999]; 777777777]) -> [[[u32; 9999999]; 777777777]; 8888888] { + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute + } +} + +fn main() {} diff --git a/tests/ui/const-generics/transmute-fail.stderr b/tests/ui/const-generics/transmute-fail.stderr new file mode 100644 index 000000000..41b098135 --- /dev/null +++ b/tests/ui/const-generics/transmute-fail.stderr @@ -0,0 +1,52 @@ +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-fail.rs:7:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[[u32; H+1]; W]` (generic size [const expr]) + = note: target type: `[[u32; W+1]; H]` (generic size [const expr]) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-fail.rs:16:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[[u32; H]; W]` (this type does not have a fixed size) + = note: target type: `[[u32; W]; H]` (size can vary because of [u32; W]) + +error[E0308]: mismatched types + --> $DIR/transmute-fail.rs:12:53 + | +LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] { + | ^ expected `usize`, found `bool` + +error[E0308]: mismatched types + --> $DIR/transmute-fail.rs:12:67 + | +LL | fn bar<const W: bool, const H: usize>(v: [[u32; H]; W]) -> [[u32; W]; H] { + | ^ expected `usize`, found `bool` + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-fail.rs:23:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[[u32; H]; W]` (generic size [const expr]) + = note: target type: `[u32; W * H * H]` (generic size [const expr]) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute-fail.rs:30:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[[[u32; 8888888]; 9999999]; 777777777]` (values of the type `[[[u32; 8888888]; 9999999]; 777777777]` are too big for the current architecture) + = note: target type: `[[[u32; 9999999]; 777777777]; 8888888]` (values of the type `[[[u32; 9999999]; 777777777]; 8888888]` are too big for the current architecture) + +error: aborting due to 6 previous errors + +Some errors have detailed explanations: E0308, E0512. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/transmute.rs b/tests/ui/const-generics/transmute.rs new file mode 100644 index 000000000..30560a95b --- /dev/null +++ b/tests/ui/const-generics/transmute.rs @@ -0,0 +1,83 @@ +// run-pass +#![feature(generic_const_exprs)] +#![feature(transmute_generic_consts)] +#![allow(incomplete_features)] + +fn transpose<const W: usize, const H: usize>(v: [[u32;H]; W]) -> [[u32; W]; H] { + unsafe { + std::mem::transmute(v) + } +} + +fn ident<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [[u32; H]; W] { + unsafe { + std::mem::transmute(v) + } +} + +fn flatten<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [u32; W * H] { + unsafe { + std::mem::transmute(v) + } +} + +fn coagulate<const W: usize, const H: usize>(v: [u32; H*W]) -> [[u32; W];H] { + unsafe { + std::mem::transmute(v) + } +} + +fn flatten_3d<const W: usize, const H: usize, const D: usize>( + v: [[[u32; D]; H]; W] +) -> [u32; D * W * H] { + unsafe { + std::mem::transmute(v) + } +} + +fn flatten_somewhat<const W: usize, const H: usize, const D: usize>( + v: [[[u32; D]; H]; W] +) -> [[u32; D * W]; H] { + unsafe { + std::mem::transmute(v) + } +} + +fn known_size<const L: usize>(v: [u16; L]) -> [u8; L * 2] { + unsafe { + std::mem::transmute(v) + } +} + +fn condense_bytes<const L: usize>(v: [u8; L * 2]) -> [u16; L] { + unsafe { + std::mem::transmute(v) + } +} + +fn singleton_each<const L: usize>(v: [u8; L]) -> [[u8;1]; L] { + unsafe { + std::mem::transmute(v) + } +} + +fn transpose_with_const<const W: usize, const H: usize>( + v: [[u32; 2 * H]; W + W] +) -> [[u32; W + W]; 2 * H] { + unsafe { + std::mem::transmute(v) + } +} + +fn main() { + let _ = transpose([[0; 8]; 16]); + let _ = transpose_with_const::<8,4>([[0; 8]; 16]); + let _ = ident([[0; 8]; 16]); + let _ = flatten([[0; 13]; 5]); + let _: [[_; 5]; 13] = coagulate([0; 65]); + let _ = flatten_3d([[[0; 3]; 13]; 5]); + let _ = flatten_somewhat([[[0; 3]; 13]; 5]); + let _ = known_size([16; 13]); + let _: [u16; 5] = condense_bytes([16u8; 10]); + let _ = singleton_each([16; 10]); +} diff --git a/tests/ui/const-generics/transmute_no_gate.rs b/tests/ui/const-generics/transmute_no_gate.rs new file mode 100644 index 000000000..e1ac44390 --- /dev/null +++ b/tests/ui/const-generics/transmute_no_gate.rs @@ -0,0 +1,91 @@ +// gate-test-transmute_generic_consts +#![feature(generic_const_exprs)] +#![allow(incomplete_features)] + +fn transpose<const W: usize, const H: usize>(v: [[u32;H]; W]) -> [[u32; W]; H] { + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute + } +} + +fn ident<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [[u32; H]; W] { + unsafe { + std::mem::transmute(v) + } +} + +fn flatten<const W: usize, const H: usize>(v: [[u32; H]; W]) -> [u32; W * H] { + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute + } +} + +fn coagulate<const W: usize, const H: usize>(v: [u32; H*W]) -> [[u32; W];H] { + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute + } +} + +fn flatten_3d<const W: usize, const H: usize, const D: usize>( + v: [[[u32; D]; H]; W] +) -> [u32; D * W * H] { + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute + } +} + +fn flatten_somewhat<const W: usize, const H: usize, const D: usize>( + v: [[[u32; D]; H]; W] +) -> [[u32; D * W]; H] { + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute + } +} + +fn known_size<const L: usize>(v: [u16; L]) -> [u8; L * 2] { + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute + } +} + +fn condense_bytes<const L: usize>(v: [u8; L * 2]) -> [u16; L] { + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute + } +} + +fn singleton_each<const L: usize>(v: [u8; L]) -> [[u8;1]; L] { + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute + } +} + +fn transpose_with_const<const W: usize, const H: usize>( + v: [[u32; 2 * H]; W + W] +) -> [[u32; W + W]; 2 * H] { + unsafe { + std::mem::transmute(v) + //~^ ERROR cannot transmute + } +} + +fn main() { + let _ = transpose([[0; 8]; 16]); + let _ = transpose_with_const::<8,4>([[0; 8]; 16]); + let _ = ident([[0; 8]; 16]); + let _ = flatten([[0; 13]; 5]); + let _: [[_; 5]; 13] = coagulate([0; 65]); + let _ = flatten_3d([[[0; 3]; 13]; 5]); + let _ = flatten_somewhat([[[0; 3]; 13]; 5]); + let _ = known_size([16; 13]); + let _: [u16; 5] = condense_bytes([16u8; 10]); + let _ = singleton_each([16; 10]); +} diff --git a/tests/ui/const-generics/transmute_no_gate.stderr b/tests/ui/const-generics/transmute_no_gate.stderr new file mode 100644 index 000000000..9c271b348 --- /dev/null +++ b/tests/ui/const-generics/transmute_no_gate.stderr @@ -0,0 +1,84 @@ +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute_no_gate.rs:7:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[[u32; H]; W]` (this type does not have a fixed size) + = note: target type: `[[u32; W]; H]` (this type does not have a fixed size) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute_no_gate.rs:20:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[[u32; H]; W]` (this type does not have a fixed size) + = note: target type: `[u32; W * H]` (this type does not have a fixed size) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute_no_gate.rs:27:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[u32; H*W]` (this type does not have a fixed size) + = note: target type: `[[u32; W]; H]` (this type does not have a fixed size) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute_no_gate.rs:36:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[[[u32; D]; H]; W]` (this type does not have a fixed size) + = note: target type: `[u32; D * W * H]` (this type does not have a fixed size) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute_no_gate.rs:45:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[[[u32; D]; H]; W]` (this type does not have a fixed size) + = note: target type: `[[u32; D * W]; H]` (this type does not have a fixed size) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute_no_gate.rs:52:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[u16; L]` (this type does not have a fixed size) + = note: target type: `[u8; L * 2]` (this type does not have a fixed size) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute_no_gate.rs:59:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[u8; L * 2]` (this type does not have a fixed size) + = note: target type: `[u16; L]` (this type does not have a fixed size) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute_no_gate.rs:66:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[u8; L]` (this type does not have a fixed size) + = note: target type: `[[u8; 1]; L]` (this type does not have a fixed size) + +error[E0512]: cannot transmute between types of different sizes, or dependently-sized types + --> $DIR/transmute_no_gate.rs:75:5 + | +LL | std::mem::transmute(v) + | ^^^^^^^^^^^^^^^^^^^ + | + = note: source type: `[[u32; 2 * H]; W + W]` (this type does not have a fixed size) + = note: target type: `[[u32; W + W]; 2 * H]` (this type does not have a fixed size) + +error: aborting due to 9 previous errors + +For more information about this error, try `rustc --explain E0512`. diff --git a/tests/ui/const-generics/type_mismatch.rs b/tests/ui/const-generics/type_mismatch.rs index 4a7534e37..daa13277b 100644 --- a/tests/ui/const-generics/type_mismatch.rs +++ b/tests/ui/const-generics/type_mismatch.rs @@ -1,5 +1,6 @@ fn foo<const N: usize>() -> [u8; N] { bar::<N>() //~ ERROR mismatched types + //~^ ERROR the constant `N` is not of type `u8` } fn bar<const N: u8>() -> [u8; N] {} diff --git a/tests/ui/const-generics/type_mismatch.stderr b/tests/ui/const-generics/type_mismatch.stderr index b28ae8f7e..394dd44d4 100644 --- a/tests/ui/const-generics/type_mismatch.stderr +++ b/tests/ui/const-generics/type_mismatch.stderr @@ -1,3 +1,15 @@ +error: the constant `N` is not of type `u8` + --> $DIR/type_mismatch.rs:2:11 + | +LL | bar::<N>() + | ^ expected `u8`, found `usize` + | +note: required by a bound in `bar` + --> $DIR/type_mismatch.rs:6:8 + | +LL | fn bar<const N: u8>() -> [u8; N] {} + | ^^^^^^^^^^^ required by this bound in `bar` + error[E0308]: mismatched types --> $DIR/type_mismatch.rs:2:11 | @@ -5,7 +17,7 @@ LL | bar::<N>() | ^ expected `u8`, found `usize` error[E0308]: mismatched types - --> $DIR/type_mismatch.rs:5:26 + --> $DIR/type_mismatch.rs:6:26 | LL | fn bar<const N: u8>() -> [u8; N] {} | --- ^^^^^^^ expected `[u8; N]`, found `()` @@ -13,11 +25,11 @@ LL | fn bar<const N: u8>() -> [u8; N] {} | implicitly returns `()` as its body has no tail or `return` expression error[E0308]: mismatched types - --> $DIR/type_mismatch.rs:5:31 + --> $DIR/type_mismatch.rs:6:31 | LL | fn bar<const N: u8>() -> [u8; N] {} | ^ expected `usize`, found `u8` -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/const-generics/type_not_in_scope.rs b/tests/ui/const-generics/type_not_in_scope.rs index 593370180..917abaed1 100644 --- a/tests/ui/const-generics/type_not_in_scope.rs +++ b/tests/ui/const-generics/type_not_in_scope.rs @@ -6,6 +6,5 @@ impl X { } fn getn<const N: cfg_attr>() -> [u8; N] {} //~^ ERROR expected type, found built-in attribute `cfg_attr` -//~| ERROR mismatched types fn main() {} diff --git a/tests/ui/const-generics/type_not_in_scope.stderr b/tests/ui/const-generics/type_not_in_scope.stderr index 5f45550a6..5eb81ca05 100644 --- a/tests/ui/const-generics/type_not_in_scope.stderr +++ b/tests/ui/const-generics/type_not_in_scope.stderr @@ -10,15 +10,7 @@ error[E0573]: expected type, found built-in attribute `cfg_attr` LL | fn getn<const N: cfg_attr>() -> [u8; N] {} | ^^^^^^^^ not a type -error[E0308]: mismatched types - --> $DIR/type_not_in_scope.rs:7:33 - | -LL | fn getn<const N: cfg_attr>() -> [u8; N] {} - | ---- ^^^^^^^ expected `[u8; N]`, found `()` - | | - | implicitly returns `()` as its body has no tail or `return` expression - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0308, E0412, E0573. -For more information about an error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0412, E0573. +For more information about an error, try `rustc --explain E0412`. diff --git a/tests/ui/const-ptr/out_of_bounds_read.stderr b/tests/ui/const-ptr/out_of_bounds_read.stderr index 3e7b09a59..89536f53f 100644 --- a/tests/ui/const-ptr/out_of_bounds_read.stderr +++ b/tests/ui/const-ptr/out_of_bounds_read.stderr @@ -1,7 +1,7 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - = note: memory access failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds + = note: dereferencing pointer failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds | note: inside `std::ptr::read::<u32>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL @@ -14,7 +14,7 @@ LL | const _READ: u32 = unsafe { ptr::read(PAST_END_PTR) }; error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - = note: memory access failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds + = note: dereferencing pointer failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds | note: inside `std::ptr::read::<u32>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL @@ -29,7 +29,7 @@ LL | const _CONST_READ: u32 = unsafe { PAST_END_PTR.read() }; error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - = note: memory access failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds + = note: dereferencing pointer failed: alloc5 has size 4, so pointer to 4 bytes starting at offset 4 is out-of-bounds | note: inside `std::ptr::read::<u32>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL diff --git a/tests/ui/const_prop/issue-86351.rs b/tests/ui/const_prop/issue-86351.rs new file mode 100644 index 000000000..b5f1e7f74 --- /dev/null +++ b/tests/ui/const_prop/issue-86351.rs @@ -0,0 +1,22 @@ +// compile-flags: --crate-type=lib -Zmir-opt-level=2 +// build-pass +// ^-- Must be build-pass, because check-pass will not run const prop. + +pub trait TestTrait { + type MyType; + fn func() -> Option<Self> + where + Self: Sized; +} + +impl<T> dyn TestTrait<MyType = T> +where + Self: Sized, +{ + pub fn other_func() -> Option<Self> { + match Self::func() { + Some(me) => Some(me), + None => None, + } + } +} diff --git a/tests/ui/const_prop/unreachable-bounds.rs b/tests/ui/const_prop/unreachable-bounds.rs new file mode 100644 index 000000000..8cf98e154 --- /dev/null +++ b/tests/ui/const_prop/unreachable-bounds.rs @@ -0,0 +1,6 @@ +// Use `build-pass` to ensure const-prop lint runs. +// build-pass + +fn main() { + [()][if false { 1 } else { return }] +} diff --git a/tests/ui/const_prop/unreachable-overflow.rs b/tests/ui/const_prop/unreachable-overflow.rs new file mode 100644 index 000000000..287513542 --- /dev/null +++ b/tests/ui/const_prop/unreachable-overflow.rs @@ -0,0 +1,10 @@ +// Use `build-pass` to ensure const-prop lint runs. +// build-pass + +fn main() { + let x = 2u32; + let y = 3u32; + if y <= x { + dbg!(x - y); + } +} diff --git a/tests/ui/consts/const-block-const-bound.stderr b/tests/ui/consts/const-block-const-bound.stderr index b9c4d8866..fef4914fa 100644 --- a/tests/ui/consts/const-block-const-bound.stderr +++ b/tests/ui/consts/const-block-const-bound.stderr @@ -1,44 +1,30 @@ error[E0277]: can't drop `UnconstDrop` in const contexts - --> $DIR/const-block-const-bound.rs:20:11 + --> $DIR/const-block-const-bound.rs:20:9 | LL | f(UnconstDrop); - | - ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `UnconstDrop` - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `UnconstDrop` | = note: the trait bound `UnconstDrop: ~const Destruct` is not satisfied -note: required by a bound in `f` - --> $DIR/const-block-const-bound.rs:6:15 - | -LL | const fn f<T: ~const Destruct>(x: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `f` help: consider borrowing here | -LL | f(&UnconstDrop); - | + -LL | f(&mut UnconstDrop); - | ++++ +LL | &f(UnconstDrop); + | + +LL | &mut f(UnconstDrop); + | ++++ error[E0277]: can't drop `NonDrop` in const contexts - --> $DIR/const-block-const-bound.rs:22:11 + --> $DIR/const-block-const-bound.rs:22:9 | LL | f(NonDrop); - | - ^^^^^^^ the trait `~const Destruct` is not implemented for `NonDrop` - | | - | required by a bound introduced by this call + | ^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonDrop` | = note: the trait bound `NonDrop: ~const Destruct` is not satisfied -note: required by a bound in `f` - --> $DIR/const-block-const-bound.rs:6:15 - | -LL | const fn f<T: ~const Destruct>(x: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `f` help: consider borrowing here | -LL | f(&NonDrop); - | + -LL | f(&mut NonDrop); - | ++++ +LL | &f(NonDrop); + | + +LL | &mut f(NonDrop); + | ++++ error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-blocks/fn-call-in-non-const.stderr b/tests/ui/consts/const-blocks/fn-call-in-non-const.stderr index ee352700c..174103eeb 100644 --- a/tests/ui/consts/const-blocks/fn-call-in-non-const.stderr +++ b/tests/ui/consts/const-blocks/fn-call-in-non-const.stderr @@ -10,7 +10,8 @@ LL | let _: [Option<Bar>; 2] = [no_copy(); 2]; = help: create an inline `const` block, see RFC #2920 <https://github.com/rust-lang/rfcs/pull/2920> for more information help: consider annotating `Bar` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | struct Bar; | error: aborting due to previous error diff --git a/tests/ui/consts/const-blocks/migrate-fail.stderr b/tests/ui/consts/const-blocks/migrate-fail.stderr index 928ffd083..d1896f755 100644 --- a/tests/ui/consts/const-blocks/migrate-fail.stderr +++ b/tests/ui/consts/const-blocks/migrate-fail.stderr @@ -8,7 +8,8 @@ LL | let arr: [Option<Bar>; 2] = [x; 2]; = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Bar` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | struct Bar; | error[E0277]: the trait bound `Bar: Copy` is not satisfied @@ -21,7 +22,8 @@ LL | let arr: [Option<Bar>; 2] = [x; 2]; = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Bar` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | struct Bar; | error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-blocks/nll-fail.stderr b/tests/ui/consts/const-blocks/nll-fail.stderr index fede00845..807c964a5 100644 --- a/tests/ui/consts/const-blocks/nll-fail.stderr +++ b/tests/ui/consts/const-blocks/nll-fail.stderr @@ -8,7 +8,8 @@ LL | let arr: [Option<Bar>; 2] = [x; 2]; = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Bar` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | struct Bar; | error[E0277]: the trait bound `Bar: Copy` is not satisfied @@ -21,7 +22,8 @@ LL | let arr: [Option<Bar>; 2] = [x; 2]; = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Bar` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | struct Bar; | error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const-err-late.stderr b/tests/ui/consts/const-err-late.stderr index cb0cab244..149d3b523 100644 --- a/tests/ui/consts/const-err-late.stderr +++ b/tests/ui/consts/const-err-late.stderr @@ -10,12 +10,6 @@ note: erroneous constant used LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); | ^^^^^^^^^^^^^ -note: erroneous constant used - --> $DIR/const-err-late.rs:19:16 - | -LL | black_box((S::<i32>::FOO, S::<u32>::FOO)); - | ^^^^^^^^^^^^^ - error[E0080]: evaluation of `S::<u32>::FOO` failed --> $DIR/const-err-late.rs:13:21 | diff --git a/tests/ui/consts/const-eval/const-eval-overflow-2.rs b/tests/ui/consts/const-eval/const-eval-overflow-2.rs index 535d91359..c19a0c443 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-2.rs +++ b/tests/ui/consts/const-eval/const-eval-overflow-2.rs @@ -14,7 +14,6 @@ fn main() { match -128i8 { NEG_NEG_128 => println!("A"), //~^ ERROR could not evaluate constant pattern - //~| ERROR could not evaluate constant pattern _ => println!("B"), } } diff --git a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr index 7b1fe49d4..fc0baf110 100644 --- a/tests/ui/consts/const-eval/const-eval-overflow-2.stderr +++ b/tests/ui/consts/const-eval/const-eval-overflow-2.stderr @@ -10,12 +10,6 @@ error: could not evaluate constant pattern LL | NEG_NEG_128 => println!("A"), | ^^^^^^^^^^^ -error: could not evaluate constant pattern - --> $DIR/const-eval-overflow-2.rs:15:9 - | -LL | NEG_NEG_128 => println!("A"), - | ^^^^^^^^^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/format.rs b/tests/ui/consts/const-eval/format.rs index 0d8b7c12d..5bdb2bf19 100644 --- a/tests/ui/consts/const-eval/format.rs +++ b/tests/ui/consts/const-eval/format.rs @@ -1,12 +1,13 @@ const fn failure() { panic!("{:?}", 0); //~^ ERROR cannot call non-const formatting macro in constant functions + //~| ERROR cannot call non-const fn `Arguments::<'_>::new_v1` in constant functions } const fn print() { println!("{:?}", 0); //~^ ERROR cannot call non-const formatting macro in constant functions - //~| ERROR `Arguments::<'a>::new_v1` is not yet stable as a const fn + //~| ERROR cannot call non-const fn `Arguments::<'_>::new_v1` in constant functions //~| ERROR cannot call non-const fn `_print` in constant functions } diff --git a/tests/ui/consts/const-eval/format.stderr b/tests/ui/consts/const-eval/format.stderr index 4bf39db58..70a1abb0a 100644 --- a/tests/ui/consts/const-eval/format.stderr +++ b/tests/ui/consts/const-eval/format.stderr @@ -1,32 +1,41 @@ error[E0015]: cannot call non-const formatting macro in constant functions - --> $DIR/format.rs:2:20 + --> $DIR/format.rs:2:13 | LL | panic!("{:?}", 0); - | ^ + | ^^^^ + | + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0015]: cannot call non-const fn `Arguments::<'_>::new_v1` in constant functions + --> $DIR/format.rs:2:5 + | +LL | panic!("{:?}", 0); + | ^^^^^^^^^^^^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const formatting macro in constant functions - --> $DIR/format.rs:7:22 + --> $DIR/format.rs:8:15 | LL | println!("{:?}", 0); - | ^ + | ^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error: `Arguments::<'a>::new_v1` is not yet stable as a const fn - --> $DIR/format.rs:7:5 +error[E0015]: cannot call non-const fn `Arguments::<'_>::new_v1` in constant functions + --> $DIR/format.rs:8:5 | LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ | - = help: add `#![feature(const_fmt_arguments_new)]` to the crate attributes to enable + = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const fn `_print` in constant functions - --> $DIR/format.rs:7:5 + --> $DIR/format.rs:8:5 | LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ @@ -63,19 +72,19 @@ LL | panic!("{:?}", 0); = note: this note originates in the macro `$crate::const_format_args` which comes from the expansion of the macro `panic` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant used - --> $DIR/format.rs:7:14 + --> $DIR/format.rs:8:14 | LL | println!("{:?}", 0); | ^^^^^^ note: erroneous constant used - --> $DIR/format.rs:7:14 + --> $DIR/format.rs:8:14 | LL | println!("{:?}", 0); | ^^^^^^ note: erroneous constant used - --> $DIR/format.rs:7:22 + --> $DIR/format.rs:8:22 | LL | println!("{:?}", 0); | ^ @@ -83,13 +92,13 @@ LL | println!("{:?}", 0); = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) note: erroneous constant used - --> $DIR/format.rs:7:22 + --> $DIR/format.rs:8:22 | LL | println!("{:?}", 0); | ^ | = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-eval/issue-44578.stderr b/tests/ui/consts/const-eval/issue-44578.stderr index 0cbf54480..f3952809e 100644 --- a/tests/ui/consts/const-eval/issue-44578.stderr +++ b/tests/ui/consts/const-eval/issue-44578.stderr @@ -26,14 +26,6 @@ LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); | = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -note: erroneous constant used - --> $DIR/issue-44578.rs:25:20 - | -LL | println!("{}", <Bar<u16, u8> as Foo>::AMT); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/panic-assoc-never-type.rs b/tests/ui/consts/const-eval/panic-assoc-never-type.rs index 28edf5144..1abe708d1 100644 --- a/tests/ui/consts/const-eval/panic-assoc-never-type.rs +++ b/tests/ui/consts/const-eval/panic-assoc-never-type.rs @@ -11,5 +11,5 @@ impl PrintName { } fn main() { - let _ = PrintName::VOID; //~ constant + let _ = PrintName::VOID; //~ erroneous constant used } diff --git a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr index 032ceb246..eaa2d6b27 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.32bit.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/ref_to_int_match.rs:25:27 + --> $DIR/ref_to_int_match.rs:24:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; | ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes @@ -13,12 +13,6 @@ error: could not evaluate constant pattern LL | 10..=BAR => {}, | ^^^ -error: could not evaluate constant pattern - --> $DIR/ref_to_int_match.rs:7:14 - | -LL | 10..=BAR => {}, - | ^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr index 032ceb246..eaa2d6b27 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr +++ b/tests/ui/consts/const-eval/ref_to_int_match.64bit.stderr @@ -1,5 +1,5 @@ error[E0080]: evaluation of constant value failed - --> $DIR/ref_to_int_match.rs:25:27 + --> $DIR/ref_to_int_match.rs:24:27 | LL | const BAR: Int = unsafe { Foo { r: &42 }.f }; | ^^^^^^^^^^^^^^^^ unable to turn pointer into raw bytes @@ -13,12 +13,6 @@ error: could not evaluate constant pattern LL | 10..=BAR => {}, | ^^^ -error: could not evaluate constant pattern - --> $DIR/ref_to_int_match.rs:7:14 - | -LL | 10..=BAR => {}, - | ^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/ref_to_int_match.rs b/tests/ui/consts/const-eval/ref_to_int_match.rs index 70c6e7d94..a2dabde25 100644 --- a/tests/ui/consts/const-eval/ref_to_int_match.rs +++ b/tests/ui/consts/const-eval/ref_to_int_match.rs @@ -5,7 +5,6 @@ fn main() { match n { 0..=10 => {}, 10..=BAR => {}, //~ ERROR could not evaluate constant pattern - //~| ERROR could not evaluate constant pattern _ => {}, } } diff --git a/tests/ui/consts/const-eval/transmute-size-mismatch.rs b/tests/ui/consts/const-eval/transmute-size-mismatch.rs new file mode 100644 index 000000000..2410baea2 --- /dev/null +++ b/tests/ui/consts/const-eval/transmute-size-mismatch.rs @@ -0,0 +1,24 @@ +#![feature(core_intrinsics)] +#![feature(custom_mir)] + +// These cases are statically rejected by `mem::transmute`, so we need custom +// MIR to be able to get to constant evaluation. +use std::intrinsics::mir::*; + +#[custom_mir(dialect = "runtime", phase = "initial")] +const unsafe fn mir_transmute<T, U>(x: T) -> U { + mir!{ + { + RET = CastTransmute(x); + //~^ ERROR evaluation of constant value failed + //~| ERROR evaluation of constant value failed + Return() + } + } +} + +const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; + +const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; + +fn main() {} diff --git a/tests/ui/consts/const-eval/transmute-size-mismatch.stderr b/tests/ui/consts/const-eval/transmute-size-mismatch.stderr new file mode 100644 index 000000000..e051491d3 --- /dev/null +++ b/tests/ui/consts/const-eval/transmute-size-mismatch.stderr @@ -0,0 +1,37 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/transmute-size-mismatch.rs:12:13 + | +LL | RET = CastTransmute(x); + | ^^^^^^^^^^^^^^^^^^^^^^ transmuting from 4-byte type to 2-byte type: `i32` -> `u16` + | +note: inside `mir_transmute::<i32, u16>` + --> $DIR/transmute-size-mismatch.rs:12:13 + | +LL | RET = CastTransmute(x); + | ^^^^^^^^^^^^^^^^^^^^^^ +note: inside `FROM_BIGGER` + --> $DIR/transmute-size-mismatch.rs:20:35 + | +LL | const FROM_BIGGER: u16 = unsafe { mir_transmute(123_i32) }; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0080]: evaluation of constant value failed + --> $DIR/transmute-size-mismatch.rs:12:13 + | +LL | RET = CastTransmute(x); + | ^^^^^^^^^^^^^^^^^^^^^^ transmuting from 2-byte type to 4-byte type: `i16` -> `u32` + | +note: inside `mir_transmute::<i16, u32>` + --> $DIR/transmute-size-mismatch.rs:12:13 + | +LL | RET = CastTransmute(x); + | ^^^^^^^^^^^^^^^^^^^^^^ +note: inside `FROM_SMALLER` + --> $DIR/transmute-size-mismatch.rs:22:36 + | +LL | const FROM_SMALLER: u32 = unsafe { mir_transmute(123_i16) }; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/ub-enum.32bit.stderr b/tests/ui/consts/const-eval/ub-enum.32bit.stderr index 2d86bd88f..3ad1ac974 100644 --- a/tests/ui/consts/const-eval/ub-enum.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-enum.32bit.stderr @@ -108,13 +108,13 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:96:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Ok)>.0.1: encountered a value of uninhabited type Never error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:98:77 | LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Ok)>.0.1: encountered a value of the never type `!` error: aborting due to 13 previous errors diff --git a/tests/ui/consts/const-eval/ub-enum.64bit.stderr b/tests/ui/consts/const-eval/ub-enum.64bit.stderr index a89d7ec5f..a66706d1a 100644 --- a/tests/ui/consts/const-eval/ub-enum.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-enum.64bit.stderr @@ -108,13 +108,13 @@ error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:96:77 | LL | const BAD_UNINHABITED_WITH_DATA1: Result<(i32, Never), (i32, !)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Ok)>.0.1: encountered a value of uninhabited type Never error[E0080]: evaluation of constant value failed --> $DIR/ub-enum.rs:98:77 | LL | const BAD_UNINHABITED_WITH_DATA2: Result<(i32, !), (i32, Never)> = unsafe { mem::transmute(0u64) }; - | ^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type + | ^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .<enum-variant(Ok)>.0.1: encountered a value of the never type `!` error: aborting due to 13 previous errors diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index 6bd367b64..080568b51 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -148,11 +148,11 @@ LL | const DATA_FN_PTR: fn() = unsafe { mem::transmute(&13) }; HEX_DUMP } -error: accessing memory with alignment 1, but alignment 4 is required +error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #68585 <https://github.com/rust-lang/rust/issues/104616> + = note: accessing memory with alignment 1, but alignment 4 is required + | note: inside `std::ptr::read::<u32>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL note: inside `ptr::const_ptr::<impl *const u32>::read` @@ -162,25 +162,7 @@ note: inside `UNALIGNED_READ` | LL | ptr.read(); | ^^^^^^^^^^ - = note: `#[deny(invalid_alignment)]` on by default error: aborting due to 15 previous errors For more information about this error, try `rustc --explain E0080`. -Future incompatibility report: Future breakage diagnostic: -error: accessing memory with alignment 1, but alignment 4 is required - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #68585 <https://github.com/rust-lang/rust/issues/104616> -note: inside `std::ptr::read::<u32>` - --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -note: inside `ptr::const_ptr::<impl *const u32>::read` - --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL -note: inside `UNALIGNED_READ` - --> $DIR/ub-ref-ptr.rs:67:5 - | -LL | ptr.read(); - | ^^^^^^^^^^ - = note: `#[deny(invalid_alignment)]` on by default - diff --git a/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs b/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs new file mode 100644 index 000000000..d9a74b4f3 --- /dev/null +++ b/tests/ui/consts/const-eval/ub-slice-get-unchecked.rs @@ -0,0 +1,9 @@ +#![feature(const_slice_index)] + +const A: [(); 5] = [(), (), (), (), ()]; + +// Since the indexing is on a ZST, the addresses are all fine, +// but we should still catch the bad range. +const B: &[()] = unsafe { A.get_unchecked(3..1) }; + +fn main() {} diff --git a/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr new file mode 100644 index 000000000..775e475df --- /dev/null +++ b/tests/ui/consts/const-eval/ub-slice-get-unchecked.stderr @@ -0,0 +1,18 @@ +error[E0080]: evaluation of constant value failed + --> $SRC_DIR/core/src/slice/index.rs:LL:COL + | + = note: overflow executing `unchecked_sub` + | +note: inside `<std::ops::Range<usize> as SliceIndex<[()]>>::get_unchecked` + --> $SRC_DIR/core/src/slice/index.rs:LL:COL +note: inside `core::slice::<impl [()]>::get_unchecked::<std::ops::Range<usize>>` + --> $SRC_DIR/core/src/slice/mod.rs:LL:COL +note: inside `B` + --> $DIR/ub-slice-get-unchecked.rs:7:27 + | +LL | const B: &[()] = unsafe { A.get_unchecked(3..1) }; + | ^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-eval/ub-uninhabit.rs b/tests/ui/consts/const-eval/ub-uninhabit.rs index 4c4ef216d..10edae437 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.rs +++ b/tests/ui/consts/const-eval/ub-uninhabit.rs @@ -14,12 +14,12 @@ union MaybeUninit<T: Copy> { } const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR evaluation of constant value failed const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; //~^ ERROR it is undefined behavior to use this value const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR evaluation of constant value failed fn main() {} diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr index 0ae376d03..733975fc0 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.stderr +++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr @@ -1,11 +1,8 @@ -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:16:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-uninhabit.rs:16:35 | LL | const BAD_BAD_BAD: Bar = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Bar - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Bar error[E0080]: it is undefined behavior to use this value --> $DIR/ub-uninhabit.rs:19:1 @@ -18,14 +15,11 @@ LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; HEX_DUMP } -error[E0080]: it is undefined behavior to use this value - --> $DIR/ub-uninhabit.rs:22:1 +error[E0080]: evaluation of constant value failed + --> $DIR/ub-uninhabit.rs:22:42 | LL | const BAD_BAD_ARRAY: [Bar; 1] = unsafe { MaybeUninit { uninit: () }.init }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type Bar - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0]: encountered a value of uninhabited type Bar error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr index 69fb1a59d..74bc6317c 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.32bit.stderr @@ -11,7 +11,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:4:14 | LL | unsafe { std::mem::transmute(()) } - | ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of the never type `!` | note: inside `foo` --> $DIR/validate_uninhabited_zsts.rs:4:14 @@ -24,14 +24,11 @@ note: inside `FOO` LL | const FOO: [empty::Empty; 3] = [foo(); 3]; | ^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/validate_uninhabited_zsts.rs:21:1 +error[E0080]: evaluation of constant value failed + --> $DIR/validate_uninhabited_zsts.rs:21:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0].0: encountered a value of uninhabited type empty::Void - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 0, align: 1) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type empty::Void warning: the type `empty::Empty` does not permit zero-initialization --> $DIR/validate_uninhabited_zsts.rs:21:42 diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr b/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr index 69fb1a59d..74bc6317c 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.64bit.stderr @@ -11,7 +11,7 @@ error[E0080]: evaluation of constant value failed --> $DIR/validate_uninhabited_zsts.rs:4:14 | LL | unsafe { std::mem::transmute(()) } - | ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of the never type `!` | note: inside `foo` --> $DIR/validate_uninhabited_zsts.rs:4:14 @@ -24,14 +24,11 @@ note: inside `FOO` LL | const FOO: [empty::Empty; 3] = [foo(); 3]; | ^^^^^ -error[E0080]: it is undefined behavior to use this value - --> $DIR/validate_uninhabited_zsts.rs:21:1 +error[E0080]: evaluation of constant value failed + --> $DIR/validate_uninhabited_zsts.rs:21:42 | LL | const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at [0].0: encountered a value of uninhabited type empty::Void - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: 0, align: 1) {} + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value at .0: encountered a value of uninhabited type empty::Void warning: the type `empty::Empty` does not permit zero-initialization --> $DIR/validate_uninhabited_zsts.rs:21:42 diff --git a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs index c0b326215..b6783175d 100644 --- a/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs +++ b/tests/ui/consts/const-eval/validate_uninhabited_zsts.rs @@ -19,7 +19,7 @@ pub mod empty { const FOO: [empty::Empty; 3] = [foo(); 3]; const BAR: [empty::Empty; 3] = [unsafe { std::mem::transmute(()) }; 3]; -//~^ ERROR it is undefined behavior to use this value +//~^ ERROR evaluation of constant value failed //~| WARN the type `empty::Empty` does not permit zero-initialization fn main() { diff --git a/tests/ui/consts/const-fn-error.rs b/tests/ui/consts/const-fn-error.rs index 50b7ce1f8..dabbd58db 100644 --- a/tests/ui/consts/const-fn-error.rs +++ b/tests/ui/consts/const-fn-error.rs @@ -7,6 +7,7 @@ const fn f(x: usize) -> usize { //~| ERROR `for` is not allowed in a `const fn` //~| ERROR mutable references are not allowed in constant functions //~| ERROR cannot call non-const fn + //~| ERROR the trait bound sum += i; } sum diff --git a/tests/ui/consts/const-fn-error.stderr b/tests/ui/consts/const-fn-error.stderr index f735b3d53..73d235d6a 100644 --- a/tests/ui/consts/const-fn-error.stderr +++ b/tests/ui/consts/const-fn-error.stderr @@ -5,7 +5,7 @@ LL | / for i in 0..x { LL | | LL | | LL | | -LL | | +... | LL | | sum += i; LL | | } | |_____^ @@ -33,6 +33,19 @@ LL | for i in 0..x { = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable +error[E0277]: the trait bound `std::ops::Range<usize>: Iterator` is not satisfied + --> $DIR/const-fn-error.rs:5:14 + | +LL | for i in 0..x { + | ^^^^ `std::ops::Range<usize>` is not an iterator + | + = help: the trait `~const Iterator` is not implemented for `std::ops::Range<usize>` +note: the trait `Iterator` is implemented for `std::ops::Range<usize>`, but that implementation is not `const` + --> $DIR/const-fn-error.rs:5:14 + | +LL | for i in 0..x { + | ^^^^ + error[E0015]: cannot call non-const fn `<std::ops::Range<usize> as Iterator>::next` in constant functions --> $DIR/const-fn-error.rs:5:14 | @@ -42,7 +55,7 @@ LL | for i in 0..x { = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors -Some errors have detailed explanations: E0015, E0658. +Some errors have detailed explanations: E0015, E0277, E0658. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-for.rs b/tests/ui/consts/const-for.rs index 8db248535..ff9c977f7 100644 --- a/tests/ui/consts/const-for.rs +++ b/tests/ui/consts/const-for.rs @@ -5,6 +5,7 @@ const _: () = { for _ in 0..5 {} //~^ error: cannot call //~| error: cannot convert + //~| error: the trait bound }; fn main() {} diff --git a/tests/ui/consts/const-for.stderr b/tests/ui/consts/const-for.stderr index 3fb9787c0..64f2f603b 100644 --- a/tests/ui/consts/const-for.stderr +++ b/tests/ui/consts/const-for.stderr @@ -9,6 +9,19 @@ note: impl defined here, but it is not `const` = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable +error[E0277]: the trait bound `std::ops::Range<i32>: Iterator` is not satisfied + --> $DIR/const-for.rs:5:14 + | +LL | for _ in 0..5 {} + | ^^^^ `std::ops::Range<i32>` is not an iterator + | + = help: the trait `~const Iterator` is not implemented for `std::ops::Range<i32>` +note: the trait `Iterator` is implemented for `std::ops::Range<i32>`, but that implementation is not `const` + --> $DIR/const-for.rs:5:14 + | +LL | for _ in 0..5 {} + | ^^^^ + error[E0015]: cannot call non-const fn `<std::ops::Range<i32> as Iterator>::next` in constants --> $DIR/const-for.rs:5:14 | @@ -18,6 +31,7 @@ LL | for _ in 0..5 {} = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0015`. +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/const-match-check.eval1.stderr b/tests/ui/consts/const-match-check.eval1.stderr index 08fcd1dea..27ff5d4cd 100644 --- a/tests/ui/consts/const-match-check.eval1.stderr +++ b/tests/ui/consts/const-match-check.eval1.stderr @@ -9,8 +9,8 @@ LL | A = { let 0 = 0; 0 }, = note: the matched value is of type `i32` help: you might want to use `if let` to ignore the variants that aren't matched | -LL | A = { if let 0 = 0 { todo!() } 0 }, - | ++ ~~~~~~~~~~~ +LL | A = { if let 0 = 0 { todo!() }; 0 }, + | ++ +++++++++++ help: alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits | LL | A = { let _0 = 0; 0 }, diff --git a/tests/ui/consts/const-match-check.eval2.stderr b/tests/ui/consts/const-match-check.eval2.stderr index 5d86ca4bf..0c74a7b3d 100644 --- a/tests/ui/consts/const-match-check.eval2.stderr +++ b/tests/ui/consts/const-match-check.eval2.stderr @@ -9,8 +9,8 @@ LL | let x: [i32; { let 0 = 0; 0 }] = []; = note: the matched value is of type `i32` help: you might want to use `if let` to ignore the variants that aren't matched | -LL | let x: [i32; { if let 0 = 0 { todo!() } 0 }] = []; - | ++ ~~~~~~~~~~~ +LL | let x: [i32; { if let 0 = 0 { todo!() }; 0 }] = []; + | ++ +++++++++++ help: alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits | LL | let x: [i32; { let _0 = 0; 0 }] = []; diff --git a/tests/ui/consts/const-match-check.matchck.stderr b/tests/ui/consts/const-match-check.matchck.stderr index c8f66bb0f..bcca4c2a6 100644 --- a/tests/ui/consts/const-match-check.matchck.stderr +++ b/tests/ui/consts/const-match-check.matchck.stderr @@ -9,8 +9,8 @@ LL | const X: i32 = { let 0 = 0; 0 }; = note: the matched value is of type `i32` help: you might want to use `if let` to ignore the variants that aren't matched | -LL | const X: i32 = { if let 0 = 0 { todo!() } 0 }; - | ++ ~~~~~~~~~~~ +LL | const X: i32 = { if let 0 = 0 { todo!() }; 0 }; + | ++ +++++++++++ help: alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits | LL | const X: i32 = { let _0 = 0; 0 }; @@ -27,8 +27,8 @@ LL | static Y: i32 = { let 0 = 0; 0 }; = note: the matched value is of type `i32` help: you might want to use `if let` to ignore the variants that aren't matched | -LL | static Y: i32 = { if let 0 = 0 { todo!() } 0 }; - | ++ ~~~~~~~~~~~ +LL | static Y: i32 = { if let 0 = 0 { todo!() }; 0 }; + | ++ +++++++++++ help: alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits | LL | static Y: i32 = { let _0 = 0; 0 }; @@ -45,8 +45,8 @@ LL | const X: i32 = { let 0 = 0; 0 }; = note: the matched value is of type `i32` help: you might want to use `if let` to ignore the variants that aren't matched | -LL | const X: i32 = { if let 0 = 0 { todo!() } 0 }; - | ++ ~~~~~~~~~~~ +LL | const X: i32 = { if let 0 = 0 { todo!() }; 0 }; + | ++ +++++++++++ help: alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits | LL | const X: i32 = { let _0 = 0; 0 }; @@ -63,8 +63,8 @@ LL | const X: i32 = { let 0 = 0; 0 }; = note: the matched value is of type `i32` help: you might want to use `if let` to ignore the variants that aren't matched | -LL | const X: i32 = { if let 0 = 0 { todo!() } 0 }; - | ++ ~~~~~~~~~~~ +LL | const X: i32 = { if let 0 = 0 { todo!() }; 0 }; + | ++ +++++++++++ help: alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits | LL | const X: i32 = { let _0 = 0; 0 }; diff --git a/tests/ui/consts/const-pattern-irrefutable.stderr b/tests/ui/consts/const-pattern-irrefutable.stderr index c156ea161..2aed68bdd 100644 --- a/tests/ui/consts/const-pattern-irrefutable.stderr +++ b/tests/ui/consts/const-pattern-irrefutable.stderr @@ -1,9 +1,6 @@ error[E0005]: refutable pattern in local binding --> $DIR/const-pattern-irrefutable.rs:12:9 | -LL | const a: u8 = 2; - | ----------- constant defined here -... LL | let a = 4; | ^ | | @@ -11,14 +8,13 @@ LL | let a = 4; | missing patterns are not covered because `a` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `a_var` | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u8` error[E0005]: refutable pattern in local binding --> $DIR/const-pattern-irrefutable.rs:17:9 | -LL | pub const b: u8 = 2; - | --------------- constant defined here -... LL | let c = 4; | ^ | | @@ -26,14 +22,13 @@ LL | let c = 4; | missing patterns are not covered because `c` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `c_var` | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u8` error[E0005]: refutable pattern in local binding --> $DIR/const-pattern-irrefutable.rs:22:9 | -LL | pub const d: u8 = 2; - | --------------- constant defined here -... LL | let d = 4; | ^ | | @@ -41,6 +36,8 @@ LL | let d = 4; | missing patterns are not covered because `d` is interpreted as a constant pattern, not a new variable | help: introduce a variable instead: `d_var` | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `u8` error: aborting due to 3 previous errors diff --git a/tests/ui/consts/const_in_pattern/cross-crate-fail.stderr b/tests/ui/consts/const_in_pattern/cross-crate-fail.stderr index a8066a88c..2f6786999 100644 --- a/tests/ui/consts/const_in_pattern/cross-crate-fail.stderr +++ b/tests/ui/consts/const_in_pattern/cross-crate-fail.stderr @@ -3,12 +3,18 @@ error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be ann | LL | consts::SOME => panic!(), | ^^^^^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `CustomEq` in a pattern, `CustomEq` must be annotated with `#[derive(PartialEq, Eq)]` --> $DIR/cross-crate-fail.rs:20:9 | LL | <Defaulted as consts::AssocConst>::SOME => panic!(), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: aborting due to 2 previous errors diff --git a/tests/ui/consts/const_in_pattern/custom-eq-branch-warn.rs b/tests/ui/consts/const_in_pattern/custom-eq-branch-warn.rs index 856d20417..41de5e7b4 100644 --- a/tests/ui/consts/const_in_pattern/custom-eq-branch-warn.rs +++ b/tests/ui/consts/const_in_pattern/custom-eq-branch-warn.rs @@ -28,6 +28,8 @@ fn main() { match Foo::Qux(CustomEq) { BAR_BAZ => panic!(), //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` + //~| NOTE the traits must be derived + //~| NOTE StructuralEq.html for details //~| WARN this was previously accepted //~| NOTE see issue #73448 //~| NOTE `#[warn(nontrivial_structural_match)]` on by default diff --git a/tests/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr b/tests/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr index 223482722..3f19c67d2 100644 --- a/tests/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr +++ b/tests/ui/consts/const_in_pattern/custom-eq-branch-warn.stderr @@ -6,6 +6,8 @@ LL | BAR_BAZ => panic!(), | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #73448 <https://github.com/rust-lang/rust/issues/73448> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details = note: `#[warn(nontrivial_structural_match)]` on by default warning: 1 warning emitted diff --git a/tests/ui/consts/const_in_pattern/incomplete-slice.stderr b/tests/ui/consts/const_in_pattern/incomplete-slice.stderr index ddc576ced..be144a87b 100644 --- a/tests/ui/consts/const_in_pattern/incomplete-slice.stderr +++ b/tests/ui/consts/const_in_pattern/incomplete-slice.stderr @@ -6,6 +6,8 @@ LL | E_SL => {} | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details = note: `#[warn(indirect_structural_match)]` on by default error[E0004]: non-exhaustive patterns: `&_` not covered @@ -17,7 +19,7 @@ LL | match &[][..] { = note: the matched value is of type `&[E]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ E_SL => {} +LL ~ E_SL => {}, LL + &_ => todo!() | diff --git a/tests/ui/consts/const_in_pattern/issue-78057.stderr b/tests/ui/consts/const_in_pattern/issue-78057.stderr index 35619594f..df155bdb6 100644 --- a/tests/ui/consts/const_in_pattern/issue-78057.stderr +++ b/tests/ui/consts/const_in_pattern/issue-78057.stderr @@ -3,6 +3,9 @@ error: to use a constant of type `Opaque` in a pattern, `Opaque` must be annotat | LL | FOO => {}, | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: unreachable pattern --> $DIR/issue-78057.rs:14:9 diff --git a/tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr b/tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr index e505dad69..cced6af49 100644 --- a/tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr +++ b/tests/ui/consts/const_in_pattern/no-eq-branch-fail.stderr @@ -3,6 +3,9 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated wit | LL | BAR_BAZ => panic!(), | ^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: aborting due to previous error diff --git a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr index 95cfa4a9e..958bf373c 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr +++ b/tests/ui/consts/const_in_pattern/reject_non_partial_eq.stderr @@ -3,6 +3,9 @@ error: to use a constant of type `NoPartialEq` in a pattern, `NoPartialEq` must | LL | NO_PARTIAL_EQ_NONE => println!("NO_PARTIAL_EQ_NONE"), | ^^^^^^^^^^^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: aborting due to previous error diff --git a/tests/ui/consts/const_in_pattern/reject_non_structural.rs b/tests/ui/consts/const_in_pattern/reject_non_structural.rs index 75fde0d92..dc6b9a331 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_structural.rs +++ b/tests/ui/consts/const_in_pattern/reject_non_structural.rs @@ -39,45 +39,67 @@ fn main() { const ENUM: Derive<NoDerive> = Derive::Some(NoDerive); match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + //~| NOTE the traits must be derived + //~| NOTE StructuralEq.html for details const FIELD: OND = TrivialEq(Some(NoDerive)).0; match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + //~| NOTE the traits must be derived + //~| NOTE StructuralEq.html for details const NO_DERIVE_SOME: OND = Some(NoDerive); const INDIRECT: OND = NO_DERIVE_SOME; match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + //~| NOTE the traits must be derived + //~| NOTE StructuralEq.html for details const TUPLE: (OND, OND) = (None, Some(NoDerive)); match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + //~| NOTE the traits must be derived + //~| NOTE StructuralEq.html for details const TYPE_ASCRIPTION: OND = type_ascribe!(Some(NoDerive), OND); match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + //~| NOTE the traits must be derived + //~| NOTE StructuralEq.html for details const ARRAY: [OND; 2] = [None, Some(NoDerive)]; match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + //~| NOTE the traits must be derived + //~| NOTE StructuralEq.html for details const REPEAT: [OND; 2] = [Some(NoDerive); 2]; match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + //~| NOTE the traits must be derived + //~| NOTE StructuralEq.html for details //~| ERROR must be annotated with `#[derive(PartialEq, Eq)]` + //~| NOTE the traits must be derived + //~| NOTE StructuralEq.html for details trait Trait: Sized { const ASSOC: Option<Self>; } impl Trait for NoDerive { const ASSOC: Option<NoDerive> = Some(NoDerive); } match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + //~| NOTE the traits must be derived + //~| NOTE StructuralEq.html for details const BLOCK: OND = { NoDerive; Some(NoDerive) }; match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), }; //~^ ERROR must be annotated with `#[derive(PartialEq, Eq)]` + //~| NOTE the traits must be derived + //~| NOTE StructuralEq.html for details const ADDR_OF: &OND = &Some(NoDerive); match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), }; //~^ WARN must be annotated with `#[derive(PartialEq, Eq)]` + //~| NOTE the traits must be derived + //~| NOTE StructuralEq.html for details //~| WARN previously accepted by the compiler but is being phased out //~| NOTE for more information, see issue #62411 } diff --git a/tests/ui/consts/const_in_pattern/reject_non_structural.stderr b/tests/ui/consts/const_in_pattern/reject_non_structural.stderr index 660198349..b6e439f21 100644 --- a/tests/ui/consts/const_in_pattern/reject_non_structural.stderr +++ b/tests/ui/consts/const_in_pattern/reject_non_structural.stderr @@ -3,69 +3,101 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be ann | LL | match Derive::Some(NoDerive) { ENUM => dbg!(ENUM), _ => panic!("whoops"), }; | ^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/reject_non_structural.rs:44:28 + --> $DIR/reject_non_structural.rs:46:28 | LL | match Some(NoDerive) { FIELD => dbg!(FIELD), _ => panic!("whoops"), }; | ^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/reject_non_structural.rs:49:27 + --> $DIR/reject_non_structural.rs:53:27 | LL | match Some(NoDerive) {INDIRECT => dbg!(INDIRECT), _ => panic!("whoops"), }; | ^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/reject_non_structural.rs:53:36 + --> $DIR/reject_non_structural.rs:59:36 | LL | match (None, Some(NoDerive)) { TUPLE => dbg!(TUPLE), _ => panic!("whoops"), }; | ^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/reject_non_structural.rs:57:28 + --> $DIR/reject_non_structural.rs:65:28 | LL | match Some(NoDerive) { TYPE_ASCRIPTION => dbg!(TYPE_ASCRIPTION), _ => panic!("whoops"), }; | ^^^^^^^^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/reject_non_structural.rs:61:36 + --> $DIR/reject_non_structural.rs:71:36 | LL | match [None, Some(NoDerive)] { ARRAY => dbg!(ARRAY), _ => panic!("whoops"), }; | ^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/reject_non_structural.rs:65:33 + --> $DIR/reject_non_structural.rs:77:33 | LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), }; | ^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/reject_non_structural.rs:65:33 + --> $DIR/reject_non_structural.rs:77:33 | LL | match [Some(NoDerive); 2] { REPEAT => dbg!(REPEAT), _ => panic!("whoops"), }; | ^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/reject_non_structural.rs:71:28 + --> $DIR/reject_non_structural.rs:87:28 | LL | match Some(NoDerive) { NoDerive::ASSOC => dbg!(NoDerive::ASSOC), _ => panic!("whoops"), }; | ^^^^^^^^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/reject_non_structural.rs:75:28 + --> $DIR/reject_non_structural.rs:93:28 | LL | match Some(NoDerive) { BLOCK => dbg!(BLOCK), _ => panic!("whoops"), }; | ^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details warning: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/reject_non_structural.rs:79:29 + --> $DIR/reject_non_structural.rs:99:29 | LL | match &Some(NoDerive) { ADDR_OF => dbg!(ADDR_OF), _ => panic!("whoops"), }; | ^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details note: the lint level is defined here --> $DIR/reject_non_structural.rs:12:9 | diff --git a/tests/ui/consts/const_in_pattern/warn_corner_cases.stderr b/tests/ui/consts/const_in_pattern/warn_corner_cases.stderr index e957a43a1..8c01d2f65 100644 --- a/tests/ui/consts/const_in_pattern/warn_corner_cases.stderr +++ b/tests/ui/consts/const_in_pattern/warn_corner_cases.stderr @@ -6,6 +6,8 @@ LL | match None { Some(_) => panic!("whoops"), INDEX => dbg!(INDEX), }; | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #73448 <https://github.com/rust-lang/rust/issues/73448> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details = note: `#[warn(nontrivial_structural_match)]` on by default warning: to use a constant of type `NoDerive` in a pattern, the constant's initializer must be trivial or `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` @@ -16,6 +18,8 @@ LL | match None { Some(_) => panic!("whoops"), CALL => dbg!(CALL), }; | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #73448 <https://github.com/rust-lang/rust/issues/73448> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details warning: to use a constant of type `NoDerive` in a pattern, the constant's initializer must be trivial or `NoDerive` must be annotated with `#[derive(PartialEq, Eq)]` --> $DIR/warn_corner_cases.rs:38:47 @@ -25,6 +29,8 @@ LL | match None { Some(_) => panic!("whoops"), METHOD_CALL => dbg!(METHOD_CA | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #73448 <https://github.com/rust-lang/rust/issues/73448> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details warning: 3 warnings emitted diff --git a/tests/ui/consts/invalid-inline-const-in-match-arm.rs b/tests/ui/consts/invalid-inline-const-in-match-arm.rs index 4d2d8fb13..17acb2d9d 100644 --- a/tests/ui/consts/invalid-inline-const-in-match-arm.rs +++ b/tests/ui/consts/invalid-inline-const-in-match-arm.rs @@ -5,5 +5,6 @@ fn main() { match () { const { (|| {})() } => {} //~^ ERROR cannot call non-const closure in constants + //~| ERROR the trait bound } } diff --git a/tests/ui/consts/invalid-inline-const-in-match-arm.stderr b/tests/ui/consts/invalid-inline-const-in-match-arm.stderr index 257ecd7f3..ac174849f 100644 --- a/tests/ui/consts/invalid-inline-const-in-match-arm.stderr +++ b/tests/ui/consts/invalid-inline-const-in-match-arm.stderr @@ -1,3 +1,17 @@ +error[E0277]: the trait bound `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]: Fn<()>` is not satisfied + --> $DIR/invalid-inline-const-in-match-arm.rs:6:17 + | +LL | const { (|| {})() } => {} + | ^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]` + | + = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]` +note: the trait `Fn<()>` is implemented for `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]`, but that implementation is not `const` + --> $DIR/invalid-inline-const-in-match-arm.rs:6:17 + | +LL | const { (|| {})() } => {} + | ^^^^^^^^^ + = note: wrap the `[closure@$DIR/invalid-inline-const-in-match-arm.rs:6:18: 6:20]` in a closure with no arguments: `|| { /* code */ }` + error[E0015]: cannot call non-const closure in constants --> $DIR/invalid-inline-const-in-match-arm.rs:6:17 | @@ -8,6 +22,7 @@ LL | const { (|| {})() } => {} = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0015`. +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-28113.rs b/tests/ui/consts/issue-28113.rs index f8131c9f3..e45c009d6 100644 --- a/tests/ui/consts/issue-28113.rs +++ b/tests/ui/consts/issue-28113.rs @@ -3,6 +3,7 @@ const X: u8 = || -> u8 { 5 }() //~^ ERROR cannot call non-const closure + //~| ERROR the trait bound ; fn main() {} diff --git a/tests/ui/consts/issue-28113.stderr b/tests/ui/consts/issue-28113.stderr index 1294cc99b..e177a3585 100644 --- a/tests/ui/consts/issue-28113.stderr +++ b/tests/ui/consts/issue-28113.stderr @@ -1,3 +1,17 @@ +error[E0277]: the trait bound `[closure@$DIR/issue-28113.rs:4:5: 4:13]: Fn<()>` is not satisfied + --> $DIR/issue-28113.rs:4:5 + | +LL | || -> u8 { 5 }() + | ^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-28113.rs:4:5: 4:13]` + | + = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-28113.rs:4:5: 4:13]` +note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-28113.rs:4:5: 4:13]`, but that implementation is not `const` + --> $DIR/issue-28113.rs:4:5 + | +LL | || -> u8 { 5 }() + | ^^^^^^^^^^^^^^^^ + = note: wrap the `[closure@$DIR/issue-28113.rs:4:5: 4:13]` in a closure with no arguments: `|| { /* code */ }` + error[E0015]: cannot call non-const closure in constants --> $DIR/issue-28113.rs:4:5 | @@ -8,6 +22,7 @@ LL | || -> u8 { 5 }() = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0015`. +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-43105.rs b/tests/ui/consts/issue-43105.rs index cac12b909..20b78d642 100644 --- a/tests/ui/consts/issue-43105.rs +++ b/tests/ui/consts/issue-43105.rs @@ -7,7 +7,6 @@ fn main() { match 1 { NUM => unimplemented!(), //~^ ERROR could not evaluate constant pattern - //~| ERROR could not evaluate constant pattern _ => unimplemented!(), } } diff --git a/tests/ui/consts/issue-43105.stderr b/tests/ui/consts/issue-43105.stderr index 2d1174af7..856a8f0da 100644 --- a/tests/ui/consts/issue-43105.stderr +++ b/tests/ui/consts/issue-43105.stderr @@ -12,12 +12,6 @@ error: could not evaluate constant pattern LL | NUM => unimplemented!(), | ^^^ -error: could not evaluate constant pattern - --> $DIR/issue-43105.rs:8:9 - | -LL | NUM => unimplemented!(), - | ^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-56164.rs b/tests/ui/consts/issue-56164.rs index 22c257d0b..00875c4b5 100644 --- a/tests/ui/consts/issue-56164.rs +++ b/tests/ui/consts/issue-56164.rs @@ -1,5 +1,6 @@ const fn foo() { (||{})() } //~^ ERROR cannot call non-const closure +//~| ERROR the trait bound const fn bad(input: fn()) { input() diff --git a/tests/ui/consts/issue-56164.stderr b/tests/ui/consts/issue-56164.stderr index 845b23d5d..003f84744 100644 --- a/tests/ui/consts/issue-56164.stderr +++ b/tests/ui/consts/issue-56164.stderr @@ -1,3 +1,17 @@ +error[E0277]: the trait bound `[closure@$DIR/issue-56164.rs:1:19: 1:21]: Fn<()>` is not satisfied + --> $DIR/issue-56164.rs:1:18 + | +LL | const fn foo() { (||{})() } + | ^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-56164.rs:1:19: 1:21]` + | + = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-56164.rs:1:19: 1:21]` +note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-56164.rs:1:19: 1:21]`, but that implementation is not `const` + --> $DIR/issue-56164.rs:1:18 + | +LL | const fn foo() { (||{})() } + | ^^^^^^^^ + = note: wrap the `[closure@$DIR/issue-56164.rs:1:19: 1:21]` in a closure with no arguments: `|| { /* code */ }` + error[E0015]: cannot call non-const closure in constant functions --> $DIR/issue-56164.rs:1:18 | @@ -9,7 +23,7 @@ LL | const fn foo() { (||{})() } = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable error: function pointer calls are not allowed in constant functions - --> $DIR/issue-56164.rs:5:5 + --> $DIR/issue-56164.rs:6:5 | LL | input() | ^^^^^^^ @@ -26,6 +40,7 @@ note: erroneous constant used LL | const fn foo() { (||{})() } | ^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0015`. +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-64506.rs b/tests/ui/consts/issue-64506.rs index db3e85a7b..9275a8a07 100644 --- a/tests/ui/consts/issue-64506.rs +++ b/tests/ui/consts/issue-64506.rs @@ -1,4 +1,4 @@ -// check-pass +// check-fail #[derive(Copy, Clone)] pub struct ChildStdin { @@ -14,6 +14,7 @@ const FOO: () = { b: (), } let x = unsafe { Foo { b: () }.a }; + //~^ ERROR: evaluation of constant value failed let x = &x.inner; }; diff --git a/tests/ui/consts/issue-64506.stderr b/tests/ui/consts/issue-64506.stderr new file mode 100644 index 000000000..31a5b1df8 --- /dev/null +++ b/tests/ui/consts/issue-64506.stderr @@ -0,0 +1,9 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/issue-64506.rs:16:22 + | +LL | let x = unsafe { Foo { b: () }.a }; + | ^^^^^^^^^^^^^^^ constructing invalid value at .inner: encountered a value of uninhabited type AnonPipe + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/issue-68542-closure-in-array-len.rs b/tests/ui/consts/issue-68542-closure-in-array-len.rs index 37958e791..a88e0cc60 100644 --- a/tests/ui/consts/issue-68542-closure-in-array-len.rs +++ b/tests/ui/consts/issue-68542-closure-in-array-len.rs @@ -4,6 +4,7 @@ struct Bug { a: [(); (|| { 0 })()] //~ ERROR cannot call non-const closure + //~^ ERROR the trait bound } fn main() {} diff --git a/tests/ui/consts/issue-68542-closure-in-array-len.stderr b/tests/ui/consts/issue-68542-closure-in-array-len.stderr index d23513ed7..ace62f09d 100644 --- a/tests/ui/consts/issue-68542-closure-in-array-len.stderr +++ b/tests/ui/consts/issue-68542-closure-in-array-len.stderr @@ -1,3 +1,17 @@ +error[E0277]: the trait bound `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]: Fn<()>` is not satisfied + --> $DIR/issue-68542-closure-in-array-len.rs:6:13 + | +LL | a: [(); (|| { 0 })()] + | ^^^^^^^^^^^^ expected an `Fn<()>` closure, found `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` + | + = help: the trait `~const Fn<()>` is not implemented for closure `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` +note: the trait `Fn<()>` is implemented for `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]`, but that implementation is not `const` + --> $DIR/issue-68542-closure-in-array-len.rs:6:13 + | +LL | a: [(); (|| { 0 })()] + | ^^^^^^^^^^^^ + = note: wrap the `[closure@$DIR/issue-68542-closure-in-array-len.rs:6:14: 6:16]` in a closure with no arguments: `|| { /* code */ }` + error[E0015]: cannot call non-const closure in constants --> $DIR/issue-68542-closure-in-array-len.rs:6:13 | @@ -8,6 +22,7 @@ LL | a: [(); (|| { 0 })()] = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0015`. +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-73976-polymorphic.rs b/tests/ui/consts/issue-73976-polymorphic.rs index 787462da9..2c576d1f9 100644 --- a/tests/ui/consts/issue-73976-polymorphic.rs +++ b/tests/ui/consts/issue-73976-polymorphic.rs @@ -19,7 +19,6 @@ impl<T: 'static> GetTypeId<T> { const fn check_type_id<T: 'static>() -> bool { matches!(GetTypeId::<T>::VALUE, GetTypeId::<T>::VALUE) //~^ ERROR constant pattern depends on a generic parameter - //~| ERROR constant pattern depends on a generic parameter } pub struct GetTypeNameLen<T>(T); @@ -31,7 +30,6 @@ impl<T: 'static> GetTypeNameLen<T> { const fn check_type_name_len<T: 'static>() -> bool { matches!(GetTypeNameLen::<T>::VALUE, GetTypeNameLen::<T>::VALUE) //~^ ERROR constant pattern depends on a generic parameter - //~| ERROR constant pattern depends on a generic parameter } fn main() { diff --git a/tests/ui/consts/issue-73976-polymorphic.stderr b/tests/ui/consts/issue-73976-polymorphic.stderr index 442ad23f2..97a5fbc57 100644 --- a/tests/ui/consts/issue-73976-polymorphic.stderr +++ b/tests/ui/consts/issue-73976-polymorphic.stderr @@ -5,22 +5,10 @@ LL | matches!(GetTypeId::<T>::VALUE, GetTypeId::<T>::VALUE) | ^^^^^^^^^^^^^^^^^^^^^ error: constant pattern depends on a generic parameter - --> $DIR/issue-73976-polymorphic.rs:32:42 + --> $DIR/issue-73976-polymorphic.rs:31:42 | LL | matches!(GetTypeNameLen::<T>::VALUE, GetTypeNameLen::<T>::VALUE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: constant pattern depends on a generic parameter - --> $DIR/issue-73976-polymorphic.rs:20:37 - | -LL | matches!(GetTypeId::<T>::VALUE, GetTypeId::<T>::VALUE) - | ^^^^^^^^^^^^^^^^^^^^^ - -error: constant pattern depends on a generic parameter - --> $DIR/issue-73976-polymorphic.rs:32:42 - | -LL | matches!(GetTypeNameLen::<T>::VALUE, GetTypeNameLen::<T>::VALUE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/consts/issue-78655.rs b/tests/ui/consts/issue-78655.rs index 82d2d7c21..cd95ee32c 100644 --- a/tests/ui/consts/issue-78655.rs +++ b/tests/ui/consts/issue-78655.rs @@ -6,5 +6,4 @@ const FOO: *const u32 = { fn main() { let FOO = FOO; //~^ ERROR could not evaluate constant pattern - //~| ERROR could not evaluate constant pattern } diff --git a/tests/ui/consts/issue-78655.stderr b/tests/ui/consts/issue-78655.stderr index 6b83fa0e5..5a38d023d 100644 --- a/tests/ui/consts/issue-78655.stderr +++ b/tests/ui/consts/issue-78655.stderr @@ -17,12 +17,6 @@ error: could not evaluate constant pattern LL | let FOO = FOO; | ^^^ -error: could not evaluate constant pattern - --> $DIR/issue-78655.rs:7:9 - | -LL | let FOO = FOO; - | ^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0381`. diff --git a/tests/ui/consts/issue-79137-toogeneric.rs b/tests/ui/consts/issue-79137-toogeneric.rs index 456035458..a80c9f48d 100644 --- a/tests/ui/consts/issue-79137-toogeneric.rs +++ b/tests/ui/consts/issue-79137-toogeneric.rs @@ -11,7 +11,6 @@ impl<T> GetVariantCount<T> { const fn check_variant_count<T>() -> bool { matches!(GetVariantCount::<T>::VALUE, GetVariantCount::<T>::VALUE) //~^ ERROR constant pattern depends on a generic parameter - //~| ERROR constant pattern depends on a generic parameter } fn main() { diff --git a/tests/ui/consts/issue-79137-toogeneric.stderr b/tests/ui/consts/issue-79137-toogeneric.stderr index 579e6aa09..efe4fd22e 100644 --- a/tests/ui/consts/issue-79137-toogeneric.stderr +++ b/tests/ui/consts/issue-79137-toogeneric.stderr @@ -4,11 +4,5 @@ error: constant pattern depends on a generic parameter LL | matches!(GetVariantCount::<T>::VALUE, GetVariantCount::<T>::VALUE) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: constant pattern depends on a generic parameter - --> $DIR/issue-79137-toogeneric.rs:12:43 - | -LL | matches!(GetVariantCount::<T>::VALUE, GetVariantCount::<T>::VALUE) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 2 previous errors +error: aborting due to previous error diff --git a/tests/ui/consts/issue-miri-1910.stderr b/tests/ui/consts/issue-miri-1910.stderr index 61865b1da..a10eea9de 100644 --- a/tests/ui/consts/issue-miri-1910.stderr +++ b/tests/ui/consts/issue-miri-1910.stderr @@ -1,7 +1,7 @@ error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL | - = note: unable to copy parts of a pointer from memory at ALLOC + = note: unable to turn pointer into raw bytes | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported diff --git a/tests/ui/consts/match_ice.stderr b/tests/ui/consts/match_ice.stderr index 699b4a5e2..342d94ed3 100644 --- a/tests/ui/consts/match_ice.stderr +++ b/tests/ui/consts/match_ice.stderr @@ -3,6 +3,9 @@ error: to use a constant of type `S` in a pattern, `S` must be annotated with `# | LL | C => {} | ^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: aborting due to previous error diff --git a/tests/ui/consts/min_const_fn/min_const_fn_libstd_stability.stderr b/tests/ui/consts/min_const_fn/min_const_fn_libstd_stability.stderr index 778b0e55f..7ec2508ca 100644 --- a/tests/ui/consts/min_const_fn/min_const_fn_libstd_stability.stderr +++ b/tests/ui/consts/min_const_fn/min_const_fn_libstd_stability.stderr @@ -22,11 +22,13 @@ LL | const fn bar3() -> u32 { (5f32 + 6f32) as u32 } | help: if it is not part of the public API, make this function unstably const | -LL | #[rustc_const_unstable(feature = "...", issue = "...")] +LL + #[rustc_const_unstable(feature = "...", issue = "...")] +LL | const fn bar3() -> u32 { (5f32 + 6f32) as u32 } | help: otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks | -LL | #[rustc_allow_const_fn_unstable(const_fn_floating_point_arithmetic)] +LL + #[rustc_allow_const_fn_unstable(const_fn_floating_point_arithmetic)] +LL | const fn bar3() -> u32 { (5f32 + 6f32) as u32 } | error: `foo2_gated` is not yet stable as a const fn diff --git a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs b/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs index a6e1788bb..df20ff446 100644 --- a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs +++ b/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.rs @@ -7,4 +7,7 @@ const unsafe fn bad_const_unsafe_deref_raw(x: *mut usize) -> usize { *x } const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static usize { &*x } //~^ dereferencing raw mutable pointers in constant functions +const unsafe fn bad_const_unsafe_deref_raw_underscore(x: *mut usize) { let _ = *x; } +//~^ dereferencing raw mutable pointers in constant functions + fn main() {} diff --git a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr b/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr index 820b6433f..e68376e7b 100644 --- a/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr +++ b/tests/ui/consts/min_const_fn/min_const_fn_unsafe_bad.stderr @@ -25,6 +25,15 @@ LL | const unsafe fn bad_const_unsafe_deref_raw_ref(x: *mut usize) -> &'static u = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable -error: aborting due to 3 previous errors +error[E0658]: dereferencing raw mutable pointers in constant functions is unstable + --> $DIR/min_const_fn_unsafe_bad.rs:10:80 + | +LL | const unsafe fn bad_const_unsafe_deref_raw_underscore(x: *mut usize) { let _ = *x; } + | ^^ + | + = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information + = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability.stderr b/tests/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability.stderr index 0174cb77f..72c1f175d 100644 --- a/tests/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability.stderr +++ b/tests/ui/consts/min_const_fn/min_const_unsafe_fn_libstd_stability.stderr @@ -22,11 +22,13 @@ LL | const unsafe fn bar3() -> u32 { (5f32 + 6f32) as u32 } | help: if it is not part of the public API, make this function unstably const | -LL | #[rustc_const_unstable(feature = "...", issue = "...")] +LL + #[rustc_const_unstable(feature = "...", issue = "...")] +LL | const unsafe fn bar3() -> u32 { (5f32 + 6f32) as u32 } | help: otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks | -LL | #[rustc_allow_const_fn_unstable(const_fn_floating_point_arithmetic)] +LL + #[rustc_allow_const_fn_unstable(const_fn_floating_point_arithmetic)] +LL | const unsafe fn bar3() -> u32 { (5f32 + 6f32) as u32 } | error: `foo2_gated` is not yet stable as a const fn diff --git a/tests/ui/consts/miri_unleashed/assoc_const.stderr b/tests/ui/consts/miri_unleashed/assoc_const.stderr index e1da43c3a..8e22cb74b 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const.stderr @@ -25,12 +25,6 @@ note: erroneous constant used LL | let y = <String as Bar<Vec<u32>, String>>::F; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: erroneous constant used - --> $DIR/assoc_const.rs:29:13 - | -LL | let y = <String as Bar<Vec<u32>, String>>::F; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - warning: skipping const checks | help: skipping check that does not even have a feature gate diff --git a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr index fc4b18056..ae7b03fc9 100644 --- a/tests/ui/consts/miri_unleashed/assoc_const_2.stderr +++ b/tests/ui/consts/miri_unleashed/assoc_const_2.stderr @@ -16,12 +16,6 @@ note: erroneous constant used LL | let y = <String as Bar<String>>::F; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: erroneous constant used - --> $DIR/assoc_const_2.rs:27:13 - | -LL | let y = <String as Bar<String>>::F; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/miri_unleashed/box.rs b/tests/ui/consts/miri_unleashed/box.rs index c2a260aa1..39cddda2b 100644 --- a/tests/ui/consts/miri_unleashed/box.rs +++ b/tests/ui/consts/miri_unleashed/box.rs @@ -1,12 +1,11 @@ // compile-flags: -Zunleash-the-miri-inside-of-you -#![feature(box_syntax)] use std::mem::ManuallyDrop; fn main() {} static TEST_BAD: &mut i32 = { - &mut *(box 0) + &mut *(Box::new(0)) //~^ ERROR could not evaluate static initializer - //~| NOTE calling non-const function `alloc::alloc::exchange_malloc` + //~| NOTE calling non-const function `Box::<i32>::new` }; diff --git a/tests/ui/consts/miri_unleashed/box.stderr b/tests/ui/consts/miri_unleashed/box.stderr index bc5d4a257..407f5d8cb 100644 --- a/tests/ui/consts/miri_unleashed/box.stderr +++ b/tests/ui/consts/miri_unleashed/box.stderr @@ -1,31 +1,26 @@ error[E0080]: could not evaluate static initializer - --> $DIR/box.rs:9:11 + --> $DIR/box.rs:8:11 | -LL | &mut *(box 0) - | ^^^^^^^ calling non-const function `alloc::alloc::exchange_malloc` +LL | &mut *(Box::new(0)) + | ^^^^^^^^^^^^^ calling non-const function `Box::<i32>::new` warning: skipping const checks | help: skipping check that does not even have a feature gate - --> $DIR/box.rs:9:11 + --> $DIR/box.rs:8:11 | -LL | &mut *(box 0) - | ^^^^^^^ +LL | &mut *(Box::new(0)) + | ^^^^^^^^^^^^^ help: skipping check for `const_mut_refs` feature - --> $DIR/box.rs:9:16 + --> $DIR/box.rs:8:5 | -LL | &mut *(box 0) - | ^ -help: skipping check for `const_mut_refs` feature - --> $DIR/box.rs:9:5 - | -LL | &mut *(box 0) - | ^^^^^^^^^^^^^ +LL | &mut *(Box::new(0)) + | ^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/box.rs:9:5 + --> $DIR/box.rs:8:5 | -LL | &mut *(box 0) - | ^^^^^^^^^^^^^ +LL | &mut *(Box::new(0)) + | ^^^^^^^^^^^^^^^^^^^ error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr index 6df2fe3d0..e3a0d93f0 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.32bit.stderr @@ -27,7 +27,7 @@ LL | const U8_MUT: &u8 = { } error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:43:9 + --> $DIR/const_refers_to_static_cross_crate.rs:42:9 | LL | U8_MUT => true, | ^^^^^^ @@ -39,7 +39,7 @@ LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:54:9 + --> $DIR/const_refers_to_static_cross_crate.rs:52:9 | LL | U8_MUT2 => true, | ^^^^^^^ @@ -51,31 +51,7 @@ LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:62:9 - | -LL | U8_MUT3 => true, - | ^^^^^^^ - -error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:34:9 - | -LL | SLICE_MUT => true, - | ^^^^^^^^^ - -error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:43:9 - | -LL | U8_MUT => true, - | ^^^^^^ - -error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:54:9 - | -LL | U8_MUT2 => true, - | ^^^^^^^ - -error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:62:9 + --> $DIR/const_refers_to_static_cross_crate.rs:59:9 | LL | U8_MUT3 => true, | ^^^^^^^ @@ -133,6 +109,6 @@ help: skipping check that does not even have a feature gate LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 12 previous errors; 1 warning emitted +error: aborting due to 8 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr index 8802f3ada..a323e9a05 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.64bit.stderr @@ -27,7 +27,7 @@ LL | const U8_MUT: &u8 = { } error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:43:9 + --> $DIR/const_refers_to_static_cross_crate.rs:42:9 | LL | U8_MUT => true, | ^^^^^^ @@ -39,7 +39,7 @@ LL | unsafe { &(*static_cross_crate::ZERO_REF)[0] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:54:9 + --> $DIR/const_refers_to_static_cross_crate.rs:52:9 | LL | U8_MUT2 => true, | ^^^^^^^ @@ -51,31 +51,7 @@ LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ constant accesses static error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:62:9 - | -LL | U8_MUT3 => true, - | ^^^^^^^ - -error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:34:9 - | -LL | SLICE_MUT => true, - | ^^^^^^^^^ - -error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:43:9 - | -LL | U8_MUT => true, - | ^^^^^^ - -error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:54:9 - | -LL | U8_MUT2 => true, - | ^^^^^^^ - -error: could not evaluate constant pattern - --> $DIR/const_refers_to_static_cross_crate.rs:62:9 + --> $DIR/const_refers_to_static_cross_crate.rs:59:9 | LL | U8_MUT3 => true, | ^^^^^^^ @@ -133,6 +109,6 @@ help: skipping check that does not even have a feature gate LL | unsafe { match static_cross_crate::OPT_ZERO { Some(ref u) => u, None => panic!() } } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 12 previous errors; 1 warning emitted +error: aborting due to 8 previous errors; 1 warning emitted For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs index bf4f14f4d..bbaa32ddf 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs @@ -33,7 +33,6 @@ pub fn test(x: &[u8; 1]) -> bool { match x { SLICE_MUT => true, //~^ ERROR could not evaluate constant pattern - //~| ERROR could not evaluate constant pattern &[1..] => false, } } @@ -42,7 +41,6 @@ pub fn test2(x: &u8) -> bool { match x { U8_MUT => true, //~^ ERROR could not evaluate constant pattern - //~| ERROR could not evaluate constant pattern &(1..) => false, } } @@ -53,7 +51,6 @@ pub fn test3(x: &u8) -> bool { match x { U8_MUT2 => true, //~^ ERROR could not evaluate constant pattern - //~| ERROR could not evaluate constant pattern &(1..) => false, } } @@ -61,7 +58,6 @@ pub fn test4(x: &u8) -> bool { match x { U8_MUT3 => true, //~^ ERROR could not evaluate constant pattern - //~| ERROR could not evaluate constant pattern &(1..) => false, } } diff --git a/tests/ui/consts/miri_unleashed/tls.stderr b/tests/ui/consts/miri_unleashed/tls.stderr index 7aaeadd04..ec24527d6 100644 --- a/tests/ui/consts/miri_unleashed/tls.stderr +++ b/tests/ui/consts/miri_unleashed/tls.stderr @@ -2,13 +2,13 @@ error[E0080]: could not evaluate static initializer --> $DIR/tls.rs:11:25 | LL | unsafe { let _val = A; } - | ^ cannot access thread local static (DefId(0:4 ~ tls[78b0]::A)) + | ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A)) error[E0080]: could not evaluate static initializer --> $DIR/tls.rs:18:26 | LL | unsafe { let _val = &A; } - | ^ cannot access thread local static (DefId(0:4 ~ tls[78b0]::A)) + | ^ cannot access thread local static (DefId(0:4 ~ tls[ca29]::A)) warning: skipping const checks | diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr index fff472968..6530084a5 100644 --- a/tests/ui/consts/offset_from_ub.stderr +++ b/tests/ui/consts/offset_from_ub.stderr @@ -39,19 +39,19 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:53:14 | LL | unsafe { ptr_offset_from(end_ptr, start_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc18 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc17 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:62:14 | LL | unsafe { ptr_offset_from(start_ptr, end_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc21 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc20 has size 4, so pointer to 10 bytes starting at offset 0 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:70:14 | LL | unsafe { ptr_offset_from(end_ptr, end_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc24 has size 4, so pointer at offset 10 is out-of-bounds + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds offset_from: alloc23 has size 4, so pointer at offset 10 is out-of-bounds error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:79:14 diff --git a/tests/ui/consts/uninhabited-const-issue-61744.stderr b/tests/ui/consts/uninhabited-const-issue-61744.stderr index 3a94e1931..adefbf336 100644 --- a/tests/ui/consts/uninhabited-const-issue-61744.stderr +++ b/tests/ui/consts/uninhabited-const-issue-61744.stderr @@ -657,12 +657,6 @@ note: erroneous constant used LL | dbg!(i32::CONSTANT); | ^^^^^^^^^^^^^ -note: erroneous constant used - --> $DIR/uninhabited-const-issue-61744.rs:18:10 - | -LL | dbg!(i32::CONSTANT); - | ^^^^^^^^^^^^^ - error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr index f6ffcc4b5..e2b2aac05 100644 --- a/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr +++ b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr @@ -1,15 +1,10 @@ error[E0391]: cycle detected when computing the super predicates of `Chromosome` - --> $DIR/cycle-trait-supertrait-direct.rs:3:1 - | -LL | trait Chromosome: Chromosome { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: ...which requires computing the super traits of `Chromosome`... --> $DIR/cycle-trait-supertrait-direct.rs:3:19 | LL | trait Chromosome: Chromosome { | ^^^^^^^^^^ - = note: ...which again requires computing the super predicates of `Chromosome`, completing the cycle + | + = note: ...which immediately requires computing the super predicates of `Chromosome` again note: cycle used when collecting item types in top-level module --> $DIR/cycle-trait-supertrait-direct.rs:3:1 | diff --git a/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr b/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr index 0a2284e0e..c903e1146 100644 --- a/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr +++ b/tests/ui/cycle-trait/cycle-trait-supertrait-indirect.stderr @@ -1,26 +1,16 @@ error[E0391]: cycle detected when computing the super predicates of `B` - --> $DIR/cycle-trait-supertrait-indirect.rs:7:1 - | -LL | trait B: C { - | ^^^^^^^^^^ - | -note: ...which requires computing the super traits of `B`... --> $DIR/cycle-trait-supertrait-indirect.rs:7:10 | LL | trait B: C { | ^ -note: ...which requires computing the super predicates of `C`... - --> $DIR/cycle-trait-supertrait-indirect.rs:11:1 | -LL | trait C: B { } - | ^^^^^^^^^^ -note: ...which requires computing the super traits of `C`... +note: ...which requires computing the super predicates of `C`... --> $DIR/cycle-trait-supertrait-indirect.rs:11:10 | LL | trait C: B { } | ^ = note: ...which again requires computing the super predicates of `B`, completing the cycle -note: cycle used when computing the super traits of `A` +note: cycle used when computing the super predicates of `A` --> $DIR/cycle-trait-supertrait-indirect.rs:4:10 | LL | trait A: B { diff --git a/tests/ui/derived-errors/issue-31997-1.stderr b/tests/ui/derived-errors/issue-31997-1.stderr index 2f4aabf84..a0262f4c1 100644 --- a/tests/ui/derived-errors/issue-31997-1.stderr +++ b/tests/ui/derived-errors/issue-31997-1.stderr @@ -6,7 +6,7 @@ LL | let mut map = HashMap::new(); | help: consider importing this struct | -LL | use std::collections::HashMap; +LL + use std::collections::HashMap; | error: aborting due to previous error diff --git a/tests/ui/derives/derive-assoc-type-not-impl.stderr b/tests/ui/derives/derive-assoc-type-not-impl.stderr index 91b334b41..9f17c76c2 100644 --- a/tests/ui/derives/derive-assoc-type-not-impl.stderr +++ b/tests/ui/derives/derive-assoc-type-not-impl.stderr @@ -23,7 +23,8 @@ LL | #[derive(Clone)] candidate #1: `Clone` help: consider annotating `NotClone` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct NotClone; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Clone-enum-struct-variant.stderr b/tests/ui/derives/derives-span-Clone-enum-struct-variant.stderr index 7326324b0..31ab589cf 100644 --- a/tests/ui/derives/derives-span-Clone-enum-struct-variant.stderr +++ b/tests/ui/derives/derives-span-Clone-enum-struct-variant.stderr @@ -10,7 +10,8 @@ LL | x: Error = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Clone-enum.stderr b/tests/ui/derives/derives-span-Clone-enum.stderr index 229a4f7d9..b5580c02f 100644 --- a/tests/ui/derives/derives-span-Clone-enum.stderr +++ b/tests/ui/derives/derives-span-Clone-enum.stderr @@ -10,7 +10,8 @@ LL | Error = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Clone-struct.stderr b/tests/ui/derives/derives-span-Clone-struct.stderr index 96bad9eda..fbe7e3f84 100644 --- a/tests/ui/derives/derives-span-Clone-struct.stderr +++ b/tests/ui/derives/derives-span-Clone-struct.stderr @@ -10,7 +10,8 @@ LL | x: Error = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Clone-tuple-struct.stderr b/tests/ui/derives/derives-span-Clone-tuple-struct.stderr index b61341e57..639f4d542 100644 --- a/tests/ui/derives/derives-span-Clone-tuple-struct.stderr +++ b/tests/ui/derives/derives-span-Clone-tuple-struct.stderr @@ -10,7 +10,8 @@ LL | Error = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Debug-enum-struct-variant.stderr b/tests/ui/derives/derives-span-Debug-enum-struct-variant.stderr index 58a64a4f5..7ff6851f6 100644 --- a/tests/ui/derives/derives-span-Debug-enum-struct-variant.stderr +++ b/tests/ui/derives/derives-span-Debug-enum-struct-variant.stderr @@ -12,7 +12,8 @@ LL | x: Error = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Debug)]` | -LL | #[derive(Debug)] +LL + #[derive(Debug)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Debug-enum.stderr b/tests/ui/derives/derives-span-Debug-enum.stderr index e9bb5f960..346cbec90 100644 --- a/tests/ui/derives/derives-span-Debug-enum.stderr +++ b/tests/ui/derives/derives-span-Debug-enum.stderr @@ -12,7 +12,8 @@ LL | Error = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Debug)]` | -LL | #[derive(Debug)] +LL + #[derive(Debug)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Debug-struct.stderr b/tests/ui/derives/derives-span-Debug-struct.stderr index 0a117c060..4b39eeb09 100644 --- a/tests/ui/derives/derives-span-Debug-struct.stderr +++ b/tests/ui/derives/derives-span-Debug-struct.stderr @@ -12,7 +12,8 @@ LL | x: Error = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Debug)]` | -LL | #[derive(Debug)] +LL + #[derive(Debug)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Debug-tuple-struct.stderr b/tests/ui/derives/derives-span-Debug-tuple-struct.stderr index f2e90a418..f3043abca 100644 --- a/tests/ui/derives/derives-span-Debug-tuple-struct.stderr +++ b/tests/ui/derives/derives-span-Debug-tuple-struct.stderr @@ -12,7 +12,8 @@ LL | Error = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Debug)]` | -LL | #[derive(Debug)] +LL + #[derive(Debug)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Default-struct.stderr b/tests/ui/derives/derives-span-Default-struct.stderr index d4affd535..4844b6359 100644 --- a/tests/ui/derives/derives-span-Default-struct.stderr +++ b/tests/ui/derives/derives-span-Default-struct.stderr @@ -10,7 +10,8 @@ LL | x: Error = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Default)]` | -LL | #[derive(Default)] +LL + #[derive(Default)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Default-tuple-struct.stderr b/tests/ui/derives/derives-span-Default-tuple-struct.stderr index 129351f59..9cac7f107 100644 --- a/tests/ui/derives/derives-span-Default-tuple-struct.stderr +++ b/tests/ui/derives/derives-span-Default-tuple-struct.stderr @@ -10,7 +10,8 @@ LL | Error = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Default)]` | -LL | #[derive(Default)] +LL + #[derive(Default)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Eq-enum-struct-variant.stderr b/tests/ui/derives/derives-span-Eq-enum-struct-variant.stderr index 2be69a30b..1a9ff9832 100644 --- a/tests/ui/derives/derives-span-Eq-enum-struct-variant.stderr +++ b/tests/ui/derives/derives-span-Eq-enum-struct-variant.stderr @@ -12,7 +12,8 @@ note: required by a bound in `AssertParamIsEq` = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Eq)]` | -LL | #[derive(Eq)] +LL + #[derive(Eq)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Eq-enum.stderr b/tests/ui/derives/derives-span-Eq-enum.stderr index 4f4f821cc..8205657bb 100644 --- a/tests/ui/derives/derives-span-Eq-enum.stderr +++ b/tests/ui/derives/derives-span-Eq-enum.stderr @@ -12,7 +12,8 @@ note: required by a bound in `AssertParamIsEq` = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Eq)]` | -LL | #[derive(Eq)] +LL + #[derive(Eq)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Eq-struct.stderr b/tests/ui/derives/derives-span-Eq-struct.stderr index f15659c3e..af510181d 100644 --- a/tests/ui/derives/derives-span-Eq-struct.stderr +++ b/tests/ui/derives/derives-span-Eq-struct.stderr @@ -12,7 +12,8 @@ note: required by a bound in `AssertParamIsEq` = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Eq)]` | -LL | #[derive(Eq)] +LL + #[derive(Eq)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Eq-tuple-struct.stderr b/tests/ui/derives/derives-span-Eq-tuple-struct.stderr index 4e5659b35..f7c371d7d 100644 --- a/tests/ui/derives/derives-span-Eq-tuple-struct.stderr +++ b/tests/ui/derives/derives-span-Eq-tuple-struct.stderr @@ -12,7 +12,8 @@ note: required by a bound in `AssertParamIsEq` = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Eq)]` | -LL | #[derive(Eq)] +LL + #[derive(Eq)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Hash-enum-struct-variant.stderr b/tests/ui/derives/derives-span-Hash-enum-struct-variant.stderr index fe5e0e96a..311edade0 100644 --- a/tests/ui/derives/derives-span-Hash-enum-struct-variant.stderr +++ b/tests/ui/derives/derives-span-Hash-enum-struct-variant.stderr @@ -10,7 +10,8 @@ LL | x: Error = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Hash)]` | -LL | #[derive(Hash)] +LL + #[derive(Hash)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Hash-enum.stderr b/tests/ui/derives/derives-span-Hash-enum.stderr index 99785b87c..043aa954b 100644 --- a/tests/ui/derives/derives-span-Hash-enum.stderr +++ b/tests/ui/derives/derives-span-Hash-enum.stderr @@ -10,7 +10,8 @@ LL | Error = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Hash)]` | -LL | #[derive(Hash)] +LL + #[derive(Hash)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Hash-struct.stderr b/tests/ui/derives/derives-span-Hash-struct.stderr index 4db83dd13..26d31b661 100644 --- a/tests/ui/derives/derives-span-Hash-struct.stderr +++ b/tests/ui/derives/derives-span-Hash-struct.stderr @@ -10,7 +10,8 @@ LL | x: Error = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Hash)]` | -LL | #[derive(Hash)] +LL + #[derive(Hash)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Hash-tuple-struct.stderr b/tests/ui/derives/derives-span-Hash-tuple-struct.stderr index 8660c97e6..3155a023c 100644 --- a/tests/ui/derives/derives-span-Hash-tuple-struct.stderr +++ b/tests/ui/derives/derives-span-Hash-tuple-struct.stderr @@ -10,7 +10,8 @@ LL | Error = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Hash)]` | -LL | #[derive(Hash)] +LL + #[derive(Hash)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Ord-enum-struct-variant.stderr b/tests/ui/derives/derives-span-Ord-enum-struct-variant.stderr index 6e48332c2..1a06aee52 100644 --- a/tests/ui/derives/derives-span-Ord-enum-struct-variant.stderr +++ b/tests/ui/derives/derives-span-Ord-enum-struct-variant.stderr @@ -10,7 +10,8 @@ LL | x: Error = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Ord)]` | -LL | #[derive(Ord)] +LL + #[derive(Ord)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Ord-enum.stderr b/tests/ui/derives/derives-span-Ord-enum.stderr index b05cf0a05..377728e8a 100644 --- a/tests/ui/derives/derives-span-Ord-enum.stderr +++ b/tests/ui/derives/derives-span-Ord-enum.stderr @@ -10,7 +10,8 @@ LL | Error = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Ord)]` | -LL | #[derive(Ord)] +LL + #[derive(Ord)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Ord-struct.stderr b/tests/ui/derives/derives-span-Ord-struct.stderr index c4def34a8..e00e990da 100644 --- a/tests/ui/derives/derives-span-Ord-struct.stderr +++ b/tests/ui/derives/derives-span-Ord-struct.stderr @@ -10,7 +10,8 @@ LL | x: Error = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Ord)]` | -LL | #[derive(Ord)] +LL + #[derive(Ord)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-Ord-tuple-struct.stderr b/tests/ui/derives/derives-span-Ord-tuple-struct.stderr index a3b288d0f..959d0b964 100644 --- a/tests/ui/derives/derives-span-Ord-tuple-struct.stderr +++ b/tests/ui/derives/derives-span-Ord-tuple-struct.stderr @@ -10,7 +10,8 @@ LL | Error = note: this error originates in the derive macro `Ord` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(Ord)]` | -LL | #[derive(Ord)] +LL + #[derive(Ord)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr b/tests/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr index 9953154fd..9fc25f2ad 100644 --- a/tests/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr +++ b/tests/ui/derives/derives-span-PartialEq-enum-struct-variant.stderr @@ -15,7 +15,8 @@ LL | struct Error; = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(PartialEq)]` | -LL | #[derive(PartialEq)] +LL + #[derive(PartialEq)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-PartialEq-enum.stderr b/tests/ui/derives/derives-span-PartialEq-enum.stderr index 7c1304523..f56e78447 100644 --- a/tests/ui/derives/derives-span-PartialEq-enum.stderr +++ b/tests/ui/derives/derives-span-PartialEq-enum.stderr @@ -15,7 +15,8 @@ LL | struct Error; = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(PartialEq)]` | -LL | #[derive(PartialEq)] +LL + #[derive(PartialEq)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-PartialEq-struct.stderr b/tests/ui/derives/derives-span-PartialEq-struct.stderr index ba3d6ced3..76c0b0104 100644 --- a/tests/ui/derives/derives-span-PartialEq-struct.stderr +++ b/tests/ui/derives/derives-span-PartialEq-struct.stderr @@ -15,7 +15,8 @@ LL | struct Error; = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(PartialEq)]` | -LL | #[derive(PartialEq)] +LL + #[derive(PartialEq)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-PartialEq-tuple-struct.stderr b/tests/ui/derives/derives-span-PartialEq-tuple-struct.stderr index ab0b56a9e..7dae01dbb 100644 --- a/tests/ui/derives/derives-span-PartialEq-tuple-struct.stderr +++ b/tests/ui/derives/derives-span-PartialEq-tuple-struct.stderr @@ -15,7 +15,8 @@ LL | struct Error; = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(PartialEq)]` | -LL | #[derive(PartialEq)] +LL + #[derive(PartialEq)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr b/tests/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr index 2d19aaf68..746c1d5d2 100644 --- a/tests/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr +++ b/tests/ui/derives/derives-span-PartialOrd-enum-struct-variant.stderr @@ -11,7 +11,8 @@ LL | x: Error = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(PartialOrd)]` | -LL | #[derive(PartialOrd)] +LL + #[derive(PartialOrd)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-PartialOrd-enum.stderr b/tests/ui/derives/derives-span-PartialOrd-enum.stderr index dfbb8060f..8af1776da 100644 --- a/tests/ui/derives/derives-span-PartialOrd-enum.stderr +++ b/tests/ui/derives/derives-span-PartialOrd-enum.stderr @@ -11,7 +11,8 @@ LL | Error = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(PartialOrd)]` | -LL | #[derive(PartialOrd)] +LL + #[derive(PartialOrd)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-PartialOrd-struct.stderr b/tests/ui/derives/derives-span-PartialOrd-struct.stderr index ba63d86e8..11ea7f9dc 100644 --- a/tests/ui/derives/derives-span-PartialOrd-struct.stderr +++ b/tests/ui/derives/derives-span-PartialOrd-struct.stderr @@ -11,7 +11,8 @@ LL | x: Error = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(PartialOrd)]` | -LL | #[derive(PartialOrd)] +LL + #[derive(PartialOrd)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/derives-span-PartialOrd-tuple-struct.stderr b/tests/ui/derives/derives-span-PartialOrd-tuple-struct.stderr index 7686ed806..0a41a3db3 100644 --- a/tests/ui/derives/derives-span-PartialOrd-tuple-struct.stderr +++ b/tests/ui/derives/derives-span-PartialOrd-tuple-struct.stderr @@ -11,7 +11,8 @@ LL | Error = note: this error originates in the derive macro `PartialOrd` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Error` with `#[derive(PartialOrd)]` | -LL | #[derive(PartialOrd)] +LL + #[derive(PartialOrd)] +LL | struct Error; | error: aborting due to previous error diff --git a/tests/ui/derives/deriving-no-inner-impl-error-message.stderr b/tests/ui/derives/deriving-no-inner-impl-error-message.stderr index ef8c44caa..10af5d36e 100644 --- a/tests/ui/derives/deriving-no-inner-impl-error-message.stderr +++ b/tests/ui/derives/deriving-no-inner-impl-error-message.stderr @@ -15,7 +15,8 @@ LL | struct NoCloneOrEq; = note: this error originates in the derive macro `PartialEq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `NoCloneOrEq` with `#[derive(PartialEq)]` | -LL | #[derive(PartialEq)] +LL + #[derive(PartialEq)] +LL | struct NoCloneOrEq; | error[E0277]: the trait bound `NoCloneOrEq: Clone` is not satisfied @@ -30,7 +31,8 @@ LL | x: NoCloneOrEq = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `NoCloneOrEq` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct NoCloneOrEq; | error: aborting due to 2 previous errors diff --git a/tests/ui/derives/deriving-with-repr-packed-2.stderr b/tests/ui/derives/deriving-with-repr-packed-2.stderr index ab3646057..afeca9fec 100644 --- a/tests/ui/derives/deriving-with-repr-packed-2.stderr +++ b/tests/ui/derives/deriving-with-repr-packed-2.stderr @@ -25,7 +25,8 @@ LL | #[derive(Copy, Clone, Default, PartialEq, Eq)] | ^^^^^ unsatisfied trait bound introduced in this `derive` macro help: consider annotating `NonCopy` with `#[derive(Clone, Copy)]` | -LL | #[derive(Clone, Copy)] +LL + #[derive(Clone, Copy)] +LL | struct NonCopy; | error: aborting due to previous error diff --git a/tests/ui/derives/issue-91492.stderr b/tests/ui/derives/issue-91492.stderr index cee30ac50..fc64828b1 100644 --- a/tests/ui/derives/issue-91492.stderr +++ b/tests/ui/derives/issue-91492.stderr @@ -11,7 +11,8 @@ LL | foo.extend_from_slice(bar); `NoDerives: Clone` help: consider annotating `NoDerives` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | pub struct NoDerives; | error[E0599]: the method `extend_from_slice` exists for mutable reference `&mut Vec<SomeDerives>`, but its trait bounds were not satisfied @@ -27,7 +28,8 @@ LL | foo.extend_from_slice(bar); `SomeDerives: Clone` help: consider annotating `SomeDerives` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | pub struct SomeDerives; | error[E0599]: the method `use_clone` exists for struct `Object<NoDerives, SomeDerives>`, but its trait bounds were not satisfied @@ -51,7 +53,8 @@ LL | impl<T: Clone, A: Default> Object<T, A> { | unsatisfied trait bound introduced here help: consider annotating `NoDerives` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | pub struct NoDerives; | error: aborting due to 3 previous errors diff --git a/tests/ui/derives/issue-91550.stderr b/tests/ui/derives/issue-91550.stderr index af03f0e5e..1324b80b5 100644 --- a/tests/ui/derives/issue-91550.stderr +++ b/tests/ui/derives/issue-91550.stderr @@ -18,7 +18,8 @@ LL | hs.insert(Value(0)); `Value: Hash` help: consider annotating `Value` with `#[derive(Eq, Hash, PartialEq)]` | -LL | #[derive(Eq, Hash, PartialEq)] +LL + #[derive(Eq, Hash, PartialEq)] +LL | struct Value(u32); | error[E0599]: the method `use_eq` exists for struct `Object<NoDerives>`, but its trait bounds were not satisfied @@ -48,7 +49,8 @@ LL | impl<T: Eq> Object<T> { which is required by `NoDerives: Eq` help: consider annotating `NoDerives` with `#[derive(Eq, PartialEq)]` | -LL | #[derive(Eq, PartialEq)] +LL + #[derive(Eq, PartialEq)] +LL | pub struct NoDerives; | error[E0599]: the method `use_ord` exists for struct `Object<NoDerives>`, but its trait bounds were not satisfied @@ -84,7 +86,8 @@ LL | impl<T: Ord> Object<T> { which is required by `NoDerives: Ord` help: consider annotating `NoDerives` with `#[derive(Eq, Ord, PartialEq, PartialOrd)]` | -LL | #[derive(Eq, Ord, PartialEq, PartialOrd)] +LL + #[derive(Eq, Ord, PartialEq, PartialOrd)] +LL | pub struct NoDerives; | error[E0599]: the method `use_ord_and_partial_ord` exists for struct `Object<NoDerives>`, but its trait bounds were not satisfied @@ -123,7 +126,8 @@ LL | impl<T: Ord + PartialOrd> Object<T> { which is required by `NoDerives: PartialOrd` help: consider annotating `NoDerives` with `#[derive(Eq, Ord, PartialEq, PartialOrd)]` | -LL | #[derive(Eq, Ord, PartialEq, PartialOrd)] +LL + #[derive(Eq, Ord, PartialEq, PartialOrd)] +LL | pub struct NoDerives; | error: aborting due to 4 previous errors diff --git a/tests/ui/diagnostic-width/auxiliary/tab_column_numbers.rs b/tests/ui/diagnostic-width/auxiliary/tab_column_numbers.rs new file mode 100644 index 000000000..93418b765 --- /dev/null +++ b/tests/ui/diagnostic-width/auxiliary/tab_column_numbers.rs @@ -0,0 +1,6 @@ +// ignore-tidy-tab + +pub struct S; +impl S { + fn method(&self) {} +} diff --git a/tests/ui/diagnostic-width/tab-column-numbers.rs b/tests/ui/diagnostic-width/tab-column-numbers.rs new file mode 100644 index 000000000..2abb0bcde --- /dev/null +++ b/tests/ui/diagnostic-width/tab-column-numbers.rs @@ -0,0 +1,12 @@ +// Test for #109537: ensure that column numbers are correctly generated when using hard tabs. +// aux-build:tab_column_numbers.rs + +// ignore-tidy-tab + +extern crate tab_column_numbers; + +fn main() { + let s = tab_column_numbers::S; + s.method(); + //~^ ERROR method `method` is private +} diff --git a/tests/ui/diagnostic-width/tab-column-numbers.stderr b/tests/ui/diagnostic-width/tab-column-numbers.stderr new file mode 100644 index 000000000..ea4e1ff52 --- /dev/null +++ b/tests/ui/diagnostic-width/tab-column-numbers.stderr @@ -0,0 +1,14 @@ +error[E0624]: method `method` is private + --> $DIR/tab-column-numbers.rs:10:4 + | +LL | s.method(); + | ^^^^^^ private method + | + ::: $DIR/auxiliary/tab_column_numbers.rs:5:3 + | +LL | fn method(&self) {} + | ---------------- private method defined here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0624`. diff --git a/tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr b/tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr index abc040c05..5c610f363 100644 --- a/tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr +++ b/tests/ui/did_you_mean/issue-56028-there-is-an-enum-variant.stderr @@ -24,13 +24,13 @@ LL | fn setup() -> Set { Set } | help: consider importing one of these items | -LL | use AffixHeart::Set; +LL + use AffixHeart::Set; | -LL | use CauseToBe::Set; +LL + use CauseToBe::Set; | -LL | use Determine::Set; +LL + use Determine::Set; | -LL | use PutDown::Set; +LL + use PutDown::Set; | and 3 other candidates diff --git a/tests/ui/did_you_mean/recursion_limit.stderr b/tests/ui/did_you_mean/recursion_limit.stderr index 247fe4b5b..70e49566a 100644 --- a/tests/ui/did_you_mean/recursion_limit.stderr +++ b/tests/ui/did_you_mean/recursion_limit.stderr @@ -1,15 +1,10 @@ -error[E0275]: overflow evaluating the requirement `K: Send` +error[E0275]: overflow evaluating the requirement `J: Send` --> $DIR/recursion_limit.rs:34:5 | LL | is_send::<A>(); | ^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "20"]` attribute to your crate (`recursion_limit`) -note: required because it appears within the type `J` - --> $DIR/recursion_limit.rs:24:9 - | -LL | link! { J, K } - | ^ note: required because it appears within the type `I` --> $DIR/recursion_limit.rs:23:9 | diff --git a/tests/ui/did_you_mean/recursion_limit_deref.stderr b/tests/ui/did_you_mean/recursion_limit_deref.stderr index 32fb628c4..b0c493faf 100644 --- a/tests/ui/did_you_mean/recursion_limit_deref.stderr +++ b/tests/ui/did_you_mean/recursion_limit_deref.stderr @@ -1,3 +1,7 @@ +error: reached the recursion limit finding the struct tail for `Bottom` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "20"]` + error[E0055]: reached the recursion limit while auto-dereferencing `J` --> $DIR/recursion_limit_deref.rs:51:22 | @@ -17,7 +21,7 @@ LL | let x: &Bottom = &t; = note: expected reference `&Bottom` found reference `&Top` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0055, E0308. For more information about an error, try `rustc --explain E0055`. diff --git a/tests/ui/dst/issue-90528-unsizing-suggestion-1.rs b/tests/ui/dst/issue-90528-unsizing-suggestion-1.rs new file mode 100644 index 000000000..52863e22b --- /dev/null +++ b/tests/ui/dst/issue-90528-unsizing-suggestion-1.rs @@ -0,0 +1,20 @@ +// Issue #90528: provide helpful suggestions when a trait bound is unsatisfied +// due to a missed unsizing coercion. +// +// This test exercises array literals and a trait implemented on immutable slices. + +trait Read {} + +impl Read for &[u8] {} + +fn wants_read(_: impl Read) {} + +fn main() { + wants_read([0u8]); + //~^ ERROR the trait bound `[u8; 1]: Read` is not satisfied + wants_read(&[0u8]); + //~^ ERROR the trait bound `&[u8; 1]: Read` is not satisfied + wants_read(&[0u8][..]); + wants_read(&mut [0u8]); + //~^ ERROR the trait bound `&mut [u8; 1]: Read` is not satisfied +} diff --git a/tests/ui/dst/issue-90528-unsizing-suggestion-1.stderr b/tests/ui/dst/issue-90528-unsizing-suggestion-1.stderr new file mode 100644 index 000000000..27ef3fe97 --- /dev/null +++ b/tests/ui/dst/issue-90528-unsizing-suggestion-1.stderr @@ -0,0 +1,56 @@ +error[E0277]: the trait bound `[u8; 1]: Read` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-1.rs:13:16 + | +LL | wants_read([0u8]); + | ---------- ^^^^^ the trait `Read` is not implemented for `[u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Read` is implemented for `&[u8]` +note: required by a bound in `wants_read` + --> $DIR/issue-90528-unsizing-suggestion-1.rs:10:23 + | +LL | fn wants_read(_: impl Read) {} + | ^^^^ required by this bound in `wants_read` +help: convert the array to a `&[u8]` slice instead + | +LL | wants_read(&[0u8][..]); + | + ++++ + +error[E0277]: the trait bound `&[u8; 1]: Read` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-1.rs:15:16 + | +LL | wants_read(&[0u8]); + | ---------- ^^^^^^ the trait `Read` is not implemented for `&[u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Read` is implemented for `&[u8]` +note: required by a bound in `wants_read` + --> $DIR/issue-90528-unsizing-suggestion-1.rs:10:23 + | +LL | fn wants_read(_: impl Read) {} + | ^^^^ required by this bound in `wants_read` +help: convert the array to a `&[u8]` slice instead + | +LL | wants_read(&[0u8][..]); + | ++++ + +error[E0277]: the trait bound `&mut [u8; 1]: Read` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-1.rs:18:16 + | +LL | wants_read(&mut [0u8]); + | ---------- ^^^^^^^^^^ the trait `Read` is not implemented for `&mut [u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Read` is implemented for `&[u8]` +note: required by a bound in `wants_read` + --> $DIR/issue-90528-unsizing-suggestion-1.rs:10:23 + | +LL | fn wants_read(_: impl Read) {} + | ^^^^ required by this bound in `wants_read` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dst/issue-90528-unsizing-suggestion-2.rs b/tests/ui/dst/issue-90528-unsizing-suggestion-2.rs new file mode 100644 index 000000000..f2762ad42 --- /dev/null +++ b/tests/ui/dst/issue-90528-unsizing-suggestion-2.rs @@ -0,0 +1,28 @@ +// Issue #90528: provide helpful suggestions when a trait bound is unsatisfied +// due to a missed unsizing coercion. +// +// This test exercises array variables and a trait implemented on immmutable slices. + +trait Read {} + +impl Read for &[u8] {} + +fn wants_read(_: impl Read) {} + +fn main() { + let x = [0u8]; + wants_read(x); + //~^ ERROR the trait bound `[u8; 1]: Read` is not satisfied + wants_read(&x); + //~^ ERROR the trait bound `&[u8; 1]: Read` is not satisfied + wants_read(&x[..]); + + let x = &[0u8]; + wants_read(x); + //~^ ERROR the trait bound `&[u8; 1]: Read` is not satisfied + wants_read(&x); + //~^ ERROR the trait bound `&&[u8; 1]: Read` is not satisfied + wants_read(*x); + //~^ ERROR the trait bound `[u8; 1]: Read` is not satisfied + wants_read(&x[..]); +} diff --git a/tests/ui/dst/issue-90528-unsizing-suggestion-2.stderr b/tests/ui/dst/issue-90528-unsizing-suggestion-2.stderr new file mode 100644 index 000000000..ae0c4ca50 --- /dev/null +++ b/tests/ui/dst/issue-90528-unsizing-suggestion-2.stderr @@ -0,0 +1,94 @@ +error[E0277]: the trait bound `[u8; 1]: Read` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-2.rs:14:16 + | +LL | wants_read(x); + | ---------- ^ the trait `Read` is not implemented for `[u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Read` is implemented for `&[u8]` +note: required by a bound in `wants_read` + --> $DIR/issue-90528-unsizing-suggestion-2.rs:10:23 + | +LL | fn wants_read(_: impl Read) {} + | ^^^^ required by this bound in `wants_read` +help: convert the array to a `&[u8]` slice instead + | +LL | wants_read(&x[..]); + | + ++++ + +error[E0277]: the trait bound `&[u8; 1]: Read` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-2.rs:16:16 + | +LL | wants_read(&x); + | ---------- ^^ the trait `Read` is not implemented for `&[u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Read` is implemented for `&[u8]` +note: required by a bound in `wants_read` + --> $DIR/issue-90528-unsizing-suggestion-2.rs:10:23 + | +LL | fn wants_read(_: impl Read) {} + | ^^^^ required by this bound in `wants_read` +help: convert the array to a `&[u8]` slice instead + | +LL | wants_read(&x[..]); + | ++++ + +error[E0277]: the trait bound `&[u8; 1]: Read` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-2.rs:21:16 + | +LL | wants_read(x); + | ---------- ^ the trait `Read` is not implemented for `&[u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Read` is implemented for `&[u8]` +note: required by a bound in `wants_read` + --> $DIR/issue-90528-unsizing-suggestion-2.rs:10:23 + | +LL | fn wants_read(_: impl Read) {} + | ^^^^ required by this bound in `wants_read` +help: convert the array to a `&[u8]` slice instead + | +LL | wants_read(&x[..]); + | + ++++ + +error[E0277]: the trait bound `&&[u8; 1]: Read` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-2.rs:23:16 + | +LL | wants_read(&x); + | ---------- ^^ the trait `Read` is not implemented for `&&[u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Read` is implemented for `&[u8]` +note: required by a bound in `wants_read` + --> $DIR/issue-90528-unsizing-suggestion-2.rs:10:23 + | +LL | fn wants_read(_: impl Read) {} + | ^^^^ required by this bound in `wants_read` + +error[E0277]: the trait bound `[u8; 1]: Read` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-2.rs:25:16 + | +LL | wants_read(*x); + | ---------- ^^ the trait `Read` is not implemented for `[u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Read` is implemented for `&[u8]` +note: required by a bound in `wants_read` + --> $DIR/issue-90528-unsizing-suggestion-2.rs:10:23 + | +LL | fn wants_read(_: impl Read) {} + | ^^^^ required by this bound in `wants_read` +help: convert the array to a `&[u8]` slice instead + | +LL | wants_read(&*x[..]); + | + ++++ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dst/issue-90528-unsizing-suggestion-3.rs b/tests/ui/dst/issue-90528-unsizing-suggestion-3.rs new file mode 100644 index 000000000..218843d05 --- /dev/null +++ b/tests/ui/dst/issue-90528-unsizing-suggestion-3.rs @@ -0,0 +1,22 @@ +// Issue #90528: provide helpful suggestions when a trait bound is unsatisfied +// due to a missed unsizing coercion. +// +// This test exercises array literals and a trait implemented on mutable slices. + +trait Write {} + +impl Write for &mut [u8] {} + +fn wants_write(_: impl Write) {} + +fn main() { + wants_write([0u8]); + //~^ ERROR the trait bound `[u8; 1]: Write` is not satisfied + wants_write(&mut [0u8]); + //~^ ERROR the trait bound `&mut [u8; 1]: Write` is not satisfied + wants_write(&mut [0u8][..]); + wants_write(&[0u8]); + //~^ ERROR the trait bound `&[u8; 1]: Write` is not satisfied + wants_write(&[0u8][..]); + //~^ ERROR the trait bound `&[u8]: Write` is not satisfied +} diff --git a/tests/ui/dst/issue-90528-unsizing-suggestion-3.stderr b/tests/ui/dst/issue-90528-unsizing-suggestion-3.stderr new file mode 100644 index 000000000..774d5ba3c --- /dev/null +++ b/tests/ui/dst/issue-90528-unsizing-suggestion-3.stderr @@ -0,0 +1,75 @@ +error[E0277]: the trait bound `[u8; 1]: Write` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-3.rs:13:17 + | +LL | wants_write([0u8]); + | ----------- ^^^^^ the trait `Write` is not implemented for `[u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Write` is implemented for `&mut [u8]` +note: required by a bound in `wants_write` + --> $DIR/issue-90528-unsizing-suggestion-3.rs:10:24 + | +LL | fn wants_write(_: impl Write) {} + | ^^^^^ required by this bound in `wants_write` +help: convert the array to a `&mut [u8]` slice instead + | +LL | wants_write(&mut [0u8][..]); + | ++++ ++++ + +error[E0277]: the trait bound `&mut [u8; 1]: Write` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-3.rs:15:17 + | +LL | wants_write(&mut [0u8]); + | ----------- ^^^^^^^^^^ the trait `Write` is not implemented for `&mut [u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Write` is implemented for `&mut [u8]` +note: required by a bound in `wants_write` + --> $DIR/issue-90528-unsizing-suggestion-3.rs:10:24 + | +LL | fn wants_write(_: impl Write) {} + | ^^^^^ required by this bound in `wants_write` +help: convert the array to a `&mut [u8]` slice instead + | +LL | wants_write(&mut [0u8][..]); + | ++++ + +error[E0277]: the trait bound `&[u8; 1]: Write` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-3.rs:18:17 + | +LL | wants_write(&[0u8]); + | ----------- ^^^^^^ the trait `Write` is not implemented for `&[u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Write` is implemented for `&mut [u8]` +note: required by a bound in `wants_write` + --> $DIR/issue-90528-unsizing-suggestion-3.rs:10:24 + | +LL | fn wants_write(_: impl Write) {} + | ^^^^^ required by this bound in `wants_write` + +error[E0277]: the trait bound `&[u8]: Write` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-3.rs:20:17 + | +LL | wants_write(&[0u8][..]); + | ----------- ^^^^^^^^^^ the trait `Write` is not implemented for `&[u8]` + | | + | required by a bound introduced by this call + | + = help: the trait `Write` is implemented for `&mut [u8]` +note: required by a bound in `wants_write` + --> $DIR/issue-90528-unsizing-suggestion-3.rs:10:24 + | +LL | fn wants_write(_: impl Write) {} + | ^^^^^ required by this bound in `wants_write` +help: consider changing this borrow's mutability + | +LL | wants_write(&mut [0u8][..]); + | ~~~~ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dst/issue-90528-unsizing-suggestion-4.rs b/tests/ui/dst/issue-90528-unsizing-suggestion-4.rs new file mode 100644 index 000000000..eae953c61 --- /dev/null +++ b/tests/ui/dst/issue-90528-unsizing-suggestion-4.rs @@ -0,0 +1,26 @@ +// Issue #90528: provide helpful suggestions when a trait bound is unsatisfied +// due to a missed unsizing coercion. +// +// This test exercises array variables and a trait implemented on mutable slices. + +trait Write {} + +impl Write for &mut [u8] {} + +fn wants_write(_: impl Write) {} + +fn main() { + let mut x = [0u8]; + wants_write(x); + //~^ ERROR the trait bound `[u8; 1]: Write` is not satisfied + wants_write(&mut x); + //~^ ERROR the trait bound `&mut [u8; 1]: Write` is not satisfied + wants_write(&mut x[..]); + + let x = &mut [0u8]; + wants_write(x); + //~^ ERROR the trait bound `&mut [u8; 1]: Write` is not satisfied + wants_write(*x); + //~^ ERROR the trait bound `[u8; 1]: Write` is not satisfied + wants_write(&mut x[..]); +} diff --git a/tests/ui/dst/issue-90528-unsizing-suggestion-4.stderr b/tests/ui/dst/issue-90528-unsizing-suggestion-4.stderr new file mode 100644 index 000000000..a4020ee07 --- /dev/null +++ b/tests/ui/dst/issue-90528-unsizing-suggestion-4.stderr @@ -0,0 +1,79 @@ +error[E0277]: the trait bound `[u8; 1]: Write` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-4.rs:14:17 + | +LL | wants_write(x); + | ----------- ^ the trait `Write` is not implemented for `[u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Write` is implemented for `&mut [u8]` +note: required by a bound in `wants_write` + --> $DIR/issue-90528-unsizing-suggestion-4.rs:10:24 + | +LL | fn wants_write(_: impl Write) {} + | ^^^^^ required by this bound in `wants_write` +help: convert the array to a `&mut [u8]` slice instead + | +LL | wants_write(&mut x[..]); + | ++++ ++++ + +error[E0277]: the trait bound `&mut [u8; 1]: Write` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-4.rs:16:17 + | +LL | wants_write(&mut x); + | ----------- ^^^^^^ the trait `Write` is not implemented for `&mut [u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Write` is implemented for `&mut [u8]` +note: required by a bound in `wants_write` + --> $DIR/issue-90528-unsizing-suggestion-4.rs:10:24 + | +LL | fn wants_write(_: impl Write) {} + | ^^^^^ required by this bound in `wants_write` +help: convert the array to a `&mut [u8]` slice instead + | +LL | wants_write(&mut x[..]); + | ++++ + +error[E0277]: the trait bound `&mut [u8; 1]: Write` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-4.rs:21:17 + | +LL | wants_write(x); + | ----------- ^ the trait `Write` is not implemented for `&mut [u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Write` is implemented for `&mut [u8]` +note: required by a bound in `wants_write` + --> $DIR/issue-90528-unsizing-suggestion-4.rs:10:24 + | +LL | fn wants_write(_: impl Write) {} + | ^^^^^ required by this bound in `wants_write` +help: convert the array to a `&mut [u8]` slice instead + | +LL | wants_write(&mut x[..]); + | ++++ ++++ + +error[E0277]: the trait bound `[u8; 1]: Write` is not satisfied + --> $DIR/issue-90528-unsizing-suggestion-4.rs:23:17 + | +LL | wants_write(*x); + | ----------- ^^ the trait `Write` is not implemented for `[u8; 1]` + | | + | required by a bound introduced by this call + | + = help: the trait `Write` is implemented for `&mut [u8]` +note: required by a bound in `wants_write` + --> $DIR/issue-90528-unsizing-suggestion-4.rs:10:24 + | +LL | fn wants_write(_: impl Write) {} + | ^^^^^ required by this bound in `wants_write` +help: convert the array to a `&mut [u8]` slice instead + | +LL | wants_write(&mut *x[..]); + | ++++ ++++ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/align.normal.stderr b/tests/ui/dyn-star/align.normal.stderr index 53c2cbeac..42fa4fd6f 100644 --- a/tests/ui/dyn-star/align.normal.stderr +++ b/tests/ui/dyn-star/align.normal.stderr @@ -1,5 +1,5 @@ warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/align.rs:4:12 + --> $DIR/align.rs:3:12 | LL | #![feature(dyn_star)] | ^^^^^^^^ @@ -7,5 +7,14 @@ LL | #![feature(dyn_star)] = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information = note: `#[warn(incomplete_features)]` on by default -warning: 1 warning emitted +error[E0277]: `AlignedUsize` needs to have the same ABI as a pointer + --> $DIR/align.rs:14:13 + | +LL | let x = AlignedUsize(12) as dyn* Debug; + | ^^^^^^^^^^^^^^^^ `AlignedUsize` needs to be a pointer-like type + | + = help: the trait `PointerLike` is not implemented for `AlignedUsize` + +error: aborting due to previous error; 1 warning emitted +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/align.over_aligned.stderr b/tests/ui/dyn-star/align.over_aligned.stderr index 0365d87a6..42fa4fd6f 100644 --- a/tests/ui/dyn-star/align.over_aligned.stderr +++ b/tests/ui/dyn-star/align.over_aligned.stderr @@ -1,5 +1,5 @@ warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/align.rs:4:12 + --> $DIR/align.rs:3:12 | LL | #![feature(dyn_star)] | ^^^^^^^^ @@ -7,8 +7,8 @@ LL | #![feature(dyn_star)] = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information = note: `#[warn(incomplete_features)]` on by default -error[E0277]: `AlignedUsize` needs to have the same alignment and size as a pointer - --> $DIR/align.rs:15:13 +error[E0277]: `AlignedUsize` needs to have the same ABI as a pointer + --> $DIR/align.rs:14:13 | LL | let x = AlignedUsize(12) as dyn* Debug; | ^^^^^^^^^^^^^^^^ `AlignedUsize` needs to be a pointer-like type diff --git a/tests/ui/dyn-star/align.rs b/tests/ui/dyn-star/align.rs index 6679997a9..79cbaba0c 100644 --- a/tests/ui/dyn-star/align.rs +++ b/tests/ui/dyn-star/align.rs @@ -1,5 +1,4 @@ // revisions: normal over_aligned -//[normal] check-pass #![feature(dyn_star)] //~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes @@ -13,5 +12,5 @@ struct AlignedUsize(usize); fn main() { let x = AlignedUsize(12) as dyn* Debug; - //[over_aligned]~^ ERROR `AlignedUsize` needs to have the same alignment and size as a pointer + //~^ ERROR `AlignedUsize` needs to have the same ABI as a pointer } diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs index 85749aa7b..913c2faac 100644 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs @@ -9,7 +9,7 @@ fn dyn_debug(_: (dyn* Debug + '_)) { fn polymorphic<T: Debug + ?Sized>(t: &T) { dyn_debug(t); - //~^ ERROR `&T` needs to have the same alignment and size as a pointer + //~^ ERROR `&T` needs to have the same ABI as a pointer } fn main() {} diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr index 350630f79..8726fae79 100644 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr +++ b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.stderr @@ -1,4 +1,4 @@ -error[E0277]: `&T` needs to have the same alignment and size as a pointer +error[E0277]: `&T` needs to have the same ABI as a pointer --> $DIR/check-size-at-cast-polymorphic-bad.rs:11:15 | LL | dyn_debug(t); diff --git a/tests/ui/dyn-star/check-size-at-cast.rs b/tests/ui/dyn-star/check-size-at-cast.rs index 17bc4f303..e15e090b5 100644 --- a/tests/ui/dyn-star/check-size-at-cast.rs +++ b/tests/ui/dyn-star/check-size-at-cast.rs @@ -5,6 +5,6 @@ use std::fmt::Debug; fn main() { let i = [1, 2, 3, 4] as dyn* Debug; - //~^ ERROR `[i32; 4]` needs to have the same alignment and size as a pointer + //~^ ERROR `[i32; 4]` needs to have the same ABI as a pointer dbg!(i); } diff --git a/tests/ui/dyn-star/check-size-at-cast.stderr b/tests/ui/dyn-star/check-size-at-cast.stderr index 19700b406..e60b5c56f 100644 --- a/tests/ui/dyn-star/check-size-at-cast.stderr +++ b/tests/ui/dyn-star/check-size-at-cast.stderr @@ -1,4 +1,4 @@ -error[E0277]: `[i32; 4]` needs to have the same alignment and size as a pointer +error[E0277]: `[i32; 4]` needs to have the same ABI as a pointer --> $DIR/check-size-at-cast.rs:7:13 | LL | let i = [1, 2, 3, 4] as dyn* Debug; diff --git a/tests/ui/dyn-star/const-and-static.rs b/tests/ui/dyn-star/const-and-static.rs new file mode 100644 index 000000000..551b072ab --- /dev/null +++ b/tests/ui/dyn-star/const-and-static.rs @@ -0,0 +1,10 @@ +// check-pass + +#![feature(dyn_star)] +//~^ WARN the feature `dyn_star` is incomplete + +const C: dyn* Send + Sync = &(); + +static S: dyn* Send + Sync = &(); + +fn main() {} diff --git a/tests/ui/dyn-star/const-and-static.stderr b/tests/ui/dyn-star/const-and-static.stderr new file mode 100644 index 000000000..df8f42fb0 --- /dev/null +++ b/tests/ui/dyn-star/const-and-static.stderr @@ -0,0 +1,11 @@ +warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/const-and-static.rs:3:12 + | +LL | #![feature(dyn_star)] + | ^^^^^^^^ + | + = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/dyn-star/feature-gate-dyn_star.rs b/tests/ui/dyn-star/feature-gate-dyn_star.rs index 4756661cf..41eed71cd 100644 --- a/tests/ui/dyn-star/feature-gate-dyn_star.rs +++ b/tests/ui/dyn-star/feature-gate-dyn_star.rs @@ -3,7 +3,7 @@ /// dyn* is not necessarily the final surface syntax (if we have one at all), /// but for now we will support it to aid in writing tests independently. pub fn dyn_star_parameter(_: &dyn* Send) { - //~^ dyn* trait objects are unstable + //~^ `dyn*` trait objects are experimental } fn main() {} diff --git a/tests/ui/dyn-star/feature-gate-dyn_star.stderr b/tests/ui/dyn-star/feature-gate-dyn_star.stderr index c3449b627..342e71c3a 100644 --- a/tests/ui/dyn-star/feature-gate-dyn_star.stderr +++ b/tests/ui/dyn-star/feature-gate-dyn_star.stderr @@ -1,8 +1,8 @@ -error[E0658]: dyn* trait objects are unstable +error[E0658]: `dyn*` trait objects are experimental --> $DIR/feature-gate-dyn_star.rs:5:31 | LL | pub fn dyn_star_parameter(_: &dyn* Send) { - | ^^^^^^^^^ + | ^^^^ | = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information = help: add `#![feature(dyn_star)]` to the crate attributes to enable diff --git a/tests/ui/dyn-star/gated-span.rs b/tests/ui/dyn-star/gated-span.rs new file mode 100644 index 000000000..a747987bd --- /dev/null +++ b/tests/ui/dyn-star/gated-span.rs @@ -0,0 +1,8 @@ +macro_rules! t { + ($t:ty) => {} +} + +t!(dyn* Send); +//~^ ERROR `dyn*` trait objects are experimental + +fn main() {} diff --git a/tests/ui/dyn-star/gated-span.stderr b/tests/ui/dyn-star/gated-span.stderr new file mode 100644 index 000000000..626b6cd1b --- /dev/null +++ b/tests/ui/dyn-star/gated-span.stderr @@ -0,0 +1,12 @@ +error[E0658]: `dyn*` trait objects are experimental + --> $DIR/gated-span.rs:5:4 + | +LL | t!(dyn* Send); + | ^^^^ + | + = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information + = help: add `#![feature(dyn_star)]` to the crate attributes to enable + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/dyn-star/no-explicit-dyn-star-cast.rs b/tests/ui/dyn-star/no-explicit-dyn-star-cast.rs index 67240c8e8..2d28f516a 100644 --- a/tests/ui/dyn-star/no-explicit-dyn-star-cast.rs +++ b/tests/ui/dyn-star/no-explicit-dyn-star-cast.rs @@ -4,8 +4,8 @@ fn make_dyn_star() { let i = 42usize; let dyn_i: dyn* Debug = i as dyn* Debug; //~^ ERROR casting `usize` as `dyn* Debug` is invalid - //~| ERROR dyn* trait objects are unstable - //~| ERROR dyn* trait objects are unstable + //~| ERROR `dyn*` trait objects are experimental + //~| ERROR `dyn*` trait objects are experimental } fn main() { diff --git a/tests/ui/dyn-star/no-explicit-dyn-star-cast.stderr b/tests/ui/dyn-star/no-explicit-dyn-star-cast.stderr index eb9c93305..78af9c7a3 100644 --- a/tests/ui/dyn-star/no-explicit-dyn-star-cast.stderr +++ b/tests/ui/dyn-star/no-explicit-dyn-star-cast.stderr @@ -1,17 +1,17 @@ -error[E0658]: dyn* trait objects are unstable +error[E0658]: `dyn*` trait objects are experimental --> $DIR/no-explicit-dyn-star-cast.rs:5:16 | LL | let dyn_i: dyn* Debug = i as dyn* Debug; - | ^^^^^^^^^^ + | ^^^^ | = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information = help: add `#![feature(dyn_star)]` to the crate attributes to enable -error[E0658]: dyn* trait objects are unstable +error[E0658]: `dyn*` trait objects are experimental --> $DIR/no-explicit-dyn-star-cast.rs:5:34 | LL | let dyn_i: dyn* Debug = i as dyn* Debug; - | ^^^^^^^^^^ + | ^^^^ | = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information = help: add `#![feature(dyn_star)]` to the crate attributes to enable diff --git a/tests/ui/dyn-star/upcast.stderr b/tests/ui/dyn-star/upcast.stderr index e60144fea..8b34c7f8b 100644 --- a/tests/ui/dyn-star/upcast.stderr +++ b/tests/ui/dyn-star/upcast.stderr @@ -7,7 +7,7 @@ LL | #![feature(dyn_star, trait_upcasting)] = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information = note: `#[warn(incomplete_features)]` on by default -error[E0277]: `dyn* Foo` needs to have the same alignment and size as a pointer +error[E0277]: `dyn* Foo` needs to have the same ABI as a pointer --> $DIR/upcast.rs:30:23 | LL | let w: dyn* Bar = w; diff --git a/tests/ui/empty/empty-struct-tuple-pat.stderr b/tests/ui/empty/empty-struct-tuple-pat.stderr index 8d0f75d20..45001c797 100644 --- a/tests/ui/empty/empty-struct-tuple-pat.stderr +++ b/tests/ui/empty/empty-struct-tuple-pat.stderr @@ -46,8 +46,8 @@ LL | XEmpty5(), | help: use the tuple variant pattern syntax instead | -LL | XE::XEmpty5(/* fields */) => (), - | ~~~~~~~~~~~~~~~~~~~~~~~~~ +LL | XE::XEmpty5() => (), + | ~~~~~~~~~~~~~ help: a unit variant with a similar name exists | LL | XE::XEmpty4 => (), diff --git a/tests/ui/enum-discriminant/auxiliary/discr-foreign-dep.rs b/tests/ui/enum-discriminant/auxiliary/discr-foreign-dep.rs new file mode 100644 index 000000000..a2cc10a4b --- /dev/null +++ b/tests/ui/enum-discriminant/auxiliary/discr-foreign-dep.rs @@ -0,0 +1,7 @@ +#[derive(Default)] +pub enum Foo { + A(u32), + #[default] + B, + C(u32), +} diff --git a/tests/ui/enum-discriminant/discr-foreign.rs b/tests/ui/enum-discriminant/discr-foreign.rs new file mode 100644 index 000000000..e7123b344 --- /dev/null +++ b/tests/ui/enum-discriminant/discr-foreign.rs @@ -0,0 +1,11 @@ +// aux-build:discr-foreign-dep.rs +// build-pass + +extern crate discr_foreign_dep; + +fn main() { + match Default::default() { + discr_foreign_dep::Foo::A(_) => {} + _ => {} + } +} diff --git a/tests/ui/enum-discriminant/issue-104519.rs b/tests/ui/enum-discriminant/issue-104519.rs index c4630f76b..507c0988f 100644 --- a/tests/ui/enum-discriminant/issue-104519.rs +++ b/tests/ui/enum-discriminant/issue-104519.rs @@ -23,14 +23,4 @@ fn some_match(result: OpenResult) -> u8 { fn main() { let result = OpenResult::Ok(()); assert_eq!(some_match(result), 0); - - let result = OpenResult::Ok(()); - match result { - OpenResult::Ok(()) => (), - _ => unreachable!("message a"), - } - match result { - OpenResult::Ok(()) => (), - _ => unreachable!("message b"), - } } diff --git a/tests/ui/issues/issue-61696.rs b/tests/ui/enum-discriminant/issue-61696.rs index dca52927f..8a633a916 100644 --- a/tests/ui/issues/issue-61696.rs +++ b/tests/ui/enum-discriminant/issue-61696.rs @@ -55,12 +55,23 @@ pub enum E2<X> { V4, } -fn main() { - if let E1::V2 { .. } = (E1::V1 { f: true }) { - unreachable!() +#[inline(never)] +fn match_e1(y: E1) -> u8 { + match y { + E1::V2 { .. } => 1, + _ => 0, } +} - if let E2::V1 { .. } = E2::V3::<Infallible> { - unreachable!() +#[inline(never)] +fn match_e2(y: E2<Infallible>) -> u8 { + match y { + E2::V1 { .. } => 1, + _ => 0, } } + +fn main() { + assert_eq!(match_e1(E1::V1 { f: true }), 0); + assert_eq!(match_e2(E2::V3), 0); +} diff --git a/tests/ui/error-codes/E0004.stderr b/tests/ui/error-codes/E0004.stderr index 4ac8c904f..603bc5237 100644 --- a/tests/ui/error-codes/E0004.stderr +++ b/tests/ui/error-codes/E0004.stderr @@ -14,7 +14,7 @@ LL | HastaLaVistaBaby, = note: the matched value is of type `Terminator` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ Terminator::TalkToMyHand => {} +LL ~ Terminator::TalkToMyHand => {}, LL + Terminator::HastaLaVistaBaby => todo!() | diff --git a/tests/ui/error-codes/E0010-teach.rs b/tests/ui/error-codes/E0010-teach.rs index fc5dffb37..798fcda2a 100644 --- a/tests/ui/error-codes/E0010-teach.rs +++ b/tests/ui/error-codes/E0010-teach.rs @@ -1,8 +1,7 @@ // compile-flags: -Z teach -#![feature(box_syntax)] #![allow(warnings)] -const CON : Box<i32> = box 0; //~ ERROR E0010 - +const CON: Vec<i32> = vec![1, 2, 3]; //~ ERROR E0010 +//~| ERROR cannot call non-const fn fn main() {} diff --git a/tests/ui/error-codes/E0010-teach.stderr b/tests/ui/error-codes/E0010-teach.stderr index 33de9fd68..7634970f3 100644 --- a/tests/ui/error-codes/E0010-teach.stderr +++ b/tests/ui/error-codes/E0010-teach.stderr @@ -1,11 +1,22 @@ error[E0010]: allocations are not allowed in constants - --> $DIR/E0010-teach.rs:6:24 + --> $DIR/E0010-teach.rs:5:23 | -LL | const CON : Box<i32> = box 0; - | ^^^^^ allocation not allowed in constants +LL | const CON: Vec<i32> = vec![1, 2, 3]; + | ^^^^^^^^^^^^^ allocation not allowed in constants | = note: The value of statics and constants must be known at compile time, and they live for the entire lifetime of a program. Creating a boxed value allocates memory on the heap at runtime, and therefore cannot be done at compile time. + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error[E0015]: cannot call non-const fn `slice::<impl [i32]>::into_vec::<std::alloc::Global>` in constants + --> $DIR/E0010-teach.rs:5:23 + | +LL | const CON: Vec<i32> = vec![1, 2, 3]; + | ^^^^^^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0010`. +Some errors have detailed explanations: E0010, E0015. +For more information about an error, try `rustc --explain E0010`. diff --git a/tests/ui/error-codes/E0010.rs b/tests/ui/error-codes/E0010.rs index e62997640..11721efff 100644 --- a/tests/ui/error-codes/E0010.rs +++ b/tests/ui/error-codes/E0010.rs @@ -1,6 +1,5 @@ -#![feature(box_syntax)] #![allow(warnings)] -const CON : Box<i32> = box 0; //~ ERROR E0010 - +const CON: Vec<i32> = vec![1, 2, 3]; //~ ERROR E0010 +//~| ERROR cannot call non-const fn fn main() {} diff --git a/tests/ui/error-codes/E0010.stderr b/tests/ui/error-codes/E0010.stderr index 0042333b9..089472224 100644 --- a/tests/ui/error-codes/E0010.stderr +++ b/tests/ui/error-codes/E0010.stderr @@ -1,9 +1,21 @@ error[E0010]: allocations are not allowed in constants - --> $DIR/E0010.rs:4:24 + --> $DIR/E0010.rs:3:23 | -LL | const CON : Box<i32> = box 0; - | ^^^^^ allocation not allowed in constants +LL | const CON: Vec<i32> = vec![1, 2, 3]; + | ^^^^^^^^^^^^^ allocation not allowed in constants + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0015]: cannot call non-const fn `slice::<impl [i32]>::into_vec::<std::alloc::Global>` in constants + --> $DIR/E0010.rs:3:23 + | +LL | const CON: Vec<i32> = vec![1, 2, 3]; + | ^^^^^^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0010`. +Some errors have detailed explanations: E0010, E0015. +For more information about an error, try `rustc --explain E0010`. diff --git a/tests/ui/error-codes/E0030-teach.rs b/tests/ui/error-codes/E0030-teach.rs index 8caa4f093..388064fb0 100644 --- a/tests/ui/error-codes/E0030-teach.rs +++ b/tests/ui/error-codes/E0030-teach.rs @@ -4,6 +4,5 @@ fn main() { match 5u32 { 1000 ..= 5 => {} //~^ ERROR lower range bound must be less than or equal to upper - //~| ERROR lower range bound must be less than or equal to upper } } diff --git a/tests/ui/error-codes/E0030-teach.stderr b/tests/ui/error-codes/E0030-teach.stderr index 800f66416..3f1ad4af3 100644 --- a/tests/ui/error-codes/E0030-teach.stderr +++ b/tests/ui/error-codes/E0030-teach.stderr @@ -6,12 +6,6 @@ LL | 1000 ..= 5 => {} | = note: When matching against a range, the compiler verifies that the range is non-empty. Range patterns include both end-points, so this is equivalent to requiring the start of the range to be less than or equal to the end of the range. -error[E0030]: lower range bound must be less than or equal to upper - --> $DIR/E0030-teach.rs:5:9 - | -LL | 1000 ..= 5 => {} - | ^^^^ lower bound larger than upper bound - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0030`. diff --git a/tests/ui/error-codes/E0030.rs b/tests/ui/error-codes/E0030.rs index a5d8f8726..58d856b7c 100644 --- a/tests/ui/error-codes/E0030.rs +++ b/tests/ui/error-codes/E0030.rs @@ -2,6 +2,5 @@ fn main() { match 5u32 { 1000 ..= 5 => {} //~^ ERROR lower range bound must be less than or equal to upper - //~| ERROR lower range bound must be less than or equal to upper } } diff --git a/tests/ui/error-codes/E0030.stderr b/tests/ui/error-codes/E0030.stderr index 8a6114024..db8161d8f 100644 --- a/tests/ui/error-codes/E0030.stderr +++ b/tests/ui/error-codes/E0030.stderr @@ -4,12 +4,6 @@ error[E0030]: lower range bound must be less than or equal to upper LL | 1000 ..= 5 => {} | ^^^^ lower bound larger than upper bound -error[E0030]: lower range bound must be less than or equal to upper - --> $DIR/E0030.rs:3:9 - | -LL | 1000 ..= 5 => {} - | ^^^^ lower bound larger than upper bound - -error: aborting due to 2 previous errors +error: aborting due to previous error For more information about this error, try `rustc --explain E0030`. diff --git a/tests/ui/error-codes/E0184.stderr b/tests/ui/error-codes/E0184.stderr index bb3017b6e..52f1f30a4 100644 --- a/tests/ui/error-codes/E0184.stderr +++ b/tests/ui/error-codes/E0184.stderr @@ -1,4 +1,4 @@ -error[E0184]: the trait `Copy` may not be implemented for this type; the type has a destructor +error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor --> $DIR/E0184.rs:1:10 | LL | #[derive(Copy)] diff --git a/tests/ui/error-codes/E0206.rs b/tests/ui/error-codes/E0206.rs index 0f3d427ce..74738d810 100644 --- a/tests/ui/error-codes/E0206.rs +++ b/tests/ui/error-codes/E0206.rs @@ -2,7 +2,7 @@ struct Bar; impl Copy for &'static mut Bar { } -//~^ ERROR the trait `Copy` may not be implemented for this type +//~^ ERROR the trait `Copy` cannot be implemented for this type fn main() { } diff --git a/tests/ui/error-codes/E0206.stderr b/tests/ui/error-codes/E0206.stderr index 57ae2647d..60d8d7bfe 100644 --- a/tests/ui/error-codes/E0206.stderr +++ b/tests/ui/error-codes/E0206.stderr @@ -1,4 +1,4 @@ -error[E0206]: the trait `Copy` may not be implemented for this type +error[E0206]: the trait `Copy` cannot be implemented for this type --> $DIR/E0206.rs:4:15 | LL | impl Copy for &'static mut Bar { } diff --git a/tests/ui/error-codes/E0275.stderr b/tests/ui/error-codes/E0275.stderr index cf9a7f69b..03c37d6f0 100644 --- a/tests/ui/error-codes/E0275.stderr +++ b/tests/ui/error-codes/E0275.stderr @@ -11,7 +11,7 @@ note: required for `Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar<Bar< LL | impl<T> Foo for T where Bar<T>: Foo {} | ^^^ ^ --- unsatisfied trait bound introduced here = note: the full type name has been written to '$TEST_BUILD_DIR/error-codes/E0275/E0275.long-type-hash.txt' - = note: 127 redundant requirements hidden + = note: 126 redundant requirements hidden = note: required for `Bar<T>` to implement `Foo` error: aborting due to previous error diff --git a/tests/ui/error-codes/E0277-3.stderr b/tests/ui/error-codes/E0277-3.stderr index 0127e1ccc..0d4782935 100644 --- a/tests/ui/error-codes/E0277-3.stderr +++ b/tests/ui/error-codes/E0277-3.stderr @@ -14,7 +14,8 @@ LL | fn foo<T: PartialEq>(_: T) {} | ^^^^^^^^^ required by this bound in `foo` help: consider annotating `S` with `#[derive(PartialEq)]` | -LL | #[derive(PartialEq)] +LL + #[derive(PartialEq)] +LL | struct S; | error: aborting due to previous error diff --git a/tests/ui/error-codes/E0449.stderr b/tests/ui/error-codes/E0449.stderr index 8221a5e0a..cf41bcce8 100644 --- a/tests/ui/error-codes/E0449.stderr +++ b/tests/ui/error-codes/E0449.stderr @@ -1,22 +1,26 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/E0449.rs:7:1 | LL | pub impl Bar {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual impl items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/E0449.rs:9:1 | LL | pub impl Foo for Bar { - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/E0449.rs:10:5 | LL | pub fn foo() {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait error: aborting due to 3 previous errors diff --git a/tests/ui/exclusive-drop-and-copy.rs b/tests/ui/exclusive-drop-and-copy.rs index 7a251671e..210ecaed7 100644 --- a/tests/ui/exclusive-drop-and-copy.rs +++ b/tests/ui/exclusive-drop-and-copy.rs @@ -1,13 +1,13 @@ // issue #20126 -#[derive(Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented +#[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented struct Foo; impl Drop for Foo { fn drop(&mut self) {} } -#[derive(Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented +#[derive(Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented struct Bar<T>(::std::marker::PhantomData<T>); impl<T> Drop for Bar<T> { diff --git a/tests/ui/exclusive-drop-and-copy.stderr b/tests/ui/exclusive-drop-and-copy.stderr index 8649c8abb..546079422 100644 --- a/tests/ui/exclusive-drop-and-copy.stderr +++ b/tests/ui/exclusive-drop-and-copy.stderr @@ -1,4 +1,4 @@ -error[E0184]: the trait `Copy` may not be implemented for this type; the type has a destructor +error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor --> $DIR/exclusive-drop-and-copy.rs:3:10 | LL | #[derive(Copy, Clone)] @@ -6,7 +6,7 @@ LL | #[derive(Copy, Clone)] | = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0184]: the trait `Copy` may not be implemented for this type; the type has a destructor +error[E0184]: the trait `Copy` cannot be implemented for this type; the type has a destructor --> $DIR/exclusive-drop-and-copy.rs:10:10 | LL | #[derive(Copy, Clone)] diff --git a/tests/ui/extenv/extenv-no-args.rs b/tests/ui/extenv/extenv-no-args.rs index 9f221ed10..2ff6d242b 100644 --- a/tests/ui/extenv/extenv-no-args.rs +++ b/tests/ui/extenv/extenv-no-args.rs @@ -1 +1 @@ -fn main() { env!(); } //~ ERROR: env! takes 1 or 2 arguments +fn main() { env!(); } //~ ERROR: `env!()` takes 1 or 2 arguments diff --git a/tests/ui/extenv/extenv-no-args.stderr b/tests/ui/extenv/extenv-no-args.stderr index 318ed635b..70b85932c 100644 --- a/tests/ui/extenv/extenv-no-args.stderr +++ b/tests/ui/extenv/extenv-no-args.stderr @@ -1,4 +1,4 @@ -error: env! takes 1 or 2 arguments +error: `env!()` takes 1 or 2 arguments --> $DIR/extenv-no-args.rs:1:13 | LL | fn main() { env!(); } diff --git a/tests/ui/extenv/extenv-too-many-args.rs b/tests/ui/extenv/extenv-too-many-args.rs index 1adbee583..ffad1c513 100644 --- a/tests/ui/extenv/extenv-too-many-args.rs +++ b/tests/ui/extenv/extenv-too-many-args.rs @@ -1 +1 @@ -fn main() { env!("one", "two", "three"); } //~ ERROR: env! takes 1 or 2 arguments +fn main() { env!("one", "two", "three"); } //~ ERROR: `env!()` takes 1 or 2 arguments diff --git a/tests/ui/extenv/extenv-too-many-args.stderr b/tests/ui/extenv/extenv-too-many-args.stderr index 54150a332..47cf810b7 100644 --- a/tests/ui/extenv/extenv-too-many-args.stderr +++ b/tests/ui/extenv/extenv-too-many-args.stderr @@ -1,4 +1,4 @@ -error: env! takes 1 or 2 arguments +error: `env!()` takes 1 or 2 arguments --> $DIR/extenv-too-many-args.rs:1:13 | LL | fn main() { env!("one", "two", "three"); } diff --git a/tests/ui/extenv/issue-55897.stderr b/tests/ui/extenv/issue-55897.stderr index 5752a965e..401db8278 100644 --- a/tests/ui/extenv/issue-55897.stderr +++ b/tests/ui/extenv/issue-55897.stderr @@ -4,7 +4,7 @@ error: environment variable `NON_EXISTENT` not defined at compile time LL | include!(concat!(env!("NON_EXISTENT"), "/data.rs")); | ^^^^^^^^^^^^^^^^^^^^ | - = help: Use `std::env::var("NON_EXISTENT")` to read the variable at run time + = help: use `std::env::var("NON_EXISTENT")` to read the variable at run time = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) error: suffixes on string literals are invalid diff --git a/tests/ui/extern-mod-syntax.rs b/tests/ui/extern-mod-syntax.rs new file mode 100644 index 000000000..65dfa6a0f --- /dev/null +++ b/tests/ui/extern-mod-syntax.rs @@ -0,0 +1,11 @@ +// run-pass + +#![allow(unused_imports)] +#![no_std] + +extern crate std; +use std::ffi::c_void; + +pub fn main() { + std::println!("Hello world!"); +} diff --git a/tests/ui/feature-gates/feature-gate-box-expr.rs b/tests/ui/feature-gates/feature-gate-box-expr.rs deleted file mode 100644 index 870253d2f..000000000 --- a/tests/ui/feature-gates/feature-gate-box-expr.rs +++ /dev/null @@ -1,14 +0,0 @@ -// gate-test-box_syntax - -// Check that `box EXPR` is feature-gated. -// -// See also feature-gate-placement-expr.rs -// -// (Note that the two tests are separated since the checks appear to -// be performed at distinct phases, with an abort_if_errors call -// separating them.) - -fn main() { - let x = box 'c'; //~ ERROR box expression syntax is experimental - println!("x: {}", x); -} diff --git a/tests/ui/feature-gates/feature-gate-box-expr.stderr b/tests/ui/feature-gates/feature-gate-box-expr.stderr deleted file mode 100644 index af864b25f..000000000 --- a/tests/ui/feature-gates/feature-gate-box-expr.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: box expression syntax is experimental; you can call `Box::new` instead - --> $DIR/feature-gate-box-expr.rs:12:13 - | -LL | let x = box 'c'; - | ^^^^^^^ - | - = note: see issue #49733 <https://github.com/rust-lang/rust/issues/49733> for more information - = help: add `#![feature(box_syntax)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-box_syntax.rs b/tests/ui/feature-gates/feature-gate-box_syntax.rs deleted file mode 100644 index 778660cc0..000000000 --- a/tests/ui/feature-gates/feature-gate-box_syntax.rs +++ /dev/null @@ -1,6 +0,0 @@ -// Test that the use of the box syntax is gated by `box_syntax` feature gate. - -fn main() { - let x = box 3; - //~^ ERROR box expression syntax is experimental; you can call `Box::new` instead -} diff --git a/tests/ui/feature-gates/feature-gate-box_syntax.stderr b/tests/ui/feature-gates/feature-gate-box_syntax.stderr deleted file mode 100644 index dcf8eeed7..000000000 --- a/tests/ui/feature-gates/feature-gate-box_syntax.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0658]: box expression syntax is experimental; you can call `Box::new` instead - --> $DIR/feature-gate-box_syntax.rs:4:13 - | -LL | let x = box 3; - | ^^^^^ - | - = note: see issue #49733 <https://github.com/rust-lang/rust/issues/49733> for more information - = help: add `#![feature(box_syntax)]` to the crate attributes to enable - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-closure_track_caller.rs b/tests/ui/feature-gates/feature-gate-closure_track_caller.rs index a8d63a814..a4c91f3bc 100644 --- a/tests/ui/feature-gates/feature-gate-closure_track_caller.rs +++ b/tests/ui/feature-gates/feature-gate-closure_track_caller.rs @@ -1,7 +1,9 @@ +// edition:2021 #![feature(stmt_expr_attributes)] #![feature(generators)] fn main() { let _closure = #[track_caller] || {}; //~ `#[track_caller]` on closures let _generator = #[track_caller] || { yield; }; //~ `#[track_caller]` on closures + let _future = #[track_caller] async {}; //~ `#[track_caller]` on closures } diff --git a/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr b/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr index ed63d74fe..cf2ea5fe1 100644 --- a/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr +++ b/tests/ui/feature-gates/feature-gate-closure_track_caller.stderr @@ -1,5 +1,5 @@ error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/feature-gate-closure_track_caller.rs:5:20 + --> $DIR/feature-gate-closure_track_caller.rs:6:20 | LL | let _closure = #[track_caller] || {}; | ^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | let _closure = #[track_caller] || {}; = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable error[E0658]: `#[track_caller]` on closures is currently unstable - --> $DIR/feature-gate-closure_track_caller.rs:6:22 + --> $DIR/feature-gate-closure_track_caller.rs:7:22 | LL | let _generator = #[track_caller] || { yield; }; | ^^^^^^^^^^^^^^^ @@ -16,6 +16,15 @@ LL | let _generator = #[track_caller] || { yield; }; = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable -error: aborting due to 2 previous errors +error[E0658]: `#[track_caller]` on closures is currently unstable + --> $DIR/feature-gate-closure_track_caller.rs:8:19 + | +LL | let _future = #[track_caller] async {}; + | ^^^^^^^^^^^^^^^ + | + = note: see issue #87417 <https://github.com/rust-lang/rust/issues/87417> for more information + = help: add `#![feature(closure_track_caller)]` to the crate attributes to enable + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-impl_trait_in_assoc_type.rs b/tests/ui/feature-gates/feature-gate-impl_trait_in_assoc_type.rs new file mode 100644 index 000000000..de0487cdb --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-impl_trait_in_assoc_type.rs @@ -0,0 +1,18 @@ +trait Foo { + type Bar; +} + +impl Foo for () { + type Bar = impl std::fmt::Debug; + //~^ ERROR: `impl Trait` in associated types is unstable +} + +struct Mop; + +impl Mop { + type Bop = impl std::fmt::Debug; + //~^ ERROR: `impl Trait` in associated types is unstable + //~| ERROR: inherent associated types are unstable +} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-impl_trait_in_assoc_type.stderr b/tests/ui/feature-gates/feature-gate-impl_trait_in_assoc_type.stderr new file mode 100644 index 000000000..9a1ded968 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-impl_trait_in_assoc_type.stderr @@ -0,0 +1,30 @@ +error[E0658]: `impl Trait` in associated types is unstable + --> $DIR/feature-gate-impl_trait_in_assoc_type.rs:6:16 + | +LL | type Bar = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information + = help: add `#![feature(impl_trait_in_assoc_type)]` to the crate attributes to enable + +error[E0658]: `impl Trait` in associated types is unstable + --> $DIR/feature-gate-impl_trait_in_assoc_type.rs:13:16 + | +LL | type Bop = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information + = help: add `#![feature(impl_trait_in_assoc_type)]` to the crate attributes to enable + +error[E0658]: inherent associated types are unstable + --> $DIR/feature-gate-impl_trait_in_assoc_type.rs:13:5 + | +LL | type Bop = impl std::fmt::Debug; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information + = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-link_cfg.stderr b/tests/ui/feature-gates/feature-gate-link_cfg.stderr index 8f47d5965..97b6cbca4 100644 --- a/tests/ui/feature-gates/feature-gate-link_cfg.stderr +++ b/tests/ui/feature-gates/feature-gate-link_cfg.stderr @@ -4,7 +4,6 @@ error[E0658]: link cfg is unstable LL | #[link(name = "foo", cfg(foo))] | ^^^^^^^^ | - = note: see issue #37406 <https://github.com/rust-lang/rust/issues/37406> for more information = help: add `#![feature(link_cfg)]` to the crate attributes to enable error: aborting due to previous error diff --git a/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr index 4d79ce3c6..fb39c404c 100644 --- a/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr +++ b/tests/ui/feature-gates/feature-gate-non_exhaustive_omitted_patterns_lint.stderr @@ -115,7 +115,7 @@ LL | A, B, C, = note: the matched value is of type `Foo` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ Foo::B => {} +LL ~ Foo::B => {}, LL + Foo::C => todo!() | diff --git a/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr b/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr index b55106833..853b57052 100644 --- a/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr +++ b/tests/ui/feature-gates/feature-gate-precise_pointer_size_matching.stderr @@ -9,7 +9,7 @@ LL | match 0usize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ 0..=usize::MAX => {} +LL ~ 0..=usize::MAX => {}, LL + _ => todo!() | @@ -24,7 +24,7 @@ LL | match 0isize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ isize::MIN..=isize::MAX => {} +LL ~ isize::MIN..=isize::MAX => {}, LL + _ => todo!() | diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr new file mode 100644 index 000000000..c3a371e25 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.cfg.stderr @@ -0,0 +1,36 @@ +error[E0658]: return type notation is experimental + --> $DIR/feature-gate-return_type_notation.rs:15:17 + | +LL | fn foo<T: Trait<m(): Send>>() {} + | ^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = help: add `#![feature(return_type_notation)]` to the crate attributes to enable + +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/feature-gate-return_type_notation.rs:7:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: parenthesized generic arguments cannot be used in associated type constraints + --> $DIR/feature-gate-return_type_notation.rs:15:17 + | +LL | fn foo<T: Trait<m(): Send>>() {} + | ^-- + | | + | help: remove these parentheses + +error[E0220]: associated type `m` not found for `Trait` + --> $DIR/feature-gate-return_type_notation.rs:15:17 + | +LL | fn foo<T: Trait<m(): Send>>() {} + | ^ associated type `m` not found + +error: aborting due to 3 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0220, E0658. +For more information about an error, try `rustc --explain E0220`. diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr b/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr new file mode 100644 index 000000000..52c90c156 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.no.stderr @@ -0,0 +1,22 @@ +warning: the feature `async_fn_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/feature-gate-return_type_notation.rs:7:12 + | +LL | #![feature(async_fn_in_trait)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: return type notation is experimental + --> $DIR/feature-gate-return_type_notation.rs:15:17 + | +LL | fn foo<T: Trait<m(): Send>>() {} + | ^^^^^^^^^ + | + = note: see issue #109417 <https://github.com/rust-lang/rust/issues/109417> for more information + = help: add `#![feature(return_type_notation)]` to the crate attributes to enable + = warning: unstable syntax can change at any point in the future, causing a hard error! + = note: for more information, see issue #65860 <https://github.com/rust-lang/rust/issues/65860> + +warning: 2 warnings emitted + diff --git a/tests/ui/feature-gates/feature-gate-return_type_notation.rs b/tests/ui/feature-gates/feature-gate-return_type_notation.rs new file mode 100644 index 000000000..5028b9ec9 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-return_type_notation.rs @@ -0,0 +1,22 @@ +// edition: 2021 +// revisions: cfg no + +//[no] check-pass +// Since we're not adding new syntax, `cfg`'d out RTN must pass. + +#![feature(async_fn_in_trait)] +//~^ WARN the feature `async_fn_in_trait` is incomplete + +trait Trait { + async fn m(); +} + +#[cfg(cfg)] +fn foo<T: Trait<m(): Send>>() {} +//[cfg]~^ ERROR return type notation is experimental +//[cfg]~| ERROR parenthesized generic arguments cannot be used in associated type constraints +//[cfg]~| ERROR associated type `m` not found for `Trait` +//[no]~^^^^ WARN return type notation is experimental +//[no]~| WARN unstable syntax can change at any point in the future, causing a hard error! + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr index f647380ef..b1613f638 100644 --- a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -64,6 +64,12 @@ error[E0229]: associated type bindings are not allowed here | LL | impl FnOnce() for Foo1 { | ^^^^^^^^ associated type not allowed here + | +help: parenthesized trait syntax expands to `FnOnce<(), Output=()>` + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:16:6 + | +LL | impl FnOnce() for Foo1 { + | ^^^^^^^^ error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:23:6 diff --git a/tests/ui/feature-gates/test-listing-format-json.rs b/tests/ui/feature-gates/test-listing-format-json.rs new file mode 100644 index 000000000..2dd0e10b5 --- /dev/null +++ b/tests/ui/feature-gates/test-listing-format-json.rs @@ -0,0 +1,18 @@ +// no-prefer-dynamic +// compile-flags: --test +// run-flags: --list --format json -Zunstable-options +// run-fail +// check-run-results +// ignore-nightly +// unset-exec-env:RUSTC_BOOTSTRAP + +#![cfg(test)] +#[test] +fn m_test() {} + +#[test] +#[ignore = "not yet implemented"] +fn z_test() {} + +#[test] +fn a_test() {} diff --git a/tests/ui/feature-gates/test-listing-format-json.run.stderr b/tests/ui/feature-gates/test-listing-format-json.run.stderr new file mode 100644 index 000000000..e81cb81f3 --- /dev/null +++ b/tests/ui/feature-gates/test-listing-format-json.run.stderr @@ -0,0 +1 @@ +error: the option `Z` is only accepted on the nightly compiler diff --git a/tests/ui/fmt/auxiliary/format-string-proc-macro.rs b/tests/ui/fmt/auxiliary/format-string-proc-macro.rs index 1b7ef93f4..0c39ade72 100644 --- a/tests/ui/fmt/auxiliary/format-string-proc-macro.rs +++ b/tests/ui/fmt/auxiliary/format-string-proc-macro.rs @@ -28,25 +28,41 @@ pub fn err_with_input_span(input: TokenStream) -> TokenStream { TokenStream::from(TokenTree::Literal(lit)) } +fn build_format(args: impl Into<TokenStream>) -> TokenStream { + TokenStream::from_iter([ + TokenTree::from(Ident::new("format", Span::call_site())), + TokenTree::from(Punct::new('!', Spacing::Alone)), + TokenTree::from(Group::new(Delimiter::Parenthesis, args.into())), + ]) +} #[proc_macro] pub fn respan_to_invalid_format_literal(input: TokenStream) -> TokenStream { let mut s = Literal::string("{"); s.set_span(input.into_iter().next().unwrap().span()); - TokenStream::from_iter([ - TokenTree::from(Ident::new("format", Span::call_site())), - TokenTree::from(Punct::new('!', Spacing::Alone)), - TokenTree::from(Group::new(Delimiter::Parenthesis, TokenTree::from(s).into())), - ]) + + build_format(TokenTree::from(s)) } #[proc_macro] pub fn capture_a_with_prepended_space_preserve_span(input: TokenStream) -> TokenStream { let mut s = Literal::string(" {a}"); s.set_span(input.into_iter().next().unwrap().span()); - TokenStream::from_iter([ - TokenTree::from(Ident::new("format", Span::call_site())), - TokenTree::from(Punct::new('!', Spacing::Alone)), - TokenTree::from(Group::new(Delimiter::Parenthesis, TokenTree::from(s).into())), - ]) + + build_format(TokenTree::from(s)) +} + +#[proc_macro] +pub fn format_args_captures(_: TokenStream) -> TokenStream { + r#"{ let x = 5; format!("{x}") }"#.parse().unwrap() +} + +#[proc_macro] +pub fn bad_format_args_captures(_: TokenStream) -> TokenStream { + r#"{ let x = 5; format!(concat!("{x}")) }"#.parse().unwrap() +} + +#[proc_macro] +pub fn identity_pm(input: TokenStream) -> TokenStream { + input } diff --git a/tests/ui/fmt/format-args-argument-span.rs b/tests/ui/fmt/format-args-argument-span.rs new file mode 100644 index 000000000..c7acb08f8 --- /dev/null +++ b/tests/ui/fmt/format-args-argument-span.rs @@ -0,0 +1,22 @@ +// check-compile + +struct DisplayOnly; + +impl std::fmt::Display for DisplayOnly { + fn fmt(&self, f: &mut std::fmt::Formatter<'_>) -> std::fmt::Result { + unimplemented!() + } +} + +fn main() { + let x = Some(1); + println!("{x:?} {x} {x:?}"); + //~^ ERROR: `Option<{integer}>` doesn't implement `std::fmt::Display` + println!("{x:?} {x} {x:?}", x = Some(1)); + //~^ ERROR: `Option<{integer}>` doesn't implement `std::fmt::Display` + let x = DisplayOnly; + println!("{x} {x:?} {x}"); + //~^ ERROR: `DisplayOnly` doesn't implement `Debug` + println!("{x} {x:?} {x}", x = DisplayOnly); + //~^ ERROR: `DisplayOnly` doesn't implement `Debug` +} diff --git a/tests/ui/fmt/format-args-argument-span.stderr b/tests/ui/fmt/format-args-argument-span.stderr new file mode 100644 index 000000000..4e2702383 --- /dev/null +++ b/tests/ui/fmt/format-args-argument-span.stderr @@ -0,0 +1,53 @@ +error[E0277]: `Option<{integer}>` doesn't implement `std::fmt::Display` + --> $DIR/format-args-argument-span.rs:13:21 + | +LL | println!("{x:?} {x} {x:?}"); + | ^^^ `Option<{integer}>` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `Option<{integer}>` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `Option<{integer}>` doesn't implement `std::fmt::Display` + --> $DIR/format-args-argument-span.rs:15:37 + | +LL | println!("{x:?} {x} {x:?}", x = Some(1)); + | ^^^^^^^ `Option<{integer}>` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `Option<{integer}>` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `DisplayOnly` doesn't implement `Debug` + --> $DIR/format-args-argument-span.rs:18:19 + | +LL | println!("{x} {x:?} {x}"); + | ^^^^^ `DisplayOnly` cannot be formatted using `{:?}` + | + = help: the trait `Debug` is not implemented for `DisplayOnly` + = note: add `#[derive(Debug)]` to `DisplayOnly` or manually `impl Debug for DisplayOnly` + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `DisplayOnly` with `#[derive(Debug)]` + | +LL + #[derive(Debug)] +LL | struct DisplayOnly; + | + +error[E0277]: `DisplayOnly` doesn't implement `Debug` + --> $DIR/format-args-argument-span.rs:20:35 + | +LL | println!("{x} {x:?} {x}", x = DisplayOnly); + | ^^^^^^^^^^^ `DisplayOnly` cannot be formatted using `{:?}` + | + = help: the trait `Debug` is not implemented for `DisplayOnly` + = note: add `#[derive(Debug)]` to `DisplayOnly` or manually `impl Debug for DisplayOnly` + = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `DisplayOnly` with `#[derive(Debug)]` + | +LL + #[derive(Debug)] +LL | struct DisplayOnly; + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/fmt/format-args-capture-first-literal-is-macro.rs b/tests/ui/fmt/format-args-capture-first-literal-is-macro.rs new file mode 100644 index 000000000..bf5c0dcb5 --- /dev/null +++ b/tests/ui/fmt/format-args-capture-first-literal-is-macro.rs @@ -0,0 +1,21 @@ +// aux-build:format-string-proc-macro.rs + +#[macro_use] +extern crate format_string_proc_macro; + +macro_rules! identity_mbe { + ($tt:tt) => { + $tt + //~^ ERROR there is no argument named `a` + }; +} + +fn main() { + let a = 0; + + format!(identity_pm!("{a}")); + //~^ ERROR there is no argument named `a` + format!(identity_mbe!("{a}")); + format!(concat!("{a}")); + //~^ ERROR there is no argument named `a` +} diff --git a/tests/ui/fmt/format-args-capture-first-literal-is-macro.stderr b/tests/ui/fmt/format-args-capture-first-literal-is-macro.stderr new file mode 100644 index 000000000..4cf3afad7 --- /dev/null +++ b/tests/ui/fmt/format-args-capture-first-literal-is-macro.stderr @@ -0,0 +1,30 @@ +error: there is no argument named `a` + --> $DIR/format-args-capture-first-literal-is-macro.rs:16:26 + | +LL | format!(identity_pm!("{a}")); + | ^^^^^ + | + = note: did you intend to capture a variable `a` from the surrounding scope? + = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro + +error: there is no argument named `a` + --> $DIR/format-args-capture-first-literal-is-macro.rs:8:9 + | +LL | $tt + | ^^^ + | + = note: did you intend to capture a variable `a` from the surrounding scope? + = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro + +error: there is no argument named `a` + --> $DIR/format-args-capture-first-literal-is-macro.rs:19:13 + | +LL | format!(concat!("{a}")); + | ^^^^^^^^^^^^^^ + | + = note: did you intend to capture a variable `a` from the surrounding scope? + = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro + = note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors + diff --git a/tests/ui/fmt/format-args-capture-from-pm-first-arg-macro.rs b/tests/ui/fmt/format-args-capture-from-pm-first-arg-macro.rs new file mode 100644 index 000000000..f67edf5e1 --- /dev/null +++ b/tests/ui/fmt/format-args-capture-from-pm-first-arg-macro.rs @@ -0,0 +1,8 @@ +// aux-build:format-string-proc-macro.rs + +extern crate format_string_proc_macro; + +fn main() { + format_string_proc_macro::bad_format_args_captures!(); + //~^ ERROR there is no argument named `x` +} diff --git a/tests/ui/fmt/format-args-capture-from-pm-first-arg-macro.stderr b/tests/ui/fmt/format-args-capture-from-pm-first-arg-macro.stderr new file mode 100644 index 000000000..bb6a14d88 --- /dev/null +++ b/tests/ui/fmt/format-args-capture-from-pm-first-arg-macro.stderr @@ -0,0 +1,12 @@ +error: there is no argument named `x` + --> $DIR/format-args-capture-from-pm-first-arg-macro.rs:6:5 + | +LL | format_string_proc_macro::bad_format_args_captures!(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: did you intend to capture a variable `x` from the surrounding scope? + = note: to avoid ambiguity, `format_args!` cannot capture variables when the format string is expanded from a macro + = note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/tests/ui/fmt/format-args-capture-issue-106408.rs b/tests/ui/fmt/format-args-capture-issue-106408.rs new file mode 100644 index 000000000..0fd195416 --- /dev/null +++ b/tests/ui/fmt/format-args-capture-issue-106408.rs @@ -0,0 +1,10 @@ +// check-pass +// aux-build:format-string-proc-macro.rs + +extern crate format_string_proc_macro; + +fn main() { + // While literal macros like `format_args!(concat!())` are not supposed to work with implicit + // captures, it should work if the whole invocation comes from a macro expansion (#106408). + format_string_proc_macro::format_args_captures!(); +} diff --git a/tests/ui/fmt/format-args-capture-macro-hygiene-pass.rs b/tests/ui/fmt/format-args-capture-macro-hygiene-pass.rs new file mode 100644 index 000000000..7553fcc4e --- /dev/null +++ b/tests/ui/fmt/format-args-capture-macro-hygiene-pass.rs @@ -0,0 +1,16 @@ +// run-pass + +macro_rules! format_mbe { + ($tt:tt) => { + { + #[allow(unused_variables)] + let a = 123; + format!($tt) + } + }; +} + +fn main() { + let a = 0; + assert_eq!(format_mbe!("{a}"), "0"); +} diff --git a/tests/ui/fmt/ifmt-bad-arg.stderr b/tests/ui/fmt/ifmt-bad-arg.stderr index d716bbe51..bf18fb315 100644 --- a/tests/ui/fmt/ifmt-bad-arg.stderr +++ b/tests/ui/fmt/ifmt-bad-arg.stderr @@ -300,10 +300,9 @@ error[E0308]: mismatched types --> $DIR/ifmt-bad-arg.rs:78:32 | LL | println!("{} {:.*} {}", 1, 3.2, 4); - | ^^^ - | | - | expected `&usize`, found `&{float}` - | arguments to this function are incorrect + | -- ^^^ expected `&usize`, found `&{float}` + | | + | arguments to this function are incorrect | = note: expected reference `&usize` found reference `&{float}` @@ -315,10 +314,9 @@ error[E0308]: mismatched types --> $DIR/ifmt-bad-arg.rs:81:35 | LL | println!("{} {:07$.*} {}", 1, 3.2, 4); - | ^^^ - | | - | expected `&usize`, found `&{float}` - | arguments to this function are incorrect + | -- ^^^ expected `&usize`, found `&{float}` + | | + | arguments to this function are incorrect | = note: expected reference `&usize` found reference `&{float}` diff --git a/tests/ui/fmt/ifmt-unimpl.stderr b/tests/ui/fmt/ifmt-unimpl.stderr index 3480a2ec8..dc2dee3f3 100644 --- a/tests/ui/fmt/ifmt-unimpl.stderr +++ b/tests/ui/fmt/ifmt-unimpl.stderr @@ -2,7 +2,9 @@ error[E0277]: the trait bound `str: UpperHex` is not satisfied --> $DIR/ifmt-unimpl.rs:2:21 | LL | format!("{:X}", "3"); - | ^^^ the trait `UpperHex` is not implemented for `str` + | ---- ^^^ the trait `UpperHex` is not implemented for `str` + | | + | required by a bound introduced by this call | = help: the following other types implement trait `UpperHex`: &T diff --git a/tests/ui/fmt/respanned-literal-issue-106191.rs b/tests/ui/fmt/respanned-literal-issue-106191.rs index 5a18983a3..44642a10f 100644 --- a/tests/ui/fmt/respanned-literal-issue-106191.rs +++ b/tests/ui/fmt/respanned-literal-issue-106191.rs @@ -1,15 +1,10 @@ // aux-build:format-string-proc-macro.rs -// check-fail -// known-bug: #106191 -// unset-rustc-env:RUST_BACKTRACE -// had to be reverted -// error-pattern:unexpectedly panicked -// failure-status:101 -// dont-check-compiler-stderr extern crate format_string_proc_macro; fn main() { format_string_proc_macro::respan_to_invalid_format_literal!("¡"); + //~^ ERROR invalid format string: expected `'}'` but string was terminated format_args!(r#concat!("¡ {")); + //~^ ERROR invalid format string: expected `'}'` but string was terminated } diff --git a/tests/ui/fmt/respanned-literal-issue-106191.stderr b/tests/ui/fmt/respanned-literal-issue-106191.stderr index 16717f422..73a3af65a 100644 --- a/tests/ui/fmt/respanned-literal-issue-106191.stderr +++ b/tests/ui/fmt/respanned-literal-issue-106191.stderr @@ -1,2 +1,19 @@ - query stack during panic: -end of query stack +error: invalid format string: expected `'}'` but string was terminated + --> $DIR/respanned-literal-issue-106191.rs:6:65 + | +LL | format_string_proc_macro::respan_to_invalid_format_literal!("¡"); + | ^^^ expected `'}'` in format string + | + = note: if you intended to print `{`, you can escape it using `{{` + +error: invalid format string: expected `'}'` but string was terminated + --> $DIR/respanned-literal-issue-106191.rs:8:18 + | +LL | format_args!(r#concat!("¡ {")); + | ^^^^^^^^^^^^^^^^^^^^^^^ expected `'}'` in format string + | + = note: if you intended to print `{`, you can escape it using `{{` + = note: this error originates in the macro `concat` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + diff --git a/tests/ui/fn/fn-ptr-trait-int-float-infer-var.rs b/tests/ui/fn/fn-ptr-trait-int-float-infer-var.rs new file mode 100644 index 000000000..eec7da044 --- /dev/null +++ b/tests/ui/fn/fn-ptr-trait-int-float-infer-var.rs @@ -0,0 +1,10 @@ +// check-pass +trait MyCmp { + fn cmp(&self) {} +} +impl MyCmp for f32 {} + +fn main() { + // Ensure that `impl<F: FnPtr> Ord for F` is never considered for int and float infer vars. + 0.0.cmp(); +} diff --git a/tests/ui/fn/fn-ptr-trait.rs b/tests/ui/fn/fn-ptr-trait.rs new file mode 100644 index 000000000..45918ae5b --- /dev/null +++ b/tests/ui/fn/fn-ptr-trait.rs @@ -0,0 +1,9 @@ +#![feature(fn_ptr_trait)] +// check-pass + +use std::marker::FnPtr; + +trait Foo {} +impl<T> Foo for Vec<T> where T: FnPtr {} + +fn main() {} diff --git a/tests/ui/fn/issue-39259.rs b/tests/ui/fn/issue-39259.rs new file mode 100644 index 000000000..5872f1007 --- /dev/null +++ b/tests/ui/fn/issue-39259.rs @@ -0,0 +1,13 @@ +#![feature(fn_traits)] +#![feature(unboxed_closures)] + +struct S; + +impl Fn(u32) -> u32 for S { +//~^ ERROR associated type bindings are not allowed here [E0229] + fn call(&self) -> u32 { + 5 + } +} + +fn main() {} diff --git a/tests/ui/fn/issue-39259.stderr b/tests/ui/fn/issue-39259.stderr new file mode 100644 index 000000000..b656b76bf --- /dev/null +++ b/tests/ui/fn/issue-39259.stderr @@ -0,0 +1,15 @@ +error[E0229]: associated type bindings are not allowed here + --> $DIR/issue-39259.rs:6:17 + | +LL | impl Fn(u32) -> u32 for S { + | ^^^ associated type not allowed here + | +help: parenthesized trait syntax expands to `Fn<(u32,), Output=u32>` + --> $DIR/issue-39259.rs:6:6 + | +LL | impl Fn(u32) -> u32 for S { + | ^^^^^^^^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0229`. diff --git a/tests/ui/generator/clone-impl.stderr b/tests/ui/generator/clone-impl.stderr index a92646b19..64eb47c1a 100644 --- a/tests/ui/generator/clone-impl.stderr +++ b/tests/ui/generator/clone-impl.stderr @@ -110,7 +110,8 @@ LL | fn check_copy<T: Copy>(_x: &T) {} | ^^^^ required by this bound in `check_copy` help: consider annotating `NonClone` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | struct NonClone; | error[E0277]: the trait bound `NonClone: Clone` is not satisfied in `[generator@$DIR/clone-impl.rs:62:25: 62:32]` @@ -134,7 +135,8 @@ LL | fn check_clone<T: Clone>(_x: &T) {} | ^^^^^ required by this bound in `check_clone` help: consider annotating `NonClone` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct NonClone; | error: aborting due to 6 previous errors diff --git a/tests/ui/generator/issue-105084.drop_tracking_mir.stderr b/tests/ui/generator/issue-105084.drop_tracking_mir.stderr index cfc0cf7cd..1cd4c4e4d 100644 --- a/tests/ui/generator/issue-105084.drop_tracking_mir.stderr +++ b/tests/ui/generator/issue-105084.drop_tracking_mir.stderr @@ -1,5 +1,5 @@ error[E0382]: borrow of moved value: `g` - --> $DIR/issue-105084.rs:44:14 + --> $DIR/issue-105084.rs:45:14 | LL | let mut g = || { | ----- move occurs because `g` has type `[generator@$DIR/issue-105084.rs:22:17: 22:19]`, which does not implement the `Copy` trait @@ -23,7 +23,7 @@ LL | let mut h = copy(g.clone()); | ++++++++ error[E0277]: the trait bound `Box<(i32, ())>: Copy` is not satisfied in `[generator@$DIR/issue-105084.rs:22:17: 22:19]` - --> $DIR/issue-105084.rs:38:17 + --> $DIR/issue-105084.rs:39:17 | LL | let mut g = || { | -- within this `[generator@$DIR/issue-105084.rs:22:17: 22:19]` @@ -32,13 +32,13 @@ LL | let mut h = copy(g); | ^^^^ within `[generator@$DIR/issue-105084.rs:22:17: 22:19]`, the trait `Copy` is not implemented for `Box<(i32, ())>` | note: generator does not implement `Copy` as this value is used across a yield - --> $DIR/issue-105084.rs:28:25 + --> $DIR/issue-105084.rs:29:22 | -LL | let t = box (5, yield); - | --------^^^^^- - | | | - | | yield occurs here, with `box (5, yield)` maybe used later - | has type `Box<(i32, ())>` which does not implement `Copy` +LL | Box::new((5, yield)); + | -------------^^^^^-- + | | | + | | yield occurs here, with `Box::new((5, yield))` maybe used later + | has type `Box<(i32, ())>` which does not implement `Copy` note: required by a bound in `copy` --> $DIR/issue-105084.rs:17:12 | diff --git a/tests/ui/generator/issue-105084.rs b/tests/ui/generator/issue-105084.rs index 7c9a97b40..ff9357b76 100644 --- a/tests/ui/generator/issue-105084.rs +++ b/tests/ui/generator/issue-105084.rs @@ -9,7 +9,7 @@ #![feature(generators)] #![feature(generator_clone)] #![feature(generator_trait)] -#![feature(box_syntax)] +#![feature(rustc_attrs, stmt_expr_attributes)] use std::ops::Generator; use std::pin::Pin; @@ -25,7 +25,8 @@ fn main() { // - create a Box that is ignored for trait computations; // - compute fields (and yields); // - assign to `t`. - let t = box (5, yield); + let t = #[rustc_box] + Box::new((5, yield)); drop(t); }; diff --git a/tests/ui/generator/issue-87142.rs b/tests/ui/generator/issue-87142.rs index fc10d04d4..7f670919e 100644 --- a/tests/ui/generator/issue-87142.rs +++ b/tests/ui/generator/issue-87142.rs @@ -4,7 +4,7 @@ // Regression test for #87142 // This test needs the above flags and the "lib" crate type. -#![feature(type_alias_impl_trait, generator_trait, generators)] +#![feature(impl_trait_in_assoc_type, generator_trait, generators)] #![crate_type = "lib"] use std::ops::Generator; diff --git a/tests/ui/generator/non-static-is-unpin.rs b/tests/ui/generator/non-static-is-unpin.rs index 96d0a8e28..17e23f5bc 100644 --- a/tests/ui/generator/non-static-is-unpin.rs +++ b/tests/ui/generator/non-static-is-unpin.rs @@ -1,3 +1,5 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next // run-pass #![feature(generators, generator_trait)] diff --git a/tests/ui/generator/print/generator-print-verbose-1.drop_tracking.stderr b/tests/ui/generator/print/generator-print-verbose-1.drop_tracking.stderr index 7d0a20169..429b202f6 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.drop_tracking.stderr +++ b/tests/ui/generator/print/generator-print-verbose-1.drop_tracking.stderr @@ -10,7 +10,7 @@ note: generator is not `Send` as this value is used across a yield --> $DIR/generator-print-verbose-1.rs:38:9 | LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[749a]::make_non_send_generator::{opaque#0}), [])` which is not `Send` + | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[7d1d]::make_non_send_generator::{opaque#0}), [])` which is not `Send` LL | yield; | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later LL | }; @@ -37,17 +37,17 @@ note: required because it's used within this generator | LL | || { | ^^ -note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [Arc<RefCell<i32>>])` +note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[7d1d]::make_gen2::{opaque#0}), [Arc<RefCell<i32>>])` --> $DIR/generator-print-verbose-1.rs:44:30 | LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])` +note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` --> $DIR/generator-print-verbose-1.rs:50:34 | LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`, `()` + = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])`, `()` note: required because it's used within this generator --> $DIR/generator-print-verbose-1.rs:55:20 | diff --git a/tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr b/tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr index c045b1441..01a30fd2f 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr +++ b/tests/ui/generator/print/generator-print-verbose-1.drop_tracking_mir.stderr @@ -10,7 +10,7 @@ note: generator is not `Send` as this value is used across a yield --> $DIR/generator-print-verbose-1.rs:38:9 | LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[749a]::make_non_send_generator::{opaque#0}), [])` which is not `Send` + | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[7d1d]::make_non_send_generator::{opaque#0}), [])` which is not `Send` LL | yield; | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later note: required by a bound in `require_send` @@ -33,17 +33,17 @@ note: required because it's used within this generator | LL | || { | ^^ -note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [Arc<RefCell<i32>>])` +note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[7d1d]::make_gen2::{opaque#0}), [Arc<RefCell<i32>>])` --> $DIR/generator-print-verbose-1.rs:44:30 | LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])` +note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` --> $DIR/generator-print-verbose-1.rs:50:34 | LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])` + = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` note: required because it's used within this generator --> $DIR/generator-print-verbose-1.rs:55:20 | diff --git a/tests/ui/generator/print/generator-print-verbose-1.no_drop_tracking.stderr b/tests/ui/generator/print/generator-print-verbose-1.no_drop_tracking.stderr index 7d0a20169..429b202f6 100644 --- a/tests/ui/generator/print/generator-print-verbose-1.no_drop_tracking.stderr +++ b/tests/ui/generator/print/generator-print-verbose-1.no_drop_tracking.stderr @@ -10,7 +10,7 @@ note: generator is not `Send` as this value is used across a yield --> $DIR/generator-print-verbose-1.rs:38:9 | LL | let _non_send_gen = make_non_send_generator(); - | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[749a]::make_non_send_generator::{opaque#0}), [])` which is not `Send` + | ------------- has type `Opaque(DefId(0:34 ~ generator_print_verbose_1[7d1d]::make_non_send_generator::{opaque#0}), [])` which is not `Send` LL | yield; | ^^^^^ yield occurs here, with `_non_send_gen` maybe used later LL | }; @@ -37,17 +37,17 @@ note: required because it's used within this generator | LL | || { | ^^ -note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[749a]::make_gen2::{opaque#0}), [Arc<RefCell<i32>>])` +note: required because it appears within the type `Opaque(DefId(0:35 ~ generator_print_verbose_1[7d1d]::make_gen2::{opaque#0}), [Arc<RefCell<i32>>])` --> $DIR/generator-print-verbose-1.rs:44:30 | LL | pub fn make_gen2<T>(t: T) -> impl Generator<Return = T> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])` +note: required because it appears within the type `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])` --> $DIR/generator-print-verbose-1.rs:50:34 | LL | fn make_non_send_generator2() -> impl Generator<Return = Arc<RefCell<i32>>> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[749a]::make_non_send_generator2::{opaque#0}), [])`, `()` + = note: required because it captures the following types: `Opaque(DefId(0:36 ~ generator_print_verbose_1[7d1d]::make_non_send_generator2::{opaque#0}), [])`, `()` note: required because it's used within this generator --> $DIR/generator-print-verbose-1.rs:55:20 | diff --git a/tests/ui/generator/static-not-unpin.stderr b/tests/ui/generator/static-not-unpin.current.stderr index e3859595f..ecd8ca60c 100644 --- a/tests/ui/generator/static-not-unpin.stderr +++ b/tests/ui/generator/static-not-unpin.current.stderr @@ -1,14 +1,15 @@ -error[E0277]: `[static generator@$DIR/static-not-unpin.rs:11:25: 11:34]` cannot be unpinned - --> $DIR/static-not-unpin.rs:14:18 +error[E0277]: `[static generator@$DIR/static-not-unpin.rs:14:25: 14:34]` cannot be unpinned + --> $DIR/static-not-unpin.rs:17:18 | LL | assert_unpin(generator); - | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:11:25: 11:34]` + | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:14:25: 14:34]` | | | required by a bound introduced by this call | - = note: consider using `Box::pin` + = note: consider using the `pin!` macro + consider using `Box::pin` if you need to access the pinned value outside of the current scope note: required by a bound in `assert_unpin` - --> $DIR/static-not-unpin.rs:7:20 + --> $DIR/static-not-unpin.rs:10:20 | LL | fn assert_unpin<T: Unpin>(_: T) { | ^^^^^ required by this bound in `assert_unpin` diff --git a/tests/ui/generator/static-not-unpin.next.stderr b/tests/ui/generator/static-not-unpin.next.stderr new file mode 100644 index 000000000..ecd8ca60c --- /dev/null +++ b/tests/ui/generator/static-not-unpin.next.stderr @@ -0,0 +1,19 @@ +error[E0277]: `[static generator@$DIR/static-not-unpin.rs:14:25: 14:34]` cannot be unpinned + --> $DIR/static-not-unpin.rs:17:18 + | +LL | assert_unpin(generator); + | ------------ ^^^^^^^^^ the trait `Unpin` is not implemented for `[static generator@$DIR/static-not-unpin.rs:14:25: 14:34]` + | | + | required by a bound introduced by this call + | + = note: consider using the `pin!` macro + consider using `Box::pin` if you need to access the pinned value outside of the current scope +note: required by a bound in `assert_unpin` + --> $DIR/static-not-unpin.rs:10:20 + | +LL | fn assert_unpin<T: Unpin>(_: T) { + | ^^^^^ required by this bound in `assert_unpin` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/generator/static-not-unpin.rs b/tests/ui/generator/static-not-unpin.rs index cfcb94737..30d3f2918 100644 --- a/tests/ui/generator/static-not-unpin.rs +++ b/tests/ui/generator/static-not-unpin.rs @@ -1,3 +1,6 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + #![feature(generators)] // normalize-stderr-test "std::pin::Unpin" -> "std::marker::Unpin" diff --git a/tests/ui/generator/yield-in-box.rs b/tests/ui/generator/yield-in-box.rs deleted file mode 100644 index dd6fa7c15..000000000 --- a/tests/ui/generator/yield-in-box.rs +++ /dev/null @@ -1,24 +0,0 @@ -// run-pass -// Test that box-statements with yields in them work. - -#![feature(generators, box_syntax, generator_trait)] -use std::pin::Pin; -use std::ops::Generator; -use std::ops::GeneratorState; - -fn main() { - let x = 0i32; - || { //~ WARN unused generator that must be used - let y = 2u32; - { - let _t = box (&x, yield 0, &y); - } - match box (&x, yield 0, &y) { - _t => {} - } - }; - - let mut g = |_| box yield; - assert_eq!(Pin::new(&mut g).resume(1), GeneratorState::Yielded(())); - assert_eq!(Pin::new(&mut g).resume(2), GeneratorState::Complete(box 2)); -} diff --git a/tests/ui/generator/yield-in-box.stderr b/tests/ui/generator/yield-in-box.stderr deleted file mode 100644 index 9d03ee008..000000000 --- a/tests/ui/generator/yield-in-box.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: unused generator that must be used - --> $DIR/yield-in-box.rs:11:5 - | -LL | / || { -LL | | let y = 2u32; -LL | | { -LL | | let _t = box (&x, yield 0, &y); -... | -LL | | } -LL | | }; - | |_____^ - | - = note: generators are lazy and do nothing unless resumed - = note: `#[warn(unused_must_use)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/generic-associated-types/bugs/issue-100013.stderr b/tests/ui/generic-associated-types/bugs/issue-100013.stderr index 9db124a81..86dbad84d 100644 --- a/tests/ui/generic-associated-types/bugs/issue-100013.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-100013.stderr @@ -28,12 +28,12 @@ LL | | async {}.await; // a yield point LL | | } | |_____^ | -note: the lifetime defined here... +note: the lifetime `'b` defined here... --> $DIR/issue-100013.rs:21:14 | LL | fn call2<'a, 'b, I: FutureIterator>() -> impl Send { | ^^ -note: ...must outlive the lifetime defined here +note: ...must outlive the lifetime `'a` defined here --> $DIR/issue-100013.rs:21:10 | LL | fn call2<'a, 'b, I: FutureIterator>() -> impl Send { @@ -62,12 +62,12 @@ LL | | async {}.await; // a yield point LL | | } | |_____^ | -note: the lifetime defined here... +note: the lifetime `'b` defined here... --> $DIR/issue-100013.rs:28:18 | LL | fn call3<'a: 'b, 'b, I: FutureIterator>() -> impl Send { | ^^ -note: ...must outlive the lifetime defined here +note: ...must outlive the lifetime `'a` defined here --> $DIR/issue-100013.rs:28:10 | LL | fn call3<'a: 'b, 'b, I: FutureIterator>() -> impl Send { diff --git a/tests/ui/generic-associated-types/gat-bounds-normalize-pred.rs b/tests/ui/generic-associated-types/gat-bounds-normalize-pred.rs new file mode 100644 index 000000000..b43f98228 --- /dev/null +++ b/tests/ui/generic-associated-types/gat-bounds-normalize-pred.rs @@ -0,0 +1,17 @@ +// check-pass + +trait Foo { + type Assoc<T>: PartialEq<Self::Assoc<i32>>; +} + +impl Foo for () { + type Assoc<T> = Wrapper<T>; +} + +struct Wrapper<T>(T); + +impl<T> PartialEq<Wrapper<i32>> for Wrapper<T> { + fn eq(&self, _other: &Wrapper<i32>) -> bool { true } +} + +fn main() {} diff --git a/tests/ui/generic-associated-types/issue-86218-2.rs b/tests/ui/generic-associated-types/issue-86218-2.rs index 63c839ea8..8a5e4a0f3 100644 --- a/tests/ui/generic-associated-types/issue-86218-2.rs +++ b/tests/ui/generic-associated-types/issue-86218-2.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] pub trait Stream { type Item; @@ -17,7 +17,9 @@ trait Yay<AdditionalValue> { impl<T> Yay<T> for () { type InnerStream<'s> = impl Stream<Item = i32> + 's; - fn foo<'s>() -> Self::InnerStream<'s> { () } + fn foo<'s>() -> Self::InnerStream<'s> { + () + } } fn main() {} diff --git a/tests/ui/generic-associated-types/issue-86218.rs b/tests/ui/generic-associated-types/issue-86218.rs index b2c3071f0..61cfdd35a 100644 --- a/tests/ui/generic-associated-types/issue-86218.rs +++ b/tests/ui/generic-associated-types/issue-86218.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] pub trait Stream { type Item; @@ -18,7 +18,9 @@ trait Yay<AdditionalValue> { impl<'a> Yay<&'a ()> for () { type InnerStream<'s> = impl Stream<Item = i32> + 's; //^ ERROR does not fulfill the required lifetime - fn foo<'s>() -> Self::InnerStream<'s> { () } + fn foo<'s>() -> Self::InnerStream<'s> { + () + } } fn main() {} diff --git a/tests/ui/generic-associated-types/issue-87258_a.rs b/tests/ui/generic-associated-types/issue-87258_a.rs index 9ab683d3d..6f737b21f 100644 --- a/tests/ui/generic-associated-types/issue-87258_a.rs +++ b/tests/ui/generic-associated-types/issue-87258_a.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] // See https://github.com/rust-lang/rust/issues/87258#issuecomment-883293367 diff --git a/tests/ui/generic-associated-types/issue-87429-associated-type-default.stderr b/tests/ui/generic-associated-types/issue-87429-associated-type-default.stderr index b1abe012b..a44bb6993 100644 --- a/tests/ui/generic-associated-types/issue-87429-associated-type-default.stderr +++ b/tests/ui/generic-associated-types/issue-87429-associated-type-default.stderr @@ -12,7 +12,8 @@ LL | type Member<'a>: for<'b> PartialEq<Self::Member<'b>> = Foo; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Family2::Member` help: consider annotating `Foo` with `#[derive(PartialEq)]` | -LL | #[derive(PartialEq)] +LL + #[derive(PartialEq)] +LL | struct Foo; | error: aborting due to previous error diff --git a/tests/ui/generic-associated-types/issue-87429-specialization.stderr b/tests/ui/generic-associated-types/issue-87429-specialization.stderr index 11c4ebf60..c259c89a7 100644 --- a/tests/ui/generic-associated-types/issue-87429-specialization.stderr +++ b/tests/ui/generic-associated-types/issue-87429-specialization.stderr @@ -22,7 +22,8 @@ LL | type Member<'a>: for<'b> PartialEq<Self::Member<'b>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Family::Member` help: consider annotating `Foo` with `#[derive(PartialEq)]` | -LL | #[derive(PartialEq)] +LL + #[derive(PartialEq)] +LL | struct Foo; | error: aborting due to previous error; 1 warning emitted diff --git a/tests/ui/generic-associated-types/issue-88595.rs b/tests/ui/generic-associated-types/issue-88595.rs index 24641ee1f..5a40a6129 100644 --- a/tests/ui/generic-associated-types/issue-88595.rs +++ b/tests/ui/generic-associated-types/issue-88595.rs @@ -1,7 +1,8 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] fn main() {} +#[rustfmt::skip] trait A<'a> { type B<'b>: Clone // FIXME(generic_associated_types): Remove one of the below bounds diff --git a/tests/ui/generic-associated-types/issue-88595.stderr b/tests/ui/generic-associated-types/issue-88595.stderr index bcefc8066..79d3479af 100644 --- a/tests/ui/generic-associated-types/issue-88595.stderr +++ b/tests/ui/generic-associated-types/issue-88595.stderr @@ -1,11 +1,11 @@ error: non-defining opaque type use in defining scope - --> $DIR/issue-88595.rs:20:35 + --> $DIR/issue-88595.rs:21:35 | LL | fn a(&'a self) -> Self::B<'a> {} | ^^ | note: lifetime used multiple times - --> $DIR/issue-88595.rs:17:6 + --> $DIR/issue-88595.rs:18:6 | LL | impl<'a> A<'a> for C { | ^^ diff --git a/tests/ui/generic-associated-types/issue-89008.rs b/tests/ui/generic-associated-types/issue-89008.rs index 669dbafb5..94b07e674 100644 --- a/tests/ui/generic-associated-types/issue-89008.rs +++ b/tests/ui/generic-associated-types/issue-89008.rs @@ -1,7 +1,7 @@ // check-pass // edition:2021 -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] use std::future::Future; use std::marker::PhantomData; diff --git a/tests/ui/generic-associated-types/issue-90014.rs b/tests/ui/generic-associated-types/issue-90014.rs index 55db95a6d..c4d762796 100644 --- a/tests/ui/generic-associated-types/issue-90014.rs +++ b/tests/ui/generic-associated-types/issue-90014.rs @@ -1,11 +1,13 @@ // edition:2018 -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] use std::future::Future; trait MakeFut { - type Fut<'a> where Self: 'a; + type Fut<'a> + where + Self: 'a; fn make_fut<'a>(&'a self) -> Self::Fut<'a>; } diff --git a/tests/ui/generic-associated-types/issue-90014.stderr b/tests/ui/generic-associated-types/issue-90014.stderr index b4b1bc7da..0d49398ca 100644 --- a/tests/ui/generic-associated-types/issue-90014.stderr +++ b/tests/ui/generic-associated-types/issue-90014.stderr @@ -1,14 +1,14 @@ error[E0477]: the type `&mut ()` does not fulfill the required lifetime - --> $DIR/issue-90014.rs:13:20 + --> $DIR/issue-90014.rs:15:20 | -LL | type Fut<'a> where Self: 'a; +LL | type Fut<'a> | ------------ definition of `Fut` from trait ... LL | type Fut<'a> = impl Future<Output = ()>; | ^^^^^^^^^^^^^^^^^^^^^^^^ | note: type must outlive the lifetime `'a` as defined here - --> $DIR/issue-90014.rs:13:14 + --> $DIR/issue-90014.rs:15:14 | LL | type Fut<'a> = impl Future<Output = ()>; | ^^ diff --git a/tests/ui/generics/auxiliary/foreign-generic-mismatch.rs b/tests/ui/generics/auxiliary/foreign-generic-mismatch.rs new file mode 100644 index 000000000..d89c1e036 --- /dev/null +++ b/tests/ui/generics/auxiliary/foreign-generic-mismatch.rs @@ -0,0 +1,3 @@ +pub fn const_arg<const N: usize, T>() {} + +pub fn lt_arg<'a: 'a>() {} diff --git a/tests/ui/generics/foreign-generic-mismatch.rs b/tests/ui/generics/foreign-generic-mismatch.rs new file mode 100644 index 000000000..403fd73d7 --- /dev/null +++ b/tests/ui/generics/foreign-generic-mismatch.rs @@ -0,0 +1,10 @@ +// aux-build: foreign-generic-mismatch.rs + +extern crate foreign_generic_mismatch; + +fn main() { + foreign_generic_mismatch::const_arg::<()>(); + //~^ ERROR function takes 2 generic arguments but 1 generic argument was supplied + foreign_generic_mismatch::lt_arg::<'static, 'static>(); + //~^ ERROR function takes 1 lifetime argument but 2 lifetime arguments were supplied +} diff --git a/tests/ui/generics/foreign-generic-mismatch.stderr b/tests/ui/generics/foreign-generic-mismatch.stderr new file mode 100644 index 000000000..5322b3f91 --- /dev/null +++ b/tests/ui/generics/foreign-generic-mismatch.stderr @@ -0,0 +1,35 @@ +error[E0107]: function takes 2 generic arguments but 1 generic argument was supplied + --> $DIR/foreign-generic-mismatch.rs:6:31 + | +LL | foreign_generic_mismatch::const_arg::<()>(); + | ^^^^^^^^^ -- supplied 1 generic argument + | | + | expected 2 generic arguments + | +note: function defined here, with 2 generic parameters: `N`, `T` + --> $DIR/auxiliary/foreign-generic-mismatch.rs:1:8 + | +LL | pub fn const_arg<const N: usize, T>() {} + | ^^^^^^^^^ -------------- - +help: add missing generic argument + | +LL | foreign_generic_mismatch::const_arg::<(), T>(); + | +++ + +error[E0107]: function takes 1 lifetime argument but 2 lifetime arguments were supplied + --> $DIR/foreign-generic-mismatch.rs:8:31 + | +LL | foreign_generic_mismatch::lt_arg::<'static, 'static>(); + | ^^^^^^ ------- help: remove this lifetime argument + | | + | expected 1 lifetime argument + | +note: function defined here, with 1 lifetime parameter: `'a` + --> $DIR/auxiliary/foreign-generic-mismatch.rs:3:8 + | +LL | pub fn lt_arg<'a: 'a>() {} + | ^^^^^^ -- + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/slightly-nice-generic-literal-messages.rs b/tests/ui/generics/slightly-nice-generic-literal-messages.rs index 268009f65..268009f65 100644 --- a/tests/ui/slightly-nice-generic-literal-messages.rs +++ b/tests/ui/generics/slightly-nice-generic-literal-messages.rs diff --git a/tests/ui/slightly-nice-generic-literal-messages.stderr b/tests/ui/generics/slightly-nice-generic-literal-messages.stderr index 83ef522ab..83ef522ab 100644 --- a/tests/ui/slightly-nice-generic-literal-messages.stderr +++ b/tests/ui/generics/slightly-nice-generic-literal-messages.stderr diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs b/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs index f55566602..4b14a314e 100644 --- a/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs +++ b/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.rs @@ -10,44 +10,31 @@ macro_rules! m { fn main() { m!(0, ..u8::MIN); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper m!(0, ..u16::MIN); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper m!(0, ..u32::MIN); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper m!(0, ..u64::MIN); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper m!(0, ..u128::MIN); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper m!(0, ..i8::MIN); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper m!(0, ..i16::MIN); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper m!(0, ..i32::MIN); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper m!(0, ..i64::MIN); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper m!(0, ..i128::MIN); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper m!(0f32, ..f32::NEG_INFINITY); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper m!(0f64, ..f64::NEG_INFINITY); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper m!('a', ..'\u{0}'); //~^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper } diff --git a/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr b/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr index 56b224a85..e9702bb38 100644 --- a/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr +++ b/tests/ui/half-open-range-patterns/half-open-range-pats-thir-lower-empty.stderr @@ -5,155 +5,77 @@ LL | m!(0, ..u8::MIN); | ^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:14:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:13:11 | LL | m!(0, ..u16::MIN); | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:17:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:15:11 | LL | m!(0, ..u32::MIN); | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:20:11 - | -LL | m!(0, ..u64::MIN); - | ^^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:23:11 - | -LL | m!(0, ..u128::MIN); - | ^^^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:27:11 - | -LL | m!(0, ..i8::MIN); - | ^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:30:11 - | -LL | m!(0, ..i16::MIN); - | ^^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:33:11 - | -LL | m!(0, ..i32::MIN); - | ^^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:36:11 - | -LL | m!(0, ..i64::MIN); - | ^^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:39:11 - | -LL | m!(0, ..i128::MIN); - | ^^^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:43:14 - | -LL | m!(0f32, ..f32::NEG_INFINITY); - | ^^^^^^^^^^^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:46:14 - | -LL | m!(0f64, ..f64::NEG_INFINITY); - | ^^^^^^^^^^^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:50:13 - | -LL | m!('a', ..'\u{0}'); - | ^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:11:11 - | -LL | m!(0, ..u8::MIN); - | ^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:14:11 - | -LL | m!(0, ..u16::MIN); - | ^^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper --> $DIR/half-open-range-pats-thir-lower-empty.rs:17:11 | -LL | m!(0, ..u32::MIN); - | ^^^^^^^^^^ - -error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:20:11 - | LL | m!(0, ..u64::MIN); | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:23:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:19:11 | LL | m!(0, ..u128::MIN); | ^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:27:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:22:11 | LL | m!(0, ..i8::MIN); | ^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:30:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:24:11 | LL | m!(0, ..i16::MIN); | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:33:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:26:11 | LL | m!(0, ..i32::MIN); | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:36:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:28:11 | LL | m!(0, ..i64::MIN); | ^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:39:11 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:30:11 | LL | m!(0, ..i128::MIN); | ^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:43:14 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:33:14 | LL | m!(0f32, ..f32::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:46:14 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:35:14 | LL | m!(0f64, ..f64::NEG_INFINITY); | ^^^^^^^^^^^^^^^^^^^ error[E0579]: lower range bound must be less than upper - --> $DIR/half-open-range-pats-thir-lower-empty.rs:50:13 + --> $DIR/half-open-range-pats-thir-lower-empty.rs:38:13 | LL | m!('a', ..'\u{0}'); | ^^^^^^^^^ -error: aborting due to 26 previous errors +error: aborting due to 13 previous errors For more information about this error, try `rustc --explain E0579`. diff --git a/tests/ui/higher-rank-trait-bounds/fn-ptr.classic.stderr b/tests/ui/higher-rank-trait-bounds/fn-ptr.classic.stderr new file mode 100644 index 000000000..9af6bc45c --- /dev/null +++ b/tests/ui/higher-rank-trait-bounds/fn-ptr.classic.stderr @@ -0,0 +1,19 @@ +error[E0277]: expected a `Fn<(&'w (),)>` closure, found `fn(&'w ())` + --> $DIR/fn-ptr.rs:12:5 + | +LL | ice(); + | ^^^ expected an `Fn<(&'w (),)>` closure, found `fn(&'w ())` + | + = help: the trait `for<'w> Fn<(&'w (),)>` is not implemented for `fn(&'w ())` +note: required by a bound in `ice` + --> $DIR/fn-ptr.rs:7:25 + | +LL | fn ice() + | --- required by a bound in this function +LL | where +LL | for<'w> fn(&'w ()): Fn(&'w ()), + | ^^^^^^^^^^ required by this bound in `ice` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/higher-rank-trait-bounds/fn-ptr.rs b/tests/ui/higher-rank-trait-bounds/fn-ptr.rs new file mode 100644 index 000000000..853160f96 --- /dev/null +++ b/tests/ui/higher-rank-trait-bounds/fn-ptr.rs @@ -0,0 +1,14 @@ +// revisions: classic next +//[next] compile-flags: -Ztrait-solver=next +//[next] check-pass + +fn ice() +where + for<'w> fn(&'w ()): Fn(&'w ()), +{ +} + +fn main() { + ice(); + //[classic]~^ ERROR expected a `Fn<(&'w (),)>` closure, found `fn(&'w ())` +} diff --git a/tests/ui/higher-rank-trait-bounds/issue-95230.new.stderr b/tests/ui/higher-rank-trait-bounds/issue-95230.new.stderr new file mode 100644 index 000000000..d4bc5b672 --- /dev/null +++ b/tests/ui/higher-rank-trait-bounds/issue-95230.new.stderr @@ -0,0 +1,19 @@ +error[E0275]: overflow evaluating the requirement `for<'a> &'a mut Bar well-formed` + --> $DIR/issue-95230.rs:9:13 + | +LL | for<'a> &'a mut Self:; + | ^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_95230`) +note: required by a bound in `Bar` + --> $DIR/issue-95230.rs:9:13 + | +LL | pub struct Bar + | --- required by a bound in this struct +LL | where +LL | for<'a> &'a mut Self:; + | ^^^^^^^^^^^^ required by this bound in `Bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/higher-rank-trait-bounds/issue-95230.rs b/tests/ui/higher-rank-trait-bounds/issue-95230.rs index 92c506eab..769b6a925 100644 --- a/tests/ui/higher-rank-trait-bounds/issue-95230.rs +++ b/tests/ui/higher-rank-trait-bounds/issue-95230.rs @@ -1,4 +1,8 @@ -// check-pass +// revisions: old new +//[new] compile-flags: -Ztrait-solver=next +//[old] check-pass +//[new] known-bug: #109764 + pub struct Bar where diff --git a/tests/ui/hygiene/arguments.rs b/tests/ui/hygiene/arguments.rs index f0f732f4c..ab58301d4 100644 --- a/tests/ui/hygiene/arguments.rs +++ b/tests/ui/hygiene/arguments.rs @@ -1,5 +1,3 @@ -// ignore-pretty pretty-printing is unhygienic - #![feature(decl_macro)] macro m($t:ty, $e:expr) { diff --git a/tests/ui/hygiene/arguments.stderr b/tests/ui/hygiene/arguments.stderr index d072086e0..714178375 100644 --- a/tests/ui/hygiene/arguments.stderr +++ b/tests/ui/hygiene/arguments.stderr @@ -1,5 +1,5 @@ error[E0412]: cannot find type `S` in this scope - --> $DIR/arguments.rs:16:8 + --> $DIR/arguments.rs:14:8 | LL | m!(S, S); | ^ not found in this scope diff --git a/tests/ui/hygiene/assoc_item_ctxt.rs b/tests/ui/hygiene/assoc_item_ctxt.rs index 65593d1d5..f09f81a5d 100644 --- a/tests/ui/hygiene/assoc_item_ctxt.rs +++ b/tests/ui/hygiene/assoc_item_ctxt.rs @@ -1,5 +1,3 @@ -// ignore-pretty pretty-printing is unhygienic - #![feature(decl_macro)] #![allow(unused)] diff --git a/tests/ui/hygiene/assoc_item_ctxt.stderr b/tests/ui/hygiene/assoc_item_ctxt.stderr index d65716ec2..effa9e8d6 100644 --- a/tests/ui/hygiene/assoc_item_ctxt.stderr +++ b/tests/ui/hygiene/assoc_item_ctxt.stderr @@ -1,5 +1,5 @@ error[E0407]: method `method` is not a member of trait `Tr` - --> $DIR/assoc_item_ctxt.rs:35:13 + --> $DIR/assoc_item_ctxt.rs:33:13 | LL | fn method() {} | ^^^------^^^^^ @@ -13,7 +13,7 @@ LL | mac_trait_impl!(); = note: this error originates in the macro `mac_trait_impl` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0046]: not all trait items implemented, missing: `method` - --> $DIR/assoc_item_ctxt.rs:34:9 + --> $DIR/assoc_item_ctxt.rs:32:9 | LL | fn method(); | ------------ `method` from trait diff --git a/tests/ui/hygiene/assoc_ty_bindings.rs b/tests/ui/hygiene/assoc_ty_bindings.rs index 0567beab9..a78612749 100644 --- a/tests/ui/hygiene/assoc_ty_bindings.rs +++ b/tests/ui/hygiene/assoc_ty_bindings.rs @@ -1,5 +1,4 @@ // check-pass -// ignore-pretty pretty-printing is unhygienic #![feature(decl_macro, associated_type_defaults)] diff --git a/tests/ui/hygiene/auxiliary/legacy_interaction.rs b/tests/ui/hygiene/auxiliary/legacy_interaction.rs index 90d5243b7..3293e346d 100644 --- a/tests/ui/hygiene/auxiliary/legacy_interaction.rs +++ b/tests/ui/hygiene/auxiliary/legacy_interaction.rs @@ -1,5 +1,3 @@ -// ignore-pretty pretty-printing is unhygienic - #[macro_export] macro_rules! m { () => { diff --git a/tests/ui/hygiene/fields.rs b/tests/ui/hygiene/fields.rs index 7a417b46f..86b3d8151 100644 --- a/tests/ui/hygiene/fields.rs +++ b/tests/ui/hygiene/fields.rs @@ -1,5 +1,3 @@ -// ignore-pretty pretty-printing is unhygienic - #![feature(decl_macro)] mod foo { diff --git a/tests/ui/hygiene/fields.stderr b/tests/ui/hygiene/fields.stderr index 978120b1f..99252c4b7 100644 --- a/tests/ui/hygiene/fields.stderr +++ b/tests/ui/hygiene/fields.stderr @@ -1,5 +1,5 @@ error: type `foo::S` is private - --> $DIR/fields.rs:15:17 + --> $DIR/fields.rs:13:17 | LL | let s = S { x: 0 }; | ^^^^^^^^^^ private type @@ -10,7 +10,7 @@ LL | let s = foo::m!(S, x); = note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `foo::S` is private - --> $DIR/fields.rs:16:17 + --> $DIR/fields.rs:14:17 | LL | let _ = s.x; | ^ private type @@ -21,7 +21,7 @@ LL | let s = foo::m!(S, x); = note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `T` is private - --> $DIR/fields.rs:18:17 + --> $DIR/fields.rs:16:17 | LL | let t = T(0); | ^^^^ private type @@ -32,7 +32,7 @@ LL | let s = foo::m!(S, x); = note: this error originates in the macro `foo::m` (in Nightly builds, run with -Z macro-backtrace for more info) error: type `T` is private - --> $DIR/fields.rs:19:17 + --> $DIR/fields.rs:17:17 | LL | let _ = t.0; | ^ private type diff --git a/tests/ui/hygiene/generic_params.rs b/tests/ui/hygiene/generic_params.rs index 3b6216c3e..b42152955 100644 --- a/tests/ui/hygiene/generic_params.rs +++ b/tests/ui/hygiene/generic_params.rs @@ -1,7 +1,6 @@ // Ensure that generic parameters always have modern hygiene. // check-pass -// ignore-pretty pretty-printing is unhygienic #![feature(decl_macro, rustc_attrs)] diff --git a/tests/ui/hygiene/globs.stderr b/tests/ui/hygiene/globs.stderr index c01901be5..180172644 100644 --- a/tests/ui/hygiene/globs.stderr +++ b/tests/ui/hygiene/globs.stderr @@ -13,7 +13,7 @@ LL | g(); | ~ help: consider importing this function | -LL | use foo::f; +LL + use foo::f; | error[E0425]: cannot find function `g` in this scope @@ -39,7 +39,7 @@ LL | f(); | ~ help: consider importing this function | -LL | use bar::g; +LL + use bar::g; | error[E0425]: cannot find function `f` in this scope diff --git a/tests/ui/hygiene/impl_items.rs b/tests/ui/hygiene/impl_items.rs index ddb25c06b..51088e369 100644 --- a/tests/ui/hygiene/impl_items.rs +++ b/tests/ui/hygiene/impl_items.rs @@ -1,5 +1,3 @@ -// ignore-pretty pretty-printing is unhygienic - #![feature(decl_macro)] mod foo { diff --git a/tests/ui/hygiene/impl_items.stderr b/tests/ui/hygiene/impl_items.stderr index 46a250038..32ba3741a 100644 --- a/tests/ui/hygiene/impl_items.stderr +++ b/tests/ui/hygiene/impl_items.stderr @@ -1,5 +1,5 @@ error: type `for<'a> fn(&'a foo::S) {foo::S::f}` is private - --> $DIR/impl_items.rs:12:23 + --> $DIR/impl_items.rs:10:23 | LL | let _: () = S.f(); | ^ private type diff --git a/tests/ui/hygiene/intercrate.rs b/tests/ui/hygiene/intercrate.rs index d9b5b789e..2de62f6af 100644 --- a/tests/ui/hygiene/intercrate.rs +++ b/tests/ui/hygiene/intercrate.rs @@ -1,5 +1,3 @@ -// ignore-pretty pretty-printing is unhygienic - // aux-build:intercrate.rs #![feature(decl_macro)] diff --git a/tests/ui/hygiene/intercrate.stderr b/tests/ui/hygiene/intercrate.stderr index 91358b279..f108617fb 100644 --- a/tests/ui/hygiene/intercrate.stderr +++ b/tests/ui/hygiene/intercrate.stderr @@ -1,5 +1,5 @@ error: type `fn() -> u32 {foo::bar::f}` is private - --> $DIR/intercrate.rs:10:16 + --> $DIR/intercrate.rs:8:16 | LL | assert_eq!(intercrate::foo::m!(), 1); | ^^^^^^^^^^^^^^^^^^^^^ private type diff --git a/tests/ui/hygiene/issue-47311.rs b/tests/ui/hygiene/issue-47311.rs index 5c2379a8a..3f1b73973 100644 --- a/tests/ui/hygiene/issue-47311.rs +++ b/tests/ui/hygiene/issue-47311.rs @@ -1,5 +1,4 @@ // check-pass -// ignore-pretty pretty-printing is unhygienic #![feature(decl_macro)] #![allow(unused)] diff --git a/tests/ui/hygiene/issue-47312.rs b/tests/ui/hygiene/issue-47312.rs index bbcb3a7f3..c8b5c3676 100644 --- a/tests/ui/hygiene/issue-47312.rs +++ b/tests/ui/hygiene/issue-47312.rs @@ -1,5 +1,4 @@ // check-pass -// ignore-pretty pretty-printing is unhygienic #![feature(decl_macro)] #![allow(unused)] diff --git a/tests/ui/hygiene/items.rs b/tests/ui/hygiene/items.rs index 1c625a972..a7ed749f5 100644 --- a/tests/ui/hygiene/items.rs +++ b/tests/ui/hygiene/items.rs @@ -1,5 +1,4 @@ // check-pass -// ignore-pretty pretty-printing is unhygienic #![feature(decl_macro)] diff --git a/tests/ui/hygiene/legacy_interaction.rs b/tests/ui/hygiene/legacy_interaction.rs index 52008eed5..4d150baf5 100644 --- a/tests/ui/hygiene/legacy_interaction.rs +++ b/tests/ui/hygiene/legacy_interaction.rs @@ -1,6 +1,5 @@ // check-pass #![allow(dead_code)] -// ignore-pretty pretty-printing is unhygienic // aux-build:legacy_interaction.rs diff --git a/tests/ui/hygiene/lexical.rs b/tests/ui/hygiene/lexical.rs index 3d25c7209..81de974c2 100644 --- a/tests/ui/hygiene/lexical.rs +++ b/tests/ui/hygiene/lexical.rs @@ -1,5 +1,4 @@ // check-pass -// ignore-pretty pretty-printing is unhygienic #![feature(decl_macro)] diff --git a/tests/ui/hygiene/no_implicit_prelude.stderr b/tests/ui/hygiene/no_implicit_prelude.stderr index c48c84035..96187b1c5 100644 --- a/tests/ui/hygiene/no_implicit_prelude.stderr +++ b/tests/ui/hygiene/no_implicit_prelude.stderr @@ -10,7 +10,7 @@ LL | Vec::new(); = note: this error originates in the macro `::bar::m` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing this struct | -LL | use std::vec::Vec; +LL + use std::vec::Vec; | error[E0599]: no method named `clone` found for unit type `()` in the current scope @@ -26,7 +26,7 @@ LL | ().clone() = note: this error originates in the macro `::bar::m` (in Nightly builds, run with -Z macro-backtrace for more info) help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use std::clone::Clone; +LL + use std::clone::Clone; | error: aborting due to 2 previous errors diff --git a/tests/ui/hygiene/panic-location.run.stderr b/tests/ui/hygiene/panic-location.run.stderr index 1c6a7b02f..a7252a400 100644 --- a/tests/ui/hygiene/panic-location.run.stderr +++ b/tests/ui/hygiene/panic-location.run.stderr @@ -1,2 +1,2 @@ -thread 'main' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:525:5 +thread 'main' panicked at 'capacity overflow', library/alloc/src/raw_vec.rs:524:5 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/hygiene/specialization.rs b/tests/ui/hygiene/specialization.rs index 656aa880a..b8c4c1b0d 100644 --- a/tests/ui/hygiene/specialization.rs +++ b/tests/ui/hygiene/specialization.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty pretty-printing is unhygienic #![feature(decl_macro)] diff --git a/tests/ui/hygiene/trait_items-2.rs b/tests/ui/hygiene/trait_items-2.rs index 39edfc37d..cd9122656 100644 --- a/tests/ui/hygiene/trait_items-2.rs +++ b/tests/ui/hygiene/trait_items-2.rs @@ -1,5 +1,4 @@ // check-pass -// ignore-pretty pretty-printing is unhygienic #![feature(decl_macro)] diff --git a/tests/ui/hygiene/trait_items.stderr b/tests/ui/hygiene/trait_items.stderr index 80bdbe0e2..f303534c7 100644 --- a/tests/ui/hygiene/trait_items.stderr +++ b/tests/ui/hygiene/trait_items.stderr @@ -14,7 +14,7 @@ LL | pub macro m() { ().f() } = note: this error originates in the macro `::baz::m` (in Nightly builds, run with -Z macro-backtrace for more info) help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use foo::T; +LL + use foo::T; | error: aborting due to previous error diff --git a/tests/ui/hygiene/wrap_unhygienic_example.rs b/tests/ui/hygiene/wrap_unhygienic_example.rs index 50c6b35ab..f6b481568 100644 --- a/tests/ui/hygiene/wrap_unhygienic_example.rs +++ b/tests/ui/hygiene/wrap_unhygienic_example.rs @@ -1,5 +1,4 @@ // check-pass -// ignore-pretty pretty-printing is unhygienic // aux-build:my_crate.rs // aux-build:unhygienic_example.rs diff --git a/tests/ui/hygiene/xcrate.rs b/tests/ui/hygiene/xcrate.rs index 6981ce3f6..6366bebb5 100644 --- a/tests/ui/hygiene/xcrate.rs +++ b/tests/ui/hygiene/xcrate.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty pretty-printing is unhygienic // aux-build:xcrate.rs diff --git a/tests/ui/impl-trait/associated-impl-trait-type-generic-trait.rs b/tests/ui/impl-trait/associated-impl-trait-type-generic-trait.rs index 6c7c46b0e..0908a0bf3 100644 --- a/tests/ui/impl-trait/associated-impl-trait-type-generic-trait.rs +++ b/tests/ui/impl-trait/associated-impl-trait-type-generic-trait.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] // build-pass (FIXME(62277): could be check-pass?) trait Bar {} diff --git a/tests/ui/impl-trait/associated-impl-trait-type-trivial.rs b/tests/ui/impl-trait/associated-impl-trait-type-trivial.rs index cdda341ca..b5ea90bb0 100644 --- a/tests/ui/impl-trait/associated-impl-trait-type-trivial.rs +++ b/tests/ui/impl-trait/associated-impl-trait-type-trivial.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] // build-pass (FIXME(62277): could be check-pass?) trait Bar {} diff --git a/tests/ui/impl-trait/associated-impl-trait-type.rs b/tests/ui/impl-trait/associated-impl-trait-type.rs index d0661d66f..f5981261c 100644 --- a/tests/ui/impl-trait/associated-impl-trait-type.rs +++ b/tests/ui/impl-trait/associated-impl-trait-type.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] // build-pass (FIXME(62277): could be check-pass?) trait Bar {} diff --git a/tests/ui/impl-trait/auto-trait-leak.stderr b/tests/ui/impl-trait/auto-trait-leak.stderr index fd0358421..e6c750d0e 100644 --- a/tests/ui/impl-trait/auto-trait-leak.stderr +++ b/tests/ui/impl-trait/auto-trait-leak.stderr @@ -29,6 +29,11 @@ note: ...which requires building MIR for `cycle1`... | LL | fn cycle1() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires match-checking `cycle1`... + --> $DIR/auto-trait-leak.rs:12:1 + | +LL | fn cycle1() -> impl Clone { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires building THIR for `cycle1`... --> $DIR/auto-trait-leak.rs:12:1 | @@ -70,6 +75,11 @@ note: ...which requires building MIR for `cycle2`... | LL | fn cycle2() -> impl Clone { | ^^^^^^^^^^^^^^^^^^^^^^^^^ +note: ...which requires match-checking `cycle2`... + --> $DIR/auto-trait-leak.rs:19:1 + | +LL | fn cycle2() -> impl Clone { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ note: ...which requires building THIR for `cycle2`... --> $DIR/auto-trait-leak.rs:19:1 | diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr b/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr index d56e1273f..835f7f765 100644 --- a/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr @@ -6,7 +6,7 @@ LL | fn a() -> impl Fn(&u8) -> impl Debug { LL | |x| x | --- ^ | | - | hidden type `&u8` captures the anonymous lifetime #1 defined here + | hidden type `&u8` captures the anonymous lifetime as defined here error: aborting due to previous error diff --git a/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs b/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs index 74df300f8..ffeabe5c2 100644 --- a/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs +++ b/tests/ui/impl-trait/in-trait/auxiliary/rpitit.rs @@ -1,11 +1,14 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty + #![feature(return_position_impl_trait_in_trait)] +use std::ops::Deref; + pub trait Foo { - fn bar() -> impl Sized; + fn bar() -> impl Deref<Target = impl Sized>; } pub struct Foreign; - impl Foo for Foreign { - fn bar() {} + fn bar() -> &'static () { &() } } diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.stderr b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.current.stderr index d681ecf25..05c025cc1 100644 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.stderr +++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.current.stderr @@ -1,5 +1,5 @@ warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/box-coerce-span-in-default.rs:3:12 + --> $DIR/box-coerce-span-in-default.rs:5:12 | LL | #![feature(return_position_impl_trait_in_trait)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.next.stderr b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.next.stderr new file mode 100644 index 000000000..05c025cc1 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.next.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/box-coerce-span-in-default.rs:5:12 + | +LL | #![feature(return_position_impl_trait_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs index a4d483dee..163bb4fcf 100644 --- a/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs +++ b/tests/ui/impl-trait/in-trait/box-coerce-span-in-default.rs @@ -1,4 +1,6 @@ // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] //~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete diff --git a/tests/ui/impl-trait/in-trait/deep-match-works.rs b/tests/ui/impl-trait/in-trait/deep-match-works.rs index 772da845e..5c9d2e356 100644 --- a/tests/ui/impl-trait/in-trait/deep-match-works.rs +++ b/tests/ui/impl-trait/in-trait/deep-match-works.rs @@ -1,4 +1,6 @@ // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] @@ -10,7 +12,9 @@ trait Foo { } impl Foo for () { - fn bar() -> Wrapper<i32> { Wrapper(0) } + fn bar() -> Wrapper<i32> { + Wrapper(0) + } } fn main() {} diff --git a/tests/ui/impl-trait/in-trait/deep-match.stderr b/tests/ui/impl-trait/in-trait/deep-match.current.stderr index 3eba419c0..400db20c7 100644 --- a/tests/ui/impl-trait/in-trait/deep-match.stderr +++ b/tests/ui/impl-trait/in-trait/deep-match.current.stderr @@ -1,7 +1,7 @@ error[E0053]: method `bar` has an incompatible return type for trait - --> $DIR/deep-match.rs:11:17 + --> $DIR/deep-match.rs:14:17 | -LL | fn bar() -> i32 { 0 } +LL | fn bar() -> i32 { | ^^^ | | | expected `Wrapper<_>`, found `i32` diff --git a/tests/ui/impl-trait/in-trait/deep-match.next.stderr b/tests/ui/impl-trait/in-trait/deep-match.next.stderr new file mode 100644 index 000000000..400db20c7 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/deep-match.next.stderr @@ -0,0 +1,15 @@ +error[E0053]: method `bar` has an incompatible return type for trait + --> $DIR/deep-match.rs:14:17 + | +LL | fn bar() -> i32 { + | ^^^ + | | + | expected `Wrapper<_>`, found `i32` + | return type in trait + | + = note: expected struct `Wrapper<_>` + found type `i32` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/deep-match.rs b/tests/ui/impl-trait/in-trait/deep-match.rs index a6385147c..413d054e1 100644 --- a/tests/ui/impl-trait/in-trait/deep-match.rs +++ b/tests/ui/impl-trait/in-trait/deep-match.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] @@ -8,8 +11,10 @@ trait Foo { } impl Foo for () { - fn bar() -> i32 { 0 } - //~^ ERROR method `bar` has an incompatible return type for trait + fn bar() -> i32 { + //~^ ERROR method `bar` has an incompatible return type for trait + 0 + } } fn main() {} diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.current.stderr index cc3bdf0e5..85450e3b0 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.stderr +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.current.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/default-body-type-err-2.rs:8:9 + --> $DIR/default-body-type-err-2.rs:10:9 | LL | 42 | ^^- help: try using a conversion method: `.to_string()` diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr new file mode 100644 index 000000000..85450e3b0 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.next.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/default-body-type-err-2.rs:10:9 + | +LL | 42 + | ^^- help: try using a conversion method: `.to_string()` + | | + | expected `String`, found integer + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs b/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs index 45ae2b8ad..623237763 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs +++ b/tests/ui/impl-trait/in-trait/default-body-type-err-2.rs @@ -1,4 +1,6 @@ // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![allow(incomplete_features)] #![feature(async_fn_in_trait)] diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err.current.stderr index 4742eb37d..c949168a3 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err.stderr +++ b/tests/ui/impl-trait/in-trait/default-body-type-err.current.stderr @@ -1,5 +1,5 @@ error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String` - --> $DIR/default-body-type-err.rs:7:22 + --> $DIR/default-body-type-err.rs:10:22 | LL | fn lol(&self) -> impl Deref<Target = String> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `String` diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr b/tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr new file mode 100644 index 000000000..c949168a3 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-body-type-err.next.stderr @@ -0,0 +1,12 @@ +error[E0271]: type mismatch resolving `<&i32 as Deref>::Target == String` + --> $DIR/default-body-type-err.rs:10:22 + | +LL | fn lol(&self) -> impl Deref<Target = String> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `i32`, found `String` +LL | +LL | &1i32 + | ----- return type was inferred to be `&i32` here + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/impl-trait/in-trait/default-body-type-err.rs b/tests/ui/impl-trait/in-trait/default-body-type-err.rs index ac9baf91c..9bd5b7779 100644 --- a/tests/ui/impl-trait/in-trait/default-body-type-err.rs +++ b/tests/ui/impl-trait/in-trait/default-body-type-err.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + #![allow(incomplete_features)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.current.stderr b/tests/ui/impl-trait/in-trait/default-body-with-rpit.current.stderr new file mode 100644 index 000000000..3c24eff9a --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-body-with-rpit.current.stderr @@ -0,0 +1,24 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/default-body-with-rpit.rs:13:9 + | +LL | "" + | ^^ expected `impl Debug`, got `&'static str` + | +note: previous use here + --> $DIR/default-body-with-rpit.rs:12:39 + | +LL | async fn baz(&self) -> impl Debug { + | _______________________________________^ +LL | | "" +LL | | } + | |_____^ + +error[E0720]: cannot resolve opaque type + --> $DIR/default-body-with-rpit.rs:12:28 + | +LL | async fn baz(&self) -> impl Debug { + | ^^^^^^^^^^ cannot resolve opaque type + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.next.stderr b/tests/ui/impl-trait/in-trait/default-body-with-rpit.next.stderr new file mode 100644 index 000000000..3c24eff9a --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-body-with-rpit.next.stderr @@ -0,0 +1,24 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/default-body-with-rpit.rs:13:9 + | +LL | "" + | ^^ expected `impl Debug`, got `&'static str` + | +note: previous use here + --> $DIR/default-body-with-rpit.rs:12:39 + | +LL | async fn baz(&self) -> impl Debug { + | _______________________________________^ +LL | | "" +LL | | } + | |_____^ + +error[E0720]: cannot resolve opaque type + --> $DIR/default-body-with-rpit.rs:12:28 + | +LL | async fn baz(&self) -> impl Debug { + | ^^^^^^^^^^ cannot resolve opaque type + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0720`. diff --git a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs index ad3cc7c25..6bcc7b9ef 100644 --- a/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs +++ b/tests/ui/impl-trait/in-trait/default-body-with-rpit.rs @@ -1,5 +1,7 @@ -// check-pass // edition:2021 +// known-bug: #108304 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/default-body.rs b/tests/ui/impl-trait/in-trait/default-body.rs index b0baf5bb1..ab6a51c6b 100644 --- a/tests/ui/impl-trait/in-trait/default-body.rs +++ b/tests/ui/impl-trait/in-trait/default-body.rs @@ -1,5 +1,7 @@ // check-pass // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.current.stderr b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.current.stderr new file mode 100644 index 000000000..a0c0589b9 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.current.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/default-method-binder-shifting.rs:5:12 + | +LL | #![feature(return_position_impl_trait_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.next.stderr b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.next.stderr new file mode 100644 index 000000000..a0c0589b9 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.next.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/default-method-binder-shifting.rs:5:12 + | +LL | #![feature(return_position_impl_trait_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs new file mode 100644 index 000000000..de82544f2 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-method-binder-shifting.rs @@ -0,0 +1,22 @@ +// check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + +#![feature(return_position_impl_trait_in_trait)] +//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete + +trait Trait { + type Type; + + // Check that we're adjusting bound vars correctly when installing the default + // method projection assumptions. + fn method(&self) -> impl Trait<Type = impl Sized + '_>; +} + +trait Trait2 { + type Type; + + fn method(&self) -> impl Trait2<Type = impl Trait2<Type = impl Sized + '_> + '_>; +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.stderr b/tests/ui/impl-trait/in-trait/default-method-constraint.current.stderr index 5e18605aa..7bb79911f 100644 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.stderr +++ b/tests/ui/impl-trait/in-trait/default-method-constraint.current.stderr @@ -1,5 +1,5 @@ warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/default-method-constraint.rs:5:12 + --> $DIR/default-method-constraint.rs:7:12 | LL | #![feature(return_position_impl_trait_in_trait)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.next.stderr b/tests/ui/impl-trait/in-trait/default-method-constraint.next.stderr new file mode 100644 index 000000000..7bb79911f --- /dev/null +++ b/tests/ui/impl-trait/in-trait/default-method-constraint.next.stderr @@ -0,0 +1,11 @@ +warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/default-method-constraint.rs:7:12 + | +LL | #![feature(return_position_impl_trait_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/impl-trait/in-trait/default-method-constraint.rs b/tests/ui/impl-trait/in-trait/default-method-constraint.rs index 8c50cc295..e85fe3c86 100644 --- a/tests/ui/impl-trait/in-trait/default-method-constraint.rs +++ b/tests/ui/impl-trait/in-trait/default-method-constraint.rs @@ -1,4 +1,6 @@ // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next // This didn't work in the previous default RPITIT method hack attempt diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr b/tests/ui/impl-trait/in-trait/doesnt-satisfy.current.stderr index aa5492d28..653016cf0 100644 --- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr +++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.current.stderr @@ -1,5 +1,5 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` - --> $DIR/doesnt-satisfy.rs:9:17 + --> $DIR/doesnt-satisfy.rs:12:17 | LL | fn bar() -> () {} | ^^ `()` cannot be formatted with the default formatter @@ -7,7 +7,7 @@ LL | fn bar() -> () {} = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `Foo::bar::{opaque#0}` - --> $DIR/doesnt-satisfy.rs:5:22 + --> $DIR/doesnt-satisfy.rs:8:22 | LL | fn bar() -> impl std::fmt::Display; | ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::bar::{opaque#0}` diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.next.stderr b/tests/ui/impl-trait/in-trait/doesnt-satisfy.next.stderr new file mode 100644 index 000000000..f0cd43bcf --- /dev/null +++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.next.stderr @@ -0,0 +1,17 @@ +error[E0277]: `()` doesn't implement `std::fmt::Display` + --> $DIR/doesnt-satisfy.rs:12:17 + | +LL | fn bar() -> () {} + | ^^ `()` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `()` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead +note: required by a bound in `Foo::{opaque#0}` + --> $DIR/doesnt-satisfy.rs:8:22 + | +LL | fn bar() -> impl std::fmt::Display; + | ^^^^^^^^^^^^^^^^^ required by this bound in `Foo::{opaque#0}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs b/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs index bb4e0d44f..fcd0b51ee 100644 --- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs +++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr new file mode 100644 index 000000000..b8a793e1a --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.current.stderr @@ -0,0 +1,21 @@ +warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/dont-project-to-rpitit-with-no-value.rs:4:12 + | +LL | #![feature(return_position_impl_trait_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/dont-project-to-rpitit-with-no-value.rs:12:1 + | +LL | fn foo(&self) -> impl Sized; + | ---------------------------- `foo` from trait +... +LL | impl MyTrait for i32 { + | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr new file mode 100644 index 000000000..b8a793e1a --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.next.stderr @@ -0,0 +1,21 @@ +warning: the feature `return_position_impl_trait_in_trait` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/dont-project-to-rpitit-with-no-value.rs:4:12 + | +LL | #![feature(return_position_impl_trait_in_trait)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/dont-project-to-rpitit-with-no-value.rs:12:1 + | +LL | fn foo(&self) -> impl Sized; + | ---------------------------- `foo` from trait +... +LL | impl MyTrait for i32 { + | ^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0046`. diff --git a/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs new file mode 100644 index 000000000..8329ce1f8 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dont-project-to-rpitit-with-no-value.rs @@ -0,0 +1,19 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + +#![feature(return_position_impl_trait_in_trait)] +//~^ WARN the feature `return_position_impl_trait_in_trait` is incomplete + +trait MyTrait { + fn foo(&self) -> impl Sized; + fn bar(&self) -> impl Sized; +} + +impl MyTrait for i32 { + //~^ ERROR not all trait items implemented, missing: `foo` + fn bar(&self) -> impl Sized { + self.foo() + } +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/early.rs b/tests/ui/impl-trait/in-trait/early.rs index 9c1c2b503..831033a58 100644 --- a/tests/ui/impl-trait/in-trait/early.rs +++ b/tests/ui/impl-trait/in-trait/early.rs @@ -1,5 +1,7 @@ // check-pass // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(async_fn_in_trait, return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/encode.rs b/tests/ui/impl-trait/in-trait/encode.rs index efb9f6498..98aaf4a65 100644 --- a/tests/ui/impl-trait/in-trait/encode.rs +++ b/tests/ui/impl-trait/in-trait/encode.rs @@ -1,5 +1,7 @@ // build-pass // compile-flags: --crate-type=lib +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/foreign.rs b/tests/ui/impl-trait/in-trait/foreign.rs index 6341f5b42..f4972d948 100644 --- a/tests/ui/impl-trait/in-trait/foreign.rs +++ b/tests/ui/impl-trait/in-trait/foreign.rs @@ -1,9 +1,21 @@ // check-pass // aux-build: rpitit.rs +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next extern crate rpitit; +use std::sync::Arc; + +// Implement an RPITIT from another crate. +struct Local; +impl rpitit::Foo for Local { + fn bar() -> Arc<String> { Arc::new(String::new()) } +} + fn main() { - // Witness an RPITIT from another crate - let () = <rpitit::Foreign as rpitit::Foo>::bar(); + // Witness an RPITIT from another crate. + let &() = <rpitit::Foreign as rpitit::Foo>::bar(); + + let x: Arc<String> = <Local as rpitit::Foo>::bar(); } diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.stderr b/tests/ui/impl-trait/in-trait/generics-mismatch.current.stderr index cd42683e0..310edbcb6 100644 --- a/tests/ui/impl-trait/in-trait/generics-mismatch.stderr +++ b/tests/ui/impl-trait/in-trait/generics-mismatch.current.stderr @@ -1,5 +1,5 @@ error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters - --> $DIR/generics-mismatch.rs:11:12 + --> $DIR/generics-mismatch.rs:14:12 | LL | fn bar(&self) -> impl Sized; | - expected 0 type parameters diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.next.stderr b/tests/ui/impl-trait/in-trait/generics-mismatch.next.stderr new file mode 100644 index 000000000..310edbcb6 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/generics-mismatch.next.stderr @@ -0,0 +1,12 @@ +error[E0049]: method `bar` has 1 type parameter but its trait declaration has 0 type parameters + --> $DIR/generics-mismatch.rs:14:12 + | +LL | fn bar(&self) -> impl Sized; + | - expected 0 type parameters +... +LL | fn bar<T>(&self) {} + | ^ found 1 type parameter + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0049`. diff --git a/tests/ui/impl-trait/in-trait/generics-mismatch.rs b/tests/ui/impl-trait/in-trait/generics-mismatch.rs index cc0fc720e..9259ca193 100644 --- a/tests/ui/impl-trait/in-trait/generics-mismatch.rs +++ b/tests/ui/impl-trait/in-trait/generics-mismatch.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/issue-102140.stderr b/tests/ui/impl-trait/in-trait/issue-102140.current.stderr index 18bb63745..7aa7880e2 100644 --- a/tests/ui/impl-trait/in-trait/issue-102140.stderr +++ b/tests/ui/impl-trait/in-trait/issue-102140.current.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/issue-102140.rs:23:22 + --> $DIR/issue-102140.rs:26:22 | LL | MyTrait::foo(&self) | ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` @@ -13,7 +13,7 @@ LL + MyTrait::foo(self) | error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/issue-102140.rs:23:9 + --> $DIR/issue-102140.rs:26:9 | LL | MyTrait::foo(&self) | ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` @@ -21,7 +21,7 @@ LL | MyTrait::foo(&self) = help: the trait `MyTrait` is implemented for `Outer` error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied - --> $DIR/issue-102140.rs:23:9 + --> $DIR/issue-102140.rs:26:9 | LL | MyTrait::foo(&self) | ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` diff --git a/tests/ui/impl-trait/in-trait/issue-102140.next.stderr b/tests/ui/impl-trait/in-trait/issue-102140.next.stderr new file mode 100644 index 000000000..7aa7880e2 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/issue-102140.next.stderr @@ -0,0 +1,33 @@ +error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied + --> $DIR/issue-102140.rs:26:22 + | +LL | MyTrait::foo(&self) + | ------------ ^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` + | | + | required by a bound introduced by this call + | +help: consider removing the leading `&`-reference + | +LL - MyTrait::foo(&self) +LL + MyTrait::foo(self) + | + +error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied + --> $DIR/issue-102140.rs:26:9 + | +LL | MyTrait::foo(&self) + | ^^^^^^^^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` + | + = help: the trait `MyTrait` is implemented for `Outer` + +error[E0277]: the trait bound `&dyn MyTrait: MyTrait` is not satisfied + --> $DIR/issue-102140.rs:26:9 + | +LL | MyTrait::foo(&self) + | ^^^^^^^^^^^^ the trait `MyTrait` is not implemented for `&dyn MyTrait` + | + = help: the trait `MyTrait` is implemented for `Outer` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/issue-102140.rs b/tests/ui/impl-trait/in-trait/issue-102140.rs index be1e012ac..4dcac4f5b 100644 --- a/tests/ui/impl-trait/in-trait/issue-102140.rs +++ b/tests/ui/impl-trait/in-trait/issue-102140.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/issue-102301.rs b/tests/ui/impl-trait/in-trait/issue-102301.rs index a93714a65..1329ca29d 100644 --- a/tests/ui/impl-trait/in-trait/issue-102301.rs +++ b/tests/ui/impl-trait/in-trait/issue-102301.rs @@ -1,4 +1,6 @@ // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/issue-102571.stderr b/tests/ui/impl-trait/in-trait/issue-102571.current.stderr index 87219941d..cac9a29f6 100644 --- a/tests/ui/impl-trait/in-trait/issue-102571.stderr +++ b/tests/ui/impl-trait/in-trait/issue-102571.current.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-102571.rs:20:9 + --> $DIR/issue-102571.rs:23:9 | LL | let () = t.bar(); | ^^ ------- this expression has type `impl Deref<Target = impl std::fmt::Display + ?Sized>` diff --git a/tests/ui/impl-trait/in-trait/issue-102571.next.stderr b/tests/ui/impl-trait/in-trait/issue-102571.next.stderr new file mode 100644 index 000000000..cac9a29f6 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/issue-102571.next.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/issue-102571.rs:23:9 + | +LL | let () = t.bar(); + | ^^ ------- this expression has type `impl Deref<Target = impl std::fmt::Display + ?Sized>` + | | + | expected associated type, found `()` + | + = note: expected associated type `impl Deref<Target = impl std::fmt::Display + ?Sized>` + found unit type `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/issue-102571.rs b/tests/ui/impl-trait/in-trait/issue-102571.rs index 61c91e644..f0ddab5e7 100644 --- a/tests/ui/impl-trait/in-trait/issue-102571.rs +++ b/tests/ui/impl-trait/in-trait/issue-102571.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/nested-rpitit.rs b/tests/ui/impl-trait/in-trait/nested-rpitit.rs index 65285e3a3..360207537 100644 --- a/tests/ui/impl-trait/in-trait/nested-rpitit.rs +++ b/tests/ui/impl-trait/in-trait/nested-rpitit.rs @@ -1,4 +1,6 @@ // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/new-lowering-strategy/simple-trait.rs b/tests/ui/impl-trait/in-trait/new-lowering-strategy/simple-trait.rs deleted file mode 100644 index dfce973d7..000000000 --- a/tests/ui/impl-trait/in-trait/new-lowering-strategy/simple-trait.rs +++ /dev/null @@ -1,11 +0,0 @@ -// check-pass -// compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty - -#![feature(return_position_impl_trait_in_trait)] -#![allow(incomplete_features)] - -trait Foo { - fn foo() -> impl Sized; -} - -fn main() {} diff --git a/tests/ui/impl-trait/in-trait/object-safety.stderr b/tests/ui/impl-trait/in-trait/object-safety.current.stderr index ca0e760ff..b7f2b019a 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.stderr +++ b/tests/ui/impl-trait/in-trait/object-safety.current.stderr @@ -1,11 +1,11 @@ error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:17:33 + --> $DIR/object-safety.rs:20:33 | LL | let i = Box::new(42_u32) as Box<dyn Foo>; | ^^^^^^^^^^^^ `Foo` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/object-safety.rs:7:22 + --> $DIR/object-safety.rs:10:22 | LL | trait Foo { | --- this trait cannot be made into an object... @@ -14,13 +14,13 @@ LL | fn baz(&self) -> impl Debug; = help: consider moving `baz` to another trait error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:20:13 + --> $DIR/object-safety.rs:23:13 | LL | let s = i.baz(); | ^^^^^^^ `Foo` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/object-safety.rs:7:22 + --> $DIR/object-safety.rs:10:22 | LL | trait Foo { | --- this trait cannot be made into an object... @@ -29,13 +29,13 @@ LL | fn baz(&self) -> impl Debug; = help: consider moving `baz` to another trait error[E0038]: the trait `Foo` cannot be made into an object - --> $DIR/object-safety.rs:17:13 + --> $DIR/object-safety.rs:20:13 | LL | let i = Box::new(42_u32) as Box<dyn Foo>; | ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object | note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> - --> $DIR/object-safety.rs:7:22 + --> $DIR/object-safety.rs:10:22 | LL | trait Foo { | --- this trait cannot be made into an object... diff --git a/tests/ui/impl-trait/in-trait/object-safety.next.stderr b/tests/ui/impl-trait/in-trait/object-safety.next.stderr new file mode 100644 index 000000000..b7f2b019a --- /dev/null +++ b/tests/ui/impl-trait/in-trait/object-safety.next.stderr @@ -0,0 +1,50 @@ +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety.rs:20:33 + | +LL | let i = Box::new(42_u32) as Box<dyn Foo>; + | ^^^^^^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/object-safety.rs:10:22 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | fn baz(&self) -> impl Debug; + | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type + = help: consider moving `baz` to another trait + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety.rs:23:13 + | +LL | let s = i.baz(); + | ^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/object-safety.rs:10:22 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | fn baz(&self) -> impl Debug; + | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type + = help: consider moving `baz` to another trait + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/object-safety.rs:20:13 + | +LL | let i = Box::new(42_u32) as Box<dyn Foo>; + | ^^^^^^^^^^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/object-safety.rs:10:22 + | +LL | trait Foo { + | --- this trait cannot be made into an object... +LL | fn baz(&self) -> impl Debug; + | ^^^^^^^^^^ ...because method `baz` references an `impl Trait` type in its return type + = help: consider moving `baz` to another trait + = note: required for `Box<u32>` to implement `CoerceUnsized<Box<dyn Foo>>` + = note: required by cast to type `Box<dyn Foo>` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/impl-trait/in-trait/object-safety.rs b/tests/ui/impl-trait/in-trait/object-safety.rs index dd35b9a2d..016a0aaae 100644 --- a/tests/ui/impl-trait/in-trait/object-safety.rs +++ b/tests/ui/impl-trait/in-trait/object-safety.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.current.stderr index 15edda483..a57653b2c 100644 --- a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.stderr +++ b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.current.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/opaque-in-impl-is-opaque.rs:17:19 + --> $DIR/opaque-in-impl-is-opaque.rs:20:19 | LL | fn bar(&self) -> impl Display { | ------------ the found opaque type diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.next.stderr b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.next.stderr new file mode 100644 index 000000000..a57653b2c --- /dev/null +++ b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.next.stderr @@ -0,0 +1,17 @@ +error[E0308]: mismatched types + --> $DIR/opaque-in-impl-is-opaque.rs:20:19 + | +LL | fn bar(&self) -> impl Display { + | ------------ the found opaque type +... +LL | let x: &str = ().bar(); + | ---- ^^^^^^^^ expected `&str`, found opaque type + | | + | expected due to this + | + = note: expected reference `&str` + found opaque type `impl std::fmt::Display` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs index 3ac264e8e..c07ece15a 100644 --- a/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs +++ b/tests/ui/impl-trait/in-trait/opaque-in-impl-is-opaque.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/opaque-in-impl.rs b/tests/ui/impl-trait/in-trait/opaque-in-impl.rs index 2e0662969..f48d9fa26 100644 --- a/tests/ui/impl-trait/in-trait/opaque-in-impl.rs +++ b/tests/ui/impl-trait/in-trait/opaque-in-impl.rs @@ -1,4 +1,6 @@ // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/reveal.rs b/tests/ui/impl-trait/in-trait/reveal.rs index d6ede1cc4..1f42ec744 100644 --- a/tests/ui/impl-trait/in-trait/reveal.rs +++ b/tests/ui/impl-trait/in-trait/reveal.rs @@ -1,4 +1,6 @@ // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.stderr b/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr index c4fcaabe4..eba270af7 100644 --- a/tests/ui/impl-trait/in-trait/signature-mismatch.stderr +++ b/tests/ui/impl-trait/in-trait/signature-mismatch.current.stderr @@ -1,5 +1,5 @@ error: `impl` item signature doesn't match `trait` item signature - --> $DIR/signature-mismatch.rs:15:5 + --> $DIR/signature-mismatch.rs:17:5 | LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>; | ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3` diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr b/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr new file mode 100644 index 000000000..eba270af7 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/signature-mismatch.next.stderr @@ -0,0 +1,16 @@ +error: `impl` item signature doesn't match `trait` item signature + --> $DIR/signature-mismatch.rs:17:5 + | +LL | fn async_fn(&self, buff: &[u8]) -> impl Future<Output = Vec<u8>>; + | ----------------------------------------------------------------- expected `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3` +... +LL | fn async_fn<'a>(&self, buff: &'a [u8]) -> impl Future<Output = Vec<u8>> + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ found `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2` + | + = note: expected signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '3` + found signature `fn(&'1 Struct, &'2 [u8]) -> impl Future<Output = Vec<u8>> + '2` + = help: the lifetime requirements from the `impl` do not correspond to the requirements in the `trait` + = help: verify the lifetime relationships in the `trait` and `impl` between the `self` argument, the other inputs and its output + +error: aborting due to previous error + diff --git a/tests/ui/impl-trait/in-trait/signature-mismatch.rs b/tests/ui/impl-trait/in-trait/signature-mismatch.rs index 90682631a..38c902a97 100644 --- a/tests/ui/impl-trait/in-trait/signature-mismatch.rs +++ b/tests/ui/impl-trait/in-trait/signature-mismatch.rs @@ -1,4 +1,6 @@ // edition:2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.current.stderr index dc621d6b8..f48e7a1ed 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.stderr +++ b/tests/ui/impl-trait/in-trait/specialization-broken.current.stderr @@ -1,5 +1,5 @@ error[E0053]: method `bar` has an incompatible type for trait - --> $DIR/specialization-broken.rs:16:22 + --> $DIR/specialization-broken.rs:19:22 | LL | default impl<U> Foo for U | - this type parameter @@ -11,7 +11,7 @@ LL | fn bar(&self) -> U { | help: change the output type to match the trait: `impl Sized` | note: type in trait - --> $DIR/specialization-broken.rs:9:22 + --> $DIR/specialization-broken.rs:12:22 | LL | fn bar(&self) -> impl Sized; | ^^^^^^^^^^ @@ -19,7 +19,7 @@ LL | fn bar(&self) -> impl Sized; found signature `fn(&U) -> U` error: method with return-position `impl Trait` in trait cannot be specialized - --> $DIR/specialization-broken.rs:16:5 + --> $DIR/specialization-broken.rs:19:5 | LL | fn bar(&self) -> U { | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.next.stderr b/tests/ui/impl-trait/in-trait/specialization-broken.next.stderr new file mode 100644 index 000000000..f48e7a1ed --- /dev/null +++ b/tests/ui/impl-trait/in-trait/specialization-broken.next.stderr @@ -0,0 +1,31 @@ +error[E0053]: method `bar` has an incompatible type for trait + --> $DIR/specialization-broken.rs:19:22 + | +LL | default impl<U> Foo for U + | - this type parameter +... +LL | fn bar(&self) -> U { + | ^ + | | + | expected associated type, found type parameter `U` + | help: change the output type to match the trait: `impl Sized` + | +note: type in trait + --> $DIR/specialization-broken.rs:12:22 + | +LL | fn bar(&self) -> impl Sized; + | ^^^^^^^^^^ + = note: expected signature `fn(&U) -> impl Sized` + found signature `fn(&U) -> U` + +error: method with return-position `impl Trait` in trait cannot be specialized + --> $DIR/specialization-broken.rs:19:5 + | +LL | fn bar(&self) -> U { + | ^^^^^^^^^^^^^^^^^^ + | + = note: specialization behaves in inconsistent and surprising ways with `#![feature(return_position_impl_trait_in_trait)]`, and for now is disallowed + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0053`. diff --git a/tests/ui/impl-trait/in-trait/specialization-broken.rs b/tests/ui/impl-trait/in-trait/specialization-broken.rs index 2fcffdf3f..658d07097 100644 --- a/tests/ui/impl-trait/in-trait/specialization-broken.rs +++ b/tests/ui/impl-trait/in-trait/specialization-broken.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + // FIXME(compiler-errors): I'm not exactly sure if this is expected to pass or not. // But we fixed an ICE anyways. diff --git a/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs b/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs index c9ee877db..dbc5d38f1 100644 --- a/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs +++ b/tests/ui/impl-trait/in-trait/specialization-substs-remap.rs @@ -1,4 +1,6 @@ // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(specialization)] #![feature(return_position_impl_trait_in_trait)] diff --git a/tests/ui/impl-trait/in-trait/success.rs b/tests/ui/impl-trait/in-trait/success.rs index 4cbe682b4..0e69e0490 100644 --- a/tests/ui/impl-trait/in-trait/success.rs +++ b/tests/ui/impl-trait/in-trait/success.rs @@ -1,4 +1,6 @@ // check-pass +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.current.stderr index 8ff54cad9..64c942705 100644 --- a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.stderr +++ b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.current.stderr @@ -1,5 +1,5 @@ error[E0049]: method `bar` has 0 type parameters but its trait declaration has 1 type parameter - --> $DIR/trait-more-generics-than-impl.rs:11:11 + --> $DIR/trait-more-generics-than-impl.rs:14:11 | LL | fn bar<T>() -> impl Sized; | - expected 1 type parameter diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.next.stderr b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.next.stderr new file mode 100644 index 000000000..64c942705 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.next.stderr @@ -0,0 +1,12 @@ +error[E0049]: method `bar` has 0 type parameters but its trait declaration has 1 type parameter + --> $DIR/trait-more-generics-than-impl.rs:14:11 + | +LL | fn bar<T>() -> impl Sized; + | - expected 1 type parameter +... +LL | fn bar() -> impl Sized {} + | ^ found 0 type parameters + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0049`. diff --git a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs index 0bbe50ea6..c2e394a1f 100644 --- a/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs +++ b/tests/ui/impl-trait/in-trait/trait-more-generics-than-impl.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr index 03cc4c2b9..1a7071612 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.stderr +++ b/tests/ui/impl-trait/in-trait/wf-bounds.current.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:9:22 + --> $DIR/wf-bounds.rs:13:22 | LL | fn nya() -> impl Wf<Vec<[u8]>>; | ^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -9,22 +9,32 @@ note: required by a bound in `Vec` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/wf-bounds.rs:12:23 + --> $DIR/wf-bounds.rs:16:23 | LL | fn nya2() -> impl Wf<[u8]>; | ^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[u8]` note: required by a bound in `Wf` - --> $DIR/wf-bounds.rs:6:10 + --> $DIR/wf-bounds.rs:8:10 | -LL | trait Wf<T> {} +LL | trait Wf<T> { | ^ required by this bound in `Wf` help: consider relaxing the implicit `Sized` restriction | -LL | trait Wf<T: ?Sized> {} +LL | trait Wf<T: ?Sized> { | ++++++++ -error: aborting due to 2 previous errors +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/wf-bounds.rs:19:44 + | +LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>; + | ^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: required by a bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr new file mode 100644 index 000000000..1a7071612 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/wf-bounds.next.stderr @@ -0,0 +1,40 @@ +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/wf-bounds.rs:13:22 + | +LL | fn nya() -> impl Wf<Vec<[u8]>>; + | ^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: required by a bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/wf-bounds.rs:16:23 + | +LL | fn nya2() -> impl Wf<[u8]>; + | ^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: required by a bound in `Wf` + --> $DIR/wf-bounds.rs:8:10 + | +LL | trait Wf<T> { + | ^ required by this bound in `Wf` +help: consider relaxing the implicit `Sized` restriction + | +LL | trait Wf<T: ?Sized> { + | ++++++++ + +error[E0277]: the size for values of type `[u8]` cannot be known at compilation time + --> $DIR/wf-bounds.rs:19:44 + | +LL | fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>; + | ^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[u8]` +note: required by a bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.rs b/tests/ui/impl-trait/in-trait/wf-bounds.rs index 2c71583b3..1c9590bd8 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.rs +++ b/tests/ui/impl-trait/in-trait/wf-bounds.rs @@ -1,9 +1,13 @@ // issue #101663 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] -trait Wf<T> {} +trait Wf<T> { + type Output; +} trait Uwu { fn nya() -> impl Wf<Vec<[u8]>>; @@ -11,6 +15,9 @@ trait Uwu { fn nya2() -> impl Wf<[u8]>; //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time + + fn nya3() -> impl Wf<(), Output = impl Wf<Vec<[u8]>>>; + //~^ ERROR the size for values of type `[u8]` cannot be known at compilation time } fn main() {} diff --git a/tests/ui/impl-trait/in-trait/where-clause.rs b/tests/ui/impl-trait/in-trait/where-clause.rs index 87bac519c..88d86e2b5 100644 --- a/tests/ui/impl-trait/in-trait/where-clause.rs +++ b/tests/ui/impl-trait/in-trait/where-clause.rs @@ -1,5 +1,7 @@ // check-pass // edition: 2021 +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] diff --git a/tests/ui/impl-trait/issue-55872-1.rs b/tests/ui/impl-trait/issue-55872-1.rs index 22ff7ffa2..f36a310dd 100644 --- a/tests/ui/impl-trait/issue-55872-1.rs +++ b/tests/ui/impl-trait/issue-55872-1.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] pub trait Bar { type E: Copy; diff --git a/tests/ui/impl-trait/issue-55872-2.rs b/tests/ui/impl-trait/issue-55872-2.rs index cbc7b5d62..7a5cb3b3d 100644 --- a/tests/ui/impl-trait/issue-55872-2.rs +++ b/tests/ui/impl-trait/issue-55872-2.rs @@ -3,7 +3,7 @@ // [drop_tracking_mir] compile-flags: -Zdrop-tracking-mir // edition:2018 -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] pub trait Bar { type E: Send; diff --git a/tests/ui/impl-trait/issue-55872-2.stderr b/tests/ui/impl-trait/issue-55872-2.stderr deleted file mode 100644 index 477c964bd..000000000 --- a/tests/ui/impl-trait/issue-55872-2.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/issue-55872-2.rs:17:9 - | -LL | async {} - | ^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/impl-trait/issue-55872-3.rs b/tests/ui/impl-trait/issue-55872-3.rs index 91811df93..d031271ac 100644 --- a/tests/ui/impl-trait/issue-55872-3.rs +++ b/tests/ui/impl-trait/issue-55872-3.rs @@ -1,7 +1,7 @@ // edition:2018 // ignore-compare-mode-chalk -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] pub trait Bar { type E: Copy; diff --git a/tests/ui/impl-trait/issue-55872.rs b/tests/ui/impl-trait/issue-55872.rs index c4e6f6436..10850f0a9 100644 --- a/tests/ui/impl-trait/issue-55872.rs +++ b/tests/ui/impl-trait/issue-55872.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] pub trait Bar { type E: Copy; diff --git a/tests/ui/impl-trait/issues/issue-78722.rs b/tests/ui/impl-trait/issues/issue-78722.rs index 78233f300..7b5ab5f22 100644 --- a/tests/ui/impl-trait/issues/issue-78722.rs +++ b/tests/ui/impl-trait/issues/issue-78722.rs @@ -12,7 +12,6 @@ struct Bug { } let f: F = async { 1 }; //~^ ERROR `async` blocks are not allowed in constants - //~| ERROR destructor of 1 }], } diff --git a/tests/ui/impl-trait/issues/issue-78722.stderr b/tests/ui/impl-trait/issues/issue-78722.stderr index c00df8087..05a2c135c 100644 --- a/tests/ui/impl-trait/issues/issue-78722.stderr +++ b/tests/ui/impl-trait/issues/issue-78722.stderr @@ -7,22 +7,13 @@ LL | let f: F = async { 1 }; = note: see issue #85368 <https://github.com/rust-lang/rust/issues/85368> for more information = help: add `#![feature(const_async_blocks)]` to the crate attributes to enable -error[E0493]: destructor of `F` cannot be evaluated at compile-time - --> $DIR/issue-78722.rs:13:13 - | -LL | let f: F = async { 1 }; - | ^ the destructor for this type cannot be evaluated in constants -... -LL | }], - | - value is dropped here - error[E0271]: expected `[async block@$DIR/issue-78722.rs:11:13: 11:21]` to be a future that resolves to `u8`, but it resolves to `()` --> $DIR/issue-78722.rs:9:30 | LL | fn concrete_use() -> F { | ^ expected `()`, found `u8` -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0271, E0493, E0658. +Some errors have detailed explanations: E0271, E0658. For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/impl-trait/issues/issue-82139.rs b/tests/ui/impl-trait/issues/issue-82139.rs index cc9167b34..3f0b0f1a8 100644 --- a/tests/ui/impl-trait/issues/issue-82139.rs +++ b/tests/ui/impl-trait/issues/issue-82139.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait Trait { type Associated; diff --git a/tests/ui/impl-trait/issues/issue-83919.rs b/tests/ui/impl-trait/issues/issue-83919.rs index e76443a65..4e699e7f3 100644 --- a/tests/ui/impl-trait/issues/issue-83919.rs +++ b/tests/ui/impl-trait/issues/issue-83919.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] // edition:2021 @@ -6,8 +6,8 @@ use std::future::Future; trait Foo { type T; - type Fut2: Future<Output=Self::T>; // ICE got triggered with traits other than Future here - type Fut: Future<Output=Self::Fut2>; + type Fut2: Future<Output = Self::T>; // ICE got triggered with traits other than Future here + type Fut: Future<Output = Self::Fut2>; fn get_fut(&self) -> Self::Fut; } @@ -15,11 +15,11 @@ struct Implementor; impl Foo for Implementor { type T = u64; - type Fut2 = impl Future<Output=u64>; - type Fut = impl Future<Output=Self::Fut2>; + type Fut2 = impl Future<Output = u64>; + type Fut = impl Future<Output = Self::Fut2>; fn get_fut(&self) -> Self::Fut { - //~^ ERROR `{integer}` is not a future + //~^ ERROR `{integer}` is not a future async move { 42 // 42 does not impl Future and rustc does actually point out the error, diff --git a/tests/ui/impl-trait/issues/issue-86719.rs b/tests/ui/impl-trait/issues/issue-86719.rs index f4b0b3f33..7abab5bfb 100644 --- a/tests/ui/impl-trait/issues/issue-86719.rs +++ b/tests/ui/impl-trait/issues/issue-86719.rs @@ -1,11 +1,12 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait Bar { type E; } impl<S> Bar for S { type E = impl ; //~ ERROR at least one trait must be specified - fn foo() -> Self::E { //~ ERROR `foo` is not a member + fn foo() -> Self::E { + //~^ ERROR `foo` is not a member |_| true //~ ERROR type annotations needed } } diff --git a/tests/ui/impl-trait/issues/issue-86719.stderr b/tests/ui/impl-trait/issues/issue-86719.stderr index 7592418fd..15893df5f 100644 --- a/tests/ui/impl-trait/issues/issue-86719.stderr +++ b/tests/ui/impl-trait/issues/issue-86719.stderr @@ -8,12 +8,13 @@ error[E0407]: method `foo` is not a member of trait `Bar` --> $DIR/issue-86719.rs:8:5 | LL | / fn foo() -> Self::E { +LL | | LL | | |_| true LL | | } | |_____^ not a member of trait `Bar` error[E0282]: type annotations needed - --> $DIR/issue-86719.rs:9:10 + --> $DIR/issue-86719.rs:10:10 | LL | |_| true | ^ diff --git a/tests/ui/impl-trait/issues/issue-87340.rs b/tests/ui/impl-trait/issues/issue-87340.rs index f0f6d2bb6..705a4addc 100644 --- a/tests/ui/impl-trait/issues/issue-87340.rs +++ b/tests/ui/impl-trait/issues/issue-87340.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait X { type I; @@ -6,7 +6,7 @@ trait X { } impl<T> X for () { -//~^ ERROR `T` is not constrained by the impl trait, self type, or predicates + //~^ ERROR `T` is not constrained by the impl trait, self type, or predicates type I = impl Sized; fn f() -> Self::I {} } diff --git a/tests/ui/impl-trait/multiple-lifetimes.rs b/tests/ui/impl-trait/multiple-lifetimes/multiple-lifetimes.rs index 5407fb6dd..5407fb6dd 100644 --- a/tests/ui/impl-trait/multiple-lifetimes.rs +++ b/tests/ui/impl-trait/multiple-lifetimes/multiple-lifetimes.rs diff --git a/tests/ui/impl-trait/nested-return-type2.rs b/tests/ui/impl-trait/nested-return-type2.rs index fe883ce6f..e1d551137 100644 --- a/tests/ui/impl-trait/nested-return-type2.rs +++ b/tests/ui/impl-trait/nested-return-type2.rs @@ -26,7 +26,6 @@ impl<R: Duh, F: FnMut() -> R> Trait for F { // Lazy TAIT would error out, but we inserted a hack to make it work again, // keeping backwards compatibility. fn foo() -> impl Trait<Assoc = impl Send> { - //~^ WARN opaque type `impl Trait<Assoc = impl Send>` does not satisfy its associated type bounds || 42 } diff --git a/tests/ui/impl-trait/nested-return-type2.stderr b/tests/ui/impl-trait/nested-return-type2.stderr deleted file mode 100644 index 09ad3bd05..000000000 --- a/tests/ui/impl-trait/nested-return-type2.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: opaque type `impl Trait<Assoc = impl Send>` does not satisfy its associated type bounds - --> $DIR/nested-return-type2.rs:28:24 - | -LL | type Assoc: Duh; - | --- this associated type bound is unsatisfied for `impl Send` -... -LL | fn foo() -> impl Trait<Assoc = impl Send> { - | ^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(opaque_hidden_inferred_bound)]` on by default -help: add this bound - | -LL | fn foo() -> impl Trait<Assoc = impl Send + Duh> { - | +++++ - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/nested-return-type3.rs b/tests/ui/impl-trait/nested-return-type3.rs index 5a764fc4c..74b4dae22 100644 --- a/tests/ui/impl-trait/nested-return-type3.rs +++ b/tests/ui/impl-trait/nested-return-type3.rs @@ -13,7 +13,6 @@ impl<F: Duh> Trait for F { } fn foo() -> impl Trait<Assoc = impl Send> { - //~^ WARN opaque type `impl Trait<Assoc = impl Send>` does not satisfy its associated type bounds 42 } diff --git a/tests/ui/impl-trait/nested-return-type3.stderr b/tests/ui/impl-trait/nested-return-type3.stderr deleted file mode 100644 index 632de71aa..000000000 --- a/tests/ui/impl-trait/nested-return-type3.stderr +++ /dev/null @@ -1,17 +0,0 @@ -warning: opaque type `impl Trait<Assoc = impl Send>` does not satisfy its associated type bounds - --> $DIR/nested-return-type3.rs:15:24 - | -LL | type Assoc: Duh; - | --- this associated type bound is unsatisfied for `impl Send` -... -LL | fn foo() -> impl Trait<Assoc = impl Send> { - | ^^^^^^^^^^^^^^^^^ - | - = note: `#[warn(opaque_hidden_inferred_bound)]` on by default -help: add this bound - | -LL | fn foo() -> impl Trait<Assoc = impl Send + Duh> { - | +++++ - -warning: 1 warning emitted - diff --git a/tests/ui/impl-trait/no-method-suggested-traits.stderr b/tests/ui/impl-trait/no-method-suggested-traits.stderr index 3c2c01dc2..160cc0440 100644 --- a/tests/ui/impl-trait/no-method-suggested-traits.stderr +++ b/tests/ui/impl-trait/no-method-suggested-traits.stderr @@ -7,13 +7,13 @@ LL | 1u32.method(); = help: items from traits can only be used if the trait is in scope help: the following traits are implemented but not in scope; perhaps add a `use` for one of them: | -LL | use foo::Bar; +LL + use foo::Bar; | -LL | use no_method_suggested_traits::Reexported; +LL + use no_method_suggested_traits::Reexported; | -LL | use no_method_suggested_traits::foo::PubPub; +LL + use no_method_suggested_traits::foo::PubPub; | -LL | use no_method_suggested_traits::qux::PrivPub; +LL + use no_method_suggested_traits::qux::PrivPub; | error[E0599]: no method named `method` found for struct `Rc<&mut Box<&u32>>` in the current scope @@ -25,13 +25,13 @@ LL | std::rc::Rc::new(&mut Box::new(&1u32)).method(); = help: items from traits can only be used if the trait is in scope help: the following traits are implemented but not in scope; perhaps add a `use` for one of them: | -LL | use foo::Bar; +LL + use foo::Bar; | -LL | use no_method_suggested_traits::Reexported; +LL + use no_method_suggested_traits::Reexported; | -LL | use no_method_suggested_traits::foo::PubPub; +LL + use no_method_suggested_traits::foo::PubPub; | -LL | use no_method_suggested_traits::qux::PrivPub; +LL + use no_method_suggested_traits::qux::PrivPub; | error[E0599]: no method named `method` found for type `char` in the current scope @@ -46,7 +46,7 @@ LL | 'a'.method(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use foo::Bar; +LL + use foo::Bar; | error[E0599]: no method named `method` found for struct `Rc<&mut Box<&char>>` in the current scope @@ -58,7 +58,7 @@ LL | std::rc::Rc::new(&mut Box::new(&'a')).method(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use foo::Bar; +LL + use foo::Bar; | error[E0599]: no method named `method` found for type `i32` in the current scope @@ -75,7 +75,7 @@ LL | fn method(&self) {} = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use no_method_suggested_traits::foo::PubPub; +LL + use no_method_suggested_traits::foo::PubPub; | error[E0599]: no method named `method` found for struct `Rc<&mut Box<&i32>>` in the current scope @@ -87,7 +87,7 @@ LL | std::rc::Rc::new(&mut Box::new(&1i32)).method(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use no_method_suggested_traits::foo::PubPub; +LL + use no_method_suggested_traits::foo::PubPub; | error[E0599]: no method named `method` found for struct `Foo` in the current scope diff --git a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr index 662c74bcd..9c67f17e9 100644 --- a/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr +++ b/tests/ui/impl-trait/recursive-impl-trait-type-indirect.drop_tracking_mir.stderr @@ -114,6 +114,9 @@ error[E0720]: cannot resolve opaque type | LL | fn generator_hold() -> impl Sized { | ^^^^^^^^^^ recursive opaque type +... +LL | let x = generator_hold(); + | - generator captures itself here error[E0720]: cannot resolve opaque type --> $DIR/recursive-impl-trait-type-indirect.rs:90:26 diff --git a/tests/ui/impl-trait/type-alias-generic-param.rs b/tests/ui/impl-trait/type-alias-generic-param.rs index 3499b2859..1211625da 100644 --- a/tests/ui/impl-trait/type-alias-generic-param.rs +++ b/tests/ui/impl-trait/type-alias-generic-param.rs @@ -3,7 +3,7 @@ // types in 'item' position when generic parameters are involved // // run-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait Meow { type MeowType; diff --git a/tests/ui/impl-trait/universal_wrong_bounds.stderr b/tests/ui/impl-trait/universal_wrong_bounds.stderr index 3b1a5e5f4..464d68958 100644 --- a/tests/ui/impl-trait/universal_wrong_bounds.stderr +++ b/tests/ui/impl-trait/universal_wrong_bounds.stderr @@ -6,7 +6,7 @@ LL | fn wants_debug(g: impl Debug) { } | help: consider importing this trait instead | -LL | use std::fmt::Debug; +LL + use std::fmt::Debug; | error[E0404]: expected trait, found derive macro `Debug` @@ -17,7 +17,7 @@ LL | fn wants_display(g: impl Debug) { } | help: consider importing this trait instead | -LL | use std::fmt::Debug; +LL + use std::fmt::Debug; | error: aborting due to 2 previous errors diff --git a/tests/ui/impl-trait/where-allowed.rs b/tests/ui/impl-trait/where-allowed.rs index ff63b04c2..509d27166 100644 --- a/tests/ui/impl-trait/where-allowed.rs +++ b/tests/ui/impl-trait/where-allowed.rs @@ -1,6 +1,8 @@ //! A simple test for testing many permutations of allowedness of //! impl Trait #![feature(impl_trait_in_fn_trait_return)] +#![feature(custom_inner_attributes)] +#![rustfmt::skip] use std::fmt::Debug; // Allowed @@ -116,7 +118,7 @@ trait DummyTrait { } impl DummyTrait for () { type Out = impl Debug; - //~^ ERROR `impl Trait` in type aliases is unstable + //~^ ERROR `impl Trait` in associated types is unstable fn in_trait_impl_parameter(_: impl Debug) { } // Allowed diff --git a/tests/ui/impl-trait/where-allowed.stderr b/tests/ui/impl-trait/where-allowed.stderr index 1cae3f77c..3e2934379 100644 --- a/tests/ui/impl-trait/where-allowed.stderr +++ b/tests/ui/impl-trait/where-allowed.stderr @@ -1,5 +1,5 @@ error[E0666]: nested `impl Trait` is not allowed - --> $DIR/where-allowed.rs:47:51 + --> $DIR/where-allowed.rs:49:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | --------^^^^^^^^^^- @@ -8,7 +8,7 @@ LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | outer `impl Trait` error[E0666]: nested `impl Trait` is not allowed - --> $DIR/where-allowed.rs:56:57 + --> $DIR/where-allowed.rs:58:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | --------^^^^^^^^^^- @@ -16,17 +16,17 @@ LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic | | nested `impl Trait` here | outer `impl Trait` -error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:118:16 +error[E0658]: `impl Trait` in associated types is unstable + --> $DIR/where-allowed.rs:120:16 | LL | type Out = impl Debug; | ^^^^^^^^^^ | = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information - = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + = help: add `#![feature(impl_trait_in_assoc_type)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:153:23 + --> $DIR/where-allowed.rs:155:23 | LL | type InTypeAlias<R> = impl Debug; | ^^^^^^^^^^ @@ -35,7 +35,7 @@ LL | type InTypeAlias<R> = impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0658]: `impl Trait` in type aliases is unstable - --> $DIR/where-allowed.rs:156:39 + --> $DIR/where-allowed.rs:158:39 | LL | type InReturnInTypeAlias<R> = fn() -> impl Debug; | ^^^^^^^^^^ @@ -44,109 +44,109 @@ LL | type InReturnInTypeAlias<R> = fn() -> impl Debug; = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer params - --> $DIR/where-allowed.rs:16:40 + --> $DIR/where-allowed.rs:18:40 | LL | fn in_fn_parameter_in_parameters(_: fn(impl Debug)) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types - --> $DIR/where-allowed.rs:20:42 + --> $DIR/where-allowed.rs:22:42 | LL | fn in_fn_return_in_parameters(_: fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer params - --> $DIR/where-allowed.rs:24:38 + --> $DIR/where-allowed.rs:26:38 | LL | fn in_fn_parameter_in_return() -> fn(impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types - --> $DIR/where-allowed.rs:28:40 + --> $DIR/where-allowed.rs:30:40 | LL | fn in_fn_return_in_return() -> fn() -> impl Debug { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params - --> $DIR/where-allowed.rs:32:49 + --> $DIR/where-allowed.rs:34:49 | LL | fn in_dyn_Fn_parameter_in_parameters(_: &dyn Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types - --> $DIR/where-allowed.rs:36:51 + --> $DIR/where-allowed.rs:38:51 | LL | fn in_dyn_Fn_return_in_parameters(_: &dyn Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params - --> $DIR/where-allowed.rs:40:55 + --> $DIR/where-allowed.rs:42:55 | LL | fn in_dyn_Fn_parameter_in_return() -> &'static dyn Fn(impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params - --> $DIR/where-allowed.rs:47:51 + --> $DIR/where-allowed.rs:49:51 | LL | fn in_impl_Fn_parameter_in_parameters(_: &impl Fn(impl Debug)) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types - --> $DIR/where-allowed.rs:52:53 + --> $DIR/where-allowed.rs:54:53 | LL | fn in_impl_Fn_return_in_parameters(_: &impl Fn() -> impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params - --> $DIR/where-allowed.rs:56:57 + --> $DIR/where-allowed.rs:58:57 | LL | fn in_impl_Fn_parameter_in_return() -> &'static impl Fn(impl Debug) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params - --> $DIR/where-allowed.rs:64:38 + --> $DIR/where-allowed.rs:66:38 | LL | fn in_Fn_parameter_in_generics<F: Fn(impl Debug)> (_: F) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types - --> $DIR/where-allowed.rs:68:40 + --> $DIR/where-allowed.rs:70:40 | LL | fn in_Fn_return_in_generics<F: Fn() -> impl Debug> (_: F) { panic!() } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types - --> $DIR/where-allowed.rs:81:32 + --> $DIR/where-allowed.rs:83:32 | LL | struct InBraceStructField { x: impl Debug } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types - --> $DIR/where-allowed.rs:85:41 + --> $DIR/where-allowed.rs:87:41 | LL | struct InAdtInBraceStructField { x: Vec<impl Debug> } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types - --> $DIR/where-allowed.rs:89:27 + --> $DIR/where-allowed.rs:91:27 | LL | struct InTupleStructField(impl Debug); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types - --> $DIR/where-allowed.rs:94:25 + --> $DIR/where-allowed.rs:96:25 | LL | InBraceVariant { x: impl Debug }, | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in field types - --> $DIR/where-allowed.rs:96:20 + --> $DIR/where-allowed.rs:98:20 | LL | InTupleVariant(impl Debug), | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in trait method return types - --> $DIR/where-allowed.rs:107:23 + --> $DIR/where-allowed.rs:109:23 | LL | fn in_return() -> impl Debug; | ^^^^^^^^^^ @@ -155,7 +155,7 @@ LL | fn in_return() -> impl Debug; = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `impl` method return types - --> $DIR/where-allowed.rs:124:34 + --> $DIR/where-allowed.rs:126:34 | LL | fn in_trait_impl_return() -> impl Debug { () } | ^^^^^^^^^^ @@ -164,127 +164,127 @@ LL | fn in_trait_impl_return() -> impl Debug { () } = help: add `#![feature(return_position_impl_trait_in_trait)]` to the crate attributes to enable error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` params - --> $DIR/where-allowed.rs:137:33 + --> $DIR/where-allowed.rs:139:33 | LL | fn in_foreign_parameters(_: impl Debug); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `extern fn` return types - --> $DIR/where-allowed.rs:140:31 + --> $DIR/where-allowed.rs:142:31 | LL | fn in_foreign_return() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `fn` pointer return types - --> $DIR/where-allowed.rs:156:39 + --> $DIR/where-allowed.rs:158:39 | LL | type InReturnInTypeAlias<R> = fn() -> impl Debug; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in traits - --> $DIR/where-allowed.rs:161:16 + --> $DIR/where-allowed.rs:163:16 | LL | impl PartialEq<impl Debug> for () { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in impl headers - --> $DIR/where-allowed.rs:166:24 + --> $DIR/where-allowed.rs:168:24 | LL | impl PartialEq<()> for impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in impl headers - --> $DIR/where-allowed.rs:171:6 + --> $DIR/where-allowed.rs:173:6 | LL | impl impl Debug { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in impl headers - --> $DIR/where-allowed.rs:177:24 + --> $DIR/where-allowed.rs:179:24 | LL | impl InInherentImplAdt<impl Debug> { | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bounds - --> $DIR/where-allowed.rs:183:11 + --> $DIR/where-allowed.rs:185:11 | LL | where impl Debug: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bounds - --> $DIR/where-allowed.rs:190:15 + --> $DIR/where-allowed.rs:192:15 | LL | where Vec<impl Debug>: Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in bounds - --> $DIR/where-allowed.rs:197:24 + --> $DIR/where-allowed.rs:199:24 | LL | where T: PartialEq<impl Debug> | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait params - --> $DIR/where-allowed.rs:204:17 + --> $DIR/where-allowed.rs:206:17 | LL | where T: Fn(impl Debug) | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in `Fn` trait return types - --> $DIR/where-allowed.rs:211:22 + --> $DIR/where-allowed.rs:213:22 | LL | where T: Fn() -> impl Debug | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults - --> $DIR/where-allowed.rs:217:40 + --> $DIR/where-allowed.rs:219:40 | LL | struct InStructGenericParamDefault<T = impl Debug>(T); | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults - --> $DIR/where-allowed.rs:221:36 + --> $DIR/where-allowed.rs:223:36 | LL | enum InEnumGenericParamDefault<T = impl Debug> { Variant(T) } | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults - --> $DIR/where-allowed.rs:225:38 + --> $DIR/where-allowed.rs:227:38 | LL | trait InTraitGenericParamDefault<T = impl Debug> {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults - --> $DIR/where-allowed.rs:229:41 + --> $DIR/where-allowed.rs:231:41 | LL | type InTypeAliasGenericParamDefault<T = impl Debug> = T; | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults - --> $DIR/where-allowed.rs:233:11 + --> $DIR/where-allowed.rs:235:11 | LL | impl <T = impl Debug> T {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in generic parameter defaults - --> $DIR/where-allowed.rs:240:40 + --> $DIR/where-allowed.rs:242:40 | LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {} | ^^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in variable bindings - --> $DIR/where-allowed.rs:246:29 + --> $DIR/where-allowed.rs:248:29 | LL | let _in_local_variable: impl Fn() = || {}; | ^^^^^^^^^ error[E0562]: `impl Trait` only allowed in function and inherent method return types, not in closure return types - --> $DIR/where-allowed.rs:248:46 + --> $DIR/where-allowed.rs:250:46 | LL | let _in_return_in_local_variable = || -> impl Fn() { || {} }; | ^^^^^^^^^ error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:233:7 + --> $DIR/where-allowed.rs:235:7 | LL | impl <T = impl Debug> T {} | ^^^^^^^^^^^^^^ @@ -294,7 +294,7 @@ LL | impl <T = impl Debug> T {} = note: `#[deny(invalid_type_param_default)]` on by default error: defaults for type parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - --> $DIR/where-allowed.rs:240:36 + --> $DIR/where-allowed.rs:242:36 | LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {} | ^^^^^^^^^^^^^^ @@ -303,7 +303,7 @@ LL | fn in_method_generic_param_default<T = impl Debug>(_: T) {} = note: for more information, see issue #36887 <https://github.com/rust-lang/rust/issues/36887> error[E0118]: no nominal type found for inherent implementation - --> $DIR/where-allowed.rs:233:1 + --> $DIR/where-allowed.rs:235:1 | LL | impl <T = impl Debug> T {} | ^^^^^^^^^^^^^^^^^^^^^^^ impl requires a nominal type diff --git a/tests/ui/implied-bounds/ice-unbound-region-vars.rs b/tests/ui/implied-bounds/ice-unbound-region-vars.rs new file mode 100644 index 000000000..9e1e3feae --- /dev/null +++ b/tests/ui/implied-bounds/ice-unbound-region-vars.rs @@ -0,0 +1,24 @@ +// Because of #109628, we can have unbounded region vars in implied bounds. +// Make sure we don't ICE in this case! +// +// check-pass + +pub trait MapAccess { + type Error; + fn next_key_seed(&mut self) -> Option<Self::Error>; +} + +struct Access<'a> { + _marker: std::marker::PhantomData<&'a ()>, +} + +// implied_bounds(Option<Self::Error>) = ['?1: 'a, ] +// where '?1 is a fresh region var. +impl<'a, 'b: 'a> MapAccess for Access<'a> { + type Error = (); + fn next_key_seed(&mut self) -> Option<Self::Error> { + unimplemented!() + } +} + +fn main() {} diff --git a/tests/ui/implied-bounds/normalization-nested.lifetime.stderr b/tests/ui/implied-bounds/normalization-nested.lifetime.stderr new file mode 100644 index 000000000..898e5e951 --- /dev/null +++ b/tests/ui/implied-bounds/normalization-nested.lifetime.stderr @@ -0,0 +1,18 @@ +error[E0759]: `fn` parameter has lifetime `'x` but it needs to satisfy a `'static` lifetime requirement + --> $DIR/normalization-nested.rs:35:20 + | +LL | pub fn test<'x>(_: Map<Vec<&'x ()>>, s: &'x str) -> &'static str { + | ^^^^^^^^^^^^^^^^ + | | + | this data with lifetime `'x`... + | ...is used and required to live as long as `'static` here + | +note: `'static` lifetime requirement introduced by this bound + --> $DIR/normalization-nested.rs:33:14 + | +LL | I::Item: 'static; + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0759`. diff --git a/tests/ui/implied-bounds/normalization-nested.rs b/tests/ui/implied-bounds/normalization-nested.rs new file mode 100644 index 000000000..5f1cbb3f6 --- /dev/null +++ b/tests/ui/implied-bounds/normalization-nested.rs @@ -0,0 +1,39 @@ +// Test for normalization of projections that appear in the item bounds +// (versus those that appear directly in the input types). +// Both revisions should pass. `lifetime` revision is a bug. +// +// revisions: param_ty lifetime +// [param_ty] check-pass +// [lifetime] check-fail +// [lifetime] known-bug: #109799 + +pub trait Iter { + type Item; +} + +#[cfg(param_ty)] +impl<X, I> Iter for I +where + I: IntoIterator<Item = X>, +{ + type Item = X; +} + +#[cfg(lifetime)] +impl<'x, I> Iter for I +where + I: IntoIterator<Item = &'x ()>, +{ + type Item = &'x (); +} + +pub struct Map<I>(I) +where + I: Iter, + I::Item: 'static; + +pub fn test<'x>(_: Map<Vec<&'x ()>>, s: &'x str) -> &'static str { + s +} + +fn main() {} diff --git a/tests/ui/implied-bounds/normalization.rs b/tests/ui/implied-bounds/normalization.rs new file mode 100644 index 000000000..f776fc98a --- /dev/null +++ b/tests/ui/implied-bounds/normalization.rs @@ -0,0 +1,58 @@ +// Test that we get implied bounds from complex projections after normalization. + +// check-pass + +// implementations wil ensure that +// WF(<T as Combine<'a>>::Ty) implies T: 'a +trait Combine<'a> { + type Ty; +} + +impl<'a, T: 'a> Combine<'a> for Box<T> { + type Ty = &'a T; +} + +// ======= Wrappers ====== + +// normalizes to a projection +struct WrapA<T>(T); +impl<'a, T> Combine<'a> for WrapA<T> +where + T: Combine<'a>, +{ + type Ty = T::Ty; +} + +// <WrapB<T> as Combine<'a>>::Ty normalizes to a type variable ?X +// with constraint `<T as Combine<'a>>::Ty == ?X` +struct WrapB<T>(T); +impl<'a, X, T> Combine<'a> for WrapB<T> +where + T: Combine<'a, Ty = X>, +{ + type Ty = X; +} + +// <WrapC<T> as Combine<'a>>::Ty normalizes to `&'a &'?x ()` +// with constraint `<T as Combine<'a>>::Ty == &'a &'?x ()` +struct WrapC<T>(T); +impl<'a, 'x: 'a, T> Combine<'a> for WrapC<T> +where + T: Combine<'a, Ty = &'a &'x ()>, +{ + type Ty = &'a &'x (); +} + +//==== Test implied bounds ====== + +fn test_wrap<'a, 'b, 'c1, 'c2, A, B>( + _: <WrapA<Box<A>> as Combine<'a>>::Ty, // normalized: &'a A + _: <WrapB<Box<B>> as Combine<'b>>::Ty, // normalized: &'b B + _: <WrapC<Box<&'c1 ()>> as Combine<'c2>>::Ty, // normalized: &'c2 &'c1 () +) { + None::<&'a A>; + None::<&'b B>; + None::<&'c2 &'c1 ()>; +} + +fn main() {} diff --git a/tests/ui/imports/auxiliary/glob-conflict.rs b/tests/ui/imports/auxiliary/glob-conflict.rs index c83db64c6..8a146378b 100644 --- a/tests/ui/imports/auxiliary/glob-conflict.rs +++ b/tests/ui/imports/auxiliary/glob-conflict.rs @@ -1,3 +1,5 @@ +#![allow(ambiguous_glob_reexports)] + mod m1 { pub fn f() {} } diff --git a/tests/ui/imports/glob-resolve1.stderr b/tests/ui/imports/glob-resolve1.stderr index 3b66a5e31..4401ef587 100644 --- a/tests/ui/imports/glob-resolve1.stderr +++ b/tests/ui/imports/glob-resolve1.stderr @@ -60,7 +60,7 @@ LL | import(); | help: consider importing this function | -LL | use other::import; +LL + use other::import; | error[E0412]: cannot find type `A` in this scope diff --git a/tests/ui/imports/issue-26873-multifile/issue-26873-multifile.rs b/tests/ui/imports/issue-26873-multifile/issue-26873-multifile.rs index da2acf6c9..d369f1e71 100644 --- a/tests/ui/imports/issue-26873-multifile/issue-26873-multifile.rs +++ b/tests/ui/imports/issue-26873-multifile/issue-26873-multifile.rs @@ -3,7 +3,6 @@ #![allow(unused_imports)] #![allow(non_snake_case)] -// ignore-pretty issue #37195 #[path = "issue-26873-multifile/mod.rs"] mod multifile; diff --git a/tests/ui/imports/issue-38293.stderr b/tests/ui/imports/issue-38293.stderr index d2450ab12..1bb7ae29e 100644 --- a/tests/ui/imports/issue-38293.stderr +++ b/tests/ui/imports/issue-38293.stderr @@ -12,7 +12,7 @@ LL | baz(); | help: consider importing this function instead | -LL | use bar::baz; +LL + use bar::baz; | error: aborting due to 2 previous errors diff --git a/tests/ui/imports/issue-4366-2.stderr b/tests/ui/imports/issue-4366-2.stderr index 4c94634ee..412423f4d 100644 --- a/tests/ui/imports/issue-4366-2.stderr +++ b/tests/ui/imports/issue-4366-2.stderr @@ -18,7 +18,7 @@ LL | foo(); | help: consider importing this function instead | -LL | use foo::foo; +LL + use foo::foo; | error: aborting due to 2 previous errors diff --git a/tests/ui/imports/issue-4366.stderr b/tests/ui/imports/issue-4366.stderr index 469ea93e9..4d5b392a7 100644 --- a/tests/ui/imports/issue-4366.stderr +++ b/tests/ui/imports/issue-4366.stderr @@ -6,7 +6,7 @@ LL | fn sub() -> isize { foo(); 1 } | help: consider importing this function | -LL | use foo::foo; +LL + use foo::foo; | error: aborting due to previous error diff --git a/tests/ui/imports/local-modularized-tricky-fail-1.rs b/tests/ui/imports/local-modularized-tricky-fail-1.rs index 29e9b8ec8..ce700ae0d 100644 --- a/tests/ui/imports/local-modularized-tricky-fail-1.rs +++ b/tests/ui/imports/local-modularized-tricky-fail-1.rs @@ -1,4 +1,5 @@ #![feature(decl_macro)] +#![allow(ambiguous_glob_reexports)] macro_rules! define_exported { () => { #[macro_export] diff --git a/tests/ui/imports/local-modularized-tricky-fail-1.stderr b/tests/ui/imports/local-modularized-tricky-fail-1.stderr index 20eadaaaa..52a01e8bc 100644 --- a/tests/ui/imports/local-modularized-tricky-fail-1.stderr +++ b/tests/ui/imports/local-modularized-tricky-fail-1.stderr @@ -1,12 +1,12 @@ error[E0659]: `exported` is ambiguous - --> $DIR/local-modularized-tricky-fail-1.rs:28:1 + --> $DIR/local-modularized-tricky-fail-1.rs:29:1 | LL | exported!(); | ^^^^^^^^ ambiguous name | = note: ambiguous because of a conflict between a name from a glob import and a macro-expanded name in the same module during import or macro resolution note: `exported` could refer to the macro defined here - --> $DIR/local-modularized-tricky-fail-1.rs:5:5 + --> $DIR/local-modularized-tricky-fail-1.rs:6:5 | LL | / macro_rules! exported { LL | | () => () @@ -16,7 +16,7 @@ LL | | } LL | define_exported!(); | ------------------ in this macro invocation note: `exported` could also refer to the macro imported here - --> $DIR/local-modularized-tricky-fail-1.rs:22:5 + --> $DIR/local-modularized-tricky-fail-1.rs:23:5 | LL | use inner1::*; | ^^^^^^^^^ @@ -24,7 +24,7 @@ LL | use inner1::*; = note: this error originates in the macro `define_exported` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `panic` is ambiguous - --> $DIR/local-modularized-tricky-fail-1.rs:35:5 + --> $DIR/local-modularized-tricky-fail-1.rs:36:5 | LL | panic!(); | ^^^^^ ambiguous name @@ -32,7 +32,7 @@ LL | panic!(); = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution = note: `panic` could refer to a macro from prelude note: `panic` could also refer to the macro defined here - --> $DIR/local-modularized-tricky-fail-1.rs:11:5 + --> $DIR/local-modularized-tricky-fail-1.rs:12:5 | LL | / macro_rules! panic { LL | | () => () @@ -45,7 +45,7 @@ LL | define_panic!(); = note: this error originates in the macro `define_panic` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0659]: `include` is ambiguous - --> $DIR/local-modularized-tricky-fail-1.rs:46:1 + --> $DIR/local-modularized-tricky-fail-1.rs:47:1 | LL | include!(); | ^^^^^^^ ambiguous name @@ -53,7 +53,7 @@ LL | include!(); = note: ambiguous because of a conflict between a macro-expanded name and a less macro-expanded name from outer scope during import or macro resolution = note: `include` could refer to a macro from prelude note: `include` could also refer to the macro defined here - --> $DIR/local-modularized-tricky-fail-1.rs:17:5 + --> $DIR/local-modularized-tricky-fail-1.rs:18:5 | LL | / macro_rules! include { LL | | () => () diff --git a/tests/ui/imports/overlapping_pub_trait.stderr b/tests/ui/imports/overlapping_pub_trait.stderr index d0c845a5e..490dccd3e 100644 --- a/tests/ui/imports/overlapping_pub_trait.stderr +++ b/tests/ui/imports/overlapping_pub_trait.stderr @@ -12,7 +12,7 @@ LL | pub trait Tr { fn method(&self); } = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use overlapping_pub_trait_source::m::Tr; +LL + use overlapping_pub_trait_source::m::Tr; | error: aborting due to previous error diff --git a/tests/ui/imports/unnamed_pub_trait.stderr b/tests/ui/imports/unnamed_pub_trait.stderr index 319dfd7e1..5133273c2 100644 --- a/tests/ui/imports/unnamed_pub_trait.stderr +++ b/tests/ui/imports/unnamed_pub_trait.stderr @@ -12,7 +12,7 @@ LL | pub trait Tr { fn method(&self); } = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use unnamed_pub_trait_source::prelude::*; // trait Tr +LL + use unnamed_pub_trait_source::prelude::*; // trait Tr | error: aborting due to previous error diff --git a/tests/ui/index_message.rs b/tests/ui/index_message.rs index 87e0cde59..88b848d6f 100644 --- a/tests/ui/index_message.rs +++ b/tests/ui/index_message.rs @@ -1,4 +1,4 @@ fn main() { - let z = (); - let _ = z[0]; //~ ERROR cannot index into a value of type `()` + let z = (10,); + let _ = z[0]; //~ ERROR cannot index into a value of type `({integer},)` } diff --git a/tests/ui/index_message.stderr b/tests/ui/index_message.stderr index 6c2b12673..56d1d7080 100644 --- a/tests/ui/index_message.stderr +++ b/tests/ui/index_message.stderr @@ -1,4 +1,4 @@ -error[E0608]: cannot index into a value of type `()` +error[E0608]: cannot index into a value of type `({integer},)` --> $DIR/index_message.rs:3:13 | LL | let _ = z[0]; diff --git a/tests/ui/inference/char-as-str-single.fixed b/tests/ui/inference/char-as-str-single.fixed index bab1854dc..1621a279f 100644 --- a/tests/ui/inference/char-as-str-single.fixed +++ b/tests/ui/inference/char-as-str-single.fixed @@ -10,3 +10,12 @@ fn main() { let _: char = '人'; //~ ERROR mismatched types let _: char = '\''; //~ ERROR mismatched types } + +// regression test for https://github.com/rust-lang/rust/issues/109586 +#[allow(dead_code)] +fn convert_c_to_str(c: char) { + match c { + 'A' => {} //~ ERROR mismatched types + _ => {} + } +} diff --git a/tests/ui/inference/char-as-str-single.rs b/tests/ui/inference/char-as-str-single.rs index 736920643..2903142f1 100644 --- a/tests/ui/inference/char-as-str-single.rs +++ b/tests/ui/inference/char-as-str-single.rs @@ -10,3 +10,12 @@ fn main() { let _: char = "人"; //~ ERROR mismatched types let _: char = "'"; //~ ERROR mismatched types } + +// regression test for https://github.com/rust-lang/rust/issues/109586 +#[allow(dead_code)] +fn convert_c_to_str(c: char) { + match c { + "A" => {} //~ ERROR mismatched types + _ => {} + } +} diff --git a/tests/ui/inference/char-as-str-single.stderr b/tests/ui/inference/char-as-str-single.stderr index 3375ec6ac..9149efe32 100644 --- a/tests/ui/inference/char-as-str-single.stderr +++ b/tests/ui/inference/char-as-str-single.stderr @@ -37,6 +37,19 @@ help: if you meant to write a `char` literal, use single quotes LL | let _: char = '\''; | ~~~~ -error: aborting due to 3 previous errors +error[E0308]: mismatched types + --> $DIR/char-as-str-single.rs:18:9 + | +LL | match c { + | - this expression has type `char` +LL | "A" => {} + | ^^^ expected `char`, found `&str` + | +help: if you meant to write a `char` literal, use single quotes + | +LL | 'A' => {} + | ~~~ + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/inference/issue-80409.rs b/tests/ui/inference/issue-80409.rs new file mode 100644 index 000000000..80cad6dfc --- /dev/null +++ b/tests/ui/inference/issue-80409.rs @@ -0,0 +1,36 @@ +// check-pass + +#![allow(unreachable_code, unused)] + +use std::marker::PhantomData; + +struct FsmBuilder<TFsm> { + _fsm: PhantomData<TFsm>, +} + +impl<TFsm> FsmBuilder<TFsm> { + fn state(&mut self) -> FsmStateBuilder<TFsm> { + todo!() + } +} + +struct FsmStateBuilder<TFsm> { + _state: PhantomData<TFsm>, +} + +impl<TFsm> FsmStateBuilder<TFsm> { + fn on_entry<TAction: Fn(&mut StateContext<'_, TFsm>)>(&self, _action: TAction) {} +} + +trait Fsm { + type Context; +} + +struct StateContext<'a, TFsm: Fsm> { + context: &'a mut TFsm::Context, +} + +fn main() { + let mut builder: FsmBuilder<usize> = todo!(); + builder.state().on_entry(|_| {}); +} diff --git a/tests/ui/inference/issue-83606.stderr b/tests/ui/inference/issue-83606.stderr index f2ee8692e..97ed53fb3 100644 --- a/tests/ui/inference/issue-83606.stderr +++ b/tests/ui/inference/issue-83606.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed for `[usize; N]` LL | let _ = foo("foo"); | ^ | -help: consider giving this pattern a type, where the the value of const parameter `N` is specified +help: consider giving this pattern a type, where the value of const parameter `N` is specified | LL | let _: [usize; N] = foo("foo"); | ++++++++++++ diff --git a/tests/ui/inference/need_type_info/concrete-impl.rs b/tests/ui/inference/need_type_info/concrete-impl.rs index 72e0e74f3..fc79e6201 100644 --- a/tests/ui/inference/need_type_info/concrete-impl.rs +++ b/tests/ui/inference/need_type_info/concrete-impl.rs @@ -7,10 +7,13 @@ struct Two; struct Struct; impl Ambiguous<One> for Struct {} +//~^ NOTE multiple `impl`s satisfying `Struct: Ambiguous<_>` found impl Ambiguous<Two> for Struct {} fn main() { <Struct as Ambiguous<_>>::method(); //~^ ERROR type annotations needed + //~| NOTE cannot infer type of the type parameter `A` //~| ERROR type annotations needed + //~| NOTE infer type of the type parameter `A` } diff --git a/tests/ui/inference/need_type_info/concrete-impl.stderr b/tests/ui/inference/need_type_info/concrete-impl.stderr index aa3296995..74c3f6cd5 100644 --- a/tests/ui/inference/need_type_info/concrete-impl.stderr +++ b/tests/ui/inference/need_type_info/concrete-impl.stderr @@ -1,20 +1,21 @@ error[E0282]: type annotations needed - --> $DIR/concrete-impl.rs:13:5 + --> $DIR/concrete-impl.rs:14:5 | LL | <Struct as Ambiguous<_>>::method(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Self` declared on the trait `Ambiguous` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `A` declared on the trait `Ambiguous` error[E0283]: type annotations needed - --> $DIR/concrete-impl.rs:13:5 + --> $DIR/concrete-impl.rs:14:5 | LL | <Struct as Ambiguous<_>>::method(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `Self` declared on the trait `Ambiguous` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `A` declared on the trait `Ambiguous` | note: multiple `impl`s satisfying `Struct: Ambiguous<_>` found --> $DIR/concrete-impl.rs:9:1 | LL | impl Ambiguous<One> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | LL | impl Ambiguous<Two> for Struct {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/inference/need_type_info/issue-109905.rs b/tests/ui/inference/need_type_info/issue-109905.rs new file mode 100644 index 000000000..99d10a5ea --- /dev/null +++ b/tests/ui/inference/need_type_info/issue-109905.rs @@ -0,0 +1,25 @@ +// Test that we show the correct type parameter that couldn't be inferred and that we don't +// end up stating nonsense like "type parameter `'a`" which we used to do. + +trait Trait<'a, T> { + fn m(self); +} + +impl<'a, A> Trait<'a, A> for () { + fn m(self) {} +} + +fn qualified() { + <() as Trait<'static, _>>::m(()); + //~^ ERROR type annotations needed + //~| NOTE cannot infer type of the type parameter `T` + +} + +fn unqualified() { + Trait::<'static, _>::m(()); + //~^ ERROR type annotations needed + //~| NOTE cannot infer type of the type parameter `T` +} + +fn main() {} diff --git a/tests/ui/inference/need_type_info/issue-109905.stderr b/tests/ui/inference/need_type_info/issue-109905.stderr new file mode 100644 index 000000000..fcdd50f14 --- /dev/null +++ b/tests/ui/inference/need_type_info/issue-109905.stderr @@ -0,0 +1,15 @@ +error[E0282]: type annotations needed + --> $DIR/issue-109905.rs:13:5 + | +LL | <() as Trait<'static, _>>::m(()); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the trait `Trait` + +error[E0282]: type annotations needed + --> $DIR/issue-109905.rs:20:5 + | +LL | Trait::<'static, _>::m(()); + | ^^^^^^^^^^^^^^^^^^^^^^ cannot infer type of the type parameter `T` declared on the trait `Trait` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/infinite/infinite-trait-alias-recursion.stderr b/tests/ui/infinite/infinite-trait-alias-recursion.stderr index b925b3b01..683987b49 100644 --- a/tests/ui/infinite/infinite-trait-alias-recursion.stderr +++ b/tests/ui/infinite/infinite-trait-alias-recursion.stderr @@ -1,30 +1,15 @@ error[E0391]: cycle detected when computing the super predicates of `T1` - --> $DIR/infinite-trait-alias-recursion.rs:3:1 - | -LL | trait T1 = T2; - | ^^^^^^^^ - | -note: ...which requires computing the super traits of `T1`... --> $DIR/infinite-trait-alias-recursion.rs:3:12 | LL | trait T1 = T2; | ^^ -note: ...which requires computing the super predicates of `T2`... - --> $DIR/infinite-trait-alias-recursion.rs:6:1 | -LL | trait T2 = T3; - | ^^^^^^^^ -note: ...which requires computing the super traits of `T2`... +note: ...which requires computing the super predicates of `T2`... --> $DIR/infinite-trait-alias-recursion.rs:6:12 | LL | trait T2 = T3; | ^^ note: ...which requires computing the super predicates of `T3`... - --> $DIR/infinite-trait-alias-recursion.rs:8:1 - | -LL | trait T3 = T1 + T3; - | ^^^^^^^^ -note: ...which requires computing the super traits of `T3`... --> $DIR/infinite-trait-alias-recursion.rs:8:12 | LL | trait T3 = T1 + T3; diff --git a/tests/ui/inline-const/const-match-pat-generic.rs b/tests/ui/inline-const/const-match-pat-generic.rs index 7c0d83516..46e501abf 100644 --- a/tests/ui/inline-const/const-match-pat-generic.rs +++ b/tests/ui/inline-const/const-match-pat-generic.rs @@ -7,7 +7,6 @@ fn foo<const V: usize>() { match 0 { const { V } => {}, //~^ ERROR constant pattern depends on a generic parameter - //~| ERROR constant pattern depends on a generic parameter _ => {}, } } @@ -20,7 +19,6 @@ fn bar<const V: usize>() { match 0 { const { f(V) } => {}, //~^ ERROR constant pattern depends on a generic parameter - //~| ERROR constant pattern depends on a generic parameter _ => {}, } } diff --git a/tests/ui/inline-const/const-match-pat-generic.stderr b/tests/ui/inline-const/const-match-pat-generic.stderr index 77267f12f..4ffbde410 100644 --- a/tests/ui/inline-const/const-match-pat-generic.stderr +++ b/tests/ui/inline-const/const-match-pat-generic.stderr @@ -5,22 +5,10 @@ LL | const { V } => {}, | ^^^^^^^^^^^ error: constant pattern depends on a generic parameter - --> $DIR/const-match-pat-generic.rs:21:9 + --> $DIR/const-match-pat-generic.rs:20:9 | LL | const { f(V) } => {}, | ^^^^^^^^^^^^^^ -error: constant pattern depends on a generic parameter - --> $DIR/const-match-pat-generic.rs:8:9 - | -LL | const { V } => {}, - | ^^^^^^^^^^^ - -error: constant pattern depends on a generic parameter - --> $DIR/const-match-pat-generic.rs:21:9 - | -LL | const { f(V) } => {}, - | ^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/internal-lints/diagnostics_incorrect.rs b/tests/ui/internal-lints/diagnostics_incorrect.rs new file mode 100644 index 000000000..99f99ffcd --- /dev/null +++ b/tests/ui/internal-lints/diagnostics_incorrect.rs @@ -0,0 +1,15 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_attrs)] + +#[rustc_lint_diagnostics] +//~^ ERROR attribute should be applied to a function +struct Foo; + +impl Foo { + #[rustc_lint_diagnostics(a)] + //~^ ERROR malformed `rustc_lint_diagnostics` + fn bar() {} +} + +fn main() {} diff --git a/tests/ui/internal-lints/diagnostics_incorrect.stderr b/tests/ui/internal-lints/diagnostics_incorrect.stderr new file mode 100644 index 000000000..e849ca282 --- /dev/null +++ b/tests/ui/internal-lints/diagnostics_incorrect.stderr @@ -0,0 +1,17 @@ +error: malformed `rustc_lint_diagnostics` attribute input + --> $DIR/diagnostics_incorrect.rs:10:5 + | +LL | #[rustc_lint_diagnostics(a)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_lint_diagnostics]` + +error: attribute should be applied to a function definition + --> $DIR/diagnostics_incorrect.rs:5:1 + | +LL | #[rustc_lint_diagnostics] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | struct Foo; + | ----------- not a function definition + +error: aborting due to 2 previous errors + diff --git a/tests/ui/internal-lints/existing_doc_keyword.rs b/tests/ui/internal-lints/existing_doc_keyword.rs new file mode 100644 index 000000000..7783dc40f --- /dev/null +++ b/tests/ui/internal-lints/existing_doc_keyword.rs @@ -0,0 +1,11 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_private)] +#![feature(rustdoc_internals)] + +#![crate_type = "lib"] + +#![deny(rustc::existing_doc_keyword)] + +#[doc(keyword = "tadam")] //~ ERROR +mod tadam {} diff --git a/tests/ui/internal-lints/existing_doc_keyword.stderr b/tests/ui/internal-lints/existing_doc_keyword.stderr new file mode 100644 index 000000000..5110b9be0 --- /dev/null +++ b/tests/ui/internal-lints/existing_doc_keyword.stderr @@ -0,0 +1,15 @@ +error: found non-existing keyword `tadam` used in `#[doc(keyword = "...")]` + --> $DIR/existing_doc_keyword.rs:10:1 + | +LL | #[doc(keyword = "tadam")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: only existing keywords are allowed in core/std +note: the lint level is defined here + --> $DIR/existing_doc_keyword.rs:8:9 + | +LL | #![deny(rustc::existing_doc_keyword)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/internal-lints/query_stability_incorrect.rs b/tests/ui/internal-lints/query_stability_incorrect.rs new file mode 100644 index 000000000..f478b7332 --- /dev/null +++ b/tests/ui/internal-lints/query_stability_incorrect.rs @@ -0,0 +1,15 @@ +// compile-flags: -Z unstable-options + +#![feature(rustc_attrs)] + +#[rustc_lint_query_instability] +//~^ ERROR attribute should be applied to a function +struct Foo; + +impl Foo { + #[rustc_lint_query_instability(a)] + //~^ ERROR malformed `rustc_lint_query_instability` + fn bar() {} +} + +fn main() {} diff --git a/tests/ui/internal-lints/query_stability_incorrect.stderr b/tests/ui/internal-lints/query_stability_incorrect.stderr new file mode 100644 index 000000000..3f78b39ed --- /dev/null +++ b/tests/ui/internal-lints/query_stability_incorrect.stderr @@ -0,0 +1,17 @@ +error: malformed `rustc_lint_query_instability` attribute input + --> $DIR/query_stability_incorrect.rs:10:5 + | +LL | #[rustc_lint_query_instability(a)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_lint_query_instability]` + +error: attribute should be applied to a function definition + --> $DIR/query_stability_incorrect.rs:5:1 + | +LL | #[rustc_lint_query_instability] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | struct Foo; + | ----------- not a function definition + +error: aborting due to 2 previous errors + diff --git a/tests/ui/internal-lints/rustc_pass_by_value_self.rs b/tests/ui/internal-lints/rustc_pass_by_value_self.rs new file mode 100644 index 000000000..6ce67dcaf --- /dev/null +++ b/tests/ui/internal-lints/rustc_pass_by_value_self.rs @@ -0,0 +1,54 @@ +// compile-flags: -Z unstable-options +// NOTE: This test doesn't actually require `fulldeps` +// so we could instead use it as a `ui` test. +// +// Considering that all other `internal-lints` are tested here +// this seems like the cleaner solution though. +#![feature(rustc_attrs)] +#![deny(rustc::pass_by_value)] +#![allow(unused)] + +#[rustc_pass_by_value] +struct TyCtxt<'tcx> { + inner: &'tcx (), +} + +impl<'tcx> TyCtxt<'tcx> { + fn by_value(self) {} // OK + fn by_ref(&self) {} //~ ERROR passing `TyCtxt<'tcx>` by reference +} + +struct TyS<'tcx> { + inner: &'tcx (), +} + +#[rustc_pass_by_value] +type Ty<'tcx> = &'tcx TyS<'tcx>; + +impl<'tcx> TyS<'tcx> { + fn by_value(self: Ty<'tcx>) {} + fn by_ref(self: &Ty<'tcx>) {} //~ ERROR passing `Ty<'tcx>` by reference +} + +#[rustc_pass_by_value] +struct Foo; + +impl Foo { + fn with_ref(&self) {} //~ ERROR passing `Foo` by reference +} + +#[rustc_pass_by_value] +struct WithParameters<T, const N: usize, M = u32> { + slice: [T; N], + m: M, +} + +impl<T> WithParameters<T, 1> { + fn with_ref(&self) {} //~ ERROR passing `WithParameters<T, 1>` by reference +} + +impl<T> WithParameters<T, 1, u8> { + fn with_ref(&self) {} //~ ERROR passing `WithParameters<T, 1, u8>` by reference +} + +fn main() {} diff --git a/tests/ui/internal-lints/rustc_pass_by_value_self.stderr b/tests/ui/internal-lints/rustc_pass_by_value_self.stderr new file mode 100644 index 000000000..fb39ed60b --- /dev/null +++ b/tests/ui/internal-lints/rustc_pass_by_value_self.stderr @@ -0,0 +1,38 @@ +error: passing `TyCtxt<'tcx>` by reference + --> $DIR/rustc_pass_by_value_self.rs:18:15 + | +LL | fn by_ref(&self) {} + | ^^^^^ help: try passing by value: `TyCtxt<'tcx>` + | +note: the lint level is defined here + --> $DIR/rustc_pass_by_value_self.rs:8:9 + | +LL | #![deny(rustc::pass_by_value)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: passing `Ty<'tcx>` by reference + --> $DIR/rustc_pass_by_value_self.rs:30:21 + | +LL | fn by_ref(self: &Ty<'tcx>) {} + | ^^^^^^^^^ help: try passing by value: `Ty<'tcx>` + +error: passing `Foo` by reference + --> $DIR/rustc_pass_by_value_self.rs:37:17 + | +LL | fn with_ref(&self) {} + | ^^^^^ help: try passing by value: `Foo` + +error: passing `WithParameters<T, 1>` by reference + --> $DIR/rustc_pass_by_value_self.rs:47:17 + | +LL | fn with_ref(&self) {} + | ^^^^^ help: try passing by value: `WithParameters<T, 1>` + +error: passing `WithParameters<T, 1, u8>` by reference + --> $DIR/rustc_pass_by_value_self.rs:51:17 + | +LL | fn with_ref(&self) {} + | ^^^^^ help: try passing by value: `WithParameters<T, 1, u8>` + +error: aborting due to 5 previous errors + diff --git a/tests/ui/internal/internal-unstable-const.stderr b/tests/ui/internal/internal-unstable-const.stderr index 37d2ea6d2..5c63992d8 100644 --- a/tests/ui/internal/internal-unstable-const.stderr +++ b/tests/ui/internal/internal-unstable-const.stderr @@ -6,11 +6,13 @@ LL | 1.0 + 1.0 | help: if it is not part of the public API, make this function unstably const | -LL | #[rustc_const_unstable(feature = "...", issue = "...")] +LL + #[rustc_const_unstable(feature = "...", issue = "...")] +LL | pub const fn foo() -> f32 { | help: otherwise `#[rustc_allow_const_fn_unstable]` can be used to bypass stability checks | -LL | #[rustc_allow_const_fn_unstable(const_fn_floating_point_arithmetic)] +LL + #[rustc_allow_const_fn_unstable(const_fn_floating_point_arithmetic)] +LL | pub const fn foo() -> f32 { | error: aborting due to previous error diff --git a/tests/ui/issue-11881.rs b/tests/ui/issue-11881.rs new file mode 100644 index 000000000..f6360db9b --- /dev/null +++ b/tests/ui/issue-11881.rs @@ -0,0 +1,91 @@ +// run-pass + +#![allow(unused_must_use)] +#![allow(dead_code)] +#![allow(unused_imports)] + +use std::fmt; +use std::io::prelude::*; +use std::io::Cursor; +use std::slice; +use std::marker::PhantomData; + +trait Encoder { + type Error; +} + +trait Encodable<S: Encoder> { + fn encode(&self, s: &mut S) -> Result<(), S::Error>; +} + +struct JsonEncoder<'a>(PhantomData<&'a mut ()>); + +impl Encoder for JsonEncoder<'_> { + type Error = (); +} + +struct AsJson<'a, T> { + inner: &'a T, +} + +impl<'a, T: for<'r> Encodable<JsonEncoder<'r>>> fmt::Display for AsJson<'a, T> { + /// Encodes a json value into a string + fn fmt(&self, _f: &mut fmt::Formatter<'_>) -> fmt::Result { + Ok(()) + } +} + +fn as_json<T>(t: &T) -> AsJson<'_, T> { + AsJson { inner: t } +} + +struct OpaqueEncoder(Vec<u8>); + +impl Encoder for OpaqueEncoder { + type Error = (); +} + + +struct Foo { + baz: bool, +} + +impl<S: Encoder> Encodable<S> for Foo { + fn encode(&self, _s: &mut S) -> Result<(), S::Error> { + Ok(()) + } +} + +struct Bar { + froboz: usize, +} + +impl<S: Encoder> Encodable<S> for Bar { + fn encode(&self, _s: &mut S) -> Result<(), S::Error> { + Ok(()) + } +} + +enum WireProtocol { + JSON, + Opaque, + // ... +} + +fn encode_json<T: for<'a> Encodable<JsonEncoder<'a>>>(val: &T, wr: &mut Cursor<Vec<u8>>) { + write!(wr, "{}", as_json(val)); +} + +fn encode_opaque<T: Encodable<OpaqueEncoder>>(val: &T, wr: Vec<u8>) { + let mut encoder = OpaqueEncoder(wr); + val.encode(&mut encoder); +} + +pub fn main() { + let target = Foo { baz: false }; + let proto = WireProtocol::JSON; + match proto { + WireProtocol::JSON => encode_json(&target, &mut Cursor::new(Vec::new())), + WireProtocol::Opaque => encode_opaque(&target, Vec::new()), + } +} diff --git a/tests/ui/issue-13560.rs b/tests/ui/issue-13560.rs new file mode 100644 index 000000000..3397202be --- /dev/null +++ b/tests/ui/issue-13560.rs @@ -0,0 +1,13 @@ +// run-pass +// ignore-cross-compile (needs dylibs and compiletest doesn't have a more specific header) +// aux-build:issue-13560-1.rs +// aux-build:issue-13560-2.rs +// aux-build:issue-13560-3.rs + +// Regression test for issue #13560, the test itself is all in the dependent +// libraries. The fail which previously failed to compile is the one numbered 3. + +extern crate issue_13560_2 as t2; +extern crate issue_13560_3 as t3; + +fn main() {} diff --git a/tests/ui/issue-15924.rs b/tests/ui/issue-15924.rs new file mode 100644 index 000000000..d8b3914d0 --- /dev/null +++ b/tests/ui/issue-15924.rs @@ -0,0 +1,53 @@ +// run-pass + +#![allow(unused_imports)] +#![allow(unused_must_use)] +// pretty-expanded FIXME #23616 + +use std::fmt; +use std::marker::PhantomData; + +trait Encoder { + type Error; +} + +trait Encodable<S: Encoder> { + fn encode(&self, s: &mut S) -> Result<(), S::Error>; +} + +impl<S: Encoder> Encodable<S> for i32 { + fn encode(&self, _s: &mut S) -> Result<(), S::Error> { + Ok(()) + } +} + +struct JsonEncoder<'a>(PhantomData<&'a mut ()>); + +impl Encoder for JsonEncoder<'_> { + type Error = (); +} + +fn encode_json<T: for<'r> Encodable<JsonEncoder<'r>>>( + object: &T, +) -> Result<String, ()> { + let s = String::new(); + { + let mut encoder = JsonEncoder(PhantomData); + object.encode(&mut encoder)?; + } + Ok(s) +} + +struct Foo<T: for<'a> Encodable<JsonEncoder<'a>>> { + v: T, +} + +impl<T: for<'a> Encodable<JsonEncoder<'a>>> Drop for Foo<T> { + fn drop(&mut self) { + encode_json(&self.v); + } +} + +fn main() { + let _ = Foo { v: 10 }; +} diff --git a/tests/ui/issue-16822.rs b/tests/ui/issue-16822.rs new file mode 100644 index 000000000..c611c33af --- /dev/null +++ b/tests/ui/issue-16822.rs @@ -0,0 +1,22 @@ +// run-pass +// aux-build:issue-16822.rs + +extern crate issue_16822 as lib; + +use std::cell::RefCell; + +struct App { + i: isize +} + +impl lib::Update for App { + fn update(&mut self) { + self.i += 1; + } +} + +fn main(){ + let app = App { i: 5 }; + let window = lib::Window { data: RefCell::new(app) }; + window.update(1); +} diff --git a/tests/ui/issue-18502.rs b/tests/ui/issue-18502.rs new file mode 100644 index 000000000..2082ae7a9 --- /dev/null +++ b/tests/ui/issue-18502.rs @@ -0,0 +1,8 @@ +// run-pass +// aux-build:issue-18502.rs + +extern crate issue_18502 as fmt; + +fn main() { + ::fmt::baz(); +} diff --git a/tests/ui/issue-24106.rs b/tests/ui/issue-24106.rs new file mode 100644 index 000000000..45f0bd5b6 --- /dev/null +++ b/tests/ui/issue-24106.rs @@ -0,0 +1,8 @@ +// run-pass +// aux-build:issue-24106.rs + +extern crate issue_24106; + +fn main() { + issue_24106::go::<()>(); +} diff --git a/tests/ui/issue-2804.rs b/tests/ui/issue-2804.rs new file mode 100644 index 000000000..571028c5e --- /dev/null +++ b/tests/ui/issue-2804.rs @@ -0,0 +1,81 @@ +// run-pass + +#![allow(non_camel_case_types)] +#![allow(dead_code)] + +use std::collections::{BTreeMap, HashMap}; +use std::option; + +#[derive(Clone, Debug)] +enum Json { + I64(i64), + U64(u64), + F64(f64), + String(String), + Boolean(bool), + Array(Array), + Object(Object), + Null, +} + +type Array = Vec<Json>; +type Object = BTreeMap<String, Json>; + +enum object { + bool_value(bool), + int_value(i64), +} + +fn lookup(table: Object, key: String, default: String) -> String +{ + match table.get(&key) { + option::Option::Some(&Json::String(ref s)) => { + s.to_string() + } + option::Option::Some(value) => { + println!("{} was expected to be a string but is a {:?}", key, value); + default + } + option::Option::None => { + default + } + } +} + +fn add_interface(_store: isize, managed_ip: String, data: Json) -> (String, object) +{ + match &data { + &Json::Object(ref interface) => { + let name = lookup(interface.clone(), + "ifDescr".to_string(), + "".to_string()); + let label = format!("{}-{}", managed_ip, name); + + (label, object::bool_value(false)) + } + _ => { + println!("Expected dict for {} interfaces, found {:?}", managed_ip, data); + ("gnos:missing-interface".to_string(), object::bool_value(true)) + } + } +} + +fn add_interfaces(store: isize, managed_ip: String, device: HashMap<String, Json>) +-> Vec<(String, object)> { + match device["interfaces"] { + Json::Array(ref interfaces) => + { + interfaces.iter().map(|interface| { + add_interface(store, managed_ip.clone(), (*interface).clone()) + }).collect() + } + _ => + { + println!("Expected list for {} interfaces, found {:?}", managed_ip, + device["interfaces"]); + Vec::new() + } + } +} + +pub fn main() {} diff --git a/tests/ui/issues/issue-10465.stderr b/tests/ui/issues/issue-10465.stderr index 0ccf69dc0..1b7b9d590 100644 --- a/tests/ui/issues/issue-10465.stderr +++ b/tests/ui/issues/issue-10465.stderr @@ -7,7 +7,7 @@ LL | b.foo(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use a::A; +LL + use a::A; | error: aborting due to previous error diff --git a/tests/ui/issues/issue-106755.rs b/tests/ui/issues/issue-106755.rs index 46ece725f..5eabc3bfb 100644 --- a/tests/ui/issues/issue-106755.rs +++ b/tests/ui/issues/issue-106755.rs @@ -15,5 +15,7 @@ impl<T: MyTrait> !Send for TestType<T> {} //~ ERROR found both positive and nega unsafe impl<T: 'static> Send for TestType<T> {} //~ ERROR conflicting implementations impl !Send for TestType<i32> {} +//~^ WARNING +//~| WARNING this will change its meaning fn main() {} diff --git a/tests/ui/issues/issue-106755.stderr b/tests/ui/issues/issue-106755.stderr index 543970340..6b3a8427e 100644 --- a/tests/ui/issues/issue-106755.stderr +++ b/tests/ui/issues/issue-106755.stderr @@ -16,7 +16,23 @@ LL | unsafe impl<T: MyTrait + 'static> Send for TestType<T> {} LL | unsafe impl<T: 'static> Send for TestType<T> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `TestType<_>` -error: aborting due to 2 previous errors +warning: cross-crate traits with a default impl, like `Send`, should not be specialized + --> $DIR/issue-106755.rs:17:1 + | +LL | impl !Send for TestType<i32> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this will change its meaning in a future release! + = note: for more information, see issue #93367 <https://github.com/rust-lang/rust/issues/93367> + = note: `i32` is not a generic parameter +note: try using the same sequence of generic parameters as the struct definition + --> $DIR/issue-106755.rs:9:1 + | +LL | struct TestType<T>(::std::marker::PhantomData<T>); + | ^^^^^^^^^^^^^^^^^^ + = note: `#[warn(suspicious_auto_trait_impls)]` on by default + +error: aborting due to 2 previous errors; 1 warning emitted Some errors have detailed explanations: E0119, E0751. For more information about an error, try `rustc --explain E0119`. diff --git a/tests/ui/issues/issue-11709.rs b/tests/ui/issues/issue-11709.rs index cb5e3dff3..58424f9e4 100644 --- a/tests/ui/issues/issue-11709.rs +++ b/tests/ui/issues/issue-11709.rs @@ -1,6 +1,5 @@ // run-pass #![allow(dead_code)] -// ignore-pretty issue #37199 // Don't panic on blocks without results // There are several tests in this run-pass that raised diff --git a/tests/ui/issues/issue-12511.stderr b/tests/ui/issues/issue-12511.stderr index 789a1141c..558aad109 100644 --- a/tests/ui/issues/issue-12511.stderr +++ b/tests/ui/issues/issue-12511.stderr @@ -1,20 +1,10 @@ error[E0391]: cycle detected when computing the super predicates of `T1` - --> $DIR/issue-12511.rs:1:1 - | -LL | trait T1 : T2 { - | ^^^^^^^^^^^^^ - | -note: ...which requires computing the super traits of `T1`... --> $DIR/issue-12511.rs:1:12 | LL | trait T1 : T2 { | ^^ -note: ...which requires computing the super predicates of `T2`... - --> $DIR/issue-12511.rs:5:1 | -LL | trait T2 : T1 { - | ^^^^^^^^^^^^^ -note: ...which requires computing the super traits of `T2`... +note: ...which requires computing the super predicates of `T2`... --> $DIR/issue-12511.rs:5:12 | LL | trait T2 : T1 { diff --git a/tests/ui/issues/issue-17546.stderr b/tests/ui/issues/issue-17546.stderr index 81592320a..cf7ed1bbd 100644 --- a/tests/ui/issues/issue-17546.stderr +++ b/tests/ui/issues/issue-17546.stderr @@ -24,13 +24,13 @@ LL | fn new() -> Result<foo::MyEnum, String> { | help: consider importing one of these items instead | -LL | use std::fmt::Result; +LL + use std::fmt::Result; | -LL | use std::io::Result; +LL + use std::io::Result; | -LL | use std::result::Result; +LL + use std::result::Result; | -LL | use std::thread::Result; +LL + use std::thread::Result; | error[E0573]: expected type, found variant `Result` @@ -41,13 +41,13 @@ LL | fn new() -> Result<foo::MyEnum, String> { | help: consider importing one of these items instead | -LL | use std::fmt::Result; +LL + use std::fmt::Result; | -LL | use std::io::Result; +LL + use std::io::Result; | -LL | use std::result::Result; +LL + use std::result::Result; | -LL | use std::thread::Result; +LL + use std::thread::Result; | error[E0573]: expected type, found variant `NoResult` diff --git a/tests/ui/issues/issue-19086.stderr b/tests/ui/issues/issue-19086.stderr index a3c06a725..90d0bb406 100644 --- a/tests/ui/issues/issue-19086.stderr +++ b/tests/ui/issues/issue-19086.stderr @@ -5,7 +5,7 @@ LL | FooB { x: i32, y: i32 } | ----------------------- `FooB` defined here ... LL | FooB(a, b) => println!("{} {}", a, b), - | ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x, y }` + | ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x: a, y: b }` error: aborting due to previous error diff --git a/tests/ui/issues/issue-20162.stderr b/tests/ui/issues/issue-20162.stderr index 1c5b76fbf..ebdf2528f 100644 --- a/tests/ui/issues/issue-20162.stderr +++ b/tests/ui/issues/issue-20162.stderr @@ -8,7 +8,8 @@ note: required by a bound in `slice::<impl [T]>::sort` --> $SRC_DIR/alloc/src/slice.rs:LL:COL help: consider annotating `X` with `#[derive(Ord)]` | -LL | #[derive(Ord)] +LL + #[derive(Ord)] +LL | struct X { x: i32 } | error: aborting due to previous error diff --git a/tests/ui/issues/issue-20413.stderr b/tests/ui/issues/issue-20413.stderr index 202e84631..8891a2678 100644 --- a/tests/ui/issues/issue-20413.stderr +++ b/tests/ui/issues/issue-20413.stderr @@ -20,51 +20,51 @@ note: required for `NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoData<NoDa LL | impl<T> Foo for T where NoData<T>: Foo { | ^^^ ^ --- unsatisfied trait bound introduced here = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' - = note: 127 redundant requirements hidden + = note: 126 redundant requirements hidden = note: required for `NoData<T>` to implement `Foo` -error[E0275]: overflow evaluating the requirement `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<...>>>>>>>: Baz` +error[E0275]: overflow evaluating the requirement `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<...>>>>>>>: Bar` --> $DIR/issue-20413.rs:28:42 | LL | impl<T> Bar for T where EvenLessData<T>: Baz { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<...>>>>>>>` to implement `Bar` - --> $DIR/issue-20413.rs:28:9 - | -LL | impl<T> Bar for T where EvenLessData<T>: Baz { - | ^^^ ^ --- unsatisfied trait bound introduced here - = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' note: required for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<...>>>>>>>` to implement `Baz` --> $DIR/issue-20413.rs:35:9 | LL | impl<T> Baz for T where AlmostNoData<T>: Bar { | ^^^ ^ --- unsatisfied trait bound introduced here = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' - = note: 126 redundant requirements hidden +note: required for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<...>>>>>>>` to implement `Bar` + --> $DIR/issue-20413.rs:28:9 + | +LL | impl<T> Bar for T where EvenLessData<T>: Baz { + | ^^^ ^ --- unsatisfied trait bound introduced here + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' + = note: 125 redundant requirements hidden = note: required for `EvenLessData<T>` to implement `Baz` -error[E0275]: overflow evaluating the requirement `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<...>>>>>>>: Bar` +error[E0275]: overflow evaluating the requirement `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<...>>>>>>>: Baz` --> $DIR/issue-20413.rs:35:42 | LL | impl<T> Baz for T where AlmostNoData<T>: Bar { | ^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`issue_20413`) -note: required for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<...>>>>>>>` to implement `Baz` - --> $DIR/issue-20413.rs:35:9 - | -LL | impl<T> Baz for T where AlmostNoData<T>: Bar { - | ^^^ ^ --- unsatisfied trait bound introduced here - = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' note: required for `AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<...>>>>>>>` to implement `Bar` --> $DIR/issue-20413.rs:28:9 | LL | impl<T> Bar for T where EvenLessData<T>: Baz { | ^^^ ^ --- unsatisfied trait bound introduced here = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' - = note: 126 redundant requirements hidden +note: required for `EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<AlmostNoData<EvenLessData<...>>>>>>>` to implement `Baz` + --> $DIR/issue-20413.rs:35:9 + | +LL | impl<T> Baz for T where AlmostNoData<T>: Bar { + | ^^^ ^ --- unsatisfied trait bound introduced here + = note: the full type name has been written to '$TEST_BUILD_DIR/issues/issue-20413/issue-20413.long-type-hash.txt' + = note: 125 redundant requirements hidden = note: required for `AlmostNoData<T>` to implement `Bar` error: aborting due to 4 previous errors diff --git a/tests/ui/issues/issue-20772.stderr b/tests/ui/issues/issue-20772.stderr index 22b9f5bd4..416fd8c06 100644 --- a/tests/ui/issues/issue-20772.stderr +++ b/tests/ui/issues/issue-20772.stderr @@ -5,7 +5,7 @@ LL | trait T : Iterator<Item=Self::Item> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = note: ...which immediately requires computing the super traits of `T` with associated type name `Item` again -note: cycle used when computing the super traits of `T` +note: cycle used when computing the super predicates of `T` --> $DIR/issue-20772.rs:1:1 | LL | trait T : Iterator<Item=Self::Item> diff --git a/tests/ui/issues/issue-21160.stderr b/tests/ui/issues/issue-21160.stderr index 266749376..b39a3aad3 100644 --- a/tests/ui/issues/issue-21160.stderr +++ b/tests/ui/issues/issue-21160.stderr @@ -9,7 +9,8 @@ LL | struct Foo(Bar); = note: this error originates in the derive macro `Hash` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Bar` with `#[derive(Hash)]` | -LL | #[derive(Hash)] +LL + #[derive(Hash)] +LL | struct Bar; | error: aborting due to previous error diff --git a/tests/ui/issues/issue-27340.rs b/tests/ui/issues/issue-27340.rs index 61c77cc1f..aff37d95a 100644 --- a/tests/ui/issues/issue-27340.rs +++ b/tests/ui/issues/issue-27340.rs @@ -1,6 +1,6 @@ struct Foo; #[derive(Copy, Clone)] -//~^ ERROR the trait `Copy` may not be implemented for this type +//~^ ERROR the trait `Copy` cannot be implemented for this type struct Bar(Foo); fn main() {} diff --git a/tests/ui/issues/issue-27340.stderr b/tests/ui/issues/issue-27340.stderr index 40889b866..9caaffd9c 100644 --- a/tests/ui/issues/issue-27340.stderr +++ b/tests/ui/issues/issue-27340.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/issue-27340.rs:2:10 | LL | #[derive(Copy, Clone)] diff --git a/tests/ui/issues/issue-27842.rs b/tests/ui/issues/issue-27842.rs index 3bcfa1330..060d3b34e 100644 --- a/tests/ui/issues/issue-27842.rs +++ b/tests/ui/issues/issue-27842.rs @@ -8,4 +8,9 @@ fn main() { let i = 0_usize; let _ = tup[i]; //~^ ERROR cannot index into a value of type + + // the case where the index is out of bounds + let tup = (10,); + let _ = tup[3]; + //~^ ERROR cannot index into a value of type } diff --git a/tests/ui/issues/issue-27842.stderr b/tests/ui/issues/issue-27842.stderr index 784666a63..83333aa0c 100644 --- a/tests/ui/issues/issue-27842.stderr +++ b/tests/ui/issues/issue-27842.stderr @@ -8,10 +8,20 @@ error[E0608]: cannot index into a value of type `({integer}, {integer}, {integer --> $DIR/issue-27842.rs:9:13 | LL | let _ = tup[i]; + | ^^^^-^ + | | + | cannot access tuple elements at a variable index + | + = help: to access tuple elements, use tuple indexing syntax (e.g., `tuple.0`) + +error[E0608]: cannot index into a value of type `({integer},)` + --> $DIR/issue-27842.rs:14:13 + | +LL | let _ = tup[3]; | ^^^^^^ | = help: to access tuple elements, use tuple indexing syntax (e.g., `tuple.0`) -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0608`. diff --git a/tests/ui/issues/issue-28433.rs b/tests/ui/issues/issue-28433.rs index 8d05c32d5..2298ad240 100644 --- a/tests/ui/issues/issue-28433.rs +++ b/tests/ui/issues/issue-28433.rs @@ -1,9 +1,9 @@ enum Bird { pub Duck, - //~^ ERROR unnecessary visibility qualifier + //~^ ERROR visibility qualifiers are not permitted here Goose, pub(crate) Dove - //~^ ERROR unnecessary visibility qualifier + //~^ ERROR visibility qualifiers are not permitted here } diff --git a/tests/ui/issues/issue-28433.stderr b/tests/ui/issues/issue-28433.stderr index 9f5f63336..5fb8a8962 100644 --- a/tests/ui/issues/issue-28433.stderr +++ b/tests/ui/issues/issue-28433.stderr @@ -1,14 +1,18 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/issue-28433.rs:2:5 | LL | pub Duck, - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: enum variants and their fields always share the visibility of the enum they are in -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/issue-28433.rs:5:5 | LL | pub(crate) Dove | ^^^^^^^^^^ + | + = note: enum variants and their fields always share the visibility of the enum they are in error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-28839.rs b/tests/ui/issues/issue-28839.rs index 73be87a0c..c086f412a 100644 --- a/tests/ui/issues/issue-28839.rs +++ b/tests/ui/issues/issue-28839.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty issue #37199 pub struct Foo; diff --git a/tests/ui/issues/issue-3029.rs b/tests/ui/issues/issue-3029.rs index a5d30960a..43c8a0a23 100644 --- a/tests/ui/issues/issue-3029.rs +++ b/tests/ui/issues/issue-3029.rs @@ -2,9 +2,7 @@ // error-pattern:so long // ignore-emscripten no processes -#![allow(unused_allocation)] #![allow(unreachable_code)] -#![allow(unused_variables)] fn main() { let mut x = Vec::new(); diff --git a/tests/ui/issues/issue-35976.unimported.stderr b/tests/ui/issues/issue-35976.unimported.stderr index 5d61bb8ea..b31d2a315 100644 --- a/tests/ui/issues/issue-35976.unimported.stderr +++ b/tests/ui/issues/issue-35976.unimported.stderr @@ -9,7 +9,7 @@ LL | arg.wait(); | help: another candidate was found in the following trait, perhaps add a `use` for it: | -LL | use private::Future; +LL + use private::Future; | error: aborting due to previous error diff --git a/tests/ui/issues/issue-37534.stderr b/tests/ui/issues/issue-37534.stderr index 895479986..7d3dd8800 100644 --- a/tests/ui/issues/issue-37534.stderr +++ b/tests/ui/issues/issue-37534.stderr @@ -6,7 +6,7 @@ LL | struct Foo<T: ?Hash> { } | help: consider importing this trait instead | -LL | use std::hash::Hash; +LL + use std::hash::Hash; | warning: default bound relaxed for a type parameter, but this does nothing because the given bound is not a default; only `?Sized` is supported diff --git a/tests/ui/issues/issue-38190.rs b/tests/ui/issues/issue-38190.rs index cfa0420c8..3bb4c7b98 100644 --- a/tests/ui/issues/issue-38190.rs +++ b/tests/ui/issues/issue-38190.rs @@ -1,6 +1,5 @@ // run-pass // aux-build:issue-38190.rs -// ignore-pretty issue #37195 #[macro_use] extern crate issue_38190; diff --git a/tests/ui/issues/issue-39175.stderr b/tests/ui/issues/issue-39175.stderr index afceae82e..3a1476ac0 100644 --- a/tests/ui/issues/issue-39175.stderr +++ b/tests/ui/issues/issue-39175.stderr @@ -7,7 +7,7 @@ LL | Command::new("echo").arg("hello").exec(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use std::os::unix::process::CommandExt; +LL + use std::os::unix::process::CommandExt; | error: aborting due to previous error diff --git a/tests/ui/issues/issue-50403.rs b/tests/ui/issues/issue-50403.rs index 012057fc2..ab22aff26 100644 --- a/tests/ui/issues/issue-50403.rs +++ b/tests/ui/issues/issue-50403.rs @@ -1,5 +1,5 @@ #![feature(concat_idents)] fn main() { - let x = concat_idents!(); //~ ERROR concat_idents! takes 1 or more arguments + let x = concat_idents!(); //~ ERROR `concat_idents!()` takes 1 or more arguments } diff --git a/tests/ui/issues/issue-50403.stderr b/tests/ui/issues/issue-50403.stderr index a3a2ed044..d50befa5e 100644 --- a/tests/ui/issues/issue-50403.stderr +++ b/tests/ui/issues/issue-50403.stderr @@ -1,4 +1,4 @@ -error: concat_idents! takes 1 or more arguments +error: `concat_idents!()` takes 1 or more arguments --> $DIR/issue-50403.rs:4:13 | LL | let x = concat_idents!(); diff --git a/tests/ui/issues/issue-56175.stderr b/tests/ui/issues/issue-56175.stderr index 013a440ed..1ddee1f48 100644 --- a/tests/ui/issues/issue-56175.stderr +++ b/tests/ui/issues/issue-56175.stderr @@ -12,7 +12,7 @@ LL | fn trait_method(&self) { = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use reexported_trait::Trait; +LL + use reexported_trait::Trait; | error[E0599]: no method named `trait_method_b` found for struct `FooStruct` in the current scope @@ -29,7 +29,7 @@ LL | fn trait_method_b(&self) { = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use reexported_trait::TraitBRename; +LL + use reexported_trait::TraitBRename; | error: aborting due to 2 previous errors diff --git a/tests/ui/issues/issue-59488.stderr b/tests/ui/issues/issue-59488.stderr index d45beefa4..ac8862716 100644 --- a/tests/ui/issues/issue-59488.stderr +++ b/tests/ui/issues/issue-59488.stderr @@ -90,16 +90,6 @@ LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}` - = help: the following other types implement trait `Debug`: - extern "C" fn() -> Ret - extern "C" fn(A, B) -> Ret - extern "C" fn(A, B, ...) -> Ret - extern "C" fn(A, B, C) -> Ret - extern "C" fn(A, B, C, ...) -> Ret - extern "C" fn(A, B, C, D) -> Ret - extern "C" fn(A, B, C, D, ...) -> Ret - extern "C" fn(A, B, C, D, E) -> Ret - and 118 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug` @@ -109,16 +99,6 @@ LL | assert_eq!(Foo::Bar, i); | ^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}` - = help: the following other types implement trait `Debug`: - extern "C" fn() -> Ret - extern "C" fn(A, B) -> Ret - extern "C" fn(A, B, ...) -> Ret - extern "C" fn(A, B, C) -> Ret - extern "C" fn(A, B, C, ...) -> Ret - extern "C" fn(A, B, C, D) -> Ret - extern "C" fn(A, B, C, D, ...) -> Ret - extern "C" fn(A, B, C, D, E) -> Ret - and 118 others = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 10 previous errors diff --git a/tests/ui/issues/issue-62375.stderr b/tests/ui/issues/issue-62375.stderr index 478e025be..a6fd3700e 100644 --- a/tests/ui/issues/issue-62375.stderr +++ b/tests/ui/issues/issue-62375.stderr @@ -13,7 +13,8 @@ LL | enum A { | ^^^^^^ must implement `PartialEq<_>` help: consider annotating `A` with `#[derive(PartialEq)]` | -LL | #[derive(PartialEq)] +LL + #[derive(PartialEq)] +LL | enum A { | error: aborting due to previous error diff --git a/tests/ui/issues/issue-66667-function-cmp-cycle.rs b/tests/ui/issues/issue-66667-function-cmp-cycle.rs index 7b025be11..b4f09fbbb 100644 --- a/tests/ui/issues/issue-66667-function-cmp-cycle.rs +++ b/tests/ui/issues/issue-66667-function-cmp-cycle.rs @@ -1,16 +1,19 @@ fn first() { second == 1 //~ ERROR binary operation //~^ ERROR mismatched types + //~| ERROR mismatched types } fn second() { first == 1 //~ ERROR binary operation //~^ ERROR mismatched types + //~| ERROR mismatched types } fn bar() { bar == 1 //~ ERROR binary operation //~^ ERROR mismatched types + //~| ERROR mismatched types } fn main() {} diff --git a/tests/ui/issues/issue-66667-function-cmp-cycle.stderr b/tests/ui/issues/issue-66667-function-cmp-cycle.stderr index 887699ef5..d9a960ce1 100644 --- a/tests/ui/issues/issue-66667-function-cmp-cycle.stderr +++ b/tests/ui/issues/issue-66667-function-cmp-cycle.stderr @@ -15,8 +15,16 @@ LL | second == 1 = note: expected fn item `fn() {second}` found type `{integer}` +error[E0308]: mismatched types + --> $DIR/issue-66667-function-cmp-cycle.rs:2:5 + | +LL | fn first() { + | - help: try adding a return type: `-> bool` +LL | second == 1 + | ^^^^^^^^^^^ expected `()`, found `bool` + error[E0369]: binary operation `==` cannot be applied to type `fn() {first}` - --> $DIR/issue-66667-function-cmp-cycle.rs:7:11 + --> $DIR/issue-66667-function-cmp-cycle.rs:8:11 | LL | first == 1 | ----- ^^ - {integer} @@ -24,7 +32,7 @@ LL | first == 1 | fn() {first} error[E0308]: mismatched types - --> $DIR/issue-66667-function-cmp-cycle.rs:7:14 + --> $DIR/issue-66667-function-cmp-cycle.rs:8:14 | LL | first == 1 | ^ expected fn item, found integer @@ -32,8 +40,16 @@ LL | first == 1 = note: expected fn item `fn() {first}` found type `{integer}` +error[E0308]: mismatched types + --> $DIR/issue-66667-function-cmp-cycle.rs:8:5 + | +LL | fn second() { + | - help: try adding a return type: `-> bool` +LL | first == 1 + | ^^^^^^^^^^ expected `()`, found `bool` + error[E0369]: binary operation `==` cannot be applied to type `fn() {bar}` - --> $DIR/issue-66667-function-cmp-cycle.rs:12:9 + --> $DIR/issue-66667-function-cmp-cycle.rs:14:9 | LL | bar == 1 | --- ^^ - {integer} @@ -41,7 +57,7 @@ LL | bar == 1 | fn() {bar} error[E0308]: mismatched types - --> $DIR/issue-66667-function-cmp-cycle.rs:12:12 + --> $DIR/issue-66667-function-cmp-cycle.rs:14:12 | LL | bar == 1 | ^ expected fn item, found integer @@ -49,7 +65,15 @@ LL | bar == 1 = note: expected fn item `fn() {bar}` found type `{integer}` -error: aborting due to 6 previous errors +error[E0308]: mismatched types + --> $DIR/issue-66667-function-cmp-cycle.rs:14:5 + | +LL | fn bar() { + | - help: try adding a return type: `-> bool` +LL | bar == 1 + | ^^^^^^^^ expected `()`, found `bool` + +error: aborting due to 9 previous errors Some errors have detailed explanations: E0308, E0369. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/issues/issue-77919.stderr b/tests/ui/issues/issue-77919.stderr index d154bfe0c..d6dcc8997 100644 --- a/tests/ui/issues/issue-77919.stderr +++ b/tests/ui/issues/issue-77919.stderr @@ -6,7 +6,7 @@ LL | _n: PhantomData, | help: consider importing this struct | -LL | use std::marker::PhantomData; +LL + use std::marker::PhantomData; | error[E0412]: cannot find type `VAL` in this scope diff --git a/tests/ui/issues/issue-9129.rs b/tests/ui/issues/issue-9129.rs index 04110b3ae..5d623ed54 100644 --- a/tests/ui/issues/issue-9129.rs +++ b/tests/ui/issues/issue-9129.rs @@ -2,7 +2,6 @@ #![allow(dead_code)] #![allow(non_camel_case_types)] #![allow(non_snake_case)] -// ignore-pretty unreported pub trait bomb { fn boom(&self, _: Ident); } pub struct S; diff --git a/tests/ui/issues/issue-98299.stderr b/tests/ui/issues/issue-98299.stderr index fd905392a..4fd9f3030 100644 --- a/tests/ui/issues/issue-98299.stderr +++ b/tests/ui/issues/issue-98299.stderr @@ -4,7 +4,7 @@ error[E0282]: type annotations needed for `SmallCString<N>` LL | SmallCString::try_from(p).map(|cstr| cstr); | ^^^^ | -help: consider giving this closure parameter an explicit type, where the the value of const parameter `N` is specified +help: consider giving this closure parameter an explicit type, where the value of const parameter `N` is specified | LL | SmallCString::try_from(p).map(|cstr: SmallCString<N>| cstr); | +++++++++++++++++ diff --git a/tests/ui/iterators/into-iter-on-arrays-lint.fixed b/tests/ui/iterators/into-iter-on-arrays-lint.fixed index 6e02a7024..5b91aaf9e 100644 --- a/tests/ui/iterators/into-iter-on-arrays-lint.fixed +++ b/tests/ui/iterators/into-iter-on-arrays-lint.fixed @@ -2,7 +2,7 @@ // run-rustfix // rustfix-only-machine-applicable -#[allow(unused_must_use)] +#[allow(unused_must_use, unused_allocation)] fn main() { let small = [1, 2]; let big = [0u8; 33]; diff --git a/tests/ui/iterators/into-iter-on-arrays-lint.rs b/tests/ui/iterators/into-iter-on-arrays-lint.rs index 582d5cadd..25b0cef73 100644 --- a/tests/ui/iterators/into-iter-on-arrays-lint.rs +++ b/tests/ui/iterators/into-iter-on-arrays-lint.rs @@ -2,7 +2,7 @@ // run-rustfix // rustfix-only-machine-applicable -#[allow(unused_must_use)] +#[allow(unused_must_use, unused_allocation)] fn main() { let small = [1, 2]; let big = [0u8; 33]; diff --git a/tests/ui/kindck/kindck-impl-type-params.stderr b/tests/ui/kindck/kindck-impl-type-params.stderr index 6fd1fc3f7..efb25bf83 100644 --- a/tests/ui/kindck/kindck-impl-type-params.stderr +++ b/tests/ui/kindck/kindck-impl-type-params.stderr @@ -107,7 +107,8 @@ LL | impl<T: Send + Copy + 'static> Gettable<T> for S<T> {} = note: required for the cast from `S<Foo>` to the object type `dyn Gettable<Foo>` help: consider annotating `Foo` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | struct Foo; // does not impl Copy | error: aborting due to 6 previous errors diff --git a/tests/ui/lang-items/no_owned_box_lang_item.rs b/tests/ui/lang-items/no_owned_box_lang_item.rs deleted file mode 100644 index c22b44ffc..000000000 --- a/tests/ui/lang-items/no_owned_box_lang_item.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Test that we don't ICE when we are missing the owned_box lang item. - -// error-pattern: requires `owned_box` lang_item - -#![feature(lang_items, box_syntax)] -#![no_std] - -use core::panic::PanicInfo; - -fn main() { - let x = box 1i32; -} - -#[lang = "eh_personality"] extern "C" fn eh_personality() {} -#[lang = "eh_catch_typeinfo"] static EH_CATCH_TYPEINFO: u8 = 0; -#[lang = "panic_impl"] fn panic_impl(panic: &PanicInfo) -> ! { loop {} } diff --git a/tests/ui/lang-items/no_owned_box_lang_item.stderr b/tests/ui/lang-items/no_owned_box_lang_item.stderr deleted file mode 100644 index c55c246b5..000000000 --- a/tests/ui/lang-items/no_owned_box_lang_item.stderr +++ /dev/null @@ -1,4 +0,0 @@ -error: requires `owned_box` lang_item - -error: aborting due to previous error - diff --git a/tests/ui/late-bound-lifetimes/issue-80618.rs b/tests/ui/late-bound-lifetimes/issue-80618.rs new file mode 100644 index 000000000..6aa8ff461 --- /dev/null +++ b/tests/ui/late-bound-lifetimes/issue-80618.rs @@ -0,0 +1,8 @@ +fn foo<'a>(x: &'a str) -> &'a str { + x +} + +fn main() { + let _ = foo::<'static>; +//~^ ERROR cannot specify lifetime arguments explicitly if late bound lifetime parameters are present [E0794] +} diff --git a/tests/ui/late-bound-lifetimes/issue-80618.stderr b/tests/ui/late-bound-lifetimes/issue-80618.stderr new file mode 100644 index 000000000..cf7423fc1 --- /dev/null +++ b/tests/ui/late-bound-lifetimes/issue-80618.stderr @@ -0,0 +1,15 @@ +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present + --> $DIR/issue-80618.rs:6:19 + | +LL | let _ = foo::<'static>; + | ^^^^^^^ + | +note: the late bound lifetime parameter is introduced here + --> $DIR/issue-80618.rs:1:8 + | +LL | fn foo<'a>(x: &'a str) -> &'a str { + | ^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0794`. diff --git a/tests/ui/layout/issue-84108.stderr b/tests/ui/layout/issue-84108.stderr index 36be64241..5ad450bed 100644 --- a/tests/ui/layout/issue-84108.stderr +++ b/tests/ui/layout/issue-84108.stderr @@ -6,7 +6,7 @@ LL | static FOO: (dyn AsRef<OsStr>, u8) = ("hello", 42); | help: consider importing this struct | -LL | use std::ffi::OsStr; +LL + use std::ffi::OsStr; | error[E0412]: cannot find type `Path` in this scope @@ -17,7 +17,7 @@ LL | const BAR: (&Path, [u8], usize) = ("hello", [], 42); | help: consider importing this struct | -LL | use std::path::Path; +LL + use std::path::Path; | error[E0277]: the size for values of type `[u8]` cannot be known at compilation time diff --git a/tests/ui/layout/transmute-to-tail-with-err.rs b/tests/ui/layout/transmute-to-tail-with-err.rs new file mode 100644 index 000000000..6753ce15e --- /dev/null +++ b/tests/ui/layout/transmute-to-tail-with-err.rs @@ -0,0 +1,8 @@ +trait Trait<T> {} + +struct Bar(Box<dyn Trait<T>>); +//~^ ERROR cannot find type `T` in this scope + +fn main() { + let x: Bar = unsafe { std::mem::transmute(()) }; +} diff --git a/tests/ui/layout/transmute-to-tail-with-err.stderr b/tests/ui/layout/transmute-to-tail-with-err.stderr new file mode 100644 index 000000000..97ab59c39 --- /dev/null +++ b/tests/ui/layout/transmute-to-tail-with-err.stderr @@ -0,0 +1,14 @@ +error[E0412]: cannot find type `T` in this scope + --> $DIR/transmute-to-tail-with-err.rs:3:26 + | +LL | struct Bar(Box<dyn Trait<T>>); + | ^ not found in this scope + | +help: you might be missing a type parameter + | +LL | struct Bar<T>(Box<dyn Trait<T>>); + | +++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/lexer/lexer-crlf-line-endings-string-literal-doc-comment.rs b/tests/ui/lexer/lexer-crlf-line-endings-string-literal-doc-comment.rs index 802be7f5a..9ba01540a 100644 --- a/tests/ui/lexer/lexer-crlf-line-endings-string-literal-doc-comment.rs +++ b/tests/ui/lexer/lexer-crlf-line-endings-string-literal-doc-comment.rs @@ -6,7 +6,6 @@ // N.B., this file needs CRLF line endings. The .gitattributes file in
// this directory should enforce it.
-// ignore-pretty issue #37195
/// Doc comment that ends in CRLF
pub fn foo() {}
diff --git a/tests/ui/unterminated-comment.rs b/tests/ui/lexer/unterminated-comment.rs index 1cfdfb1fb..1cfdfb1fb 100644 --- a/tests/ui/unterminated-comment.rs +++ b/tests/ui/lexer/unterminated-comment.rs diff --git a/tests/ui/unterminated-comment.stderr b/tests/ui/lexer/unterminated-comment.stderr index c513fafee..c513fafee 100644 --- a/tests/ui/unterminated-comment.stderr +++ b/tests/ui/lexer/unterminated-comment.stderr diff --git a/tests/ui/unterminated-nested-comment.rs b/tests/ui/lexer/unterminated-nested-comment.rs index db5f2f3ba..db5f2f3ba 100644 --- a/tests/ui/unterminated-nested-comment.rs +++ b/tests/ui/lexer/unterminated-nested-comment.rs diff --git a/tests/ui/unterminated-nested-comment.stderr b/tests/ui/lexer/unterminated-nested-comment.stderr index 3653e76c9..3653e76c9 100644 --- a/tests/ui/unterminated-nested-comment.stderr +++ b/tests/ui/lexer/unterminated-nested-comment.stderr diff --git a/tests/ui/lifetimes/issue-93911.rs b/tests/ui/lifetimes/issue-93911.rs new file mode 100644 index 000000000..b7ccac1ee --- /dev/null +++ b/tests/ui/lifetimes/issue-93911.rs @@ -0,0 +1,18 @@ +// check-pass +// edition:2021 + +#![allow(dead_code)] + +struct Foo<'a>(&'a u32); + +impl<'a> Foo<'a> { + async fn foo() { + struct Bar<'b>(&'b u32); + + impl<'b> Bar<'b> { + async fn bar() {} + } + } +} + +fn main() {} diff --git a/tests/ui/lifetimes/issue-95023.stderr b/tests/ui/lifetimes/issue-95023.stderr index 35c3797c7..5b93eff86 100644 --- a/tests/ui/lifetimes/issue-95023.stderr +++ b/tests/ui/lifetimes/issue-95023.stderr @@ -25,6 +25,12 @@ error[E0229]: associated type bindings are not allowed here | LL | impl Fn(&isize) for Error { | ^^^^^^^^^^ associated type not allowed here + | +help: parenthesized trait syntax expands to `Fn<(&isize,), Output=()>` + --> $DIR/issue-95023.rs:3:6 + | +LL | impl Fn(&isize) for Error { + | ^^^^^^^^^^ error[E0220]: associated type `B` not found for `Self` --> $DIR/issue-95023.rs:6:44 diff --git a/tests/ui/lifetimes/unusual-rib-combinations.rs b/tests/ui/lifetimes/unusual-rib-combinations.rs index 1c122f42e..0ae68ad04 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.rs +++ b/tests/ui/lifetimes/unusual-rib-combinations.rs @@ -25,4 +25,9 @@ fn d<const C: S>() {} //~^ ERROR missing lifetime specifier //~| ERROR `S<'_>` is forbidden as the type of a const generic parameter +trait Foo<'a> {} +struct Bar<const N: &'a (dyn for<'a> Foo<'a>)>; +//~^ ERROR use of non-static lifetime `'a` in const generic +//~| ERROR `&dyn for<'a> Foo<'a>` is forbidden as the type of a const generic parameter + fn main() {} diff --git a/tests/ui/lifetimes/unusual-rib-combinations.stderr b/tests/ui/lifetimes/unusual-rib-combinations.stderr index 68f4fce01..20163d289 100644 --- a/tests/ui/lifetimes/unusual-rib-combinations.stderr +++ b/tests/ui/lifetimes/unusual-rib-combinations.stderr @@ -9,6 +9,14 @@ help: consider introducing a named lifetime parameter LL | fn d<'a, const C: S<'a>>() {} | +++ ++++ +error[E0771]: use of non-static lifetime `'a` in const generic + --> $DIR/unusual-rib-combinations.rs:29:22 + | +LL | struct Bar<const N: &'a (dyn for<'a> Foo<'a>)>; + | ^^ + | + = note: for more information, see issue #74052 <https://github.com/rust-lang/rust/issues/74052> + error[E0214]: parenthesized type parameters may only be used with a `Fn` trait --> $DIR/unusual-rib-combinations.rs:7:16 | @@ -55,7 +63,16 @@ LL | fn d<const C: S>() {} = note: the only supported types are integers, `bool` and `char` = help: more complex types are supported with `#![feature(adt_const_params)]` -error: aborting due to 7 previous errors +error: `&dyn for<'a> Foo<'a>` is forbidden as the type of a const generic parameter + --> $DIR/unusual-rib-combinations.rs:29:21 + | +LL | struct Bar<const N: &'a (dyn for<'a> Foo<'a>)>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: the only supported types are integers, `bool` and `char` + = help: more complex types are supported with `#![feature(adt_const_params)]` + +error: aborting due to 9 previous errors -Some errors have detailed explanations: E0106, E0214, E0308. +Some errors have detailed explanations: E0106, E0214, E0308, E0771. For more information about an error, try `rustc --explain E0106`. diff --git a/tests/ui/limits/issue-55878.stderr b/tests/ui/limits/issue-55878.stderr index 99f1fdf75..510b36edd 100644 --- a/tests/ui/limits/issue-55878.stderr +++ b/tests/ui/limits/issue-55878.stderr @@ -25,14 +25,6 @@ LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); | = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) -note: erroneous constant used - --> $DIR/issue-55878.rs:7:26 - | -LL | println!("Size: {}", std::mem::size_of::<[u8; u64::MAX as usize]>()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: this note originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) - error: aborting due to previous error For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/linkage-attr/issue-109144.rs b/tests/ui/linkage-attr/issue-109144.rs new file mode 100644 index 000000000..2f740e553 --- /dev/null +++ b/tests/ui/linkage-attr/issue-109144.rs @@ -0,0 +1,4 @@ +#![crate_type = "lib"] +#[link(kind = "static", modifiers = "+whole-archive,+bundle")] +//~^ ERROR `#[link]` attribute requires a `name = "string"` argument +extern {} diff --git a/tests/ui/linkage-attr/issue-109144.stderr b/tests/ui/linkage-attr/issue-109144.stderr new file mode 100644 index 000000000..33187cfdb --- /dev/null +++ b/tests/ui/linkage-attr/issue-109144.stderr @@ -0,0 +1,9 @@ +error[E0459]: `#[link]` attribute requires a `name = "string"` argument + --> $DIR/issue-109144.rs:2:1 + | +LL | #[link(kind = "static", modifiers = "+whole-archive,+bundle")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `name` argument + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0459`. diff --git a/tests/ui/lint/anonymous-reexport.rs b/tests/ui/lint/anonymous-reexport.rs new file mode 100644 index 000000000..11ac5d071 --- /dev/null +++ b/tests/ui/lint/anonymous-reexport.rs @@ -0,0 +1,19 @@ +#![deny(unused_imports)] +#![crate_type = "rlib"] + +mod my_mod { + pub trait Foo {} + pub type TyFoo = dyn Foo; + pub struct Bar; + pub type TyBar = Bar; +} + +pub use self::my_mod::Foo as _; +pub use self::my_mod::TyFoo as _; //~ ERROR unused import +pub use self::my_mod::Bar as _; //~ ERROR unused import +pub use self::my_mod::TyBar as _; //~ ERROR unused import +pub use self::my_mod::{Bar as _}; //~ ERROR unused import +pub use self::my_mod::{Bar as _, Foo as _}; //~ ERROR unused import +pub use self::my_mod::{Bar as _, TyBar as _}; //~ ERROR unused imports +#[allow(unused_imports)] +use self::my_mod::TyBar as _; diff --git a/tests/ui/lint/anonymous-reexport.stderr b/tests/ui/lint/anonymous-reexport.stderr new file mode 100644 index 000000000..e3854a545 --- /dev/null +++ b/tests/ui/lint/anonymous-reexport.stderr @@ -0,0 +1,44 @@ +error: unused import: `self::my_mod::TyFoo as _` + --> $DIR/anonymous-reexport.rs:12:9 + | +LL | pub use self::my_mod::TyFoo as _; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/anonymous-reexport.rs:1:9 + | +LL | #![deny(unused_imports)] + | ^^^^^^^^^^^^^^ + +error: unused import: `self::my_mod::Bar as _` + --> $DIR/anonymous-reexport.rs:13:9 + | +LL | pub use self::my_mod::Bar as _; + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: unused import: `self::my_mod::TyBar as _` + --> $DIR/anonymous-reexport.rs:14:9 + | +LL | pub use self::my_mod::TyBar as _; + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: unused import: `Bar as _` + --> $DIR/anonymous-reexport.rs:15:24 + | +LL | pub use self::my_mod::{Bar as _}; + | ^^^^^^^^ + +error: unused import: `Bar as _` + --> $DIR/anonymous-reexport.rs:16:24 + | +LL | pub use self::my_mod::{Bar as _, Foo as _}; + | ^^^^^^^^ + +error: unused imports: `Bar as _`, `TyBar as _` + --> $DIR/anonymous-reexport.rs:17:24 + | +LL | pub use self::my_mod::{Bar as _, TyBar as _}; + | ^^^^^^^^ ^^^^^^^^^^ + +error: aborting due to 6 previous errors + diff --git a/tests/ui/lint/clashing-extern-fn.rs b/tests/ui/lint/clashing-extern-fn.rs index 809e06026..09fda33db 100644 --- a/tests/ui/lint/clashing-extern-fn.rs +++ b/tests/ui/lint/clashing-extern-fn.rs @@ -122,8 +122,8 @@ mod banana { weight: u32, length: u16, } // note: distinct type - // This should not trigger the lint because two::Banana is structurally equivalent to - // one::Banana. + // This should not trigger the lint because two::Banana is structurally equivalent to + // one::Banana. extern "C" { fn weigh_banana(count: *const Banana) -> u64; } @@ -223,6 +223,27 @@ mod transparent { } } +#[allow(improper_ctypes)] +mod zst { + mod transparent { + #[repr(transparent)] + struct TransparentZst(()); + extern "C" { + fn zst() -> (); + fn transparent_zst() -> TransparentZst; + } + } + + mod not_transparent { + struct NotTransparentZst(()); + extern "C" { + // These shouldn't warn since all return types are zero sized + fn zst() -> NotTransparentZst; + fn transparent_zst() -> NotTransparentZst; + } + } +} + mod missing_return_type { mod a { extern "C" { @@ -397,10 +418,14 @@ mod hidden_niche { use std::num::NonZeroUsize; #[repr(transparent)] - struct Transparent { x: NonZeroUsize } + struct Transparent { + x: NonZeroUsize, + } #[repr(transparent)] - struct TransparentNoNiche { y: UnsafeCell<NonZeroUsize> } + struct TransparentNoNiche { + y: UnsafeCell<NonZeroUsize>, + } extern "C" { fn hidden_niche_transparent() -> Option<Transparent>; diff --git a/tests/ui/lint/clashing-extern-fn.stderr b/tests/ui/lint/clashing-extern-fn.stderr index 217eed6c9..5d457ba0e 100644 --- a/tests/ui/lint/clashing-extern-fn.stderr +++ b/tests/ui/lint/clashing-extern-fn.stderr @@ -130,7 +130,7 @@ LL | fn transparent_incorrect() -> isize; found `unsafe extern "C" fn() -> isize` warning: `missing_return_type` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:238:13 + --> $DIR/clashing-extern-fn.rs:259:13 | LL | fn missing_return_type() -> usize; | ---------------------------------- `missing_return_type` previously declared here @@ -142,7 +142,7 @@ LL | fn missing_return_type(); found `unsafe extern "C" fn()` warning: `non_zero_usize` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:256:13 + --> $DIR/clashing-extern-fn.rs:277:13 | LL | fn non_zero_usize() -> core::num::NonZeroUsize; | ----------------------------------------------- `non_zero_usize` previously declared here @@ -154,7 +154,7 @@ LL | fn non_zero_usize() -> usize; found `unsafe extern "C" fn() -> usize` warning: `non_null_ptr` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:258:13 + --> $DIR/clashing-extern-fn.rs:279:13 | LL | fn non_null_ptr() -> core::ptr::NonNull<usize>; | ----------------------------------------------- `non_null_ptr` previously declared here @@ -166,7 +166,7 @@ LL | fn non_null_ptr() -> *const usize; found `unsafe extern "C" fn() -> *const usize` warning: `option_non_zero_usize_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:356:13 + --> $DIR/clashing-extern-fn.rs:377:13 | LL | fn option_non_zero_usize_incorrect() -> usize; | ---------------------------------------------- `option_non_zero_usize_incorrect` previously declared here @@ -178,7 +178,7 @@ LL | fn option_non_zero_usize_incorrect() -> isize; found `unsafe extern "C" fn() -> isize` warning: `option_non_null_ptr_incorrect` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:358:13 + --> $DIR/clashing-extern-fn.rs:379:13 | LL | fn option_non_null_ptr_incorrect() -> *const usize; | --------------------------------------------------- `option_non_null_ptr_incorrect` previously declared here @@ -190,7 +190,7 @@ LL | fn option_non_null_ptr_incorrect() -> *const isize; found `unsafe extern "C" fn() -> *const isize` warning: `hidden_niche_transparent_no_niche` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:408:13 + --> $DIR/clashing-extern-fn.rs:433:13 | LL | fn hidden_niche_transparent_no_niche() -> usize; | ------------------------------------------------ `hidden_niche_transparent_no_niche` previously declared here @@ -202,7 +202,7 @@ LL | fn hidden_niche_transparent_no_niche() -> Option<TransparentNoN found `unsafe extern "C" fn() -> Option<TransparentNoNiche>` warning: `hidden_niche_unsafe_cell` redeclared with a different signature - --> $DIR/clashing-extern-fn.rs:412:13 + --> $DIR/clashing-extern-fn.rs:437:13 | LL | fn hidden_niche_unsafe_cell() -> usize; | --------------------------------------- `hidden_niche_unsafe_cell` previously declared here @@ -214,7 +214,7 @@ LL | fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize found `unsafe extern "C" fn() -> Option<UnsafeCell<NonZeroUsize>>` warning: `extern` block uses type `Option<TransparentNoNiche>`, which is not FFI-safe - --> $DIR/clashing-extern-fn.rs:408:55 + --> $DIR/clashing-extern-fn.rs:433:55 | LL | fn hidden_niche_transparent_no_niche() -> Option<TransparentNoNiche>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -224,7 +224,7 @@ LL | fn hidden_niche_transparent_no_niche() -> Option<TransparentNoN = note: `#[warn(improper_ctypes)]` on by default warning: `extern` block uses type `Option<UnsafeCell<NonZeroUsize>>`, which is not FFI-safe - --> $DIR/clashing-extern-fn.rs:412:46 + --> $DIR/clashing-extern-fn.rs:437:46 | LL | fn hidden_niche_unsafe_cell() -> Option<UnsafeCell<NonZeroUsize>>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe diff --git a/tests/ui/lint/dead-code/issue-59003.rs b/tests/ui/lint/dead-code/issue-59003.rs new file mode 100644 index 000000000..966d64128 --- /dev/null +++ b/tests/ui/lint/dead-code/issue-59003.rs @@ -0,0 +1,18 @@ +// check-pass + +// Make sure we don't have any false positives about the "struct is never constructed" lint. + +#![deny(dead_code)] + +struct Foo { + #[allow(dead_code)] + inner: u32, +} + +impl From<u32> for Foo { + fn from(inner: u32) -> Self { + Self { inner } + } +} + +fn main() {} diff --git a/tests/ui/lint/dead-code/issue-85255.rs b/tests/ui/lint/dead-code/issue-85255.rs index 1978bd4e8..d75a8e2dd 100644 --- a/tests/ui/lint/dead-code/issue-85255.rs +++ b/tests/ui/lint/dead-code/issue-85255.rs @@ -11,8 +11,8 @@ struct Foo { struct Bar; impl Bar { - fn a(&self) -> i32 { 5 } //~ WARNING: method `a` is never used - pub fn b(&self) -> i32 { 6 } //~ WARNING: method `b` is never used + fn a(&self) -> i32 { 5 } //~ WARNING: methods `a` and `b` are never used [dead_code] + pub fn b(&self) -> i32 { 6 } } pub(crate) struct Foo1 { @@ -23,8 +23,8 @@ pub(crate) struct Foo1 { pub(crate) struct Bar1; impl Bar1 { - fn a(&self) -> i32 { 5 } //~ WARNING: method `a` is never used - pub fn b(&self) -> i32 { 6 } //~ WARNING: method `b` is never used + fn a(&self) -> i32 { 5 } //~ WARNING: methods `a` and `b` are never used [dead_code] + pub fn b(&self) -> i32 { 6 } } pub(crate) struct Foo2 { @@ -35,8 +35,8 @@ pub(crate) struct Foo2 { pub(crate) struct Bar2; impl Bar2 { - fn a(&self) -> i32 { 5 } //~ WARNING: method `a` is never used - pub fn b(&self) -> i32 { 6 } //~ WARNING: method `b` is never used + fn a(&self) -> i32 { 5 } //~ WARNING: methods `a` and `b` are never used [dead_code] + pub fn b(&self) -> i32 { 6 } } diff --git a/tests/ui/lint/dead-code/issue-85255.stderr b/tests/ui/lint/dead-code/issue-85255.stderr index 58a19cf3c..d981085a4 100644 --- a/tests/ui/lint/dead-code/issue-85255.stderr +++ b/tests/ui/lint/dead-code/issue-85255.stderr @@ -14,6 +14,16 @@ note: the lint level is defined here LL | #![warn(dead_code)] | ^^^^^^^^^ +warning: methods `a` and `b` are never used + --> $DIR/issue-85255.rs:14:8 + | +LL | impl Bar { + | -------- methods in this implementation +LL | fn a(&self) -> i32 { 5 } + | ^ +LL | pub fn b(&self) -> i32 { 6 } + | ^ + warning: fields `a` and `b` are never read --> $DIR/issue-85255.rs:19:5 | @@ -24,6 +34,16 @@ LL | a: i32, LL | pub b: i32, | ^ +warning: methods `a` and `b` are never used + --> $DIR/issue-85255.rs:26:8 + | +LL | impl Bar1 { + | --------- methods in this implementation +LL | fn a(&self) -> i32 { 5 } + | ^ +LL | pub fn b(&self) -> i32 { 6 } + | ^ + warning: fields `a` and `b` are never read --> $DIR/issue-85255.rs:31:5 | @@ -34,41 +54,15 @@ LL | a: i32, LL | pub b: i32, | ^ -warning: method `a` is never used - --> $DIR/issue-85255.rs:14:8 - | -LL | fn a(&self) -> i32 { 5 } - | ^ - -warning: method `b` is never used - --> $DIR/issue-85255.rs:15:12 - | -LL | pub fn b(&self) -> i32 { 6 } - | ^ - -warning: method `a` is never used - --> $DIR/issue-85255.rs:26:8 - | -LL | fn a(&self) -> i32 { 5 } - | ^ - -warning: method `b` is never used - --> $DIR/issue-85255.rs:27:12 - | -LL | pub fn b(&self) -> i32 { 6 } - | ^ - -warning: method `a` is never used +warning: methods `a` and `b` are never used --> $DIR/issue-85255.rs:38:8 | +LL | impl Bar2 { + | --------- methods in this implementation LL | fn a(&self) -> i32 { 5 } | ^ - -warning: method `b` is never used - --> $DIR/issue-85255.rs:39:12 - | LL | pub fn b(&self) -> i32 { 6 } | ^ -warning: 9 warnings emitted +warning: 6 warnings emitted diff --git a/tests/ui/lint/dead-code/lint-dead-code-3.stderr b/tests/ui/lint/dead-code/lint-dead-code-3.stderr index 797b7559c..5c68cf0e1 100644 --- a/tests/ui/lint/dead-code/lint-dead-code-3.stderr +++ b/tests/ui/lint/dead-code/lint-dead-code-3.stderr @@ -10,6 +10,14 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ +error: method `foo` is never used + --> $DIR/lint-dead-code-3.rs:16:8 + | +LL | impl Foo { + | -------- method in this implementation +LL | fn foo(&self) { + | ^^^ + error: function `bar` is never used --> $DIR/lint-dead-code-3.rs:21:4 | @@ -34,12 +42,6 @@ error: function `blah` is never used LL | fn blah() {} | ^^^^ -error: method `foo` is never used - --> $DIR/lint-dead-code-3.rs:16:8 - | -LL | fn foo(&self) { - | ^^^ - error: function `free` is never used --> $DIR/lint-dead-code-3.rs:62:8 | diff --git a/tests/ui/lint/dead-code/lint-dead-code-6.rs b/tests/ui/lint/dead-code/lint-dead-code-6.rs index e3074acf1..5b2b76b76 100644 --- a/tests/ui/lint/dead-code/lint-dead-code-6.rs +++ b/tests/ui/lint/dead-code/lint-dead-code-6.rs @@ -2,17 +2,16 @@ struct UnusedStruct; //~ ERROR struct `UnusedStruct` is never constructed impl UnusedStruct { - fn unused_impl_fn_1() { //~ ERROR associated function `unused_impl_fn_1` is never used + fn unused_impl_fn_1() { + //~^ ERROR associated functions `unused_impl_fn_1`, `unused_impl_fn_2`, and `unused_impl_fn_3` are never used [dead_code] println!("blah"); } - fn unused_impl_fn_2(var: i32) { //~ ERROR associated function `unused_impl_fn_2` is never used + fn unused_impl_fn_2(var: i32) { println!("foo {}", var); } - fn unused_impl_fn_3( //~ ERROR associated function `unused_impl_fn_3` is never used - var: i32, - ) { + fn unused_impl_fn_3(var: i32) { println!("bar {}", var); } } diff --git a/tests/ui/lint/dead-code/lint-dead-code-6.stderr b/tests/ui/lint/dead-code/lint-dead-code-6.stderr index f9d83308a..ce4110086 100644 --- a/tests/ui/lint/dead-code/lint-dead-code-6.stderr +++ b/tests/ui/lint/dead-code/lint-dead-code-6.stderr @@ -10,23 +10,19 @@ note: the lint level is defined here LL | #![deny(dead_code)] | ^^^^^^^^^ -error: associated function `unused_impl_fn_1` is never used +error: associated functions `unused_impl_fn_1`, `unused_impl_fn_2`, and `unused_impl_fn_3` are never used --> $DIR/lint-dead-code-6.rs:5:8 | +LL | impl UnusedStruct { + | ----------------- associated functions in this implementation LL | fn unused_impl_fn_1() { | ^^^^^^^^^^^^^^^^ - -error: associated function `unused_impl_fn_2` is never used - --> $DIR/lint-dead-code-6.rs:9:8 - | +... LL | fn unused_impl_fn_2(var: i32) { | ^^^^^^^^^^^^^^^^ - -error: associated function `unused_impl_fn_3` is never used - --> $DIR/lint-dead-code-6.rs:13:8 - | -LL | fn unused_impl_fn_3( +... +LL | fn unused_impl_fn_3(var: i32) { | ^^^^^^^^^^^^^^^^ -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/lint/dead-code/unused-assoc-fns.rs b/tests/ui/lint/dead-code/unused-assoc-fns.rs new file mode 100644 index 000000000..b111f4b94 --- /dev/null +++ b/tests/ui/lint/dead-code/unused-assoc-fns.rs @@ -0,0 +1,35 @@ +#![feature(inherent_associated_types)] +#![allow(incomplete_features)] +#![deny(unused)] + +struct Foo; + +impl Foo { + fn one() {} + //~^ ERROR associated items `one`, `two`, `CONSTANT`, `Type`, and `three` are never used [dead_code] + + fn two(&self) {} + + // seperation between items + // ... + // ... + + fn used() {} + + const CONSTANT: usize = 5; + + // more seperation + // ... + // ... + + type Type = usize; + + fn three(&self) { + Foo::one(); + // ... + } +} + +fn main() { + Foo::used(); +} diff --git a/tests/ui/lint/dead-code/unused-assoc-fns.stderr b/tests/ui/lint/dead-code/unused-assoc-fns.stderr new file mode 100644 index 000000000..6344a70ea --- /dev/null +++ b/tests/ui/lint/dead-code/unused-assoc-fns.stderr @@ -0,0 +1,29 @@ +error: associated items `one`, `two`, `CONSTANT`, `Type`, and `three` are never used + --> $DIR/unused-assoc-fns.rs:8:8 + | +LL | impl Foo { + | -------- associated items in this implementation +LL | fn one() {} + | ^^^ +... +LL | fn two(&self) {} + | ^^^ +... +LL | const CONSTANT: usize = 5; + | ^^^^^^^^ +... +LL | type Type = usize; + | ^^^^ +LL | +LL | fn three(&self) { + | ^^^^^ + | +note: the lint level is defined here + --> $DIR/unused-assoc-fns.rs:3:9 + | +LL | #![deny(unused)] + | ^^^^^^ + = note: `#[deny(dead_code)]` implied by `#[deny(unused)]` + +error: aborting due to previous error + diff --git a/tests/ui/lint/fn_must_use.stderr b/tests/ui/lint/fn_must_use.stderr index 657f23c60..e88c1a9b8 100644 --- a/tests/ui/lint/fn_must_use.stderr +++ b/tests/ui/lint/fn_must_use.stderr @@ -10,12 +10,21 @@ note: the lint level is defined here | LL | #![warn(unused_must_use)] | ^^^^^^^^^^^^^^^ +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = need_to_use_this_value(); + | +++++++ warning: unused return value of `MyStruct::need_to_use_this_method_value` that must be used --> $DIR/fn_must_use.rs:60:5 | LL | m.need_to_use_this_method_value(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = m.need_to_use_this_method_value(); + | +++++++ warning: unused return value of `EvenNature::is_even` that must be used --> $DIR/fn_must_use.rs:61:5 @@ -24,24 +33,43 @@ LL | m.is_even(); // trait method! | ^^^^^^^^^^^ | = note: no side effects +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = m.is_even(); // trait method! + | +++++++ warning: unused return value of `MyStruct::need_to_use_this_associated_function_value` that must be used --> $DIR/fn_must_use.rs:64:5 | LL | MyStruct::need_to_use_this_associated_function_value(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = MyStruct::need_to_use_this_associated_function_value(); + | +++++++ warning: unused return value of `std::cmp::PartialEq::eq` that must be used --> $DIR/fn_must_use.rs:70:5 | LL | 2.eq(&3); | ^^^^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = 2.eq(&3); + | +++++++ warning: unused return value of `std::cmp::PartialEq::eq` that must be used --> $DIR/fn_must_use.rs:71:5 | LL | m.eq(&n); | ^^^^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = m.eq(&n); + | +++++++ warning: unused comparison that must be used --> $DIR/fn_must_use.rs:74:5 diff --git a/tests/ui/lint/inline-trait-and-foreign-items.rs b/tests/ui/lint/inline-trait-and-foreign-items.rs index 13dab7ed9..39bc01f71 100644 --- a/tests/ui/lint/inline-trait-and-foreign-items.rs +++ b/tests/ui/lint/inline-trait-and-foreign-items.rs @@ -1,5 +1,5 @@ #![feature(extern_types)] -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] #![warn(unused_attributes)] diff --git a/tests/ui/lint/issue-109152.rs b/tests/ui/lint/issue-109152.rs new file mode 100644 index 000000000..daf530e6d --- /dev/null +++ b/tests/ui/lint/issue-109152.rs @@ -0,0 +1,7 @@ +#![deny(map_unit_fn)] + +#![crate_type = "lib"] +fn _y() { + vec![42].iter().map(drop); + //~^ ERROR `Iterator::map` call that discard the iterator's values +} diff --git a/tests/ui/lint/issue-109152.stderr b/tests/ui/lint/issue-109152.stderr new file mode 100644 index 000000000..7db9e71a5 --- /dev/null +++ b/tests/ui/lint/issue-109152.stderr @@ -0,0 +1,23 @@ +error: `Iterator::map` call that discard the iterator's values + --> $DIR/issue-109152.rs:5:21 + | +LL | vec![42].iter().map(drop); + | ^^^^----^ + | | | + | | this function returns `()`, which is likely not what you wanted + | | called `Iterator::map` with callable that returns `()` + | after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items + | + = note: `Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated +note: the lint level is defined here + --> $DIR/issue-109152.rs:1:9 + | +LL | #![deny(map_unit_fn)] + | ^^^^^^^^^^^ +help: you might have meant to use `Iterator::for_each` + | +LL | vec![42].iter().for_each(drop); + | ~~~~~~~~ + +error: aborting due to previous error + diff --git a/tests/ui/lint/issue-109529.fixed b/tests/ui/lint/issue-109529.fixed new file mode 100644 index 000000000..5ad489073 --- /dev/null +++ b/tests/ui/lint/issue-109529.fixed @@ -0,0 +1,6 @@ +// run-rustfix + +fn main() { + for _ in 0..=255 as u8 {} //~ ERROR range endpoint is out of range + for _ in 0..=(255 as u8) {} //~ ERROR range endpoint is out of range +} diff --git a/tests/ui/lint/issue-109529.rs b/tests/ui/lint/issue-109529.rs new file mode 100644 index 000000000..383d7bc4c --- /dev/null +++ b/tests/ui/lint/issue-109529.rs @@ -0,0 +1,6 @@ +// run-rustfix + +fn main() { + for _ in 0..256 as u8 {} //~ ERROR range endpoint is out of range + for _ in 0..(256 as u8) {} //~ ERROR range endpoint is out of range +} diff --git a/tests/ui/lint/issue-109529.stderr b/tests/ui/lint/issue-109529.stderr new file mode 100644 index 000000000..9e857d1b0 --- /dev/null +++ b/tests/ui/lint/issue-109529.stderr @@ -0,0 +1,23 @@ +error: range endpoint is out of range for `u8` + --> $DIR/issue-109529.rs:4:14 + | +LL | for _ in 0..256 as u8 {} + | ------^^^^^^ + | | + | help: use an inclusive range instead: `0..=255` + | + = note: `#[deny(overflowing_literals)]` on by default + +error: range endpoint is out of range for `u8` + --> $DIR/issue-109529.rs:5:14 + | +LL | for _ in 0..(256 as u8) {} + | ^^^^^^^^^^^^^^ + | +help: use an inclusive range instead + | +LL | for _ in 0..=(255 as u8) {} + | + ~~~ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/lint/lint-temporary-cstring-as-ptr.rs b/tests/ui/lint/lint-temporary-cstring-as-ptr.rs index 7aa4f2e1e..fab792f12 100644 --- a/tests/ui/lint/lint-temporary-cstring-as-ptr.rs +++ b/tests/ui/lint/lint-temporary-cstring-as-ptr.rs @@ -3,7 +3,15 @@ use std::ffi::CString; +macro_rules! mymacro { + () => { + let s = CString::new("some text").unwrap().as_ptr(); + //~^ ERROR getting the inner pointer of a temporary `CString` + } +} + fn main() { let s = CString::new("some text").unwrap().as_ptr(); //~^ ERROR getting the inner pointer of a temporary `CString` + mymacro!(); } diff --git a/tests/ui/lint/lint-temporary-cstring-as-ptr.stderr b/tests/ui/lint/lint-temporary-cstring-as-ptr.stderr index 79ef57dd1..4e5c8aa06 100644 --- a/tests/ui/lint/lint-temporary-cstring-as-ptr.stderr +++ b/tests/ui/lint/lint-temporary-cstring-as-ptr.stderr @@ -1,5 +1,5 @@ error: getting the inner pointer of a temporary `CString` - --> $DIR/lint-temporary-cstring-as-ptr.rs:7:48 + --> $DIR/lint-temporary-cstring-as-ptr.rs:14:48 | LL | let s = CString::new("some text").unwrap().as_ptr(); | ---------------------------------- ^^^^^^ this pointer will be invalid @@ -14,5 +14,20 @@ note: the lint level is defined here LL | #![deny(temporary_cstring_as_ptr)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to previous error +error: getting the inner pointer of a temporary `CString` + --> $DIR/lint-temporary-cstring-as-ptr.rs:8:52 + | +LL | let s = CString::new("some text").unwrap().as_ptr(); + | ---------------------------------- ^^^^^^ this pointer will be invalid + | | + | this `CString` is deallocated at the end of the statement, bind it to a variable to extend its lifetime +... +LL | mymacro!(); + | ---------- in this macro invocation + | + = note: pointers do not have a lifetime; when calling `as_ptr` the `CString` will be deallocated at the end of the statement because nothing is referencing it as far as the type system is concerned + = help: for more information, see https://doc.rust-lang.org/reference/destructors.html + = note: this error originates in the macro `mymacro` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors diff --git a/tests/ui/lint/no-coverage.rs b/tests/ui/lint/no-coverage.rs index ff24c12b2..07906a434 100644 --- a/tests/ui/lint/no-coverage.rs +++ b/tests/ui/lint/no-coverage.rs @@ -1,6 +1,6 @@ #![feature(extern_types)] #![feature(no_coverage)] -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] #![warn(unused_attributes)] #![no_coverage] //~^ WARN: `#[no_coverage]` does not propagate into items and must be applied to the contained functions directly diff --git a/tests/ui/lint/unconditional_panic_98444.rs b/tests/ui/lint/unconditional_panic_98444.rs new file mode 100644 index 000000000..011fabfbb --- /dev/null +++ b/tests/ui/lint/unconditional_panic_98444.rs @@ -0,0 +1,7 @@ +// build-fail + +fn main() { + let xs: [i32; 5] = [1, 2, 3, 4, 5]; + let _ = &xs; + let _ = xs[7]; //~ ERROR: this operation will panic at runtime [unconditional_panic] +} diff --git a/tests/ui/lint/unconditional_panic_98444.stderr b/tests/ui/lint/unconditional_panic_98444.stderr new file mode 100644 index 000000000..a34745809 --- /dev/null +++ b/tests/ui/lint/unconditional_panic_98444.stderr @@ -0,0 +1,10 @@ +error: this operation will panic at runtime + --> $DIR/unconditional_panic_98444.rs:6:13 + | +LL | let _ = xs[7]; + | ^^^^^ index out of bounds: the length is 5 but the index is 7 + | + = note: `#[deny(unconditional_panic)]` on by default + +error: aborting due to previous error + diff --git a/tests/ui/lint/unused/auxiliary/must-use-foreign.rs b/tests/ui/lint/unused/auxiliary/must-use-foreign.rs new file mode 100644 index 000000000..f773f09c3 --- /dev/null +++ b/tests/ui/lint/unused/auxiliary/must-use-foreign.rs @@ -0,0 +1,12 @@ +// edition:2021 + +use std::future::Future; + +pub struct Manager; + +impl Manager { + #[must_use] + pub async fn new() -> (Self, impl Future<Output = ()>) { + (Manager, async {}) + } +} diff --git a/tests/ui/lint/unused/must-use-box-from-raw.stderr b/tests/ui/lint/unused/must-use-box-from-raw.stderr index 47ab613be..4898db7fe 100644 --- a/tests/ui/lint/unused/must-use-box-from-raw.stderr +++ b/tests/ui/lint/unused/must-use-box-from-raw.stderr @@ -10,6 +10,10 @@ note: the lint level is defined here | LL | #![warn(unused_must_use)] | ^^^^^^^^^^^^^^^ +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = Box::from_raw(ptr); + | +++++++ warning: 1 warning emitted diff --git a/tests/ui/lint/unused/must-use-foreign.rs b/tests/ui/lint/unused/must-use-foreign.rs new file mode 100644 index 000000000..21a110585 --- /dev/null +++ b/tests/ui/lint/unused/must-use-foreign.rs @@ -0,0 +1,15 @@ +// edition:2021 +// aux-build:must-use-foreign.rs +// check-pass + +extern crate must_use_foreign; + +use must_use_foreign::Manager; + +async fn async_main() { + Manager::new().await.1.await; +} + +fn main() { + let _ = async_main(); +} diff --git a/tests/ui/lint/unused/must_use-unit.stderr b/tests/ui/lint/unused/must_use-unit.stderr index 9fcbc5074..993a19e5f 100644 --- a/tests/ui/lint/unused/must_use-unit.stderr +++ b/tests/ui/lint/unused/must_use-unit.stderr @@ -9,12 +9,21 @@ note: the lint level is defined here | LL | #![deny(unused_must_use)] | ^^^^^^^^^^^^^^^ +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = foo(); + | +++++++ error: unused return value of `bar` that must be used --> $DIR/must_use-unit.rs:15:5 | LL | bar(); | ^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = bar(); + | +++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/lint/unused/trait-alias-supertrait.rs b/tests/ui/lint/unused/trait-alias-supertrait.rs new file mode 100644 index 000000000..46f00c06b --- /dev/null +++ b/tests/ui/lint/unused/trait-alias-supertrait.rs @@ -0,0 +1,15 @@ +// check-pass + +// Make sure that we only consider *Self* supertrait predicates +// in the `unused_must_use` lint. + +#![feature(trait_alias)] +#![deny(unused_must_use)] + +trait Foo<T> = Sized where T: Iterator; + +fn test<T: Iterator>() -> impl Foo<T> {} + +fn main() { + test::<std::iter::Once<()>>(); +} diff --git a/tests/ui/lint/unused/unused-allocation.rs b/tests/ui/lint/unused/unused-allocation.rs new file mode 100644 index 000000000..c1a6f5cea --- /dev/null +++ b/tests/ui/lint/unused/unused-allocation.rs @@ -0,0 +1,7 @@ +#![feature(rustc_attrs, stmt_expr_attributes)] +#![deny(unused_allocation)] + +fn main() { + _ = (#[rustc_box] Box::new([1])).len(); //~ error: unnecessary allocation, use `&` instead + _ = Box::new([1]).len(); //~ error: unnecessary allocation, use `&` instead +} diff --git a/tests/ui/lint/unused/unused-allocation.stderr b/tests/ui/lint/unused/unused-allocation.stderr new file mode 100644 index 000000000..c9ccfbd30 --- /dev/null +++ b/tests/ui/lint/unused/unused-allocation.stderr @@ -0,0 +1,20 @@ +error: unnecessary allocation, use `&` instead + --> $DIR/unused-allocation.rs:5:9 + | +LL | _ = (#[rustc_box] Box::new([1])).len(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/unused-allocation.rs:2:9 + | +LL | #![deny(unused_allocation)] + | ^^^^^^^^^^^^^^^^^ + +error: unnecessary allocation, use `&` instead + --> $DIR/unused-allocation.rs:6:9 + | +LL | _ = Box::new([1]).len(); + | ^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/lint/unused/unused-async.rs b/tests/ui/lint/unused/unused-async.rs index 4be93aa15..6355f47f0 100644 --- a/tests/ui/lint/unused/unused-async.rs +++ b/tests/ui/lint/unused/unused-async.rs @@ -33,7 +33,7 @@ async fn test() { foo().await; //~ ERROR unused output of future returned by `foo` that must be used bar(); //~ ERROR unused return value of `bar` that must be used //~^ ERROR unused implementer of `Future` that must be used - bar().await; //~ ERROR unused output of future returned by `bar` that must be used + bar().await; // ok, it's not an async fn baz(); //~ ERROR unused implementer of `Future` that must be used baz().await; // ok } diff --git a/tests/ui/lint/unused/unused-async.stderr b/tests/ui/lint/unused/unused-async.stderr index 4bcb26dc1..e93a40658 100644 --- a/tests/ui/lint/unused/unused-async.stderr +++ b/tests/ui/lint/unused/unused-async.stderr @@ -16,12 +16,22 @@ error: unused return value of `foo` that must be used | LL | foo(); | ^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = foo(); + | +++++++ error: unused output of future returned by `foo` that must be used --> $DIR/unused-async.rs:33:5 | LL | foo().await; | ^^^^^^^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = foo().await; + | +++++++ error: unused implementer of `Future` that must be used --> $DIR/unused-async.rs:34:5 @@ -36,12 +46,11 @@ error: unused return value of `bar` that must be used | LL | bar(); | ^^^^^ - -error: unused output of future returned by `bar` that must be used - --> $DIR/unused-async.rs:36:5 | -LL | bar().await; - | ^^^^^^^^^^^ +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = bar(); + | +++++++ error: unused implementer of `Future` that must be used --> $DIR/unused-async.rs:37:5 @@ -51,5 +60,5 @@ LL | baz(); | = note: futures do nothing unless you `.await` or poll them -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors diff --git a/tests/ui/lint/unused/unused-result.stderr b/tests/ui/lint/unused/unused-result.stderr index 4e1ba1fd9..f42995a65 100644 --- a/tests/ui/lint/unused/unused-result.stderr +++ b/tests/ui/lint/unused/unused-result.stderr @@ -9,6 +9,10 @@ note: the lint level is defined here | LL | #![deny(unused_results, unused_must_use)] | ^^^^^^^^^^^^^^^ +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = foo::<MustUse>(); + | +++++++ error: unused `MustUseMsg` that must be used --> $DIR/unused-result.rs:22:5 @@ -17,6 +21,10 @@ LL | foo::<MustUseMsg>(); | ^^^^^^^^^^^^^^^^^^^ | = note: some message +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = foo::<MustUseMsg>(); + | +++++++ error: unused result of type `isize` --> $DIR/unused-result.rs:34:5 @@ -35,6 +43,11 @@ error: unused `MustUse` that must be used | LL | foo::<MustUse>(); | ^^^^^^^^^^^^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = foo::<MustUse>(); + | +++++++ error: unused `MustUseMsg` that must be used --> $DIR/unused-result.rs:36:5 @@ -43,6 +56,10 @@ LL | foo::<MustUseMsg>(); | ^^^^^^^^^^^^^^^^^^^ | = note: some message +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = foo::<MustUseMsg>(); + | +++++++ error: aborting due to 5 previous errors diff --git a/tests/ui/lint/unused/unused_attributes-must_use.stderr b/tests/ui/lint/unused/unused_attributes-must_use.stderr index 0f699429e..9633767c4 100644 --- a/tests/ui/lint/unused/unused_attributes-must_use.stderr +++ b/tests/ui/lint/unused/unused_attributes-must_use.stderr @@ -146,42 +146,76 @@ note: the lint level is defined here | LL | #![deny(unused_attributes, unused_must_use)] | ^^^^^^^^^^^^^^^ +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = X; + | +++++++ error: unused `Y` that must be used --> $DIR/unused_attributes-must_use.rs:104:5 | LL | Y::Z; | ^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = Y::Z; + | +++++++ error: unused `U` that must be used --> $DIR/unused_attributes-must_use.rs:105:5 | LL | U { unit: () }; | ^^^^^^^^^^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = U { unit: () }; + | +++++++ error: unused return value of `U::method` that must be used --> $DIR/unused_attributes-must_use.rs:106:5 | LL | U::method(); | ^^^^^^^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = U::method(); + | +++++++ error: unused return value of `foo` that must be used --> $DIR/unused_attributes-must_use.rs:107:5 | LL | foo(); | ^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = foo(); + | +++++++ error: unused return value of `foreign_foo` that must be used --> $DIR/unused_attributes-must_use.rs:110:9 | LL | foreign_foo(); | ^^^^^^^^^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = foreign_foo(); + | +++++++ error: unused return value of `Use::get_four` that must be used --> $DIR/unused_attributes-must_use.rs:118:5 | LL | ().get_four(); | ^^^^^^^^^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = ().get_four(); + | +++++++ error: aborting due to 28 previous errors diff --git a/tests/ui/lint/use-redundant/issue-92904.rs b/tests/ui/lint/use-redundant/issue-92904.rs new file mode 100644 index 000000000..511d9d263 --- /dev/null +++ b/tests/ui/lint/use-redundant/issue-92904.rs @@ -0,0 +1,17 @@ +// check-pass + +pub struct Foo(bar::Bar); + +pub mod bar { + pub struct Foo(pub Bar); + pub struct Bar(pub char); +} + +pub fn warning() -> Foo { + use bar::*; + #[deny(unused_imports)] + use self::Foo; // no error + Foo(Bar('a')) +} + +fn main() {} diff --git a/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs b/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs new file mode 100644 index 000000000..6b1e018d2 --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-glob-parent.rs @@ -0,0 +1,16 @@ +// check-pass +#![warn(unused_imports)] + +pub mod bar { + pub struct Foo(pub Bar); + pub struct Bar(pub char); +} + +use bar::*; + +pub fn warning() -> Foo { + use bar::Foo; //~ WARNING imported redundantly + Foo(Bar('a')) +} + +fn main() {} diff --git a/tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr b/tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr new file mode 100644 index 000000000..2c3b33452 --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-glob-parent.stderr @@ -0,0 +1,17 @@ +warning: the item `Foo` is imported redundantly + --> $DIR/use-redundant-glob-parent.rs:12:9 + | +LL | use bar::*; + | ------ the item `Foo` is already imported here +... +LL | use bar::Foo; + | ^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/use-redundant-glob-parent.rs:2:9 + | +LL | #![warn(unused_imports)] + | ^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/lint/use-redundant/use-redundant-glob.rs b/tests/ui/lint/use-redundant/use-redundant-glob.rs new file mode 100644 index 000000000..bd9e51b6f --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-glob.rs @@ -0,0 +1,15 @@ +// check-pass +#![warn(unused_imports)] + +pub mod bar { + pub struct Foo(pub Bar); + pub struct Bar(pub char); +} + +pub fn warning() -> bar::Foo { + use bar::*; + use bar::Foo; //~ WARNING imported redundantly + Foo(Bar('a')) +} + +fn main() {} diff --git a/tests/ui/lint/use-redundant/use-redundant-glob.stderr b/tests/ui/lint/use-redundant/use-redundant-glob.stderr new file mode 100644 index 000000000..d3b406d82 --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-glob.stderr @@ -0,0 +1,16 @@ +warning: the item `Foo` is imported redundantly + --> $DIR/use-redundant-glob.rs:11:9 + | +LL | use bar::*; + | ------ the item `Foo` is already imported here +LL | use bar::Foo; + | ^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/use-redundant-glob.rs:2:9 + | +LL | #![warn(unused_imports)] + | ^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/lint/use-redundant/use-redundant-multiple-namespaces.rs b/tests/ui/lint/use-redundant/use-redundant-multiple-namespaces.rs new file mode 100644 index 000000000..0fb60840f --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-multiple-namespaces.rs @@ -0,0 +1,21 @@ +// check-pass +#![allow(nonstandard_style)] + +pub mod bar { + pub struct Foo { pub bar: Bar } + pub struct Bar(pub char); +} + +pub mod x { + use crate::bar; + pub const Foo: bar::Bar = bar::Bar('a'); +} + +pub fn warning() -> bar::Foo { + #![deny(unused_imports)] // no error + use bar::*; + use x::Foo; + Foo { bar: Foo } +} + +fn main() {} diff --git a/tests/ui/lint/use-redundant/use-redundant-not-parent.rs b/tests/ui/lint/use-redundant/use-redundant-not-parent.rs new file mode 100644 index 000000000..c97a3d341 --- /dev/null +++ b/tests/ui/lint/use-redundant/use-redundant-not-parent.rs @@ -0,0 +1,19 @@ +// check-pass + +pub mod bar { + pub struct Foo(pub Bar); + pub struct Bar(pub char); +} + +pub mod x { + pub struct Foo(pub crate::bar::Bar); +} + +pub fn warning() -> x::Foo { + use bar::*; + #[deny(unused_imports)] + use x::Foo; // no error + Foo(Bar('a')) +} + +fn main() {} diff --git a/tests/ui/lint/use-redundant.rs b/tests/ui/lint/use-redundant/use-redundant.rs index 53315dcf6..53315dcf6 100644 --- a/tests/ui/lint/use-redundant.rs +++ b/tests/ui/lint/use-redundant/use-redundant.rs diff --git a/tests/ui/lint/use-redundant.stderr b/tests/ui/lint/use-redundant/use-redundant.stderr index c861a1956..c861a1956 100644 --- a/tests/ui/lint/use-redundant.stderr +++ b/tests/ui/lint/use-redundant/use-redundant.stderr diff --git a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs index c9b16e439..293fdca1c 100644 --- a/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs +++ b/tests/ui/liveness/liveness-assign/liveness-assign-imm-local-with-drop.rs @@ -5,6 +5,7 @@ fn test() { drop(b); b = Box::new(2); //~ ERROR cannot assign twice to immutable variable `b` //~| NOTE cannot assign twice to immutable + //~| NOTE in this expansion of desugaring of drop and replace drop(b); } diff --git a/tests/ui/macros/bad-concat.stderr b/tests/ui/macros/bad-concat.stderr index 4316fd312..d67f3c33d 100644 --- a/tests/ui/macros/bad-concat.stderr +++ b/tests/ui/macros/bad-concat.stderr @@ -4,7 +4,7 @@ error: expected a literal LL | let _ = concat!(x, y, z, "bar"); | ^ ^ ^ | - = note: only literals (like `"foo"`, `42` and `3.14`) can be passed to `concat!()` + = note: only literals (like `"foo"`, `-42` and `3.14`) can be passed to `concat!()` error: aborting due to previous error diff --git a/tests/ui/macros/concat-bytes-error.stderr b/tests/ui/macros/concat-bytes-error.stderr index d6cd1a3d1..3f2c64922 100644 --- a/tests/ui/macros/concat-bytes-error.stderr +++ b/tests/ui/macros/concat-bytes-error.stderr @@ -4,7 +4,7 @@ error: expected a byte literal LL | concat_bytes!(pie); | ^^^ | - = note: only byte literals (like `b"foo"`, `b's'`, and `[3, 4, 5]`) can be passed to `concat_bytes!()` + = note: only byte literals (like `b"foo"`, `b's'` and `[3, 4, 5]`) can be passed to `concat_bytes!()` error: expected a byte literal --> $DIR/concat-bytes-error.rs:5:19 @@ -12,7 +12,7 @@ error: expected a byte literal LL | concat_bytes!(pie, pie); | ^^^ ^^^ | - = note: only byte literals (like `b"foo"`, `b's'`, and `[3, 4, 5]`) can be passed to `concat_bytes!()` + = note: only byte literals (like `b"foo"`, `b's'` and `[3, 4, 5]`) can be passed to `concat_bytes!()` error: cannot concatenate string literals --> $DIR/concat-bytes-error.rs:6:19 @@ -98,7 +98,7 @@ error: expected a byte literal LL | -33, | ^^^ | - = note: only byte literals (like `b"foo"`, `b's'`, and `[3, 4, 5]`) can be passed to `concat_bytes!()` + = note: only byte literals (like `b"foo"`, `b's'` and `[3, 4, 5]`) can be passed to `concat_bytes!()` error: cannot concatenate doubly nested array --> $DIR/concat-bytes-error.rs:35:9 @@ -151,7 +151,7 @@ error: expected a byte literal LL | concat_bytes!([pie; 2]); | ^^^ | - = note: only byte literals (like `b"foo"`, `b's'`, and `[3, 4, 5]`) can be passed to `concat_bytes!()` + = note: only byte literals (like `b"foo"`, `b's'` and `[3, 4, 5]`) can be passed to `concat_bytes!()` error: cannot concatenate float literals --> $DIR/concat-bytes-error.rs:46:20 diff --git a/tests/ui/macros/concat.stderr b/tests/ui/macros/concat.stderr index 61fb9de1e..d65d93544 100644 --- a/tests/ui/macros/concat.stderr +++ b/tests/ui/macros/concat.stderr @@ -16,7 +16,7 @@ error: expected a literal LL | concat!(foo); | ^^^ | - = note: only literals (like `"foo"`, `42` and `3.14`) can be passed to `concat!()` + = note: only literals (like `"foo"`, `-42` and `3.14`) can be passed to `concat!()` error: expected a literal --> $DIR/concat.rs:5:13 @@ -24,7 +24,7 @@ error: expected a literal LL | concat!(foo()); | ^^^^^ | - = note: only literals (like `"foo"`, `42` and `3.14`) can be passed to `concat!()` + = note: only literals (like `"foo"`, `-42` and `3.14`) can be passed to `concat!()` error: aborting due to 4 previous errors diff --git a/tests/ui/macros/issue-100199.stderr b/tests/ui/macros/issue-100199.stderr index 2cb45dc12..89a6f585c 100644 --- a/tests/ui/macros/issue-100199.stderr +++ b/tests/ui/macros/issue-100199.stderr @@ -7,7 +7,7 @@ LL | #[issue_100199::struct_with_bound] = note: this error originates in the attribute macro `issue_100199::struct_with_bound` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider importing this trait | -LL | use traits::MyTrait; +LL + use traits::MyTrait; | error: aborting due to previous error diff --git a/tests/ui/macros/issue-106837.rs b/tests/ui/macros/issue-106837.rs new file mode 100644 index 000000000..7bbd3d68a --- /dev/null +++ b/tests/ui/macros/issue-106837.rs @@ -0,0 +1,10 @@ +fn main() { + concat!(-42); + concat!(-3.14); + + concat!(-"hello"); + //~^ ERROR expected a literal + + concat!(--1); + //~^ ERROR expected a literal +} diff --git a/tests/ui/macros/issue-106837.stderr b/tests/ui/macros/issue-106837.stderr new file mode 100644 index 000000000..998d6c5eb --- /dev/null +++ b/tests/ui/macros/issue-106837.stderr @@ -0,0 +1,18 @@ +error: expected a literal + --> $DIR/issue-106837.rs:5:13 + | +LL | concat!(-"hello"); + | ^^^^^^^^ + | + = note: only literals (like `"foo"`, `-42` and `3.14`) can be passed to `concat!()` + +error: expected a literal + --> $DIR/issue-106837.rs:8:13 + | +LL | concat!(--1); + | ^^^ + | + = note: only literals (like `"foo"`, `-42` and `3.14`) can be passed to `concat!()` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/macros/issue-109237.rs b/tests/ui/macros/issue-109237.rs new file mode 100644 index 000000000..86a193c9e --- /dev/null +++ b/tests/ui/macros/issue-109237.rs @@ -0,0 +1,7 @@ +macro_rules! statement { + () => {;}; //~ ERROR expected expression +} + +fn main() { + let _ = statement!(); +} diff --git a/tests/ui/macros/issue-109237.stderr b/tests/ui/macros/issue-109237.stderr new file mode 100644 index 000000000..d125cff63 --- /dev/null +++ b/tests/ui/macros/issue-109237.stderr @@ -0,0 +1,18 @@ +error: expected expression, found `;` + --> $DIR/issue-109237.rs:2:12 + | +LL | () => {;}; + | ^ expected expression +... +LL | let _ = statement!(); + | ------------ in this macro invocation + | + = note: the macro call doesn't expand to an expression, but it can expand to a statement + = note: this error originates in the macro `statement` (in Nightly builds, run with -Z macro-backtrace for more info) +help: surround the macro invocation with `{}` to interpret the expansion as a statement + | +LL | let _ = { statement!(); }; + | ~~~~~~~~~~~~~~~~~ + +error: aborting due to previous error + diff --git a/tests/ui/macros/issue-40469.rs b/tests/ui/macros/issue-40469.rs index 25e08ef85..9b22aaef2 100644 --- a/tests/ui/macros/issue-40469.rs +++ b/tests/ui/macros/issue-40469.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty issue #37195 #![allow(dead_code)] diff --git a/tests/ui/macros/issue-98790.rs b/tests/ui/macros/issue-98790.rs new file mode 100644 index 000000000..8fe6fc41d --- /dev/null +++ b/tests/ui/macros/issue-98790.rs @@ -0,0 +1,24 @@ +// run-pass + +macro_rules! stringify_item { + ($item:item) => { + stringify!($item) + }; +} + +macro_rules! repro { + ($expr:expr) => { + stringify_item! { + pub fn repro() -> bool { + $expr + } + } + }; +} + +fn main() { + assert_eq!( + repro!(match () { () => true } | true), + "pub fn repro() -> bool { (match () { () => true, }) | true }" + ); +} diff --git a/tests/ui/macros/macro-comma-support-rpass.rs b/tests/ui/macros/macro-comma-support-rpass.rs index 25b8c3cc6..cb019792e 100644 --- a/tests/ui/macros/macro-comma-support-rpass.rs +++ b/tests/ui/macros/macro-comma-support-rpass.rs @@ -8,7 +8,6 @@ // implementations for some macro_rules! macros as an implementation // detail. -// ignore-pretty issue #37195 // compile-flags: --test -C debug_assertions=yes // revisions: std core diff --git a/tests/ui/macros/macro-include-items.rs b/tests/ui/macros/macro-include-items.rs index 332bf59c9..ad6f04009 100644 --- a/tests/ui/macros/macro-include-items.rs +++ b/tests/ui/macros/macro-include-items.rs @@ -1,7 +1,6 @@ // run-pass #![allow(non_camel_case_types)] -// ignore-pretty issue #37195 fn bar() {} diff --git a/tests/ui/macros/macro-outer-attributes.stderr b/tests/ui/macros/macro-outer-attributes.stderr index 4ea760ab8..0bdc3416f 100644 --- a/tests/ui/macros/macro-outer-attributes.stderr +++ b/tests/ui/macros/macro-outer-attributes.stderr @@ -6,7 +6,7 @@ LL | a::bar(); | help: consider importing this function | -LL | use b::bar; +LL + use b::bar; | help: if you import `bar`, refer to it directly | diff --git a/tests/ui/macros/macro-path-prelude-fail-4.stderr b/tests/ui/macros/macro-path-prelude-fail-4.stderr index dfd6818b6..81c6722b5 100644 --- a/tests/ui/macros/macro-path-prelude-fail-4.stderr +++ b/tests/ui/macros/macro-path-prelude-fail-4.stderr @@ -3,6 +3,14 @@ error: expected derive macro, found built-in attribute `inline` | LL | #[derive(inline)] | ^^^^^^ not a derive macro + | +help: remove from the surrounding `derive()` + --> $DIR/macro-path-prelude-fail-4.rs:1:10 + | +LL | #[derive(inline)] + | ^^^^^^ + = help: add as non-Derive macro + `#[inline]` error: aborting due to previous error diff --git a/tests/ui/macros/macro-path-prelude-fail-5.rs b/tests/ui/macros/macro-path-prelude-fail-5.rs new file mode 100644 index 000000000..b82b6bc78 --- /dev/null +++ b/tests/ui/macros/macro-path-prelude-fail-5.rs @@ -0,0 +1,10 @@ +#[derive(Clone, Debug)] // OK +struct S; + +#[derive(Debug, inline)] //~ ERROR expected derive macro, found built-in attribute `inline` +struct T; + +#[derive(inline, Debug)] //~ ERROR expected derive macro, found built-in attribute `inline` +struct U; + +fn main() {} diff --git a/tests/ui/macros/macro-path-prelude-fail-5.stderr b/tests/ui/macros/macro-path-prelude-fail-5.stderr new file mode 100644 index 000000000..105c59db6 --- /dev/null +++ b/tests/ui/macros/macro-path-prelude-fail-5.stderr @@ -0,0 +1,30 @@ +error: expected derive macro, found built-in attribute `inline` + --> $DIR/macro-path-prelude-fail-5.rs:4:17 + | +LL | #[derive(Debug, inline)] + | ^^^^^^ not a derive macro + | +help: remove from the surrounding `derive()` + --> $DIR/macro-path-prelude-fail-5.rs:4:17 + | +LL | #[derive(Debug, inline)] + | ^^^^^^ + = help: add as non-Derive macro + `#[inline]` + +error: expected derive macro, found built-in attribute `inline` + --> $DIR/macro-path-prelude-fail-5.rs:7:10 + | +LL | #[derive(inline, Debug)] + | ^^^^^^ not a derive macro + | +help: remove from the surrounding `derive()` + --> $DIR/macro-path-prelude-fail-5.rs:7:10 + | +LL | #[derive(inline, Debug)] + | ^^^^^^ + = help: add as non-Derive macro + `#[inline]` + +error: aborting due to 2 previous errors + diff --git a/tests/ui/macros/macros-nonfatal-errors.stderr b/tests/ui/macros/macros-nonfatal-errors.stderr index 93fbc9c8a..ca373ea6c 100644 --- a/tests/ui/macros/macros-nonfatal-errors.stderr +++ b/tests/ui/macros/macros-nonfatal-errors.stderr @@ -3,36 +3,48 @@ error: the `#[default]` attribute may only be used on unit enum variants | LL | #[default] | ^^^^^^^^^^ + | + = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants --> $DIR/macros-nonfatal-errors.rs:18:36 | LL | struct DefaultInnerAttrTupleStruct(#[default] ()); | ^^^^^^^^^^ + | + = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants --> $DIR/macros-nonfatal-errors.rs:22:1 | LL | #[default] | ^^^^^^^^^^ + | + = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants --> $DIR/macros-nonfatal-errors.rs:26:1 | LL | #[default] | ^^^^^^^^^^ + | + = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants --> $DIR/macros-nonfatal-errors.rs:36:11 | LL | Foo = #[default] 0, | ^^^^^^^^^^ + | + = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants --> $DIR/macros-nonfatal-errors.rs:37:14 | LL | Bar([u8; #[default] 1]), | ^^^^^^^^^^ + | + = help: consider a manual implementation of `Default` error: no default declared --> $DIR/macros-nonfatal-errors.rs:42:10 @@ -132,7 +144,7 @@ error: asm template must be a string literal LL | asm!(invalid); | ^^^^^^^ -error: concat_idents! requires ident args +error: `concat_idents!()` requires ident args --> $DIR/macros-nonfatal-errors.rs:101:5 | LL | concat_idents!("not", "idents"); @@ -150,7 +162,7 @@ error: expected string literal LL | env!(invalid); | ^^^^^^^ -error: env! takes 1 or 2 arguments +error: `env!()` takes 1 or 2 arguments --> $DIR/macros-nonfatal-errors.rs:105:5 | LL | env!(foo, abr, baz); @@ -162,7 +174,7 @@ error: environment variable `RUST_HOPEFULLY_THIS_DOESNT_EXIST` not defined at co LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: Use `std::env::var("RUST_HOPEFULLY_THIS_DOESNT_EXIST")` to read the variable at run time + = help: use `std::env::var("RUST_HOPEFULLY_THIS_DOESNT_EXIST")` to read the variable at run time = note: this error originates in the macro `env` (in Nightly builds, run with -Z macro-backtrace for more info) error: format argument must be a string literal diff --git a/tests/ui/macros/missing-writer.rs b/tests/ui/macros/missing-writer.rs new file mode 100644 index 000000000..7df965c36 --- /dev/null +++ b/tests/ui/macros/missing-writer.rs @@ -0,0 +1,17 @@ +// Check error for missing writer in writeln! and write! macro +fn main() { + let x = 1; + let y = 2; + write!("{}_{}", x, y); + //~^ ERROR format argument must be a string literal + //~| HELP you might be missing a string literal to format with + //~| ERROR cannot write into `&'static str` + //~| NOTE must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method + //~| HELP a writer is needed before this format string + writeln!("{}_{}", x, y); + //~^ ERROR format argument must be a string literal + //~| HELP you might be missing a string literal to format with + //~| ERROR cannot write into `&'static str` + //~| NOTE must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method + //~| HELP a writer is needed before this format string +} diff --git a/tests/ui/macros/missing-writer.stderr b/tests/ui/macros/missing-writer.stderr new file mode 100644 index 000000000..86dfe7d65 --- /dev/null +++ b/tests/ui/macros/missing-writer.stderr @@ -0,0 +1,59 @@ +error: format argument must be a string literal + --> $DIR/missing-writer.rs:5:21 + | +LL | write!("{}_{}", x, y); + | ^ + | +help: you might be missing a string literal to format with + | +LL | write!("{}_{}", "{} {}", x, y); + | ++++++++ + +error: format argument must be a string literal + --> $DIR/missing-writer.rs:11:23 + | +LL | writeln!("{}_{}", x, y); + | ^ + | +help: you might be missing a string literal to format with + | +LL | writeln!("{}_{}", "{} {}", x, y); + | ++++++++ + +error[E0599]: cannot write into `&'static str` + --> $DIR/missing-writer.rs:5:12 + | +LL | write!("{}_{}", x, y); + | -------^^^^^^^------- method not found in `&str` + | +note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method + --> $DIR/missing-writer.rs:5:12 + | +LL | write!("{}_{}", x, y); + | ^^^^^^^ +help: a writer is needed before this format string + --> $DIR/missing-writer.rs:5:12 + | +LL | write!("{}_{}", x, y); + | ^ + +error[E0599]: cannot write into `&'static str` + --> $DIR/missing-writer.rs:11:14 + | +LL | writeln!("{}_{}", x, y); + | ---------^^^^^^^------- method not found in `&str` + | +note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method + --> $DIR/missing-writer.rs:11:14 + | +LL | writeln!("{}_{}", x, y); + | ^^^^^^^ +help: a writer is needed before this format string + --> $DIR/missing-writer.rs:11:14 + | +LL | writeln!("{}_{}", x, y); + | ^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/macros/nested-use-as.rs b/tests/ui/macros/nested-use-as.rs new file mode 100644 index 000000000..21aa81e80 --- /dev/null +++ b/tests/ui/macros/nested-use-as.rs @@ -0,0 +1,83 @@ +// check-pass +// edition:2018 +// issue: https://github.com/rust-lang/rust/issues/97534 + +macro_rules! m { + () => { + macro_rules! foo { + () => {} + } + use foo as bar; + } +} + +m!{} + +use bar as baz; + +baz!{} + +macro_rules! foo2 { + () => {}; +} + +macro_rules! m2 { + () => { + use foo2 as bar2; + }; +} + +m2! {} + +use bar2 as baz2; + +baz2! {} + +macro_rules! n1 { + () => { + macro_rules! n2 { + () => { + macro_rules! n3 { + () => { + macro_rules! n4 { + () => {} + } + use n4 as c4; + } + } + use n3 as c3; + } + } + use n2 as c2; + } +} + +use n1 as c1; +c1!{} +use c2 as a2; +a2!{} +use c3 as a3; +a3!{} +use c4 as a4; +a4!{} + +// https://github.com/rust-lang/rust/pull/108729#issuecomment-1474750675 +// reversed +use d5 as d6; +use d4 as d5; +use d3 as d4; +use d2 as d3; +use d1 as d2; +use foo2 as d1; +d6! {} + +// mess +use f3 as f4; +f5! {} +use f1 as f2; +use f4 as f5; +use f2 as f3; +use foo2 as f1; + +fn main() { +} diff --git a/tests/ui/macros/nonterminal-matching.stderr b/tests/ui/macros/nonterminal-matching.stderr index 5bbd54390..c2b047022 100644 --- a/tests/ui/macros/nonterminal-matching.stderr +++ b/tests/ui/macros/nonterminal-matching.stderr @@ -18,6 +18,9 @@ LL | macro n(a $nt_item b) { ... LL | complex_nonterminal!(enum E {}); | ------------------------------- in this macro invocation + = note: captured metavariables except for `:tt`, `:ident` and `:lifetime` cannot be compared to other tokens + = note: see <https://doc.rust-lang.org/nightly/reference/macros-by-example.html#forwarding-a-matched-fragment> for more information + = help: try using `:tt` instead in the macro definition = note: this error originates in the macro `complex_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to previous error diff --git a/tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs b/tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs index b8b6f0846..e88e24482 100644 --- a/tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs +++ b/tests/ui/macros/rfc-2011-nicer-assert-messages/all-expr-kinds.rs @@ -5,7 +5,7 @@ // needs-unwind Asserting on contents of error message #![allow(path_statements, unused_allocation)] -#![feature(box_syntax, core_intrinsics, generic_assert, generic_assert_internals)] +#![feature(core_intrinsics, generic_assert, generic_assert_internals)] macro_rules! test { ( @@ -127,9 +127,6 @@ fn main() { // block [ { elem } == 3 ] => "Assertion failed: { elem } == 3" - // box - [ box elem == box 3 ] => "Assertion failed: box elem == box 3" - // break [ loop { break elem; } == 3 ] => "Assertion failed: loop { break elem; } == 3" @@ -164,7 +161,7 @@ fn main() { // mac call // match - [ match elem { _ => elem } == 3 ] => "Assertion failed: match elem { _ => elem, } == 3" + [ match elem { _ => elem } == 3 ] => "Assertion failed: (match elem { _ => elem, }) == 3" // ret [ (|| { return elem; })() == 3 ] => "Assertion failed: (|| { return elem; })() == 3" diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index fdc2a7666..79d8cd757 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -4,7 +4,6 @@ #![feature(async_closure)] #![feature(box_patterns)] -#![feature(box_syntax)] #![feature(const_trait_impl)] #![feature(decl_macro)] #![feature(generators)] @@ -91,9 +90,6 @@ fn test_block() { #[test] fn test_expr() { - // ExprKind::Box - assert_eq!(stringify_expr!(box expr), "box expr"); - // ExprKind::Array assert_eq!(stringify_expr!([]), "[]"); assert_eq!(stringify_expr!([true]), "[true]"); diff --git a/tests/ui/macros/syntax-extension-source-utils.rs b/tests/ui/macros/syntax-extension-source-utils.rs index 7e46260d5..f41fadddd 100644 --- a/tests/ui/macros/syntax-extension-source-utils.rs +++ b/tests/ui/macros/syntax-extension-source-utils.rs @@ -1,7 +1,6 @@ // run-pass #![allow(stable_features)] -// ignore-pretty issue #37195 pub mod m1 { pub mod m2 { @@ -14,9 +13,9 @@ pub mod m1 { macro_rules! indirect_line { () => ( line!() ) } pub fn main() { - assert_eq!(line!(), 17); + assert_eq!(line!(), 16); assert_eq!(column!(), 16); - assert_eq!(indirect_line!(), 19); + assert_eq!(indirect_line!(), 18); assert!((file!().ends_with("syntax-extension-source-utils.rs"))); assert_eq!(stringify!((2*3) + 5).to_string(), "(2 * 3) + 5".to_string()); assert!(include!("syntax-extension-source-utils-files/includeme.\ @@ -33,5 +32,5 @@ pub fn main() { // The Windows tests are wrapped in an extra module for some reason assert!((m1::m2::where_am_i().ends_with("m1::m2"))); - assert_eq!((36, "(2 * 3) + 5"), (line!(), stringify!((2*3) + 5))); + assert_eq!((35, "(2 * 3) + 5"), (line!(), stringify!((2*3) + 5))); } diff --git a/tests/ui/malformed/malformed-derive-entry.stderr b/tests/ui/malformed/malformed-derive-entry.stderr index 6ff6fbabb..3059d75d7 100644 --- a/tests/ui/malformed/malformed-derive-entry.stderr +++ b/tests/ui/malformed/malformed-derive-entry.stderr @@ -27,7 +27,8 @@ note: required by a bound in `Copy` = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Test1` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct Test1; | error[E0277]: the trait bound `Test2: Clone` is not satisfied @@ -41,7 +42,8 @@ note: required by a bound in `Copy` = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Test2` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct Test2; | error: aborting due to 5 previous errors diff --git a/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs b/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs index 62aa22d41..b9f1de7ec 100644 --- a/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs +++ b/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.rs @@ -1,4 +1,8 @@ -// check-pass +// known-bug: #89515 +// +// The trait solver cannot deal with ambiguous marker trait impls +// if there are lifetimes involved. As we must not special-case any +// regions this does not work, even with 'static #![feature(marker_trait_attr)] #[marker] diff --git a/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.stderr b/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.stderr new file mode 100644 index 000000000..fe4de540b --- /dev/null +++ b/tests/ui/marker_trait_attr/overlap-marker-trait-with-static-lifetime.stderr @@ -0,0 +1,31 @@ +error[E0283]: type annotations needed: cannot satisfy `&'static (): Marker` + --> $DIR/overlap-marker-trait-with-static-lifetime.rs:11:17 + | +LL | impl Marker for &'static () {} + | ^^^^^^^^^^^ + | +note: multiple `impl`s satisfying `&'static (): Marker` found + --> $DIR/overlap-marker-trait-with-static-lifetime.rs:11:1 + | +LL | impl Marker for &'static () {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl Marker for &'static () {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0283]: type annotations needed: cannot satisfy `&'static (): Marker` + --> $DIR/overlap-marker-trait-with-static-lifetime.rs:12:17 + | +LL | impl Marker for &'static () {} + | ^^^^^^^^^^^ + | +note: multiple `impl`s satisfying `&'static (): Marker` found + --> $DIR/overlap-marker-trait-with-static-lifetime.rs:11:1 + | +LL | impl Marker for &'static () {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl Marker for &'static () {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0283`. diff --git a/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs b/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs index a8f3db5f5..97a814f51 100644 --- a/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs +++ b/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.rs @@ -1,9 +1,17 @@ -// check-pass +// known-bug: #109481 +// +// While the `T: Copy` is always applicable when checking +// that the impl `impl<T: Copy> F for T {}` is well formed, +// the old trait solver can only approximate this by checking +// that there are no inference variables in the obligation and +// no region constraints in the evaluation result. +// +// Because of this we end up with ambiguity here. #![feature(marker_trait_attr)] #[marker] pub trait F {} -impl<T> F for T where T: Copy {} -impl<T> F for T where T: 'static {} +impl<T: Copy> F for T {} +impl<T: 'static> F for T {} fn main() {} diff --git a/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.stderr b/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.stderr new file mode 100644 index 000000000..e713d1451 --- /dev/null +++ b/tests/ui/marker_trait_attr/overlapping-impl-1-modulo-regions.stderr @@ -0,0 +1,14 @@ +error[E0310]: the parameter type `T` may not live long enough + --> $DIR/overlapping-impl-1-modulo-regions.rs:14:21 + | +LL | impl<T: Copy> F for T {} + | ^ ...so that the type `T` will meet its required lifetime bounds + | +help: consider adding an explicit lifetime bound... + | +LL | impl<T: Copy + 'static> F for T {} + | +++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0310`. diff --git a/tests/ui/match/guards-parenthesized-and.rs b/tests/ui/match/guards-parenthesized-and.rs new file mode 100644 index 000000000..3a1c341f3 --- /dev/null +++ b/tests/ui/match/guards-parenthesized-and.rs @@ -0,0 +1,10 @@ +// check-pass + +fn main() { + let c = 1; + let w = "T"; + match Some(5) { + None if c == 1 && (w != "Y" && w != "E") => {} + _ => panic!(), + } +} diff --git a/tests/ui/match/match-range-fail-2.rs b/tests/ui/match/match-range-fail-2.rs index 792664e1d..4489cf1ab 100644 --- a/tests/ui/match/match-range-fail-2.rs +++ b/tests/ui/match/match-range-fail-2.rs @@ -3,22 +3,19 @@ fn main() { match 5 { 6 ..= 1 => { } + //~^ ERROR lower range bound must be less than or equal to upper _ => { } }; - //~^^^ ERROR lower range bound must be less than or equal to upper - //~| ERROR lower range bound must be less than or equal to upper match 5 { 0 .. 0 => { } + //~^ ERROR lower range bound must be less than upper _ => { } }; - //~^^^ ERROR lower range bound must be less than upper - //~| ERROR lower range bound must be less than upper match 5u64 { 0xFFFF_FFFF_FFFF_FFFF ..= 1 => { } + //~^ ERROR lower range bound must be less than or equal to upper _ => { } }; - //~^^^ ERROR lower range bound must be less than or equal to upper - //~| ERROR lower range bound must be less than or equal to upper } diff --git a/tests/ui/match/match-range-fail-2.stderr b/tests/ui/match/match-range-fail-2.stderr index 7a0852d7e..52a2bf2b3 100644 --- a/tests/ui/match/match-range-fail-2.stderr +++ b/tests/ui/match/match-range-fail-2.stderr @@ -5,36 +5,18 @@ LL | 6 ..= 1 => { } | ^ lower bound larger than upper bound error[E0579]: lower range bound must be less than upper - --> $DIR/match-range-fail-2.rs:12:9 + --> $DIR/match-range-fail-2.rs:11:9 | LL | 0 .. 0 => { } | ^ error[E0030]: lower range bound must be less than or equal to upper - --> $DIR/match-range-fail-2.rs:19:9 + --> $DIR/match-range-fail-2.rs:17:9 | LL | 0xFFFF_FFFF_FFFF_FFFF ..= 1 => { } | ^^^^^^^^^^^^^^^^^^^^^ lower bound larger than upper bound -error[E0030]: lower range bound must be less than or equal to upper - --> $DIR/match-range-fail-2.rs:5:9 - | -LL | 6 ..= 1 => { } - | ^ lower bound larger than upper bound - -error[E0579]: lower range bound must be less than upper - --> $DIR/match-range-fail-2.rs:12:9 - | -LL | 0 .. 0 => { } - | ^ - -error[E0030]: lower range bound must be less than or equal to upper - --> $DIR/match-range-fail-2.rs:19:9 - | -LL | 0xFFFF_FFFF_FFFF_FFFF ..= 1 => { } - | ^^^^^^^^^^^^^^^^^^^^^ lower bound larger than upper bound - -error: aborting due to 6 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0030, E0579. For more information about an error, try `rustc --explain E0030`. diff --git a/tests/ui/methods/inherent-bound-in-probe.rs b/tests/ui/methods/inherent-bound-in-probe.rs new file mode 100644 index 000000000..81a99ca01 --- /dev/null +++ b/tests/ui/methods/inherent-bound-in-probe.rs @@ -0,0 +1,49 @@ +// normalize-stderr-test: "long-type-\d+" -> "long-type-hash" + +// Fixes #110131 +// +// The issue is that we were constructing an `ImplDerived` cause code for the +// `&'a T: IntoIterator<Item = &'a u8>` obligation for `Helper::new`, which is +// incorrect because derived obligations are only expected to come from *traits*. + +struct SeqBuffer<'a, T> +where + &'a T: IntoIterator<Item = &'a u8>, +{ + iter: <&'a T as IntoIterator>::IntoIter, +} + +struct Helper<'a, T> +where + &'a T: IntoIterator<Item = &'a u8>, +{ + buf: SeqBuffer<'a, T>, +} + +impl<'a, T> Helper<'a, T> +where + &'a T: IntoIterator<Item = &'a u8>, +{ + fn new(sq: &'a T) -> Self { + loop {} + } +} + +struct BitReaderWrapper<T>(T); + +impl<'a, T> IntoIterator for &'a BitReaderWrapper<T> +where + &'a T: IntoIterator<Item = &'a u8>, +{ + type Item = u32; + + type IntoIter = Helper<'a, T>; + //~^ ERROR `Helper<'a, T>` is not an iterator + + fn into_iter(self) -> Self::IntoIter { + Helper::new(&self.0) + //~^ ERROR overflow evaluating the requirement `&_: IntoIterator` + } +} + +fn main() {} diff --git a/tests/ui/methods/inherent-bound-in-probe.stderr b/tests/ui/methods/inherent-bound-in-probe.stderr new file mode 100644 index 000000000..ff03a7edb --- /dev/null +++ b/tests/ui/methods/inherent-bound-in-probe.stderr @@ -0,0 +1,38 @@ +error[E0277]: `Helper<'a, T>` is not an iterator + --> $DIR/inherent-bound-in-probe.rs:40:21 + | +LL | type IntoIter = Helper<'a, T>; + | ^^^^^^^^^^^^^ `Helper<'a, T>` is not an iterator + | + = help: the trait `Iterator` is not implemented for `Helper<'a, T>` +note: required by a bound in `std::iter::IntoIterator::IntoIter` + --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL + +error[E0275]: overflow evaluating the requirement `&_: IntoIterator` + --> $DIR/inherent-bound-in-probe.rs:44:17 + | +LL | Helper::new(&self.0) + | ^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_bound_in_probe`) +note: required for `&BitReaderWrapper<_>` to implement `IntoIterator` + --> $DIR/inherent-bound-in-probe.rs:34:13 + | +LL | impl<'a, T> IntoIterator for &'a BitReaderWrapper<T> + | ^^^^^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ +LL | where +LL | &'a T: IntoIterator<Item = &'a u8>, + | ------------- unsatisfied trait bound introduced here + = note: 126 redundant requirements hidden + = note: required for `&BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<BitReaderWrapper<...>>>>>` to implement `IntoIterator` + = note: the full type name has been written to '$TEST_BUILD_DIR/methods/inherent-bound-in-probe/inherent-bound-in-probe.long-type-hash.txt' +note: required by a bound in `Helper<'a, T>` + --> $DIR/inherent-bound-in-probe.rs:25:25 + | +LL | &'a T: IntoIterator<Item = &'a u8>, + | ^^^^^^^^^^^^^ required by this bound in `Helper<'a, T>` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0275, E0277. +For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/methods/method-call-lifetime-args-fail.stderr b/tests/ui/methods/method-call-lifetime-args-fail.stderr index 34526256f..645d8b8d1 100644 --- a/tests/ui/methods/method-call-lifetime-args-fail.stderr +++ b/tests/ui/methods/method-call-lifetime-args-fail.stderr @@ -30,7 +30,7 @@ note: method defined here, with 2 lifetime parameters: `'a`, `'b` LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } | ^^^^^ -- -- -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:27:15 | LL | S::late::<'static>(S, &0, &0); @@ -42,7 +42,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:29:15 | LL | S::late::<'static, 'static>(S, &0, &0); @@ -54,7 +54,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:31:15 | LL | S::late::<'static, 'static, 'static>(S, &0, &0); @@ -66,7 +66,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:34:21 | LL | S::late_early::<'static, 'static>(S, &0); @@ -78,7 +78,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:36:21 | LL | S::late_early::<'static, 'static, 'static>(S, &0); @@ -90,7 +90,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late_early<'a, 'b>(self, _: &'a u8) -> &'b u8 { loop {} } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:40:24 | LL | S::late_implicit::<'static>(S, &0, &0); @@ -102,7 +102,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:42:24 | LL | S::late_implicit::<'static, 'static>(S, &0, &0); @@ -114,7 +114,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:44:24 | LL | S::late_implicit::<'static, 'static, 'static>(S, &0, &0); @@ -126,7 +126,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late_implicit(self, _: &u8, _: &u8) {} | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:47:30 | LL | S::late_implicit_early::<'static, 'static>(S, &0); @@ -138,7 +138,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:49:30 | LL | S::late_implicit_early::<'static, 'static, 'static>(S, &0); @@ -150,7 +150,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late_implicit_early<'b>(self, _: &u8) -> &'b u8 { loop {} } | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:52:35 | LL | S::late_implicit_self_early::<'static, 'static>(&S); @@ -162,7 +162,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:54:35 | LL | S::late_implicit_self_early::<'static, 'static, 'static>(&S); @@ -174,7 +174,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late_implicit_self_early<'b>(&self) -> &'b u8 { loop {} } | ^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:57:28 | LL | S::late_unused_early::<'static, 'static>(S); @@ -186,7 +186,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late_unused_early<'a, 'b>(self) -> &'b u8 { loop {} } | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-fail.rs:59:28 | LL | S::late_unused_early::<'static, 'static, 'static>(S); @@ -232,4 +232,5 @@ LL | fn early<'a, 'b>(self) -> (&'a u8, &'b u8) { loop {} } error: aborting due to 18 previous errors -For more information about this error, try `rustc --explain E0107`. +Some errors have detailed explanations: E0107, E0794. +For more information about an error, try `rustc --explain E0107`. diff --git a/tests/ui/methods/method-call-lifetime-args.stderr b/tests/ui/methods/method-call-lifetime-args.stderr index 64ae79e9b..b215d5832 100644 --- a/tests/ui/methods/method-call-lifetime-args.stderr +++ b/tests/ui/methods/method-call-lifetime-args.stderr @@ -1,4 +1,4 @@ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args.rs:9:15 | LL | S::late::<'static>(S, &0, &0); @@ -10,7 +10,7 @@ note: the late bound lifetime parameter is introduced here LL | fn late<'a, 'b>(self, _: &'a u8, _: &'b u8) {} | ^^ -error: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present +error[E0794]: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args.rs:11:24 | LL | S::late_implicit::<'static>(S, &0, &0); @@ -24,3 +24,4 @@ LL | fn late_implicit(self, _: &u8, _: &u8) {} error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0794`. diff --git a/tests/ui/mir/addrof_alignment.rs b/tests/ui/mir/addrof_alignment.rs new file mode 100644 index 000000000..892638bfb --- /dev/null +++ b/tests/ui/mir/addrof_alignment.rs @@ -0,0 +1,15 @@ +// run-pass +// ignore-wasm32-bare: No panic messages +// compile-flags: -C debug-assertions + +struct Misalignment { + a: u32, +} + +fn main() { + let items: [Misalignment; 2] = [Misalignment { a: 0 }, Misalignment { a: 1 }]; + unsafe { + let ptr: *const Misalignment = items.as_ptr().cast::<u8>().add(1).cast::<Misalignment>(); + let _ptr = core::ptr::addr_of!((*ptr).a); + } +} diff --git a/tests/ui/mir/checks_without_panic_impl.rs b/tests/ui/mir/checks_without_panic_impl.rs new file mode 100644 index 000000000..04f410b77 --- /dev/null +++ b/tests/ui/mir/checks_without_panic_impl.rs @@ -0,0 +1,17 @@ +// Ensures that the alignment check we insert for raw pointer dereferences +// does not prevent crates without a panic_impl from compiling. +// See rust-lang/rust#109996 + +// build-pass +// compile-flags: -Cdebug-assertions=yes + +#![crate_type = "lib"] + +#![feature(lang_items)] +#![feature(no_core)] +#![no_core] + +#[lang = "sized"] +trait Foo {} + +pub unsafe fn foo(x: *const i32) -> &'static i32 { unsafe { &*x } } diff --git a/tests/ui/mir/issue-109004-drop-large-array.rs b/tests/ui/mir/issue-109004-drop-large-array.rs new file mode 100644 index 000000000..5e3361cef --- /dev/null +++ b/tests/ui/mir/issue-109004-drop-large-array.rs @@ -0,0 +1,16 @@ +// check-pass + +const SZ: usize = 64_000_000; +type BigDrop = [String; SZ]; + +fn f(_dropme: BigDrop) {} + +fn f2(_moveme: BigDrop) -> String { + let [a, ..] = _moveme; + a +} + +fn main() { + f(std::array::from_fn(|_| String::new())); + f2(std::array::from_fn(|_| String::new())); +} diff --git a/tests/ui/mir/mir_alignment_check.rs b/tests/ui/mir/mir_alignment_check.rs new file mode 100644 index 000000000..68a5384b3 --- /dev/null +++ b/tests/ui/mir/mir_alignment_check.rs @@ -0,0 +1,12 @@ +// run-fail +// ignore-wasm32-bare: No panic messages +// compile-flags: -C debug-assertions +// error-pattern: misaligned pointer dereference: address must be a multiple of 0x4 but is + +fn main() { + let mut x = [0u32; 2]; + let ptr: *mut u8 = x.as_mut_ptr().cast::<u8>(); + unsafe { + *(ptr.add(1).cast::<u32>()) = 42; + } +} diff --git a/tests/ui/mir/mir_boxing.rs b/tests/ui/mir/mir_boxing.rs deleted file mode 100644 index 83e1cfb64..000000000 --- a/tests/ui/mir/mir_boxing.rs +++ /dev/null @@ -1,10 +0,0 @@ -// run-pass -#![feature(box_syntax)] - -fn test() -> Box<i32> { - box 42 -} - -fn main() { - assert_eq!(*test(), 42); -} diff --git a/tests/ui/mir/unsize-trait.rs b/tests/ui/mir/unsize-trait.rs new file mode 100644 index 000000000..45b5308c0 --- /dev/null +++ b/tests/ui/mir/unsize-trait.rs @@ -0,0 +1,15 @@ +// Check that the interpreter does not ICE when trying to unsize `B` to `[u8]`. +// This is a `build` test to ensure that const-prop-lint runs. +// build-pass + +#![feature(unsize)] + +fn foo<B>(buffer: &mut [B; 2]) + where B: std::marker::Unsize<[u8]>, +{ + let buffer: &[u8] = &buffer[0]; +} + +fn main() { + foo(&mut [[0], [5]]); +} diff --git a/tests/ui/mir/validate/transmute_cast_sized.rs b/tests/ui/mir/validate/transmute_cast_sized.rs new file mode 100644 index 000000000..eaaf7eb3e --- /dev/null +++ b/tests/ui/mir/validate/transmute_cast_sized.rs @@ -0,0 +1,17 @@ +// build-pass +// compile-flags: -Zvalidate-mir +// edition: 2021 + +#![crate_type = "lib"] + +// Use `PhantomData` to get target-independent size +async fn get(_r: std::marker::PhantomData<&i32>) { + loop {} +} + +pub fn check() { + let mut v = get(loop {}); + let _ = || unsafe { + v = std::mem::transmute([0_u8; 1]); + }; +} diff --git a/tests/ui/mismatched_types/method-help-unsatisfied-bound.stderr b/tests/ui/mismatched_types/method-help-unsatisfied-bound.stderr index d3b752507..9dab3e522 100644 --- a/tests/ui/mismatched_types/method-help-unsatisfied-bound.stderr +++ b/tests/ui/mismatched_types/method-help-unsatisfied-bound.stderr @@ -10,7 +10,8 @@ note: required by a bound in `Result::<T, E>::unwrap` --> $SRC_DIR/core/src/result.rs:LL:COL help: consider annotating `Foo` with `#[derive(Debug)]` | -LL | #[derive(Debug)] +LL + #[derive(Debug)] +LL | struct Foo; | error: aborting due to previous error diff --git a/tests/ui/missing/missing-items/missing-const-parameter.rs b/tests/ui/missing/missing-items/missing-const-parameter.rs new file mode 100644 index 000000000..a3af88f26 --- /dev/null +++ b/tests/ui/missing/missing-items/missing-const-parameter.rs @@ -0,0 +1,24 @@ +struct Struct<const N: usize>; + +impl Struct<{ N }> {} +//~^ ERROR cannot find value `N` in this scope +//~| HELP you might be missing a const parameter + +fn func0(_: Struct<{ N }>) {} +//~^ ERROR cannot find value `N` in this scope +//~| HELP you might be missing a const parameter + +fn func1(_: [u8; N]) {} +//~^ ERROR cannot find value `N` in this scope +//~| HELP you might be missing a const parameter + +fn func2<T>(_: [T; N]) {} +//~^ ERROR cannot find value `N` in this scope +//~| HELP you might be missing a const parameter + +struct Image<const R: usize>([[u32; C]; R]); +//~^ ERROR cannot find value `C` in this scope +//~| HELP a const parameter with a similar name exists +//~| HELP you might be missing a const parameter + +fn main() {} diff --git a/tests/ui/missing/missing-items/missing-const-parameter.stderr b/tests/ui/missing/missing-items/missing-const-parameter.stderr new file mode 100644 index 000000000..d9fea1306 --- /dev/null +++ b/tests/ui/missing/missing-items/missing-const-parameter.stderr @@ -0,0 +1,64 @@ +error[E0425]: cannot find value `N` in this scope + --> $DIR/missing-const-parameter.rs:3:15 + | +LL | impl Struct<{ N }> {} + | ^ not found in this scope + | +help: you might be missing a const parameter + | +LL | impl<const N: /* Type */> Struct<{ N }> {} + | +++++++++++++++++++++ + +error[E0425]: cannot find value `N` in this scope + --> $DIR/missing-const-parameter.rs:7:22 + | +LL | fn func0(_: Struct<{ N }>) {} + | ^ not found in this scope + | +help: you might be missing a const parameter + | +LL | fn func0<const N: /* Type */>(_: Struct<{ N }>) {} + | +++++++++++++++++++++ + +error[E0425]: cannot find value `N` in this scope + --> $DIR/missing-const-parameter.rs:11:18 + | +LL | fn func1(_: [u8; N]) {} + | ^ not found in this scope + | +help: you might be missing a const parameter + | +LL | fn func1<const N: /* Type */>(_: [u8; N]) {} + | +++++++++++++++++++++ + +error[E0425]: cannot find value `N` in this scope + --> $DIR/missing-const-parameter.rs:15:20 + | +LL | fn func2<T>(_: [T; N]) {} + | ^ not found in this scope + | +help: you might be missing a const parameter + | +LL | fn func2<T, const N: /* Type */>(_: [T; N]) {} + | +++++++++++++++++++++ + +error[E0425]: cannot find value `C` in this scope + --> $DIR/missing-const-parameter.rs:19:37 + | +LL | struct Image<const R: usize>([[u32; C]; R]); + | - ^ + | | + | similarly named const parameter `R` defined here + | +help: a const parameter with a similar name exists + | +LL | struct Image<const R: usize>([[u32; R]; R]); + | ~ +help: you might be missing a const parameter + | +LL | struct Image<const R: usize, const C: /* Type */>([[u32; C]; R]); + | +++++++++++++++++++++ + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/modules/issue-107649.stderr b/tests/ui/modules/issue-107649.stderr index 1cea71f28..38a910b57 100644 --- a/tests/ui/modules/issue-107649.stderr +++ b/tests/ui/modules/issue-107649.stderr @@ -10,7 +10,8 @@ error[E0277]: `Dummy` doesn't implement `Debug` help: consider annotating `Dummy` with `#[derive(Debug)]` --> $DIR/auxiliary/dummy_lib.rs:2:1 | -2 | #[derive(Debug)] +2 + #[derive(Debug)] +3 | #[path = "auxiliary/dummy_lib.rs"] | error: aborting due to previous error diff --git a/tests/ui/modules/mod_dir_implicit.rs b/tests/ui/modules/mod_dir_implicit.rs index d6ea6a98b..7eac90f4d 100644 --- a/tests/ui/modules/mod_dir_implicit.rs +++ b/tests/ui/modules/mod_dir_implicit.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty issue #37195 mod mod_dir_implicit_aux; diff --git a/tests/ui/modules/mod_dir_path.rs b/tests/ui/modules/mod_dir_path.rs index 70f592d0c..72db8e44b 100644 --- a/tests/ui/modules/mod_dir_path.rs +++ b/tests/ui/modules/mod_dir_path.rs @@ -1,6 +1,5 @@ // run-pass #![allow(unused_macros)] -// ignore-pretty issue #37195 mod mod_dir_simple { #[path = "test.rs"] diff --git a/tests/ui/modules/mod_dir_path2.rs b/tests/ui/modules/mod_dir_path2.rs index c3e3e1d63..b4f8f1c84 100644 --- a/tests/ui/modules/mod_dir_path2.rs +++ b/tests/ui/modules/mod_dir_path2.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty issue #37195 #[path = "mod_dir_simple"] mod pancakes { diff --git a/tests/ui/modules/mod_dir_path3.rs b/tests/ui/modules/mod_dir_path3.rs index fed70c1bc..56980c010 100644 --- a/tests/ui/modules/mod_dir_path3.rs +++ b/tests/ui/modules/mod_dir_path3.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty issue #37195 #[path = "mod_dir_simple"] mod pancakes { diff --git a/tests/ui/modules/mod_dir_path_multi.rs b/tests/ui/modules/mod_dir_path_multi.rs index 2b805141a..1c111294a 100644 --- a/tests/ui/modules/mod_dir_path_multi.rs +++ b/tests/ui/modules/mod_dir_path_multi.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty issue #37195 #[path = "mod_dir_simple"] mod biscuits { diff --git a/tests/ui/modules/mod_dir_recursive.rs b/tests/ui/modules/mod_dir_recursive.rs index b109d13d1..56f261398 100644 --- a/tests/ui/modules/mod_dir_recursive.rs +++ b/tests/ui/modules/mod_dir_recursive.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty issue #37195 // Testing that the parser for each file tracks its modules // and paths independently. The load_another_mod module should diff --git a/tests/ui/modules/mod_dir_simple.rs b/tests/ui/modules/mod_dir_simple.rs index 1d92c968a..56f15b1d6 100644 --- a/tests/ui/modules/mod_dir_simple.rs +++ b/tests/ui/modules/mod_dir_simple.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty issue #37195 mod mod_dir_simple { pub mod test; diff --git a/tests/ui/modules/mod_file.rs b/tests/ui/modules/mod_file.rs index 0ca52889e..7b56b99eb 100644 --- a/tests/ui/modules/mod_file.rs +++ b/tests/ui/modules/mod_file.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty issue #37195 // Testing that a plain .rs file can load modules from other source files diff --git a/tests/ui/modules/mod_file_with_path_attr.rs b/tests/ui/modules/mod_file_with_path_attr.rs index 48e253ead..e73936695 100644 --- a/tests/ui/modules/mod_file_with_path_attr.rs +++ b/tests/ui/modules/mod_file_with_path_attr.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty issue #37195 // Testing that a plain .rs file can load modules from other source files diff --git a/tests/ui/modules_and_files_visibility/mod_file_disambig_aux/compiletest-ignore-dir b/tests/ui/modules_and_files_visibility/mod_file_disambig_aux/compiletest-ignore-dir new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/ui/modules_and_files_visibility/mod_file_disambig_aux/compiletest-ignore-dir diff --git a/tests/ui/myriad-closures.rs b/tests/ui/myriad-closures.rs new file mode 100644 index 000000000..310351f50 --- /dev/null +++ b/tests/ui/myriad-closures.rs @@ -0,0 +1,39 @@ +// run-pass +// This test case tests whether we can handle code bases that contain a high +// number of closures, something that needs special handling in the MingGW +// toolchain. +// See https://github.com/rust-lang/rust/issues/34793 for more information. + +// Make sure we don't optimize anything away: +// compile-flags: -C no-prepopulate-passes -Cpasses=name-anon-globals + +// Expand something exponentially +macro_rules! go_bacterial { + ($mac:ident) => ($mac!()); + ($mac:ident 1 $($t:tt)*) => ( + go_bacterial!($mac $($t)*); + go_bacterial!($mac $($t)*); + ) +} + +macro_rules! mk_closure { + () => ((move || {})()) +} + +macro_rules! mk_fn { + () => { + { + fn function() { + // Make 16 closures + go_bacterial!(mk_closure 1 1 1 1); + } + let _ = function(); + } + } +} + +fn main() { + // Make 2^8 functions, each containing 16 closures, + // resulting in 2^12 closures overall. + go_bacterial!(mk_fn 1 1 1 1 1 1 1 1); +} diff --git a/tests/ui/namespace/namespace-mix.stderr b/tests/ui/namespace/namespace-mix.stderr index cb72d4a1c..3ac5e96c5 100644 --- a/tests/ui/namespace/namespace-mix.stderr +++ b/tests/ui/namespace/namespace-mix.stderr @@ -14,9 +14,9 @@ LL | check(m1::TS); | ~~ help: consider importing one of these items instead | -LL | use m2::S; +LL + use m2::S; | -LL | use xm2::S; +LL + use xm2::S; | help: if you import `S`, refer to it directly | @@ -42,9 +42,9 @@ LL | check(xm1::TS); | ~~ help: consider importing one of these items instead | -LL | use m2::S; +LL + use m2::S; | -LL | use xm2::S; +LL + use xm2::S; | help: if you import `S`, refer to it directly | @@ -68,9 +68,9 @@ LL | check(m7::TV); | ~~ help: consider importing one of these items instead | -LL | use m8::V; +LL + use m8::V; | -LL | use xm8::V; +LL + use xm8::V; | help: if you import `V`, refer to it directly | @@ -96,9 +96,9 @@ LL | check(xm7::TV); | ~~ help: consider importing one of these items instead | -LL | use m8::V; +LL + use m8::V; | -LL | use xm8::V; +LL + use xm8::V; | help: if you import `V`, refer to it directly | diff --git a/tests/ui/never_type/exhaustive_patterns.stderr b/tests/ui/never_type/exhaustive_patterns.stderr index 40c7c1d10..5fed903eb 100644 --- a/tests/ui/never_type/exhaustive_patterns.stderr +++ b/tests/ui/never_type/exhaustive_patterns.stderr @@ -17,8 +17,8 @@ LL | B(inner::Wrapper<B>), = note: the matched value is of type `Either<(), !>` help: you might want to use `if let` to ignore the variant that isn't matched | -LL | if let Either::A(()) = foo() { todo!() } - | ++ ~~~~~~~~~~~ +LL | if let Either::A(()) = foo() { todo!() }; + | ++ +++++++++++ error: aborting due to previous error diff --git a/tests/ui/never_type/issue-52443.rs b/tests/ui/never_type/issue-52443.rs index 0498a8a16..4669d7c1a 100644 --- a/tests/ui/never_type/issue-52443.rs +++ b/tests/ui/never_type/issue-52443.rs @@ -11,4 +11,5 @@ fn main() { //~| ERROR cannot convert //~| ERROR mutable references //~| ERROR cannot call + //~| ERROR the trait bound } diff --git a/tests/ui/never_type/issue-52443.stderr b/tests/ui/never_type/issue-52443.stderr index 99dfce869..1233bdc5d 100644 --- a/tests/ui/never_type/issue-52443.stderr +++ b/tests/ui/never_type/issue-52443.stderr @@ -58,6 +58,19 @@ LL | [(); { for _ in 0usize.. {}; 0}]; = note: see issue #57349 <https://github.com/rust-lang/rust/issues/57349> for more information = help: add `#![feature(const_mut_refs)]` to the crate attributes to enable +error[E0277]: the trait bound `RangeFrom<usize>: Iterator` is not satisfied + --> $DIR/issue-52443.rs:9:21 + | +LL | [(); { for _ in 0usize.. {}; 0}]; + | ^^^^^^^^ `RangeFrom<usize>` is not an iterator + | + = help: the trait `~const Iterator` is not implemented for `RangeFrom<usize>` +note: the trait `Iterator` is implemented for `RangeFrom<usize>`, but that implementation is not `const` + --> $DIR/issue-52443.rs:9:21 + | +LL | [(); { for _ in 0usize.. {}; 0}]; + | ^^^^^^^^ + error[E0015]: cannot call non-const fn `<RangeFrom<usize> as Iterator>::next` in constants --> $DIR/issue-52443.rs:9:21 | @@ -67,7 +80,7 @@ LL | [(); { for _ in 0usize.. {}; 0}]; = note: calls in constants are limited to constant functions, tuple structs and tuple variants = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable -error: aborting due to 6 previous errors; 1 warning emitted +error: aborting due to 7 previous errors; 1 warning emitted -Some errors have detailed explanations: E0015, E0308, E0658. +Some errors have detailed explanations: E0015, E0277, E0308, E0658. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/nll/closure-requirements/escape-argument-callee.stderr b/tests/ui/nll/closure-requirements/escape-argument-callee.stderr index 363ddfaff..c0d95ddaa 100644 --- a/tests/ui/nll/closure-requirements/escape-argument-callee.stderr +++ b/tests/ui/nll/closure-requirements/escape-argument-callee.stderr @@ -6,7 +6,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); | = note: defining type: test::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None)), Region(BrAnon(2, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(2, None) }) i32)), + for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) i32)), (), ] diff --git a/tests/ui/nll/closure-requirements/escape-argument.stderr b/tests/ui/nll/closure-requirements/escape-argument.stderr index 5a8462d4d..61e2a1ea6 100644 --- a/tests/ui/nll/closure-requirements/escape-argument.stderr +++ b/tests/ui/nll/closure-requirements/escape-argument.stderr @@ -6,7 +6,7 @@ LL | let mut closure = expect_sig(|p, y| *p = y); | = note: defining type: test::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) i32)), + for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) mut &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) i32)), (), ] diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr index 7da6ce58b..5a7b12732 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-fail-no-postdom.stderr @@ -6,7 +6,7 @@ LL | |_outlives1, _outlives2, _outlives3, x, y| { | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&'_#2r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) &'_#3r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&'_#2r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'_#3r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), (), ] = note: late-bound region is '_#4r diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr index 993687605..db2ecc779 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-ref.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None)), Region(BrAnon(2, None)), Region(BrAnon(3, None)), Region(BrAnon(4, None)), Region(BrAnon(5, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(2, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) &'_#2r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(4, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(5, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) &'_#2r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), (), ] = note: late-bound region is '_#3r diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr index 721cd45de..1d9dafbe5 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-comparing-against-free.stderr @@ -6,7 +6,7 @@ LL | foo(cell, |cell_a, cell_x| { | = note: defining type: case1::{closure#0} with closure substs [ i32, - for<Region(BrAnon(0, None))> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>)), + for<Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>)), (), ] @@ -36,7 +36,7 @@ LL | foo(cell, |cell_a, cell_x| { | = note: defining type: case2::{closure#0} with closure substs [ i32, - for<Region(BrAnon(0, None))> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>)), + for<Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'_#1r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>)), (), ] = note: number of external vids: 2 diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr index 43dfc3bb9..85f7fe35c 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-no-bound.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None)), Region(BrAnon(2, None)), Region(BrAnon(3, None)), Region(BrAnon(4, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(2, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(4, None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) u32>)), (), ] = note: late-bound region is '_#2r diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr index 96c734226..7194843e2 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-shorter-to-static-wrong-bound.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None)), Region(BrAnon(2, None)), Region(BrAnon(3, None)), Region(BrAnon(4, None)), Region(BrAnon(5, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(2, None) }) std::cell::Cell<&'_#2r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(4, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(5, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&'_#2r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), (), ] = note: late-bound region is '_#3r diff --git a/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr b/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr index 03dbd686e..71f8a1c67 100644 --- a/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr +++ b/tests/ui/nll/closure-requirements/propagate-approximated-val.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(cell_a, cell_b, |outlives1, outlives2, x, y| { | = note: defining type: test::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) &'_#2r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'_#2r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), (), ] = note: late-bound region is '_#3r diff --git a/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr b/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr index d716d3de2..e1cb97b1c 100644 --- a/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr +++ b/tests/ui/nll/closure-requirements/propagate-despite-same-free-region.stderr @@ -6,7 +6,7 @@ LL | |_outlives1, _outlives2, x, y| { | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) &'_#2r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'_#2r u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) u32>, std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), (), ] = note: late-bound region is '_#3r diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr index b924873fc..b66e8391c 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-no-bounds.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives, x, y| { | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None)), Region(BrAnon(2, None)), Region(BrAnon(3, None)), Region(BrAnon(4, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) &'_#1r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(2, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(4, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'_#1r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>)), (), ] = note: late-bound region is '_#2r diff --git a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr index 9b25efd0b..49641fd06 100644 --- a/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr +++ b/tests/ui/nll/closure-requirements/propagate-fail-to-approximate-longer-wrong-bounds.stderr @@ -6,7 +6,7 @@ LL | establish_relationships(&cell_a, &cell_b, |_outlives1, _outlives2, x, y | = note: defining type: supply::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None)), Region(BrAnon(2, None)), Region(BrAnon(3, None)), Region(BrAnon(4, None)), Region(BrAnon(5, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) &'_#1r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(2, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) &'_#2r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(4, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(5, None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(3, None) }) u32>)), + for<Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) &'_#1r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 2, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) &'_#2r u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 4, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) u32>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 5, kind: BrAnon(None) }) std::cell::Cell<&ReLateBound(DebruijnIndex(0), BoundRegion { var: 3, kind: BrAnon(None) }) u32>)), (), ] = note: late-bound region is '_#3r diff --git a/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr b/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr index 6db72b886..4e34ba516 100644 --- a/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr +++ b/tests/ui/nll/closure-requirements/return-wrong-bound-region.stderr @@ -6,7 +6,7 @@ LL | expect_sig(|a, b| b); // ought to return `a` | = note: defining type: test::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) i32)) -> &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) i32, + for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((&ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) i32, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) i32)) -> &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) i32, (), ] diff --git a/tests/ui/nll/issue-78561.rs b/tests/ui/nll/issue-78561.rs index 55147fcd1..1a2a3ca56 100644 --- a/tests/ui/nll/issue-78561.rs +++ b/tests/ui/nll/issue-78561.rs @@ -1,5 +1,5 @@ // check-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] pub trait Trait { type A; diff --git a/tests/ui/nll/ty-outlives/impl-trait-captures.stderr b/tests/ui/nll/ty-outlives/impl-trait-captures.stderr index 7fcb68252..da4b9595c 100644 --- a/tests/ui/nll/ty-outlives/impl-trait-captures.stderr +++ b/tests/ui/nll/ty-outlives/impl-trait-captures.stderr @@ -1,16 +1,16 @@ -error[E0700]: hidden type for `Opaque(DefId(0:13 ~ impl_trait_captures[1afc]::foo::{opaque#0}), [ReEarlyBound(0, 'a), T, ReEarlyBound(0, 'a)])` captures lifetime that does not appear in bounds +error[E0700]: hidden type for `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [ReEarlyBound(0, 'a), T, ReEarlyBound(0, 'a)])` captures lifetime that does not appear in bounds --> $DIR/impl-trait-captures.rs:11:5 | LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> { | -- ------------ opaque type defined here | | - | hidden type `&ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_), '_)) T` captures the anonymous lifetime defined here + | hidden type `&ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_)) T` captures the anonymous lifetime defined here LL | x | ^ | -help: to declare that `Opaque(DefId(0:13 ~ impl_trait_captures[1afc]::foo::{opaque#0}), [ReEarlyBound(0, 'a), T, ReEarlyBound(2, 'a)])` captures `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_), '_))`, you can add an explicit `ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_), '_))` lifetime bound +help: to declare that `Opaque(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::{opaque#0}), [ReEarlyBound(0, 'a), T, ReEarlyBound(2, 'a)])` captures `ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))`, you can add an explicit `ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_))` lifetime bound | -LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + ReFree(DefId(0:8 ~ impl_trait_captures[1afc]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[1afc]::foo::'_), '_)) { +LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + ReFree(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), BrNamed(DefId(0:12 ~ impl_trait_captures[aeb9]::foo::'_), '_)) { | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to previous error diff --git a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr index a442cf12d..2c4a05975 100644 --- a/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr +++ b/tests/ui/nll/ty-outlives/ty-param-closure-approximate-lower-bound.stderr @@ -6,7 +6,7 @@ LL | twice(cell, value, |a, b| invoke(a, b)); | = note: defining type: generic::<T>::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) T)), + for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) T)), (), ] = note: number of external vids: 2 @@ -28,7 +28,7 @@ LL | twice(cell, value, |a, b| invoke(a, b)); | = note: defining type: generic_fail::<T>::{closure#0} with closure substs [ i16, - for<Region(BrAnon(0, None)), Region(BrAnon(1, None))> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(0, None) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(1, None) }) T)), + for<Region(BrAnon(None)), Region(BrAnon(None))> extern "rust-call" fn((std::option::Option<std::cell::Cell<&'_#1r &ReLateBound(DebruijnIndex(0), BoundRegion { var: 0, kind: BrAnon(None) }) ()>>, &ReLateBound(DebruijnIndex(0), BoundRegion { var: 1, kind: BrAnon(None) }) T)), (), ] = note: late-bound region is '_#2r diff --git a/tests/ui/nll/user-annotations/region-error-ice-109072.rs b/tests/ui/nll/user-annotations/region-error-ice-109072.rs new file mode 100644 index 000000000..3f2ad3ccb --- /dev/null +++ b/tests/ui/nll/user-annotations/region-error-ice-109072.rs @@ -0,0 +1,14 @@ +// Regression test for #109072. +// Check that we don't ICE when canonicalizing user annotation. + +trait Lt<'a> { + type T; +} + +impl Lt<'missing> for () { //~ ERROR undeclared lifetime + type T = &'missing (); //~ ERROR undeclared lifetime +} + +fn main() { + let _: <() as Lt<'_>>::T = &(); +} diff --git a/tests/ui/nll/user-annotations/region-error-ice-109072.stderr b/tests/ui/nll/user-annotations/region-error-ice-109072.stderr new file mode 100644 index 000000000..d90971bed --- /dev/null +++ b/tests/ui/nll/user-annotations/region-error-ice-109072.stderr @@ -0,0 +1,26 @@ +error[E0261]: use of undeclared lifetime name `'missing` + --> $DIR/region-error-ice-109072.rs:8:9 + | +LL | impl Lt<'missing> for () { + | - ^^^^^^^^ undeclared lifetime + | | + | help: consider introducing lifetime `'missing` here: `<'missing>` + +error[E0261]: use of undeclared lifetime name `'missing` + --> $DIR/region-error-ice-109072.rs:9:15 + | +LL | type T = &'missing (); + | ^^^^^^^^ undeclared lifetime + | +help: consider introducing lifetime `'missing` here + | +LL | type T<'missing> = &'missing (); + | ++++++++++ +help: consider introducing lifetime `'missing` here + | +LL | impl<'missing> Lt<'missing> for () { + | ++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0261`. diff --git a/tests/ui/non_modrs_mods/non_modrs_mods.rs b/tests/ui/non_modrs_mods/non_modrs_mods.rs index f664b0166..b3fa39008 100644 --- a/tests/ui/non_modrs_mods/non_modrs_mods.rs +++ b/tests/ui/non_modrs_mods/non_modrs_mods.rs @@ -1,6 +1,5 @@ // run-pass // -// ignore-pretty issue #37195 pub mod modrs_mod; pub mod foors_mod; #[path = "some_crazy_attr_mod_dir/arbitrary_name.rs"] diff --git a/tests/ui/non_modrs_mods_and_inline_mods/x/y/z/compiletest-ignore-dir b/tests/ui/non_modrs_mods_and_inline_mods/x/y/z/compiletest-ignore-dir new file mode 100644 index 000000000..e69de29bb --- /dev/null +++ b/tests/ui/non_modrs_mods_and_inline_mods/x/y/z/compiletest-ignore-dir diff --git a/tests/ui/not-clone-closure.stderr b/tests/ui/not-clone-closure.stderr index 37d94cf0e..db9307c61 100644 --- a/tests/ui/not-clone-closure.stderr +++ b/tests/ui/not-clone-closure.stderr @@ -14,7 +14,8 @@ LL | let hello = move || { | ^^^^^^^ help: consider annotating `S` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct S(i32); | error: aborting due to previous error diff --git a/tests/ui/on-unimplemented/no-debug.stderr b/tests/ui/on-unimplemented/no-debug.stderr index 1035da54d..97d67dbd8 100644 --- a/tests/ui/on-unimplemented/no-debug.stderr +++ b/tests/ui/on-unimplemented/no-debug.stderr @@ -9,7 +9,8 @@ LL | println!("{:?} {:?}", Foo, Bar); = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Foo` with `#[derive(Debug)]` | -LL | #[derive(Debug)] +LL + #[derive(Debug)] +LL | struct Foo; | error[E0277]: `Bar` doesn't implement `Debug` diff --git a/tests/ui/opt-in-copy.rs b/tests/ui/opt-in-copy.rs index 0b48418e4..d0257b574 100644 --- a/tests/ui/opt-in-copy.rs +++ b/tests/ui/opt-in-copy.rs @@ -5,7 +5,7 @@ struct IWantToCopyThis { } impl Copy for IWantToCopyThis {} -//~^ ERROR the trait `Copy` may not be implemented for this type +//~^ ERROR the trait `Copy` cannot be implemented for this type enum CantCopyThisEither { A, @@ -17,6 +17,6 @@ enum IWantToCopyThisToo { } impl Copy for IWantToCopyThisToo {} -//~^ ERROR the trait `Copy` may not be implemented for this type +//~^ ERROR the trait `Copy` cannot be implemented for this type fn main() {} diff --git a/tests/ui/opt-in-copy.stderr b/tests/ui/opt-in-copy.stderr index 4461567df..258ff16e6 100644 --- a/tests/ui/opt-in-copy.stderr +++ b/tests/ui/opt-in-copy.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/opt-in-copy.rs:7:15 | LL | but_i_cant: CantCopyThis, @@ -7,7 +7,7 @@ LL | but_i_cant: CantCopyThis, LL | impl Copy for IWantToCopyThis {} | ^^^^^^^^^^^^^^^ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/opt-in-copy.rs:19:15 | LL | ButICant(CantCopyThisEither), diff --git a/tests/ui/or-patterns/exhaustiveness-non-exhaustive.stderr b/tests/ui/or-patterns/exhaustiveness-non-exhaustive.stderr index 9aa808e6b..9f691aea8 100644 --- a/tests/ui/or-patterns/exhaustiveness-non-exhaustive.stderr +++ b/tests/ui/or-patterns/exhaustiveness-non-exhaustive.stderr @@ -7,7 +7,7 @@ LL | match (0u8, 0u8) { = note: the matched value is of type `(u8, u8)` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ (0 | 1, 2 | 3) => {} +LL ~ (0 | 1, 2 | 3) => {}, LL + (2_u8..=u8::MAX, _) => todo!() | @@ -20,7 +20,7 @@ LL | match ((0u8,),) { = note: the matched value is of type `((u8,),)` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ ((0 | 1,) | (2 | 3,),) => {} +LL ~ ((0 | 1,) | (2 | 3,),) => {}, LL + ((4_u8..=u8::MAX)) => todo!() | @@ -33,7 +33,7 @@ LL | match (Some(0u8),) { = note: the matched value is of type `(Option<u8>,)` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ (None | Some(0 | 1),) => {} +LL ~ (None | Some(0 | 1),) => {}, LL + (Some(2_u8..=u8::MAX)) => todo!() | diff --git a/tests/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr b/tests/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr index 4adcf4fee..fdb1a9bb4 100644 --- a/tests/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr +++ b/tests/ui/or-patterns/issue-69875-should-have-been-expanded-earlier-non-exhaustive.stderr @@ -9,8 +9,8 @@ LL | let (0 | (1 | 2)) = 0; = note: the matched value is of type `i32` help: you might want to use `if let` to ignore the variants that aren't matched | -LL | if let (0 | (1 | 2)) = 0 { todo!() } - | ++ ~~~~~~~~~~~ +LL | if let (0 | (1 | 2)) = 0 { todo!() }; + | ++ +++++++++++ error[E0004]: non-exhaustive patterns: `i32::MIN..=-1_i32` and `3_i32..=i32::MAX` not covered --> $DIR/issue-69875-should-have-been-expanded-earlier-non-exhaustive.rs:3:11 @@ -21,7 +21,7 @@ LL | match 0 { = note: the matched value is of type `i32` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ 0 | (1 | 2) => {} +LL ~ 0 | (1 | 2) => {}, LL + i32::MIN..=-1_i32 | 3_i32..=i32::MAX => todo!() | diff --git a/tests/ui/panic-runtime/unwind-tables-target-required.rs b/tests/ui/panic-runtime/unwind-tables-target-required.rs index 3abb52b67..5a90b314a 100644 --- a/tests/ui/panic-runtime/unwind-tables-target-required.rs +++ b/tests/ui/panic-runtime/unwind-tables-target-required.rs @@ -1,10 +1,11 @@ // Tests that the compiler errors if the user tries to turn off unwind tables // when they are required. // -// only-x86_64-windows-msvc +// only-x86_64-pc-windows-msvc // compile-flags: -C force-unwind-tables=no // -// error-pattern: target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no`. +// dont-check-compiler-stderr +// error-pattern: target requires unwind tables, they cannot be disabled with `-C force-unwind-tables=no` pub fn main() { } diff --git a/tests/ui/parser/assoc-static-semantic-fail.rs b/tests/ui/parser/assoc-static-semantic-fail.rs index a8759d209..403160f12 100644 --- a/tests/ui/parser/assoc-static-semantic-fail.rs +++ b/tests/ui/parser/assoc-static-semantic-fail.rs @@ -31,7 +31,7 @@ trait T { //~| ERROR a static item cannot be `default` pub(crate) default static TD: u8; //~^ ERROR associated `static` items are not allowed - //~| ERROR unnecessary visibility qualifier + //~| ERROR visibility qualifiers are not permitted here //~| ERROR a static item cannot be `default` } @@ -47,6 +47,6 @@ impl T for S { pub default static TD: u8; //~^ ERROR associated `static` items are not allowed //~| ERROR associated constant in `impl` without body - //~| ERROR unnecessary visibility qualifier + //~| ERROR visibility qualifiers are not permitted here //~| ERROR a static item cannot be `default` } diff --git a/tests/ui/parser/assoc-static-semantic-fail.stderr b/tests/ui/parser/assoc-static-semantic-fail.stderr index 8a74f49b9..8178bd223 100644 --- a/tests/ui/parser/assoc-static-semantic-fail.stderr +++ b/tests/ui/parser/assoc-static-semantic-fail.stderr @@ -134,11 +134,13 @@ LL | pub(crate) default static ID: u8; | | | help: provide a definition for the constant: `= <expr>;` -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/assoc-static-semantic-fail.rs:32:5 | LL | pub(crate) default static TD: u8; | ^^^^^^^^^^ + | + = note: trait items always share the visibility of their trait error: associated constant in `impl` without body --> $DIR/assoc-static-semantic-fail.rs:41:5 @@ -156,11 +158,13 @@ LL | pub default static TD: u8; | | | help: provide a definition for the constant: `= <expr>;` -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/assoc-static-semantic-fail.rs:47:5 | LL | pub default static TD: u8; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/assoc-static-semantic-fail.rs:3:12 diff --git a/tests/ui/parser/attr-stmt-expr-attr-bad.rs b/tests/ui/parser/attr-stmt-expr-attr-bad.rs index 469c3855c..c94a32146 100644 --- a/tests/ui/parser/attr-stmt-expr-attr-bad.rs +++ b/tests/ui/parser/attr-stmt-expr-attr-bad.rs @@ -1,7 +1,5 @@ fn main() {} -#[cfg(FALSE)] fn e() { let _ = box #![attr] 0; } -//~^ ERROR an inner attribute is not permitted in this context #[cfg(FALSE)] fn e() { let _ = [#[attr]]; } //~^ ERROR expected expression, found `]` #[cfg(FALSE)] fn e() { let _ = foo#[attr](); } diff --git a/tests/ui/parser/attr-stmt-expr-attr-bad.stderr b/tests/ui/parser/attr-stmt-expr-attr-bad.stderr index 872c560cb..a857f11fd 100644 --- a/tests/ui/parser/attr-stmt-expr-attr-bad.stderr +++ b/tests/ui/parser/attr-stmt-expr-attr-bad.stderr @@ -1,26 +1,17 @@ -error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:3:36 - | -LL | #[cfg(FALSE)] fn e() { let _ = box #![attr] 0; } - | ^^^^^^^^ - | - = note: inner attributes, like `#![no_std]`, annotate the item enclosing them, and are usually found at the beginning of source files - = note: outer attributes, like `#[test]`, annotate the item following them - error: expected expression, found `]` - --> $DIR/attr-stmt-expr-attr-bad.rs:5:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:3:40 | LL | #[cfg(FALSE)] fn e() { let _ = [#[attr]]; } | ^ expected expression error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:7:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:5:35 | LL | #[cfg(FALSE)] fn e() { let _ = foo#[attr](); } | ^ expected one of 8 possible tokens error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:9:36 + --> $DIR/attr-stmt-expr-attr-bad.rs:7:36 | LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); } | ^^^^^^^^ @@ -29,13 +20,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); } = note: outer attributes, like `#[test]`, annotate the item following them error: expected expression, found `)` - --> $DIR/attr-stmt-expr-attr-bad.rs:9:44 + --> $DIR/attr-stmt-expr-attr-bad.rs:7:44 | LL | #[cfg(FALSE)] fn e() { let _ = foo(#![attr]); } | ^ expected expression error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:12:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:10:38 | LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); } | ^^^^^^^^ @@ -44,13 +35,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); } = note: outer attributes, like `#[test]`, annotate the item following them error: expected expression, found `)` - --> $DIR/attr-stmt-expr-attr-bad.rs:12:46 + --> $DIR/attr-stmt-expr-attr-bad.rs:10:46 | LL | #[cfg(FALSE)] fn e() { let _ = x.foo(#![attr]); } | ^ expected expression error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:15:36 + --> $DIR/attr-stmt-expr-attr-bad.rs:13:36 | LL | #[cfg(FALSE)] fn e() { let _ = 0 + #![attr] 0; } | ^^^^^^^^ @@ -59,7 +50,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = 0 + #![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:17:33 + --> $DIR/attr-stmt-expr-attr-bad.rs:15:33 | LL | #[cfg(FALSE)] fn e() { let _ = !#![attr] 0; } | ^^^^^^^^ @@ -68,7 +59,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = !#![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:19:33 + --> $DIR/attr-stmt-expr-attr-bad.rs:17:33 | LL | #[cfg(FALSE)] fn e() { let _ = -#![attr] 0; } | ^^^^^^^^ @@ -77,13 +68,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = -#![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: expected one of `!`, `.`, `::`, `;`, `?`, `else`, `{`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:21:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:19:34 | LL | #[cfg(FALSE)] fn e() { let _ = x #![attr] as Y; } | ^ expected one of 8 possible tokens error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:23:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:21:35 | LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] foo; } | ^^^^^^^^ @@ -92,7 +83,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] foo; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:25:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:23:40 | LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] foo; } | ^^^^^^^^ @@ -101,7 +92,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] foo; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:27:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:25:35 | LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] {foo}; } | ^^^^^^^^ @@ -110,7 +101,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = || #![attr] {foo}; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:29:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:27:40 | LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] {foo}; } | ^^^^^^^^ @@ -119,19 +110,19 @@ LL | #[cfg(FALSE)] fn e() { let _ = move || #![attr] {foo}; } = note: outer attributes, like `#[test]`, annotate the item following them error: expected expression, found `..` - --> $DIR/attr-stmt-expr-attr-bad.rs:31:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:29:40 | LL | #[cfg(FALSE)] fn e() { let _ = #[attr] ..#[attr] 0; } | ^^ expected expression error: expected expression, found `..` - --> $DIR/attr-stmt-expr-attr-bad.rs:33:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:31:40 | LL | #[cfg(FALSE)] fn e() { let _ = #[attr] ..; } | ^^ expected expression error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:35:41 + --> $DIR/attr-stmt-expr-attr-bad.rs:33:41 | LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &#![attr] 0; } | ^^^^^^^^ @@ -140,7 +131,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &#![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:37:45 + --> $DIR/attr-stmt-expr-attr-bad.rs:35:45 | LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; } | ^^^^^^^^ @@ -149,7 +140,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = #[attr] &mut #![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:39:37 + --> $DIR/attr-stmt-expr-attr-bad.rs:37:37 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; } | -- ^^^^^^^ -- the attributes are attached to this branch @@ -158,7 +149,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 #[attr] {}; } | the branch belongs to this `if` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:41:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:39:38 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; } | ^^^^^^^^ @@ -167,13 +158,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:43:40 + --> $DIR/attr-stmt-expr-attr-bad.rs:41:40 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} #[attr] else {}; } | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:45:45 + --> $DIR/attr-stmt-expr-attr-bad.rs:43:45 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; } | ---- ^^^^^^^ -- the attributes are attached to this branch @@ -182,7 +173,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] {}; } | the branch belongs to this `else` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:47:46 + --> $DIR/attr-stmt-expr-attr-bad.rs:45:46 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; } | ^^^^^^^^ @@ -191,7 +182,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:49:45 + --> $DIR/attr-stmt-expr-attr-bad.rs:47:45 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; } | ---- ^^^^^^^ ------- the attributes are attached to this branch @@ -200,7 +191,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else #[attr] if 0 {}; } | the branch belongs to this `else` error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:51:50 + --> $DIR/attr-stmt-expr-attr-bad.rs:49:50 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; } | -- ^^^^^^^ -- the attributes are attached to this branch @@ -209,7 +200,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 #[attr] {}; } | the branch belongs to this `if` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:53:51 + --> $DIR/attr-stmt-expr-attr-bad.rs:51:51 | LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; } | ^^^^^^^^ @@ -218,7 +209,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if 0 {} else if 0 {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:55:45 + --> $DIR/attr-stmt-expr-attr-bad.rs:53:45 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; } | -- ^^^^^^^ -- the attributes are attached to this branch @@ -227,7 +218,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 #[attr] {}; } | the branch belongs to this `if` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:57:46 + --> $DIR/attr-stmt-expr-attr-bad.rs:55:46 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; } | ^^^^^^^^ @@ -236,13 +227,13 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:59:48 + --> $DIR/attr-stmt-expr-attr-bad.rs:57:48 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} #[attr] else {}; } | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:61:53 + --> $DIR/attr-stmt-expr-attr-bad.rs:59:53 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; } | ---- ^^^^^^^ -- the attributes are attached to this branch @@ -251,7 +242,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] {}; } | the branch belongs to this `else` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:63:54 + --> $DIR/attr-stmt-expr-attr-bad.rs:61:54 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; } | ^^^^^^^^ @@ -260,7 +251,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else {#![attr]}; } = note: outer attributes, like `#[test]`, annotate the item following them error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:65:53 + --> $DIR/attr-stmt-expr-attr-bad.rs:63:53 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {}; } | ---- ^^^^^^^ --------------- the attributes are attached to this branch @@ -269,7 +260,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else #[attr] if let _ = 0 {} | the branch belongs to this `else` error: outer attributes are not allowed on `if` and `else` branches - --> $DIR/attr-stmt-expr-attr-bad.rs:67:66 + --> $DIR/attr-stmt-expr-attr-bad.rs:65:66 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {}; } | -- ^^^^^^^ -- the attributes are attached to this branch @@ -278,7 +269,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 #[attr] {} | the branch belongs to this `if` error: an inner attribute is not permitted in this context - --> $DIR/attr-stmt-expr-attr-bad.rs:69:67 + --> $DIR/attr-stmt-expr-attr-bad.rs:67:67 | LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]}; } | ^^^^^^^^ @@ -287,7 +278,7 @@ LL | #[cfg(FALSE)] fn e() { let _ = if let _ = 0 {} else if let _ = 0 {#![attr]} = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:72:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:70:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; } | ------- ^^^^^^^^ not permitted following an outer attribute @@ -298,7 +289,7 @@ LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] let _ = 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:74:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:72:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; } | ------- ^^^^^^^^ not permitted following an outer attribute @@ -309,7 +300,7 @@ LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] 0; } = note: outer attributes, like `#[test]`, annotate the item following them error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:76:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:74:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!(); } | ------- ^^^^^^^^ ------- the inner attribute doesn't annotate this item macro invocation @@ -325,7 +316,7 @@ LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo!(); } | error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:78:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:76:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo![]; } | ------- ^^^^^^^^ ------- the inner attribute doesn't annotate this item macro invocation @@ -341,7 +332,7 @@ LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo![]; } | error: an inner attribute is not permitted following an outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:80:32 + --> $DIR/attr-stmt-expr-attr-bad.rs:78:32 | LL | #[cfg(FALSE)] fn s() { #[attr] #![attr] foo!{}; } | ------- ^^^^^^^^ ------ the inner attribute doesn't annotate this item macro invocation @@ -357,7 +348,7 @@ LL + #[cfg(FALSE)] fn s() { #[attr] #[attr] foo!{}; } | error[E0586]: inclusive range with no end - --> $DIR/attr-stmt-expr-attr-bad.rs:86:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:84:35 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } | ^^^ help: use `..` instead @@ -365,13 +356,13 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: expected one of `=>`, `if`, or `|`, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:86:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:84:38 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] 10 => () } } | ^ expected one of `=>`, `if`, or `|` error[E0586]: inclusive range with no end - --> $DIR/attr-stmt-expr-attr-bad.rs:89:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:87:35 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } | ^^^ help: use `..` instead @@ -379,19 +370,19 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: expected one of `=>`, `if`, or `|`, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:89:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:87:38 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] -10 => () } } | ^ expected one of `=>`, `if`, or `|` error: unexpected token: `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:92:39 + --> $DIR/attr-stmt-expr-attr-bad.rs:90:39 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=-#[attr] 10 => () } } | ^ error[E0586]: inclusive range with no end - --> $DIR/attr-stmt-expr-attr-bad.rs:94:35 + --> $DIR/attr-stmt-expr-attr-bad.rs:92:35 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } | ^^^ help: use `..` instead @@ -399,47 +390,47 @@ LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } = note: inclusive ranges must be bounded at the end (`..=b` or `a..=b`) error: expected one of `=>`, `if`, or `|`, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:94:38 + --> $DIR/attr-stmt-expr-attr-bad.rs:92:38 | LL | #[cfg(FALSE)] fn e() { match 0 { 0..=#[attr] FOO => () } } | ^ expected one of `=>`, `if`, or `|` error: unexpected token: `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:98:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:96:34 | LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); } | ^ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:98:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:96:34 | LL | #[cfg(FALSE)] fn e() { let _ = x.#![attr]foo(); } | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: unexpected token: `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:101:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:99:34 | LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); } | ^ error: expected one of `.`, `;`, `?`, `else`, or an operator, found `#` - --> $DIR/attr-stmt-expr-attr-bad.rs:101:34 + --> $DIR/attr-stmt-expr-attr-bad.rs:99:34 | LL | #[cfg(FALSE)] fn e() { let _ = x.#[attr]foo(); } | ^ expected one of `.`, `;`, `?`, `else`, or an operator error: expected statement after outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:106:37 + --> $DIR/attr-stmt-expr-attr-bad.rs:104:37 | LL | #[cfg(FALSE)] fn e() { { fn foo() { #[attr]; } } } | ^^^^^^^ error: expected statement after outer attribute - --> $DIR/attr-stmt-expr-attr-bad.rs:108:37 + --> $DIR/attr-stmt-expr-attr-bad.rs:106:37 | LL | #[cfg(FALSE)] fn e() { { fn foo() { #[attr] } } } | ^^^^^^^ -error: aborting due to 53 previous errors +error: aborting due to 52 previous errors For more information about this error, try `rustc --explain E0586`. diff --git a/tests/ui/parser/circular_modules_main.stderr b/tests/ui/parser/circular_modules_main.stderr index 1094def60..2de707893 100644 --- a/tests/ui/parser/circular_modules_main.stderr +++ b/tests/ui/parser/circular_modules_main.stderr @@ -12,7 +12,7 @@ LL | println!("{}", circular_modules_main::hi_str()); | help: consider importing this function | -LL | use hi_str; +LL + use hi_str; | help: if you import `hi_str`, refer to it directly | diff --git a/tests/ui/parser/default.rs b/tests/ui/parser/default.rs index 52338c1f1..d1058ceb2 100644 --- a/tests/ui/parser/default.rs +++ b/tests/ui/parser/default.rs @@ -14,7 +14,7 @@ impl Foo for u8 { } impl Foo for u16 { - pub default fn foo<T: Default>() -> T { //~ ERROR unnecessary visibility qualifier + pub default fn foo<T: Default>() -> T { //~ ERROR visibility qualifiers are not permitted here T::default() } } diff --git a/tests/ui/parser/default.stderr b/tests/ui/parser/default.stderr index 37aa48ccf..e6330f368 100644 --- a/tests/ui/parser/default.stderr +++ b/tests/ui/parser/default.stderr @@ -17,11 +17,13 @@ LL | default pub fn foo<T: Default>() -> T { T::default() } LL | } | - item list ends here -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/default.rs:17:5 | LL | pub default fn foo<T: Default>() -> T { - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/default.rs:3:12 diff --git a/tests/ui/parser/dyn-trait-compatibility.rs b/tests/ui/parser/dyn-trait-compatibility.rs index d2b02cc2a..6341e0532 100644 --- a/tests/ui/parser/dyn-trait-compatibility.rs +++ b/tests/ui/parser/dyn-trait-compatibility.rs @@ -9,6 +9,6 @@ type A2 = dyn<dyn, dyn>; type A3 = dyn<<dyn as dyn>::dyn>; //~^ ERROR cannot find type `dyn` in this scope //~| ERROR cannot find type `dyn` in this scope -//~| ERROR use of undeclared crate or module `dyn` +//~| ERROR cannot find trait `dyn` in this scope fn main() {} diff --git a/tests/ui/parser/dyn-trait-compatibility.stderr b/tests/ui/parser/dyn-trait-compatibility.stderr index 0cae01bd1..653be5b3b 100644 --- a/tests/ui/parser/dyn-trait-compatibility.stderr +++ b/tests/ui/parser/dyn-trait-compatibility.stderr @@ -4,12 +4,6 @@ error[E0433]: failed to resolve: use of undeclared crate or module `dyn` LL | type A1 = dyn::dyn; | ^^^ use of undeclared crate or module `dyn` -error[E0433]: failed to resolve: use of undeclared crate or module `dyn` - --> $DIR/dyn-trait-compatibility.rs:9:23 - | -LL | type A3 = dyn<<dyn as dyn>::dyn>; - | ^^^ use of undeclared crate or module `dyn` - error[E0412]: cannot find type `dyn` in this scope --> $DIR/dyn-trait-compatibility.rs:1:11 | @@ -40,6 +34,12 @@ error[E0412]: cannot find type `dyn` in this scope LL | type A3 = dyn<<dyn as dyn>::dyn>; | ^^^ not found in this scope +error[E0405]: cannot find trait `dyn` in this scope + --> $DIR/dyn-trait-compatibility.rs:9:23 + | +LL | type A3 = dyn<<dyn as dyn>::dyn>; + | ^^^ not found in this scope + error[E0412]: cannot find type `dyn` in this scope --> $DIR/dyn-trait-compatibility.rs:9:16 | @@ -48,5 +48,5 @@ LL | type A3 = dyn<<dyn as dyn>::dyn>; error: aborting due to 8 previous errors -Some errors have detailed explanations: E0412, E0433. -For more information about an error, try `rustc --explain E0412`. +Some errors have detailed explanations: E0405, E0412, E0433. +For more information about an error, try `rustc --explain E0405`. diff --git a/tests/ui/parser/fn-header-semantic-fail.rs b/tests/ui/parser/fn-header-semantic-fail.rs index cf5d3dab4..71f18a27e 100644 --- a/tests/ui/parser/fn-header-semantic-fail.rs +++ b/tests/ui/parser/fn-header-semantic-fail.rs @@ -11,7 +11,6 @@ fn main() { extern "C" fn ff4() {} // OK. const async unsafe extern "C" fn ff5() {} //~^ ERROR functions cannot be both `const` and `async` - //~| ERROR cycle detected trait X { async fn ft1(); //~ ERROR functions in traits cannot be declared `async` @@ -34,7 +33,6 @@ fn main() { //~^ ERROR functions in traits cannot be declared `async` //~| ERROR functions in traits cannot be declared const //~| ERROR functions cannot be both `const` and `async` - //~| ERROR cycle detected } impl Y { @@ -44,7 +42,6 @@ fn main() { extern "C" fn fi4() {} // OK. const async unsafe extern "C" fn fi5() {} //~^ ERROR functions cannot be both `const` and `async` - //~| ERROR cycle detected } extern "C" { diff --git a/tests/ui/parser/fn-header-semantic-fail.stderr b/tests/ui/parser/fn-header-semantic-fail.stderr index 2d8bd19a7..7f7b7e835 100644 --- a/tests/ui/parser/fn-header-semantic-fail.stderr +++ b/tests/ui/parser/fn-header-semantic-fail.stderr @@ -8,19 +8,19 @@ LL | const async unsafe extern "C" fn ff5() {} | `const` because of this error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:19:9 + --> $DIR/fn-header-semantic-fail.rs:18:9 | LL | const fn ft3(); | ^^^^^ functions in traits cannot be const error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:21:9 + --> $DIR/fn-header-semantic-fail.rs:20:9 | LL | const async unsafe extern "C" fn ft5(); | ^^^^^ functions in traits cannot be const error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:21:9 + --> $DIR/fn-header-semantic-fail.rs:20:9 | LL | const async unsafe extern "C" fn ft5(); | ^^^^^-^^^^^---------------------------- @@ -29,19 +29,19 @@ LL | const async unsafe extern "C" fn ft5(); | `const` because of this error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:31:9 + --> $DIR/fn-header-semantic-fail.rs:30:9 | LL | const fn ft3() {} | ^^^^^ functions in traits cannot be const error[E0379]: functions in traits cannot be declared const - --> $DIR/fn-header-semantic-fail.rs:33:9 + --> $DIR/fn-header-semantic-fail.rs:32:9 | LL | const async unsafe extern "C" fn ft5() {} | ^^^^^ functions in traits cannot be const error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:33:9 + --> $DIR/fn-header-semantic-fail.rs:32:9 | LL | const async unsafe extern "C" fn ft5() {} | ^^^^^-^^^^^------------------------------ @@ -50,7 +50,7 @@ LL | const async unsafe extern "C" fn ft5() {} | `const` because of this error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:45:9 + --> $DIR/fn-header-semantic-fail.rs:43:9 | LL | const async unsafe extern "C" fn fi5() {} | ^^^^^-^^^^^------------------------------ @@ -59,7 +59,7 @@ LL | const async unsafe extern "C" fn fi5() {} | `const` because of this error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:51:18 + --> $DIR/fn-header-semantic-fail.rs:48:18 | LL | extern "C" { | ---------- in this `extern` block @@ -72,7 +72,7 @@ LL | fn fe1(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:52:19 + --> $DIR/fn-header-semantic-fail.rs:49:19 | LL | extern "C" { | ---------- in this `extern` block @@ -86,7 +86,7 @@ LL | fn fe2(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:53:18 + --> $DIR/fn-header-semantic-fail.rs:50:18 | LL | extern "C" { | ---------- in this `extern` block @@ -100,7 +100,7 @@ LL | fn fe3(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:54:23 + --> $DIR/fn-header-semantic-fail.rs:51:23 | LL | extern "C" { | ---------- in this `extern` block @@ -114,7 +114,7 @@ LL | fn fe4(); | ~~ error: functions in `extern` blocks cannot have qualifiers - --> $DIR/fn-header-semantic-fail.rs:55:42 + --> $DIR/fn-header-semantic-fail.rs:52:42 | LL | extern "C" { | ---------- in this `extern` block @@ -128,7 +128,7 @@ LL | fn fe5(); | ~~ error: functions cannot be both `const` and `async` - --> $DIR/fn-header-semantic-fail.rs:55:9 + --> $DIR/fn-header-semantic-fail.rs:52:9 | LL | const async unsafe extern "C" fn fe5(); | ^^^^^-^^^^^---------------------------- @@ -137,7 +137,7 @@ LL | const async unsafe extern "C" fn fe5(); | `const` because of this error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:17:9 + --> $DIR/fn-header-semantic-fail.rs:16:9 | LL | async fn ft1(); | -----^^^^^^^^^^ @@ -150,7 +150,7 @@ LL | async fn ft1(); = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:21:9 + --> $DIR/fn-header-semantic-fail.rs:20:9 | LL | const async unsafe extern "C" fn ft5(); | ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -163,7 +163,7 @@ LL | const async unsafe extern "C" fn ft5(); = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:29:9 + --> $DIR/fn-header-semantic-fail.rs:28:9 | LL | async fn ft1() {} | -----^^^^^^^^^ @@ -176,7 +176,7 @@ LL | async fn ft1() {} = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable error[E0706]: functions in traits cannot be declared `async` - --> $DIR/fn-header-semantic-fail.rs:33:9 + --> $DIR/fn-header-semantic-fail.rs:32:9 | LL | const async unsafe extern "C" fn ft5() {} | ^^^^^^-----^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -188,115 +188,7 @@ LL | const async unsafe extern "C" fn ft5() {} = note: see issue #91611 <https://github.com/rust-lang/rust/issues/91611> for more information = help: add `#![feature(async_fn_in_trait)]` to the crate attributes to enable -error[E0391]: cycle detected when computing type of `main::ff5::{opaque#0}` - --> $DIR/fn-header-semantic-fail.rs:12:44 - | -LL | const async unsafe extern "C" fn ff5() {} - | ^ - | -note: ...which requires borrow-checking `main::ff5`... - --> $DIR/fn-header-semantic-fail.rs:12:5 - | -LL | const async unsafe extern "C" fn ff5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `main::ff5`... - --> $DIR/fn-header-semantic-fail.rs:12:5 - | -LL | const async unsafe extern "C" fn ff5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `main::ff5`... - --> $DIR/fn-header-semantic-fail.rs:12:5 - | -LL | const async unsafe extern "C" fn ff5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `main::ff5::{opaque#0}` is freeze... - = note: ...which requires evaluating trait selection obligation `main::ff5::{opaque#0}: core::marker::Freeze`... - = note: ...which again requires computing type of `main::ff5::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/fn-header-semantic-fail.rs:5:1 - | -LL | / #![feature(const_extern_fn)] -LL | | -LL | | fn main() { -LL | | async fn ff1() {} // OK. -... | -LL | | } -LL | | } - | |_^ - -error[E0391]: cycle detected when computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5::{opaque#0}` - --> $DIR/fn-header-semantic-fail.rs:33:48 - | -LL | const async unsafe extern "C" fn ft5() {} - | ^ - | -note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5`... - --> $DIR/fn-header-semantic-fail.rs:33:9 - | -LL | const async unsafe extern "C" fn ft5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5`... - --> $DIR/fn-header-semantic-fail.rs:33:9 - | -LL | const async unsafe extern "C" fn ft5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5`... - --> $DIR/fn-header-semantic-fail.rs:33:9 - | -LL | const async unsafe extern "C" fn ft5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5::{opaque#0}` is freeze... - = note: ...which requires evaluating trait selection obligation `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5::{opaque#0}: core::marker::Freeze`... - = note: ...which again requires computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:28:5: 28:17>::ft5::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/fn-header-semantic-fail.rs:5:1 - | -LL | / #![feature(const_extern_fn)] -LL | | -LL | | fn main() { -LL | | async fn ff1() {} // OK. -... | -LL | | } -LL | | } - | |_^ - -error[E0391]: cycle detected when computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5::{opaque#0}` - --> $DIR/fn-header-semantic-fail.rs:45:48 - | -LL | const async unsafe extern "C" fn fi5() {} - | ^ - | -note: ...which requires borrow-checking `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5`... - --> $DIR/fn-header-semantic-fail.rs:45:9 - | -LL | const async unsafe extern "C" fn fi5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires processing MIR for `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5`... - --> $DIR/fn-header-semantic-fail.rs:45:9 - | -LL | const async unsafe extern "C" fn fi5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: ...which requires const checking `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5`... - --> $DIR/fn-header-semantic-fail.rs:45:9 - | -LL | const async unsafe extern "C" fn fi5() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = note: ...which requires computing whether `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5::{opaque#0}` is freeze... - = note: ...which requires evaluating trait selection obligation `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5::{opaque#0}: core::marker::Freeze`... - = note: ...which again requires computing type of `main::<impl at $DIR/fn-header-semantic-fail.rs:40:5: 40:11>::fi5::{opaque#0}`, completing the cycle -note: cycle used when checking item types in top-level module - --> $DIR/fn-header-semantic-fail.rs:5:1 - | -LL | / #![feature(const_extern_fn)] -LL | | -LL | | fn main() { -LL | | async fn ff1() {} // OK. -... | -LL | | } -LL | | } - | |_^ - -error: aborting due to 21 previous errors +error: aborting due to 18 previous errors -Some errors have detailed explanations: E0379, E0391, E0706. +Some errors have detailed explanations: E0379, E0706. For more information about an error, try `rustc --explain E0379`. diff --git a/tests/ui/parser/ident-recovery.rs b/tests/ui/parser/ident-recovery.rs new file mode 100644 index 000000000..7575372b9 --- /dev/null +++ b/tests/ui/parser/ident-recovery.rs @@ -0,0 +1,16 @@ +fn ,comma() { + //~^ ERROR expected identifier, found `,` + struct Foo { + x: i32,, + //~^ ERROR expected identifier, found `,` + y: u32, + } +} + +fn break() { +//~^ ERROR expected identifier, found keyword `break` + let continue = 5; + //~^ ERROR expected identifier, found keyword `continue` +} + +fn main() {} diff --git a/tests/ui/parser/ident-recovery.stderr b/tests/ui/parser/ident-recovery.stderr new file mode 100644 index 000000000..e9a55026d --- /dev/null +++ b/tests/ui/parser/ident-recovery.stderr @@ -0,0 +1,42 @@ +error: expected identifier, found `,` + --> $DIR/ident-recovery.rs:1:4 + | +LL | fn ,comma() { + | ^ + | | + | expected identifier + | help: remove this comma + +error: expected identifier, found `,` + --> $DIR/ident-recovery.rs:4:16 + | +LL | x: i32,, + | ^ + | | + | expected identifier + | help: remove this comma + +error: expected identifier, found keyword `break` + --> $DIR/ident-recovery.rs:10:4 + | +LL | fn break() { + | ^^^^^ expected identifier, found keyword + | +help: escape `break` to use it as an identifier + | +LL | fn r#break() { + | ++ + +error: expected identifier, found keyword `continue` + --> $DIR/ident-recovery.rs:12:9 + | +LL | let continue = 5; + | ^^^^^^^^ expected identifier, found keyword + | +help: escape `continue` to use it as an identifier + | +LL | let r#continue = 5; + | ++ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/parser/integer-literal-start-ident.rs b/tests/ui/parser/integer-literal-start-ident.rs new file mode 100644 index 000000000..12537482e --- /dev/null +++ b/tests/ui/parser/integer-literal-start-ident.rs @@ -0,0 +1,2 @@ +fn 1main() {} +//~^ ERROR expected identifier, found `1main` diff --git a/tests/ui/parser/integer-literal-start-ident.stderr b/tests/ui/parser/integer-literal-start-ident.stderr new file mode 100644 index 000000000..b2c661296 --- /dev/null +++ b/tests/ui/parser/integer-literal-start-ident.stderr @@ -0,0 +1,14 @@ +error: expected identifier, found `1main` + --> $DIR/integer-literal-start-ident.rs:1:4 + | +LL | fn 1main() {} + | ^^^^^ expected identifier + | +help: identifiers cannot start with a number + --> $DIR/integer-literal-start-ident.rs:1:4 + | +LL | fn 1main() {} + | ^ + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-104088.rs b/tests/ui/parser/issues/issue-104088.rs index 5f794fe2d..3dc636b6a 100644 --- a/tests/ui/parser/issues/issue-104088.rs +++ b/tests/ui/parser/issues/issue-104088.rs @@ -1,26 +1,19 @@ -fn test() { +fn 1234test() { +//~^ ERROR expected identifier, found `1234test` if let 123 = 123 { println!("yes"); } -} - -fn test_2() { - let 1x = 123; - //~^ ERROR expected identifier, found number literal -} - -fn test_3() { - let 2x: i32 = 123; - //~^ ERROR expected identifier, found number literal -} -fn test_4() { if let 2e1 = 123 { //~^ ERROR mismatched types } -} -fn test_5() { let 23name = 123; - //~^ ERROR expected identifier, found number literal + //~^ ERROR expected identifier, found `23name` + + let 2x: i32 = 123; + //~^ ERROR expected identifier, found `2x` + + let 1x = 123; + //~^ ERROR expected identifier, found `1x` } fn main() {} diff --git a/tests/ui/parser/issues/issue-104088.stderr b/tests/ui/parser/issues/issue-104088.stderr index ff4b4bdb6..8b751759d 100644 --- a/tests/ui/parser/issues/issue-104088.stderr +++ b/tests/ui/parser/issues/issue-104088.stderr @@ -1,29 +1,59 @@ -error: expected identifier, found number literal - --> $DIR/issue-104088.rs:6:9 +error: expected identifier, found `1234test` + --> $DIR/issue-104088.rs:1:4 | -LL | let 1x = 123; - | ^^ identifiers cannot start with a number +LL | fn 1234test() { + | ^^^^^^^^ expected identifier + | +help: identifiers cannot start with a number + --> $DIR/issue-104088.rs:1:4 + | +LL | fn 1234test() { + | ^^^^ + +error: expected identifier, found `23name` + --> $DIR/issue-104088.rs:9:9 + | +LL | let 23name = 123; + | ^^^^^^ expected identifier + | +help: identifiers cannot start with a number + --> $DIR/issue-104088.rs:9:9 + | +LL | let 23name = 123; + | ^^ -error: expected identifier, found number literal - --> $DIR/issue-104088.rs:11:9 +error: expected identifier, found `2x` + --> $DIR/issue-104088.rs:12:9 | LL | let 2x: i32 = 123; - | ^^ identifiers cannot start with a number + | ^^ expected identifier + | +help: identifiers cannot start with a number + --> $DIR/issue-104088.rs:12:9 + | +LL | let 2x: i32 = 123; + | ^ -error: expected identifier, found number literal - --> $DIR/issue-104088.rs:22:9 +error: expected identifier, found `1x` + --> $DIR/issue-104088.rs:15:9 | -LL | let 23name = 123; - | ^^^^^^ identifiers cannot start with a number +LL | let 1x = 123; + | ^^ expected identifier + | +help: identifiers cannot start with a number + --> $DIR/issue-104088.rs:15:9 + | +LL | let 1x = 123; + | ^ error[E0308]: mismatched types - --> $DIR/issue-104088.rs:16:12 + --> $DIR/issue-104088.rs:5:12 | LL | if let 2e1 = 123 { | ^^^ --- this expression has type `{integer}` | | | expected integer, found floating-point number -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/issues/issue-108242-semicolon-recovery.rs b/tests/ui/parser/issues/issue-108242-semicolon-recovery.rs new file mode 100644 index 000000000..2fc0b2947 --- /dev/null +++ b/tests/ui/parser/issues/issue-108242-semicolon-recovery.rs @@ -0,0 +1,5 @@ +fn foo() {} +fn main() { + foo(; + foo(; +} //~ ERROR mismatched closing delimiter diff --git a/tests/ui/parser/issues/issue-108242-semicolon-recovery.stderr b/tests/ui/parser/issues/issue-108242-semicolon-recovery.stderr new file mode 100644 index 000000000..f68d6d501 --- /dev/null +++ b/tests/ui/parser/issues/issue-108242-semicolon-recovery.stderr @@ -0,0 +1,13 @@ +error: mismatched closing delimiter: `}` + --> $DIR/issue-108242-semicolon-recovery.rs:4:8 + | +LL | fn main() { + | - closing delimiter possibly meant for this +LL | foo(; +LL | foo(; + | ^ unclosed delimiter +LL | } + | ^ mismatched closing delimiter + +error: aborting due to previous error + diff --git a/tests/ui/parser/issues/issue-110014.rs b/tests/ui/parser/issues/issue-110014.rs new file mode 100644 index 000000000..69d8f402b --- /dev/null +++ b/tests/ui/parser/issues/issue-110014.rs @@ -0,0 +1,3 @@ +fn`2222222222222222222222222222222222222222() {} +//~^ ERROR unknown start of token: ` +//~^^ ERROR expected identifier, found `2222222222222222222222222222222222222222` diff --git a/tests/ui/parser/issues/issue-110014.stderr b/tests/ui/parser/issues/issue-110014.stderr new file mode 100644 index 000000000..7f1dd592e --- /dev/null +++ b/tests/ui/parser/issues/issue-110014.stderr @@ -0,0 +1,19 @@ +error: unknown start of token: ` + --> $DIR/issue-110014.rs:1:3 + | +LL | fn`2222222222222222222222222222222222222222() {} + | ^ + | +help: Unicode character '`' (Grave Accent) looks like ''' (Single Quote), but it is not + | +LL | fn'2222222222222222222222222222222222222222() {} + | ~ + +error: expected identifier, found `2222222222222222222222222222222222222222` + --> $DIR/issue-110014.rs:1:4 + | +LL | fn`2222222222222222222222222222222222222222() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected identifier + +error: aborting due to 2 previous errors + diff --git a/tests/ui/parser/issues/issue-48508.rs b/tests/ui/parser/issues/issue-48508.rs index 37d04c5d6..1e7db9df8 100644 --- a/tests/ui/parser/issues/issue-48508.rs +++ b/tests/ui/parser/issues/issue-48508.rs @@ -7,7 +7,6 @@ // issue-48508-aux.rs // compile-flags:-g -// ignore-pretty issue #37195 // ignore-asmjs wasm2js does not support source maps yet #![allow(uncommon_codepoints)] diff --git a/tests/ui/parser/issues/issue-65846-rollback-gating-failing-matcher.rs b/tests/ui/parser/issues/issue-65846-rollback-gating-failing-matcher.rs index 76c07bbfd..b0e8f4d99 100644 --- a/tests/ui/parser/issues/issue-65846-rollback-gating-failing-matcher.rs +++ b/tests/ui/parser/issues/issue-65846-rollback-gating-failing-matcher.rs @@ -5,11 +5,17 @@ #[allow(unused_macro_rules)] macro_rules! m { - ($e:expr) => { 0 }; // This fails on the input below due to `, foo`. - ($e:expr,) => { 1 }; // This also fails to match due to `foo`. - (box $e:expr, foo) => { 2 }; // Successful matcher, we should get `2`. + ($e:expr) => { + 0 + }; // This fails on the input below due to `, foo`. + ($e:expr,) => { + 1 + }; // This also fails to match due to `foo`. + (do yeet $e:expr, foo) => { + 2 + }; // Successful matcher, we should get `2`. } fn main() { - assert_eq!(2, m!(box 42, foo)); + assert_eq!(2, m!(do yeet 42, foo)); } diff --git a/tests/ui/parser/removed-syntax-box.fixed b/tests/ui/parser/removed-syntax-box.fixed new file mode 100644 index 000000000..09d1304b7 --- /dev/null +++ b/tests/ui/parser/removed-syntax-box.fixed @@ -0,0 +1,14 @@ +// run-rustfix + +fn main() { + #[allow(dead_code)] + struct T { + a: u8, + b: u8, + } + let _ = Box::new(()); //~ ERROR `box_syntax` has been removed + let _ = Box::new(1); //~ ERROR `box_syntax` has been removed + let _ = Box::new(T { a: 12, b: 18 }); //~ ERROR `box_syntax` has been removed + let _ = Box::new([5; 30]); //~ ERROR `box_syntax` has been removed + let _: Box<()> = Box::new(()); //~ ERROR `box_syntax` has been removed +} diff --git a/tests/ui/parser/removed-syntax-box.rs b/tests/ui/parser/removed-syntax-box.rs new file mode 100644 index 000000000..1f5061b02 --- /dev/null +++ b/tests/ui/parser/removed-syntax-box.rs @@ -0,0 +1,14 @@ +// run-rustfix + +fn main() { + #[allow(dead_code)] + struct T { + a: u8, + b: u8, + } + let _ = box (); //~ ERROR `box_syntax` has been removed + let _ = box 1; //~ ERROR `box_syntax` has been removed + let _ = box T { a: 12, b: 18 }; //~ ERROR `box_syntax` has been removed + let _ = box [5; 30]; //~ ERROR `box_syntax` has been removed + let _: Box<()> = box (); //~ ERROR `box_syntax` has been removed +} diff --git a/tests/ui/parser/removed-syntax-box.stderr b/tests/ui/parser/removed-syntax-box.stderr new file mode 100644 index 000000000..46b891587 --- /dev/null +++ b/tests/ui/parser/removed-syntax-box.stderr @@ -0,0 +1,57 @@ +error: `box_syntax` has been removed + --> $DIR/removed-syntax-box.rs:9:13 + | +LL | let _ = box (); + | ^^^^^^ + | +help: use `Box::new()` instead + | +LL | let _ = Box::new(()); + | ~~~~~~~~~~~~ + +error: `box_syntax` has been removed + --> $DIR/removed-syntax-box.rs:10:13 + | +LL | let _ = box 1; + | ^^^^^ + | +help: use `Box::new()` instead + | +LL | let _ = Box::new(1); + | ~~~~~~~~~~~ + +error: `box_syntax` has been removed + --> $DIR/removed-syntax-box.rs:11:13 + | +LL | let _ = box T { a: 12, b: 18 }; + | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: use `Box::new()` instead + | +LL | let _ = Box::new(T { a: 12, b: 18 }); + | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~ + +error: `box_syntax` has been removed + --> $DIR/removed-syntax-box.rs:12:13 + | +LL | let _ = box [5; 30]; + | ^^^^^^^^^^^ + | +help: use `Box::new()` instead + | +LL | let _ = Box::new([5; 30]); + | ~~~~~~~~~~~~~~~~~ + +error: `box_syntax` has been removed + --> $DIR/removed-syntax-box.rs:13:22 + | +LL | let _: Box<()> = box (); + | ^^^^^^ + | +help: use `Box::new()` instead + | +LL | let _: Box<()> = Box::new(()); + | ~~~~~~~~~~~~ + +error: aborting due to 5 previous errors + diff --git a/tests/ui/parser/trait-pub-assoc-const.rs b/tests/ui/parser/trait-pub-assoc-const.rs index 219ffa309..7953e12ec 100644 --- a/tests/ui/parser/trait-pub-assoc-const.rs +++ b/tests/ui/parser/trait-pub-assoc-const.rs @@ -1,6 +1,6 @@ trait Foo { pub const Foo: u32; - //~^ ERROR unnecessary visibility qualifier + //~^ ERROR visibility qualifiers are not permitted here } fn main() {} diff --git a/tests/ui/parser/trait-pub-assoc-const.stderr b/tests/ui/parser/trait-pub-assoc-const.stderr index efd09a036..c14a2f2ee 100644 --- a/tests/ui/parser/trait-pub-assoc-const.stderr +++ b/tests/ui/parser/trait-pub-assoc-const.stderr @@ -1,8 +1,10 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/trait-pub-assoc-const.rs:2:5 | LL | pub const Foo: u32; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait error: aborting due to previous error diff --git a/tests/ui/parser/trait-pub-assoc-ty.rs b/tests/ui/parser/trait-pub-assoc-ty.rs index a78dfbdcd..5d9434edc 100644 --- a/tests/ui/parser/trait-pub-assoc-ty.rs +++ b/tests/ui/parser/trait-pub-assoc-ty.rs @@ -1,6 +1,6 @@ trait Foo { pub type Foo; - //~^ ERROR unnecessary visibility qualifier + //~^ ERROR visibility qualifiers are not permitted here } fn main() {} diff --git a/tests/ui/parser/trait-pub-assoc-ty.stderr b/tests/ui/parser/trait-pub-assoc-ty.stderr index e76373f5c..7f6e7350c 100644 --- a/tests/ui/parser/trait-pub-assoc-ty.stderr +++ b/tests/ui/parser/trait-pub-assoc-ty.stderr @@ -1,8 +1,10 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/trait-pub-assoc-ty.rs:2:5 | LL | pub type Foo; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait error: aborting due to previous error diff --git a/tests/ui/parser/trait-pub-method.rs b/tests/ui/parser/trait-pub-method.rs index 1f6ee028a..c8f33e782 100644 --- a/tests/ui/parser/trait-pub-method.rs +++ b/tests/ui/parser/trait-pub-method.rs @@ -1,6 +1,6 @@ trait Foo { pub fn foo(); - //~^ ERROR unnecessary visibility qualifier + //~^ ERROR visibility qualifiers are not permitted here } fn main() {} diff --git a/tests/ui/parser/trait-pub-method.stderr b/tests/ui/parser/trait-pub-method.stderr index 0e3fe027c..2bf1d468a 100644 --- a/tests/ui/parser/trait-pub-method.stderr +++ b/tests/ui/parser/trait-pub-method.stderr @@ -1,8 +1,10 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/trait-pub-method.rs:2:5 | LL | pub fn foo(); - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait error: aborting due to previous error diff --git a/tests/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr b/tests/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr index 29cd6c45c..25838fbf0 100644 --- a/tests/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr +++ b/tests/ui/pattern/bindings-after-at/bind-by-move-neither-can-live-while-the-other-survives-1.stderr @@ -2,18 +2,16 @@ error: cannot move out of value because it is borrowed --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:12:14 | LL | Some(ref _y @ _z) => {} - | ------^^^-- - | | | - | | value is moved into `_z` here + | ^^^^^^ -- value is moved into `_z` here + | | | value is borrowed by `_y` here error: borrow of moved value --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:19:14 | LL | Some(_z @ ref _y) => {} - | --^^^------ - | | | - | | value borrowed here after move + | ^^ ------ value borrowed here after move + | | | value moved into `_z` here | move occurs because `_z` has type `X` which does not implement the `Copy` trait | @@ -26,18 +24,16 @@ error: cannot move out of value because it is borrowed --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:26:14 | LL | Some(ref mut _y @ _z) => {} - | ----------^^^-- - | | | - | | value is moved into `_z` here + | ^^^^^^^^^^ -- value is moved into `_z` here + | | | value is mutably borrowed by `_y` here error: borrow of moved value --> $DIR/bind-by-move-neither-can-live-while-the-other-survives-1.rs:33:14 | LL | Some(_z @ ref mut _y) => {} - | --^^^---------- - | | | - | | value borrowed here after move + | ^^ ---------- value borrowed here after move + | | | value moved into `_z` here | move occurs because `_z` has type `X` which does not implement the `Copy` trait | diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr index 2c123b01e..9305facc4 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-at-and-box.stderr @@ -2,72 +2,64 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-at-and-box.rs:31:9 | LL | let ref a @ box b = Box::new(NC); - | -----^^^^^^^- - | | | - | | value is moved into `b` here + | ^^^^^ - value is moved into `b` here + | | | value is borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-at-and-box.rs:34:9 | LL | let ref a @ box ref mut b = Box::new(nc()); - | -----^^^^^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-at-and-box.rs:36:9 | LL | let ref a @ box ref mut b = Box::new(NC); - | -----^^^^^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-at-and-box.rs:38:9 | LL | let ref a @ box ref mut b = Box::new(NC); - | -----^^^^^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-at-and-box.rs:42:9 | LL | let ref a @ box ref mut b = Box::new(NC); - | -----^^^^^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-at-and-box.rs:48:9 | LL | let ref mut a @ box ref b = Box::new(NC); - | ---------^^^^^^^----- - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-at-and-box.rs:62:9 | LL | ref mut a @ box ref b => { - | ---------^^^^^^^----- - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-at-and-box.rs:54:11 | LL | fn f5(ref mut a @ box ref b: Box<NC>) { - | ---------^^^^^^^----- - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error[E0382]: borrow of moved value diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr index d6474f1b4..c440f4619 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse-promotion.stderr @@ -2,9 +2,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse-promotion.rs:6:9 | LL | let a @ ref b = U; - | -^^^----- - | | | - | | value borrowed here after move + | ^ ----- value borrowed here after move + | | | value moved into `a` here | move occurs because `a` has type `U` which does not implement the `Copy` trait | diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr index 389e86e64..13989ebad 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref-inverse.stderr @@ -2,9 +2,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:22:9 | LL | let a @ ref b = U; - | -^^^----- - | | | - | | value borrowed here after move + | ^ ----- value borrowed here after move + | | | value moved into `a` here | move occurs because `a` has type `U` which does not implement the `Copy` trait | @@ -17,9 +16,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:9 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); - | -^^^^^^^^^^^^---------^^^^^^-----^ - | | | | - | | | value borrowed here after move + | ^ --------- ----- value borrowed here after move + | | | | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait @@ -33,9 +31,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:14 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); - | -----^^^--------- - | | | - | | value borrowed here after move + | ^^^^^ --------- value borrowed here after move + | | | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait | @@ -48,9 +45,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:24:33 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (U, U); - | -^^^----- - | | | - | | value borrowed here after move + | ^ ----- value borrowed here after move + | | | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait | @@ -63,9 +59,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:29:9 | LL | let a @ [ref mut b, ref c] = [U, U]; - | -^^^^---------^^-----^ - | | | | - | | | value borrowed here after move + | ^ --------- ----- value borrowed here after move + | | | | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait @@ -79,9 +74,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:31:9 | LL | let a @ ref b = u(); - | -^^^----- - | | | - | | value borrowed here after move + | ^ ----- value borrowed here after move + | | | value moved into `a` here | move occurs because `a` has type `U` which does not implement the `Copy` trait | @@ -94,9 +88,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:9 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); - | -^^^^^^^^^^^^---------^^^^^^-----^ - | | | | - | | | value borrowed here after move + | ^ --------- ----- value borrowed here after move + | | | | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait @@ -110,9 +103,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:14 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); - | -----^^^--------- - | | | - | | value borrowed here after move + | ^^^^^ --------- value borrowed here after move + | | | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait | @@ -125,9 +117,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:33:33 | LL | let a @ (mut b @ ref mut c, d @ ref e) = (u(), u()); - | -^^^----- - | | | - | | value borrowed here after move + | ^ ----- value borrowed here after move + | | | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait | @@ -140,9 +131,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:38:9 | LL | let a @ [ref mut b, ref c] = [u(), u()]; - | -^^^^---------^^-----^ - | | | | - | | | value borrowed here after move + | ^ --------- ----- value borrowed here after move + | | | | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait @@ -156,9 +146,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:42:9 | LL | a @ Some(ref b) => {} - | -^^^^^^^^-----^ - | | | - | | value borrowed here after move + | ^ ----- value borrowed here after move + | | | value moved into `a` here | move occurs because `a` has type `Option<U>` which does not implement the `Copy` trait | @@ -171,9 +160,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:9 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | -^^^^^^^^^^^^^^^^^---------^^^^^^-----^^ - | | | | - | | | value borrowed here after move + | ^ --------- ----- value borrowed here after move + | | | | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait @@ -187,9 +175,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:19 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | -----^^^--------- - | | | - | | value borrowed here after move + | ^^^^^ --------- value borrowed here after move + | | | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait | @@ -202,9 +189,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:47:38 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | -^^^----- - | | | - | | value borrowed here after move + | ^ ----- value borrowed here after move + | | | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait | @@ -217,9 +203,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:55:9 | LL | mut a @ Some([ref b, ref mut c]) => {} - | -----^^^^^^^^^-----^^---------^^ - | | | | - | | | value borrowed here after move + | ^^^^^ ----- --------- value borrowed here after move + | | | | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait @@ -233,9 +218,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:61:9 | LL | a @ Some(ref b) => {} - | -^^^^^^^^-----^ - | | | - | | value borrowed here after move + | ^ ----- value borrowed here after move + | | | value moved into `a` here | move occurs because `a` has type `Option<U>` which does not implement the `Copy` trait | @@ -248,9 +232,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:9 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | -^^^^^^^^^^^^^^^^^---------^^^^^^-----^^ - | | | | - | | | value borrowed here after move + | ^ --------- ----- value borrowed here after move + | | | | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<(U, U)>` which does not implement the `Copy` trait @@ -264,9 +247,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:19 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | -----^^^--------- - | | | - | | value borrowed here after move + | ^^^^^ --------- value borrowed here after move + | | | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait | @@ -279,9 +261,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:67:38 | LL | a @ Some((mut b @ ref mut c, d @ ref e)) => {} - | -^^^----- - | | | - | | value borrowed here after move + | ^ ----- value borrowed here after move + | | | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait | @@ -294,9 +275,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:75:9 | LL | mut a @ Some([ref b, ref mut c]) => {} - | -----^^^^^^^^^-----^^---------^^ - | | | | - | | | value borrowed here after move + | ^^^^^ ----- --------- value borrowed here after move + | | | | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `Option<[U; 2]>` which does not implement the `Copy` trait @@ -310,9 +290,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:11:11 | LL | fn f1(a @ ref b: U) {} - | -^^^----- - | | | - | | value borrowed here after move + | ^ ----- value borrowed here after move + | | | value moved into `a` here | move occurs because `a` has type `U` which does not implement the `Copy` trait | @@ -325,9 +304,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:11 | LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | -----^^^^^^^^-----^^^^^^^^^^-----^ - | | | | - | | | value borrowed here after move + | ^^^^^ ----- ----- value borrowed here after move + | | | | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait @@ -341,9 +319,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:20 | LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | -^^^----- - | | | - | | value borrowed here after move + | ^ ----- value borrowed here after move + | | | value moved into `b` here | move occurs because `b` has type `U` which does not implement the `Copy` trait | @@ -356,9 +333,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:14:31 | LL | fn f2(mut a @ (b @ ref c, mut d @ ref e): (U, U)) {} - | -----^^^----- - | | | - | | value borrowed here after move + | ^^^^^ ----- value borrowed here after move + | | | value moved into `d` here | move occurs because `d` has type `U` which does not implement the `Copy` trait | @@ -371,9 +347,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-by-move-and-ref-inverse.rs:19:11 | LL | fn f3(a @ [ref mut b, ref c]: [U; 2]) {} - | -^^^^---------^^-----^ - | | | | - | | | value borrowed here after move + | ^ --------- ----- value borrowed here after move + | | | | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `[U; 2]` which does not implement the `Copy` trait diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr index 4f7fbc9e0..00593b2a9 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-by-move-and-ref.stderr @@ -2,18 +2,16 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:24:9 | LL | let ref a @ b = U; - | -----^^^- - | | | - | | value is moved into `b` here + | ^^^^^ - value is moved into `b` here + | | | value is borrowed by `a` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:26:9 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); - | -----^^^^^^^^^^^^-----^^^^^^^^^^-^ - | | | | - | | | value is moved into `e` here + | ^^^^^ ----- - value is moved into `e` here + | | | | | value is moved into `c` here | value is borrowed by `a` here @@ -21,27 +19,24 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:26:18 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); - | -----^^^----- - | | | - | | value is moved into `c` here + | ^^^^^ ----- value is moved into `c` here + | | | value is borrowed by `b` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:26:33 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (U, U); - | -----^^^- - | | | - | | value is moved into `e` here + | ^^^^^ - value is moved into `e` here + | | | value is borrowed by `d` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:30:9 | LL | let ref mut a @ [b, mut c] = [U, U]; - | ---------^^^^-^^-----^ - | | | | - | | | value is moved into `c` here + | ^^^^^^^^^ - ----- value is moved into `c` here + | | | | | value is moved into `b` here | value is mutably borrowed by `a` here @@ -49,18 +44,16 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:33:9 | LL | let ref a @ b = u(); - | -----^^^- - | | | - | | value is moved into `b` here + | ^^^^^ - value is moved into `b` here + | | | value is borrowed by `a` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:36:9 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); - | -----^^^^^^^^^^^^-----^^^^^^^^^^-^ - | | | | - | | | value is moved into `e` here + | ^^^^^ ----- - value is moved into `e` here + | | | | | value is moved into `c` here | value is borrowed by `a` here @@ -68,27 +61,24 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:36:18 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); - | -----^^^----- - | | | - | | value is moved into `c` here + | ^^^^^ ----- value is moved into `c` here + | | | value is borrowed by `b` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:36:33 | LL | let ref a @ (ref b @ mut c, ref d @ e) = (u(), u()); - | -----^^^- - | | | - | | value is moved into `e` here + | ^^^^^ - value is moved into `e` here + | | | value is borrowed by `d` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:42:9 | LL | let ref mut a @ [b, mut c] = [u(), u()]; - | ---------^^^^-^^-----^ - | | | | - | | | value is moved into `c` here + | ^^^^^^^^^ - ----- value is moved into `c` here + | | | | | value is moved into `b` here | value is mutably borrowed by `a` here @@ -96,18 +86,16 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:47:9 | LL | ref a @ Some(b) => {} - | -----^^^^^^^^-^ - | | | - | | value is moved into `b` here + | ^^^^^ - value is moved into `b` here + | | | value is borrowed by `a` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:52:9 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} - | -----^^^^^^^^^^^^^^^^^-----^^^^^^^^^^-^^ - | | | | - | | | value is moved into `e` here + | ^^^^^ ----- - value is moved into `e` here + | | | | | value is moved into `c` here | value is borrowed by `a` here @@ -115,27 +103,24 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:52:23 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} - | -----^^^----- - | | | - | | value is moved into `c` here + | ^^^^^ ----- value is moved into `c` here + | | | value is borrowed by `b` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:52:38 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} - | -----^^^- - | | | - | | value is moved into `e` here + | ^^^^^ - value is moved into `e` here + | | | value is borrowed by `d` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:59:9 | LL | ref mut a @ Some([b, mut c]) => {} - | ---------^^^^^^^^^-^^-----^^ - | | | | - | | | value is moved into `c` here + | ^^^^^^^^^ - ----- value is moved into `c` here + | | | | | value is moved into `b` here | value is mutably borrowed by `a` here @@ -143,18 +128,16 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:64:9 | LL | ref a @ Some(b) => {} - | -----^^^^^^^^-^ - | | | - | | value is moved into `b` here + | ^^^^^ - value is moved into `b` here + | | | value is borrowed by `a` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:69:9 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} - | -----^^^^^^^^^^^^^^^^^-----^^^^^^^^^^-^^ - | | | | - | | | value is moved into `e` here + | ^^^^^ ----- - value is moved into `e` here + | | | | | value is moved into `c` here | value is borrowed by `a` here @@ -162,27 +145,24 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:69:23 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} - | -----^^^----- - | | | - | | value is moved into `c` here + | ^^^^^ ----- value is moved into `c` here + | | | value is borrowed by `b` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:69:38 | LL | ref a @ Some((ref b @ mut c, ref d @ e)) => {} - | -----^^^- - | | | - | | value is moved into `e` here + | ^^^^^ - value is moved into `e` here + | | | value is borrowed by `d` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:78:9 | LL | ref mut a @ Some([b, mut c]) => {} - | ---------^^^^^^^^^-^^-----^^ - | | | | - | | | value is moved into `c` here + | ^^^^^^^^^ - ----- value is moved into `c` here + | | | | | value is moved into `b` here | value is mutably borrowed by `a` here @@ -190,18 +170,16 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:11:11 | LL | fn f1(ref a @ b: U) {} - | -----^^^- - | | | - | | value is moved into `b` here + | ^^^^^ - value is moved into `b` here + | | | value is borrowed by `a` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:14:11 | LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} - | -----^^^^^^^^^^^^-----^^^^^^^^^^-^ - | | | | - | | | value is moved into `e` here + | ^^^^^ ----- - value is moved into `e` here + | | | | | value is moved into `c` here | value is borrowed by `a` here @@ -209,27 +187,24 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:14:20 | LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} - | -----^^^----- - | | | - | | value is moved into `c` here + | ^^^^^ ----- value is moved into `c` here + | | | value is borrowed by `b` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:14:35 | LL | fn f2(ref a @ (ref b @ mut c, ref d @ e): (U, U)) {} - | -----^^^- - | | | - | | value is moved into `e` here + | ^^^^^ - value is moved into `e` here + | | | value is borrowed by `d` here error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-by-move-and-ref.rs:20:11 | LL | fn f3(ref mut a @ [b, mut c]: [U; 2]) {} - | ---------^^^^-^^-----^ - | | | | - | | | value is moved into `c` here + | ^^^^^^^^^ - ----- value is moved into `c` here + | | | | | value is moved into `b` here | value is mutably borrowed by `a` here diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr index f51b50418..d6409d1b6 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-and-ref.stderr @@ -2,18 +2,16 @@ error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:8:9 | LL | ref mut z @ &mut Some(ref a) => { - | ---------^^^^^^^^^^^^^-----^ - | | | - | | value is borrowed by `a` here + | ^^^^^^^^^ ----- value is borrowed by `a` here + | | | value is mutably borrowed by `z` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-and-ref.rs:33:9 | LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub - | ---------^^^^-----------------^ - | | | | - | | | value is mutably borrowed by `c` here + | ^^^^^^^^^ ----- --------- value is mutably borrowed by `c` here + | | | | | value is borrowed by `b` here | value is mutably borrowed by `a` here @@ -21,36 +19,32 @@ error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:33:22 | LL | let ref mut a @ (ref b @ ref mut c) = u(); // sub-in-sub - | -----^^^--------- - | | | - | | value is mutably borrowed by `c` here + | ^^^^^ --------- value is mutably borrowed by `c` here + | | | value is borrowed by `b` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:37:9 | LL | let ref a @ ref mut b = U; - | -----^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:39:9 | LL | let ref mut a @ ref b = U; - | ---------^^^----- - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:41:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | -----^^^^---------^^---------^ - | | | | - | | | value is mutably borrowed by `c` here + | ^^^^^ --------- --------- value is mutably borrowed by `c` here + | | | | | value is mutably borrowed by `b` here | value is borrowed by `a` here @@ -58,9 +52,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:43:9 | LL | let ref mut a @ (ref b, ref c) = (U, U); - | ---------^^^^-----^^-----^ - | | | | - | | | value is borrowed by `c` here + | ^^^^^^^^^ ----- ----- value is borrowed by `c` here + | | | | | value is borrowed by `b` here | value is mutably borrowed by `a` here @@ -68,153 +61,136 @@ error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:46:9 | LL | let ref mut a @ ref b = u(); - | ---------^^^----- - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:51:9 | LL | let ref a @ ref mut b = u(); - | -----^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:57:9 | LL | let ref mut a @ ref b = U; - | ---------^^^----- - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:61:9 | LL | let ref a @ ref mut b = U; - | -----^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:67:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => { - | ---------^^^^^^-----^ - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:67:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) => { - | ---------^^^^^^^-----^ - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:76:9 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { - | -----^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:76:33 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) => { - | -----^^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:87:9 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} - | -----^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:87:33 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { *b = U; false } => {} - | -----^^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:94:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} - | ---------^^^^^^-----^ - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:94:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { *a = Err(U); false } => {} - | ---------^^^^^^^-----^ - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:101:9 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} - | -----^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:101:33 | LL | ref a @ Ok(ref mut b) | ref a @ Err(ref mut b) if { drop(b); false } => {} - | -----^^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:109:9 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} - | ---------^^^^^^-----^ - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:109:33 | LL | ref mut a @ Ok(ref b) | ref mut a @ Err(ref b) if { drop(a); false } => {} - | ---------^^^^^^^-----^ - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:117:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | -----^^^^---------^^---------^ - | | | | - | | | value is mutably borrowed by `c` here + | ^^^^^ --------- --------- value is mutably borrowed by `c` here + | | | | | value is mutably borrowed by `b` here | value is borrowed by `a` here @@ -222,9 +198,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:123:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | -----^^^^---------^^---------^ - | | | | - | | | value is mutably borrowed by `c` here + | ^^^^^ --------- --------- value is mutably borrowed by `c` here + | | | | | value is mutably borrowed by `b` here | value is borrowed by `a` here @@ -232,9 +207,8 @@ error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:129:9 | LL | let ref a @ (ref mut b, ref mut c) = (U, U); - | -----^^^^---------^^---------^ - | | | | - | | | value is mutably borrowed by `c` here + | ^^^^^ --------- --------- value is mutably borrowed by `c` here + | | | | | value is mutably borrowed by `b` here | value is borrowed by `a` here @@ -242,9 +216,8 @@ error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:134:9 | LL | let ref mut a @ (ref b, ref c) = (U, U); - | ---------^^^^-----^^-----^ - | | | | - | | | value is borrowed by `c` here + | ^^^^^^^^^ ----- ----- value is borrowed by `c` here + | | | | | value is borrowed by `b` here | value is mutably borrowed by `a` here @@ -252,36 +225,32 @@ error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:22:11 | LL | fn f1(ref a @ ref mut b: U) {} - | -----^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^ --------- value is mutably borrowed by `b` here + | | | value is borrowed by `a` here error: cannot borrow value as immutable because it is also borrowed as mutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:24:11 | LL | fn f2(ref mut a @ ref b: U) {} - | ---------^^^----- - | | | - | | value is borrowed by `b` here + | ^^^^^^^^^ ----- value is borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:26:11 | LL | fn f3(ref a @ [ref b, ref mut mid @ .., ref c]: [U; 4]) {} - | -----^^^^^^^^^^^----------------^^^^^^^^ - | | | - | | value is mutably borrowed by `mid` here + | ^^^^^ ----------- value is mutably borrowed by `mid` here + | | | value is borrowed by `a` here error: cannot borrow value as mutable because it is also borrowed as immutable --> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:22 | LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {} - | -----^^^------------- - | | | | - | | | value is moved into `c` here + | ^^^^^ --------- - value is moved into `c` here + | | | | | value is mutably borrowed by `b` here | value is borrowed by `a` here @@ -289,9 +258,8 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-ref-mut-and-ref.rs:28:30 | LL | fn f4_also_moved(ref a @ ref mut b @ c: U) {} - | ---------^^^- - | | | - | | value is moved into `c` here + | ^^^^^^^^^ - value is moved into `c` here + | | | value is mutably borrowed by `b` here error[E0502]: cannot borrow value as immutable because it is also borrowed as mutable diff --git a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr index a0cb04a06..24189d061 100644 --- a/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr +++ b/tests/ui/pattern/bindings-after-at/borrowck-pat-ref-mut-twice.stderr @@ -2,98 +2,80 @@ error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:26:9 | LL | let ref mut a @ ref mut b = U; - | ---------^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:29:9 | LL | let ref mut a @ ref mut b = U; - | ---------^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:33:9 | LL | let ref mut a @ ref mut b = U; - | ---------^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:36:9 | LL | let ref mut a @ ref mut b = U; - | ---------^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:39:9 | LL | let ref mut a @ ref mut b = U; - | ---------^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:44:9 | -LL | let ref mut a @ ( - | ^-------- - | | - | _________value is mutably borrowed by `a` here - | | -LL | | -LL | | ref mut b, - | | --------- value is mutably borrowed by `b` here -LL | | [ -LL | | ref mut c, - | | --------- value is mutably borrowed by `c` here -LL | | ref mut d, - | | --------- value is mutably borrowed by `d` here -LL | | ref e, - | | ----- value is borrowed by `e` here -LL | | ] -LL | | ) = (U, [U, U, U]); - | |_____^ +LL | let ref mut a @ ( + | ^^^^^^^^^ value is mutably borrowed by `a` here +LL | +LL | ref mut b, + | --------- value is mutably borrowed by `b` here +LL | [ +LL | ref mut c, + | --------- value is mutably borrowed by `c` here +LL | ref mut d, + | --------- value is mutably borrowed by `d` here +LL | ref e, + | ----- value is borrowed by `e` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:54:9 | -LL | let ref mut a @ ( - | ^-------- - | | - | _________value is mutably borrowed by `a` here - | | -LL | | -LL | | ref mut b, - | | --------- value is mutably borrowed by `b` here -LL | | [ -LL | | ref mut c, - | | --------- value is mutably borrowed by `c` here -LL | | ref mut d, - | | --------- value is mutably borrowed by `d` here -LL | | ref e, - | | ----- value is borrowed by `e` here -LL | | ] -LL | | ) = (u(), [u(), u(), u()]); - | |_________^ +LL | let ref mut a @ ( + | ^^^^^^^^^ value is mutably borrowed by `a` here +LL | +LL | ref mut b, + | --------- value is mutably borrowed by `b` here +LL | [ +LL | ref mut c, + | --------- value is mutably borrowed by `c` here +LL | ref mut d, + | --------- value is mutably borrowed by `d` here +LL | ref e, + | ----- value is borrowed by `e` here error: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:64:9 | LL | let a @ (ref mut b, ref mut c) = (U, U); - | -^^^^---------^^---------^ - | | | | - | | | value borrowed here after move + | ^ --------- --------- value borrowed here after move + | | | | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `(U, U)` which does not implement the `Copy` trait @@ -107,9 +89,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:67:9 | LL | let a @ (b, [c, d]) = &mut val; // Same as ^-- - | -^^^^-^^^-^^-^^ - | | | | | - | | | | value borrowed here after move + | ^ - - - value borrowed here after move + | | | | | | | value borrowed here after move | | value borrowed here after move | value moved into `a` here @@ -124,9 +105,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:70:9 | LL | let a @ &mut ref mut b = &mut U; - | -^^^^^^^^--------- - | | | - | | value borrowed here after move + | ^ --------- value borrowed here after move + | | | value moved into `a` here | move occurs because `a` has type `&mut U` which does not implement the `Copy` trait | @@ -139,9 +119,8 @@ error: borrow of moved value --> $DIR/borrowck-pat-ref-mut-twice.rs:72:9 | LL | let a @ &mut (ref mut b, ref mut c) = &mut (U, U); - | -^^^^^^^^^---------^^---------^ - | | | | - | | | value borrowed here after move + | ^ --------- --------- value borrowed here after move + | | | | | value borrowed here after move | value moved into `a` here | move occurs because `a` has type `&mut (U, U)` which does not implement the `Copy` trait @@ -155,117 +134,99 @@ error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:76:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ---------^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:76:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ---------^^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:82:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ---------^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:82:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ---------^^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:89:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ---------^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:89:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ---------^^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:101:9 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ---------^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:101:37 | LL | ref mut a @ Ok(ref mut b) | ref mut a @ Err(ref mut b) => { - | ---------^^^^^^^---------^ - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:8:11 | LL | fn f1(ref mut a @ ref mut b: U) {} - | ---------^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:10:11 | LL | fn f2(ref mut a @ ref mut b: U) {} - | ---------^^^--------- - | | | - | | value is mutably borrowed by `b` here + | ^^^^^^^^^ --------- value is mutably borrowed by `b` here + | | | value is mutably borrowed by `a` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:13:9 | -LL | ref mut a @ [ - | ^-------- - | | - | _________value is mutably borrowed by `a` here - | | -LL | | -LL | | [ref b @ .., _], - | | ---------- value is borrowed by `b` here -LL | | [_, ref mut mid @ ..], - | | ---------------- value is mutably borrowed by `mid` here -LL | | .., -LL | | [..], -LL | | ] : [[U; 4]; 5] - | |_________^ +LL | ref mut a @ [ + | ^^^^^^^^^ value is mutably borrowed by `a` here +LL | +LL | [ref b @ .., _], + | ----- value is borrowed by `b` here +LL | [_, ref mut mid @ ..], + | ----------- value is mutably borrowed by `mid` here error: cannot borrow value as mutable more than once at a time --> $DIR/borrowck-pat-ref-mut-twice.rs:21:22 | LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} - | ---------^^^------------- - | | | | - | | | value is moved into `c` here + | ^^^^^^^^^ --------- - value is moved into `c` here + | | | | | value is mutably borrowed by `b` here | value is mutably borrowed by `a` here @@ -273,9 +234,8 @@ error: cannot move out of value because it is borrowed --> $DIR/borrowck-pat-ref-mut-twice.rs:21:34 | LL | fn f4_also_moved(ref mut a @ ref mut b @ c: U) {} - | ---------^^^- - | | | - | | value is moved into `c` here + | ^^^^^^^^^ - value is moved into `c` here + | | | value is mutably borrowed by `b` here error[E0499]: cannot borrow value as mutable more than once at a time diff --git a/tests/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr b/tests/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr index 73ebbf481..36515c1a2 100644 --- a/tests/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr +++ b/tests/ui/pattern/bindings-after-at/default-binding-modes-both-sides-independent.stderr @@ -2,36 +2,32 @@ error: cannot move out of value because it is borrowed --> $DIR/default-binding-modes-both-sides-independent.rs:26:9 | LL | let ref a @ b = NotCopy; - | -----^^^- - | | | - | | value is moved into `b` here + | ^^^^^ - value is moved into `b` here + | | | value is borrowed by `a` here error: cannot move out of value because it is borrowed --> $DIR/default-binding-modes-both-sides-independent.rs:29:9 | LL | let ref mut a @ b = NotCopy; - | ---------^^^- - | | | - | | value is moved into `b` here + | ^^^^^^^^^ - value is moved into `b` here + | | | value is mutably borrowed by `a` here error: cannot move out of value because it is borrowed --> $DIR/default-binding-modes-both-sides-independent.rs:34:12 | LL | Ok(ref a @ b) | Err(b @ ref a) => { - | -----^^^- - | | | - | | value is moved into `b` here + | ^^^^^ - value is moved into `b` here + | | | value is borrowed by `a` here error: borrow of moved value --> $DIR/default-binding-modes-both-sides-independent.rs:34:29 | LL | Ok(ref a @ b) | Err(b @ ref a) => { - | -^^^----- - | | | - | | value borrowed here after move + | ^ ----- value borrowed here after move + | | | value moved into `b` here | move occurs because `b` has type `NotCopy` which does not implement the `Copy` trait | @@ -44,9 +40,8 @@ error: cannot move out of value because it is borrowed --> $DIR/default-binding-modes-both-sides-independent.rs:42:9 | LL | ref a @ b => { - | -----^^^- - | | | - | | value is moved into `b` here + | ^^^^^ - value is moved into `b` here + | | | value is borrowed by `a` here error[E0382]: borrow of moved value diff --git a/tests/ui/pattern/issue-106552.stderr b/tests/ui/pattern/issue-106552.stderr index ed5d40c09..96f3d6845 100644 --- a/tests/ui/pattern/issue-106552.stderr +++ b/tests/ui/pattern/issue-106552.stderr @@ -9,8 +9,8 @@ LL | let 5 = 6; = note: the matched value is of type `i32` help: you might want to use `if let` to ignore the variants that aren't matched | -LL | if let 5 = 6 { todo!() } - | ++ ~~~~~~~~~~~ +LL | if let 5 = 6 { todo!() }; + | ++ +++++++++++ help: alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits | LL | let _5 = 6; @@ -20,7 +20,7 @@ error[E0005]: refutable pattern in local binding --> $DIR/issue-106552.rs:5:9 | LL | let x @ 5 = 6; - | ^^^^^ patterns `i32::MIN..=4_i32` and `6_i32..=i32::MAX` not covered + | ^ patterns `i32::MIN..=4_i32` and `6_i32..=i32::MAX` not covered | = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html diff --git a/tests/ui/pattern/issue-106862.fixed b/tests/ui/pattern/issue-106862.fixed new file mode 100644 index 000000000..9b27a61ff --- /dev/null +++ b/tests/ui/pattern/issue-106862.fixed @@ -0,0 +1,44 @@ +// run-rustfix + +#![allow(unused)] + +use Foo::{FooB, FooA}; + +enum Foo { + FooA { opt_x: Option<i32>, y: i32 }, + FooB { x: i32, y: i32 } +} + +fn main() { + let f = FooB { x: 3, y: 4 }; + + match f { + FooB { x: a, y: b } => println!("{} {}", a, b), + //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + _ => (), + } + + match f { + FooB { x, y } => println!("{} {}", x, y), + //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + _ => (), + } + + match f { + FooA { opt_x: Some(x), y } => println!("{} {}", x, y), + //~^ ERROR expected tuple struct or tuple variant, found variant `FooA` + _ => (), + } + + match f { + FooB { x: a, y: _ } => println!("{}", a), + //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + _ => (), + } + + match f { + FooB { x, y } => (), + //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + _ => (), + } +} diff --git a/tests/ui/pattern/issue-106862.rs b/tests/ui/pattern/issue-106862.rs new file mode 100644 index 000000000..590430a78 --- /dev/null +++ b/tests/ui/pattern/issue-106862.rs @@ -0,0 +1,44 @@ +// run-rustfix + +#![allow(unused)] + +use Foo::{FooB, FooA}; + +enum Foo { + FooA { opt_x: Option<i32>, y: i32 }, + FooB { x: i32, y: i32 } +} + +fn main() { + let f = FooB { x: 3, y: 4 }; + + match f { + FooB(a, b) => println!("{} {}", a, b), + //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + _ => (), + } + + match f { + FooB(x, y) => println!("{} {}", x, y), + //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + _ => (), + } + + match f { + FooA(Some(x), y) => println!("{} {}", x, y), + //~^ ERROR expected tuple struct or tuple variant, found variant `FooA` + _ => (), + } + + match f { + FooB(a, _, _) => println!("{}", a), + //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + _ => (), + } + + match f { + FooB() => (), + //~^ ERROR expected tuple struct or tuple variant, found variant `FooB` + _ => (), + } +} diff --git a/tests/ui/pattern/issue-106862.stderr b/tests/ui/pattern/issue-106862.stderr new file mode 100644 index 000000000..27f8ac972 --- /dev/null +++ b/tests/ui/pattern/issue-106862.stderr @@ -0,0 +1,48 @@ +error[E0532]: expected tuple struct or tuple variant, found variant `FooB` + --> $DIR/issue-106862.rs:16:9 + | +LL | FooB { x: i32, y: i32 } + | ----------------------- `FooB` defined here +... +LL | FooB(a, b) => println!("{} {}", a, b), + | ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x: a, y: b }` + +error[E0532]: expected tuple struct or tuple variant, found variant `FooB` + --> $DIR/issue-106862.rs:22:9 + | +LL | FooB { x: i32, y: i32 } + | ----------------------- `FooB` defined here +... +LL | FooB(x, y) => println!("{} {}", x, y), + | ^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x, y }` + +error[E0532]: expected tuple struct or tuple variant, found variant `FooA` + --> $DIR/issue-106862.rs:28:9 + | +LL | FooA { opt_x: Option<i32>, y: i32 }, + | ----------------------------------- `FooA` defined here +... +LL | FooA(Some(x), y) => println!("{} {}", x, y), + | ^^^^^^^^^^^^^^^^ help: use struct pattern syntax instead: `FooA { opt_x: Some(x), y }` + +error[E0532]: expected tuple struct or tuple variant, found variant `FooB` + --> $DIR/issue-106862.rs:34:9 + | +LL | FooB { x: i32, y: i32 } + | ----------------------- `FooB` defined here +... +LL | FooB(a, _, _) => println!("{}", a), + | ^^^^^^^^^^^^^ help: use struct pattern syntax instead: `FooB { x: a, y: _ }` + +error[E0532]: expected tuple struct or tuple variant, found variant `FooB` + --> $DIR/issue-106862.rs:40:9 + | +LL | FooB { x: i32, y: i32 } + | ----------------------- `FooB` defined here +... +LL | FooB() => (), + | ^^^^^^ help: use struct pattern syntax instead: `FooB { x, y }` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0532`. diff --git a/tests/ui/pattern/issue-68393-let-pat-assoc-constant.stderr b/tests/ui/pattern/issue-68393-let-pat-assoc-constant.stderr index 54ecc2498..62c90b638 100644 --- a/tests/ui/pattern/issue-68393-let-pat-assoc-constant.stderr +++ b/tests/ui/pattern/issue-68393-let-pat-assoc-constant.stderr @@ -1,15 +1,15 @@ error[E0158]: associated consts cannot be referenced in patterns - --> $DIR/issue-68393-let-pat-assoc-constant.rs:20:40 - | -LL | pub fn test<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) { - | ^^^^ - -error[E0158]: associated consts cannot be referenced in patterns --> $DIR/issue-68393-let-pat-assoc-constant.rs:22:9 | LL | let A::X = arg; | ^^^^ +error[E0158]: associated consts cannot be referenced in patterns + --> $DIR/issue-68393-let-pat-assoc-constant.rs:20:40 + | +LL | pub fn test<A: Foo, B: Foo>(arg: EFoo, A::X: EFoo) { + | ^^^^ + error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0158`. diff --git a/tests/ui/pattern/pat-tuple-field-count-cross.stderr b/tests/ui/pattern/pat-tuple-field-count-cross.stderr index d92957461..0d7f2e4af 100644 --- a/tests/ui/pattern/pat-tuple-field-count-cross.stderr +++ b/tests/ui/pattern/pat-tuple-field-count-cross.stderr @@ -113,8 +113,8 @@ LL | pub enum E1 { Z0, Z1(), S(u8, u8, u8) } | help: use the tuple variant pattern syntax instead | -LL | E1::Z1(/* fields */) => {} - | ~~~~~~~~~~~~~~~~~~~~ +LL | E1::Z1() => {} + | ~~~~~~~~ help: a unit variant with a similar name exists | LL | E1::Z0 => {} diff --git a/tests/ui/pattern/suggest-adding-appropriate-missing-pattern-excluding-comments.fixed b/tests/ui/pattern/suggest-adding-appropriate-missing-pattern-excluding-comments.fixed index b28dce881..b469fade3 100644 --- a/tests/ui/pattern/suggest-adding-appropriate-missing-pattern-excluding-comments.fixed +++ b/tests/ui/pattern/suggest-adding-appropriate-missing-pattern-excluding-comments.fixed @@ -4,7 +4,7 @@ fn main() { match Some(1) { //~ ERROR non-exhaustive patterns: `None` not covered Some(1) => {} // hello - Some(_) => {} + Some(_) => {}, None => todo!() } } diff --git a/tests/ui/pattern/suggest-adding-appropriate-missing-pattern-excluding-comments.stderr b/tests/ui/pattern/suggest-adding-appropriate-missing-pattern-excluding-comments.stderr index 2a016048f..5f2c89246 100644 --- a/tests/ui/pattern/suggest-adding-appropriate-missing-pattern-excluding-comments.stderr +++ b/tests/ui/pattern/suggest-adding-appropriate-missing-pattern-excluding-comments.stderr @@ -12,7 +12,7 @@ note: `Option<i32>` defined here = note: the matched value is of type `Option<i32>` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ Some(_) => {} +LL ~ Some(_) => {}, LL + None => todo!() | diff --git a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr index 358421cd6..dbd46da44 100644 --- a/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr +++ b/tests/ui/pattern/usefulness/const-partial_eq-fallback-ice.stderr @@ -3,6 +3,9 @@ error: to use a constant of type `MyType` in a pattern, `MyType` must be annotat | LL | if let CONSTANT = &&MyType { | ^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: aborting due to previous error diff --git a/tests/ui/pattern/usefulness/consts-opaque.stderr b/tests/ui/pattern/usefulness/consts-opaque.stderr index 35396751a..3f0b4a9f2 100644 --- a/tests/ui/pattern/usefulness/consts-opaque.stderr +++ b/tests/ui/pattern/usefulness/consts-opaque.stderr @@ -3,36 +3,18 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated wit | LL | FOO => {} | ^^^ - -error: unreachable pattern - --> $DIR/consts-opaque.rs:32:9 - | -LL | FOO => {} - | --- matches any value -LL | -LL | _ => {} // should not be emitting unreachable warning - | ^ unreachable pattern - | -note: the lint level is defined here - --> $DIR/consts-opaque.rs:6:9 | -LL | #![deny(unreachable_patterns)] - | ^^^^^^^^^^^^^^^^^^^^ + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` --> $DIR/consts-opaque.rs:37:9 | LL | FOO_REF => {} | ^^^^^^^ - -error: unreachable pattern - --> $DIR/consts-opaque.rs:39:9 | -LL | FOO_REF => {} - | ------- matches any value -LL | -LL | Foo(_) => {} // should not be emitting unreachable warning - | ^^^^^^ unreachable pattern + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details warning: to use a constant of type `Foo` in a pattern, `Foo` must be annotated with `#[derive(PartialEq, Eq)]` --> $DIR/consts-opaque.rs:45:9 @@ -42,6 +24,8 @@ LL | FOO_REF_REF => {} | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details = note: `#[warn(indirect_structural_match)]` on by default error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` @@ -49,6 +33,87 @@ error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated wit | LL | BAR => {} // should not be emitting unreachable warning | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/consts-opaque.rs:61:9 + | +LL | BAR => {} + | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/consts-opaque.rs:70:9 + | +LL | BAR => {} + | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/consts-opaque.rs:72:9 + | +LL | BAR => {} // should not be emitting unreachable warning + | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/consts-opaque.rs:80:9 + | +LL | BAZ => {} + | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/consts-opaque.rs:90:9 + | +LL | BAZ => {} + | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` + --> $DIR/consts-opaque.rs:97:9 + | +LL | BAZ => {} + | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details + +error: unreachable pattern + --> $DIR/consts-opaque.rs:32:9 + | +LL | FOO => {} + | --- matches any value +LL | +LL | _ => {} // should not be emitting unreachable warning + | ^ unreachable pattern + | +note: the lint level is defined here + --> $DIR/consts-opaque.rs:6:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ + +error: unreachable pattern + --> $DIR/consts-opaque.rs:39:9 + | +LL | FOO_REF => {} + | ------- matches any value +LL | +LL | Foo(_) => {} // should not be emitting unreachable warning + | ^^^^^^ unreachable pattern error: unreachable pattern --> $DIR/consts-opaque.rs:53:9 @@ -67,12 +132,6 @@ LL | Bar => {} LL | _ => {} | ^ unreachable pattern -error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:61:9 - | -LL | BAR => {} - | ^^^ - error: unreachable pattern --> $DIR/consts-opaque.rs:63:9 | @@ -91,18 +150,6 @@ LL | BAR => {} LL | _ => {} | ^ unreachable pattern -error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:70:9 - | -LL | BAR => {} - | ^^^ - -error: to use a constant of type `Bar` in a pattern, `Bar` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:72:9 - | -LL | BAR => {} // should not be emitting unreachable warning - | ^^^ - error: unreachable pattern --> $DIR/consts-opaque.rs:72:9 | @@ -121,12 +168,6 @@ LL | BAR => {} LL | _ => {} // should not be emitting unreachable warning | ^ unreachable pattern -error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:80:9 - | -LL | BAZ => {} - | ^^^ - error: unreachable pattern --> $DIR/consts-opaque.rs:82:9 | @@ -145,12 +186,6 @@ LL | BAZ => {} LL | _ => {} | ^ unreachable pattern -error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:90:9 - | -LL | BAZ => {} - | ^^^ - error: unreachable pattern --> $DIR/consts-opaque.rs:92:9 | @@ -160,12 +195,6 @@ LL | LL | _ => {} | ^ unreachable pattern -error: to use a constant of type `Baz` in a pattern, `Baz` must be annotated with `#[derive(PartialEq, Eq)]` - --> $DIR/consts-opaque.rs:97:9 - | -LL | BAZ => {} - | ^^^ - error: unreachable pattern --> $DIR/consts-opaque.rs:99:9 | diff --git a/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr b/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr index 17e1a2304..ff29de03d 100644 --- a/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr +++ b/tests/ui/pattern/usefulness/doc-hidden-non-exhaustive.stderr @@ -12,7 +12,7 @@ LL | pub enum HiddenEnum { = note: the matched value is of type `HiddenEnum` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ HiddenEnum::B => {} +LL ~ HiddenEnum::B => {}, LL + _ => todo!() | @@ -33,7 +33,7 @@ LL | B, = note: the matched value is of type `HiddenEnum` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ HiddenEnum::C => {} +LL ~ HiddenEnum::C => {}, LL + HiddenEnum::B => todo!() | @@ -54,7 +54,7 @@ LL | B, = note: the matched value is of type `HiddenEnum` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ HiddenEnum::A => {} +LL ~ HiddenEnum::A => {}, LL + HiddenEnum::B | _ => todo!() | @@ -72,7 +72,7 @@ note: `Option<HiddenEnum>` defined here = note: the matched value is of type `Option<HiddenEnum>` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ Some(HiddenEnum::A) => {} +LL ~ Some(HiddenEnum::A) => {}, LL + Some(HiddenEnum::B) | Some(_) => todo!() | @@ -93,7 +93,7 @@ LL | C, = note: the matched value is of type `InCrate` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ InCrate::B => {} +LL ~ InCrate::B => {}, LL + InCrate::C => todo!() | diff --git a/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr b/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr index 5e12bc1d2..5a145efce 100644 --- a/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr +++ b/tests/ui/pattern/usefulness/empty-match.exhaustive_patterns.stderr @@ -162,7 +162,7 @@ LL | match_guarded_arm!(0u8); = note: the matched value is of type `u8` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + _ => todo!() | @@ -180,7 +180,7 @@ LL | struct NonEmptyStruct1; = note: the matched value is of type `NonEmptyStruct1` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + NonEmptyStruct1 => todo!() | @@ -198,7 +198,7 @@ LL | struct NonEmptyStruct2(bool); = note: the matched value is of type `NonEmptyStruct2` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + NonEmptyStruct2(_) => todo!() | @@ -216,7 +216,7 @@ LL | union NonEmptyUnion1 { = note: the matched value is of type `NonEmptyUnion1` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + NonEmptyUnion1 { .. } => todo!() | @@ -234,7 +234,7 @@ LL | union NonEmptyUnion2 { = note: the matched value is of type `NonEmptyUnion2` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + NonEmptyUnion2 { .. } => todo!() | @@ -254,7 +254,7 @@ LL | Foo(bool), = note: the matched value is of type `NonEmptyEnum1` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + NonEmptyEnum1::Foo(_) => todo!() | @@ -276,7 +276,7 @@ LL | Bar, = note: the matched value is of type `NonEmptyEnum2` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!() | @@ -294,7 +294,7 @@ LL | enum NonEmptyEnum5 { = note: the matched value is of type `NonEmptyEnum5` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + _ => todo!() | diff --git a/tests/ui/pattern/usefulness/empty-match.normal.stderr b/tests/ui/pattern/usefulness/empty-match.normal.stderr index 5e12bc1d2..5a145efce 100644 --- a/tests/ui/pattern/usefulness/empty-match.normal.stderr +++ b/tests/ui/pattern/usefulness/empty-match.normal.stderr @@ -162,7 +162,7 @@ LL | match_guarded_arm!(0u8); = note: the matched value is of type `u8` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + _ => todo!() | @@ -180,7 +180,7 @@ LL | struct NonEmptyStruct1; = note: the matched value is of type `NonEmptyStruct1` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + NonEmptyStruct1 => todo!() | @@ -198,7 +198,7 @@ LL | struct NonEmptyStruct2(bool); = note: the matched value is of type `NonEmptyStruct2` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + NonEmptyStruct2(_) => todo!() | @@ -216,7 +216,7 @@ LL | union NonEmptyUnion1 { = note: the matched value is of type `NonEmptyUnion1` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + NonEmptyUnion1 { .. } => todo!() | @@ -234,7 +234,7 @@ LL | union NonEmptyUnion2 { = note: the matched value is of type `NonEmptyUnion2` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + NonEmptyUnion2 { .. } => todo!() | @@ -254,7 +254,7 @@ LL | Foo(bool), = note: the matched value is of type `NonEmptyEnum1` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + NonEmptyEnum1::Foo(_) => todo!() | @@ -276,7 +276,7 @@ LL | Bar, = note: the matched value is of type `NonEmptyEnum2` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + NonEmptyEnum2::Foo(_) | NonEmptyEnum2::Bar => todo!() | @@ -294,7 +294,7 @@ LL | enum NonEmptyEnum5 { = note: the matched value is of type `NonEmptyEnum5` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | -LL ~ _ if false => {} +LL ~ _ if false => {}, LL + _ => todo!() | diff --git a/tests/ui/pattern/usefulness/floats.stderr b/tests/ui/pattern/usefulness/floats.stderr index c926e50b3..d66d4ba29 100644 --- a/tests/ui/pattern/usefulness/floats.stderr +++ b/tests/ui/pattern/usefulness/floats.stderr @@ -7,7 +7,7 @@ LL | match 0.0 { = note: the matched value is of type `f64` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ 0.0..=1.0 => {} +LL ~ 0.0..=1.0 => {}, LL + _ => todo!() | diff --git a/tests/ui/pattern/usefulness/guards.stderr b/tests/ui/pattern/usefulness/guards.stderr index 0c1563c16..fc6748958 100644 --- a/tests/ui/pattern/usefulness/guards.stderr +++ b/tests/ui/pattern/usefulness/guards.stderr @@ -7,7 +7,7 @@ LL | match 0u8 { = note: the matched value is of type `u8` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ 128 ..= 255 if true => {} +LL ~ 128 ..= 255 if true => {}, LL + 128_u8..=u8::MAX => todo!() | diff --git a/tests/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr b/tests/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr index f30ba05df..b585de206 100644 --- a/tests/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr +++ b/tests/ui/pattern/usefulness/integer-ranges/exhaustiveness.stderr @@ -91,7 +91,7 @@ LL | match 0i8 { = note: the matched value is of type `i8` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ 1 ..= i8::MAX => {} +LL ~ 1 ..= i8::MAX => {}, LL + 0_i8 => todo!() | @@ -140,7 +140,7 @@ LL | match (0u8, true) { = note: the matched value is of type `(u8, bool)` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ (0 ..= 255, true) => {} +LL ~ (0 ..= 255, true) => {}, LL + (126_u8..=127_u8, false) => todo!() | diff --git a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr index e3eb98ccd..0e0f0c3e1 100644 --- a/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr +++ b/tests/ui/pattern/usefulness/integer-ranges/pointer-sized-int.deny.stderr @@ -9,7 +9,7 @@ LL | match 0usize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ 0 ..= usize::MAX => {} +LL ~ 0 ..= usize::MAX => {}, LL + _ => todo!() | @@ -24,7 +24,7 @@ LL | match 0isize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ isize::MIN ..= isize::MAX => {} +LL ~ isize::MIN ..= isize::MAX => {}, LL + _ => todo!() | @@ -147,7 +147,7 @@ LL | match 0isize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ 1 ..= isize::MAX => {} +LL ~ 1 ..= isize::MAX => {}, LL + _ => todo!() | diff --git a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr index 30492c982..b80411b26 100644 --- a/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr +++ b/tests/ui/pattern/usefulness/integer-ranges/precise_pointer_matching-message.stderr @@ -9,7 +9,7 @@ LL | match 0usize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `usize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ 0..=usize::MAX => {} +LL ~ 0..=usize::MAX => {}, LL + _ => todo!() | @@ -24,7 +24,7 @@ LL | match 0isize { = help: add `#![feature(precise_pointer_size_matching)]` to the crate attributes to enable precise `isize` matching help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ isize::MIN..=isize::MAX => {} +LL ~ isize::MIN..=isize::MAX => {}, LL + _ => todo!() | diff --git a/tests/ui/pattern/usefulness/issue-2111.stderr b/tests/ui/pattern/usefulness/issue-2111.stderr index 01890b73c..7f7c5a0f1 100644 --- a/tests/ui/pattern/usefulness/issue-2111.stderr +++ b/tests/ui/pattern/usefulness/issue-2111.stderr @@ -7,7 +7,7 @@ LL | match (a, b) { = note: the matched value is of type `(Option<usize>, Option<usize>)` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ (Some(_), None) | (None, Some(_)) => {} +LL ~ (Some(_), None) | (None, Some(_)) => {}, LL + (None, None) | (Some(_), Some(_)) => todo!() | diff --git a/tests/ui/pattern/usefulness/issue-30240.stderr b/tests/ui/pattern/usefulness/issue-30240.stderr index 759fdeafe..ff755d681 100644 --- a/tests/ui/pattern/usefulness/issue-30240.stderr +++ b/tests/ui/pattern/usefulness/issue-30240.stderr @@ -7,7 +7,7 @@ LL | match "world" { = note: the matched value is of type `&str` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ "hello" => {} +LL ~ "hello" => {}, LL + &_ => todo!() | @@ -20,7 +20,7 @@ LL | match "world" { = note: the matched value is of type `&str` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ "hello" => {} +LL ~ "hello" => {}, LL + &_ => todo!() | diff --git a/tests/ui/pattern/usefulness/issue-35609.stderr b/tests/ui/pattern/usefulness/issue-35609.stderr index 12113957d..6d5e2f410 100644 --- a/tests/ui/pattern/usefulness/issue-35609.stderr +++ b/tests/ui/pattern/usefulness/issue-35609.stderr @@ -7,7 +7,7 @@ LL | match (A, ()) { = note: the matched value is of type `(Enum, ())` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | -LL ~ (A, _) => {} +LL ~ (A, _) => {}, LL + _ => todo!() | @@ -20,7 +20,7 @@ LL | match (A, A) { = note: the matched value is of type `(Enum, Enum)` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | -LL ~ (_, A) => {} +LL ~ (_, A) => {}, LL + _ => todo!() | @@ -33,7 +33,7 @@ LL | match ((A, ()), ()) { = note: the matched value is of type `((Enum, ()), ())` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | -LL ~ ((A, ()), _) => {} +LL ~ ((A, ()), _) => {}, LL + _ => todo!() | @@ -46,7 +46,7 @@ LL | match ((A, ()), A) { = note: the matched value is of type `((Enum, ()), Enum)` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | -LL ~ ((A, ()), _) => {} +LL ~ ((A, ()), _) => {}, LL + _ => todo!() | @@ -59,7 +59,7 @@ LL | match ((A, ()), ()) { = note: the matched value is of type `((Enum, ()), ())` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | -LL ~ ((A, _), _) => {} +LL ~ ((A, _), _) => {}, LL + _ => todo!() | @@ -77,7 +77,7 @@ LL | struct S(Enum, ()); = note: the matched value is of type `S` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | -LL ~ S(A, _) => {} +LL ~ S(A, _) => {}, LL + _ => todo!() | @@ -95,7 +95,7 @@ LL | struct Sd { x: Enum, y: () } = note: the matched value is of type `Sd` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | -LL ~ Sd { x: A, y: _ } => {} +LL ~ Sd { x: A, y: _ } => {}, LL + _ => todo!() | diff --git a/tests/ui/pattern/usefulness/issue-3601.stderr b/tests/ui/pattern/usefulness/issue-3601.stderr index 59d7bcd4b..2f6b167d4 100644 --- a/tests/ui/pattern/usefulness/issue-3601.stderr +++ b/tests/ui/pattern/usefulness/issue-3601.stderr @@ -9,7 +9,7 @@ note: `Box<ElementKind>` defined here = note: the matched value is of type `Box<ElementKind>` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => { true } +LL ~ box ElementKind::HTMLImageElement(ref d) if d.image.is_some() => { true }, LL + box _ => todo!() | diff --git a/tests/ui/pattern/usefulness/issue-50900.stderr b/tests/ui/pattern/usefulness/issue-50900.stderr index 348246d28..7880c8925 100644 --- a/tests/ui/pattern/usefulness/issue-50900.stderr +++ b/tests/ui/pattern/usefulness/issue-50900.stderr @@ -12,7 +12,7 @@ LL | pub struct Tag(pub Context, pub u16); = note: the matched value is of type `Tag` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ Tag::ExifIFDPointer => {} +LL ~ Tag::ExifIFDPointer => {}, LL + Tag(Context::Exif, _) => todo!() | diff --git a/tests/ui/pattern/usefulness/issue-56379.stderr b/tests/ui/pattern/usefulness/issue-56379.stderr index 6eed6bfae..b3e40b992 100644 --- a/tests/ui/pattern/usefulness/issue-56379.stderr +++ b/tests/ui/pattern/usefulness/issue-56379.stderr @@ -18,7 +18,7 @@ LL | C(bool), = note: the matched value is of type `Foo` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ Foo::C(true) => {} +LL ~ Foo::C(true) => {}, LL + Foo::A(false) | Foo::B(false) | Foo::C(false) => todo!() | diff --git a/tests/ui/pattern/usefulness/match-byte-array-patterns-2.stderr b/tests/ui/pattern/usefulness/match-byte-array-patterns-2.stderr index a90f32f7a..3c482eef2 100644 --- a/tests/ui/pattern/usefulness/match-byte-array-patterns-2.stderr +++ b/tests/ui/pattern/usefulness/match-byte-array-patterns-2.stderr @@ -7,7 +7,7 @@ LL | match buf { = note: the matched value is of type `&[u8; 4]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ b"AAAA" => {} +LL ~ b"AAAA" => {}, LL + &[0_u8..=64_u8, _, _, _] | &[66_u8..=u8::MAX, _, _, _] => todo!() | @@ -20,7 +20,7 @@ LL | match buf { = note: the matched value is of type `&[u8]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern as shown, or multiple match arms | -LL ~ b"AAAA" => {} +LL ~ b"AAAA" => {}, LL + _ => todo!() | diff --git a/tests/ui/pattern/usefulness/match-privately-empty.stderr b/tests/ui/pattern/usefulness/match-privately-empty.stderr index 86f75d15c..45352f094 100644 --- a/tests/ui/pattern/usefulness/match-privately-empty.stderr +++ b/tests/ui/pattern/usefulness/match-privately-empty.stderr @@ -12,7 +12,7 @@ note: `Option<Private>` defined here = note: the matched value is of type `Option<Private>` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ }) => {} +LL ~ }) => {}, LL + Some(Private { misc: true, .. }) => todo!() | diff --git a/tests/ui/pattern/usefulness/match-slice-patterns.stderr b/tests/ui/pattern/usefulness/match-slice-patterns.stderr index 961dd5901..63d1f38e9 100644 --- a/tests/ui/pattern/usefulness/match-slice-patterns.stderr +++ b/tests/ui/pattern/usefulness/match-slice-patterns.stderr @@ -7,7 +7,7 @@ LL | match list { = note: the matched value is of type `&[Option<()>]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ &[.., Some(_), _] => {} +LL ~ &[.., Some(_), _] => {}, LL ~ &[_, Some(_), .., None, _] => todo!(), | diff --git a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr index 769d4070f..8489e2f14 100644 --- a/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr +++ b/tests/ui/pattern/usefulness/non-exhaustive-defined-here.stderr @@ -18,7 +18,7 @@ LL | C = note: the matched value is of type `E` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ E::A => {} +LL ~ E::A => {}, LL + E::B | E::C => todo!() | @@ -44,8 +44,8 @@ LL | C = note: the matched value is of type `E` help: you might want to use `if let` to ignore the variants that aren't matched | -LL | if let E::A = e { todo!() } - | ++ ~~~~~~~~~~~ +LL | if let E::A = e { todo!() }; + | ++ +++++++++++ error[E0004]: non-exhaustive patterns: `&E::B` and `&E::C` not covered --> $DIR/non-exhaustive-defined-here.rs:50:11 @@ -67,7 +67,7 @@ LL | C = note: the matched value is of type `&E` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ E::A => {} +LL ~ E::A => {}, LL + &E::B | &E::C => todo!() | @@ -93,8 +93,8 @@ LL | C = note: the matched value is of type `&E` help: you might want to use `if let` to ignore the variants that aren't matched | -LL | if let E::A = e { todo!() } - | ++ ~~~~~~~~~~~ +LL | if let E::A = e { todo!() }; + | ++ +++++++++++ error[E0004]: non-exhaustive patterns: `&&mut &E::B` and `&&mut &E::C` not covered --> $DIR/non-exhaustive-defined-here.rs:66:11 @@ -116,7 +116,7 @@ LL | C = note: the matched value is of type `&&mut &E` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ E::A => {} +LL ~ E::A => {}, LL + &&mut &E::B | &&mut &E::C => todo!() | @@ -142,8 +142,8 @@ LL | C = note: the matched value is of type `&&mut &E` help: you might want to use `if let` to ignore the variants that aren't matched | -LL | if let E::A = e { todo!() } - | ++ ~~~~~~~~~~~ +LL | if let E::A = e { todo!() }; + | ++ +++++++++++ error[E0004]: non-exhaustive patterns: `Opt::None` not covered --> $DIR/non-exhaustive-defined-here.rs:92:11 @@ -162,7 +162,7 @@ LL | None, = note: the matched value is of type `Opt` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ Opt::Some(ref _x) => {} +LL ~ Opt::Some(ref _x) => {}, LL + Opt::None => todo!() | diff --git a/tests/ui/pattern/usefulness/non-exhaustive-match-nested.stderr b/tests/ui/pattern/usefulness/non-exhaustive-match-nested.stderr index 44f327421..98e417a17 100644 --- a/tests/ui/pattern/usefulness/non-exhaustive-match-nested.stderr +++ b/tests/ui/pattern/usefulness/non-exhaustive-match-nested.stderr @@ -25,7 +25,7 @@ LL | enum T { A(U), B } = note: the matched value is of type `T` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ T::B => { panic!("goodbye"); } +LL ~ T::B => { panic!("goodbye"); }, LL + T::A(U::C) => todo!() | diff --git a/tests/ui/pattern/usefulness/non-exhaustive-match.stderr b/tests/ui/pattern/usefulness/non-exhaustive-match.stderr index e2260f50b..e59e8885e 100644 --- a/tests/ui/pattern/usefulness/non-exhaustive-match.stderr +++ b/tests/ui/pattern/usefulness/non-exhaustive-match.stderr @@ -24,7 +24,7 @@ LL | match true { = note: the matched value is of type `bool` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ true => {} +LL ~ true => {}, LL + false => todo!() | @@ -42,7 +42,7 @@ note: `Option<i32>` defined here = note: the matched value is of type `Option<i32>` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ None => {} +LL ~ None => {}, LL + Some(_) => todo!() | @@ -55,7 +55,7 @@ LL | match (2, 3, 4) { = note: the matched value is of type `(i32, i32, i32)` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ (_, _, 4) => {} +LL ~ (_, _, 4) => {}, LL + (_, _, i32::MIN..=3_i32) | (_, _, 5_i32..=i32::MAX) => todo!() | @@ -68,7 +68,7 @@ LL | match (T::A, T::A) { = note: the matched value is of type `(T, T)` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ (T::B, T::A) => {} +LL ~ (T::B, T::A) => {}, LL + (T::A, T::A) | (T::B, T::B) => todo!() | @@ -86,7 +86,7 @@ LL | enum T { A, B } = note: the matched value is of type `T` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ T::A => {} +LL ~ T::A => {}, LL + T::B => todo!() | @@ -99,7 +99,7 @@ LL | match *vec { = note: the matched value is of type `[Option<isize>]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [None] => {} +LL ~ [None] => {}, LL + [] => todo!() | diff --git a/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr b/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr index c518de477..beb51a4d4 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr +++ b/tests/ui/pattern/usefulness/refutable-pattern-errors.stderr @@ -17,8 +17,8 @@ LL | let (1, (Some(1), 2..=3)) = (1, (None, 2)); = note: the matched value is of type `(i32, (Option<i32>, i32))` help: you might want to use `if let` to ignore the variants that aren't matched | -LL | if let (1, (Some(1), 2..=3)) = (1, (None, 2)) { todo!() } - | ++ ~~~~~~~~~~~ +LL | if let (1, (Some(1), 2..=3)) = (1, (None, 2)) { todo!() }; + | ++ +++++++++++ error: aborting due to 2 previous errors diff --git a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr index 55f0b2319..ab3f6f69f 100644 --- a/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr +++ b/tests/ui/pattern/usefulness/refutable-pattern-in-fn-arg.stderr @@ -5,6 +5,10 @@ LL | let f = |3: isize| println!("hello"); | ^ pattern `_` not covered | = note: the matched value is of type `isize` +help: alternatively, you could prepend the pattern with an underscore to define a new named variable; identifiers cannot begin with digits + | +LL | let f = |_3: isize| println!("hello"); + | + error: aborting due to previous error diff --git a/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr b/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr index 5d1e170ae..fb6ecda3c 100644 --- a/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr +++ b/tests/ui/pattern/usefulness/slice-patterns-exhaustiveness.stderr @@ -7,7 +7,7 @@ LL | match s2 { = note: the matched value is of type `&[bool; 2]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [true, .., true] => {} +LL ~ [true, .., true] => {}, LL + &[false, _] => todo!() | @@ -20,7 +20,7 @@ LL | match s3 { = note: the matched value is of type `&[bool; 3]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [true, .., true] => {} +LL ~ [true, .., true] => {}, LL + &[false, ..] => todo!() | @@ -33,7 +33,7 @@ LL | match s10 { = note: the matched value is of type `&[bool; 10]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [true, .., true] => {} +LL ~ [true, .., true] => {}, LL + &[false, ..] => todo!() | @@ -46,7 +46,7 @@ LL | match s2 { = note: the matched value is of type `&[bool; 2]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [.., false] => {} +LL ~ [.., false] => {}, LL + &[false, true] => todo!() | @@ -59,7 +59,7 @@ LL | match s3 { = note: the matched value is of type `&[bool; 3]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [.., false] => {} +LL ~ [.., false] => {}, LL + &[false, .., true] => todo!() | @@ -72,7 +72,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [.., false] => {} +LL ~ [.., false] => {}, LL + &[false, .., true] => todo!() | @@ -85,7 +85,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [] => {} +LL ~ [] => {}, LL + &[_, ..] => todo!() | @@ -98,7 +98,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [_] => {} +LL ~ [_] => {}, LL + &[_, _, ..] => todo!() | @@ -111,7 +111,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [true, ..] => {} +LL ~ [true, ..] => {}, LL + &[false, ..] => todo!() | @@ -124,7 +124,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [true, ..] => {} +LL ~ [true, ..] => {}, LL + &[false, _, ..] => todo!() | @@ -137,7 +137,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [.., true] => {} +LL ~ [.., true] => {}, LL + &[_, .., false] => todo!() | @@ -150,7 +150,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [.., false] => {} +LL ~ [.., false] => {}, LL + &[_, _, .., true] => todo!() | @@ -163,7 +163,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [false, .., false] => {} +LL ~ [false, .., false] => {}, LL + &[true, _, .., _] => todo!() | @@ -176,7 +176,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ &[true] => {} +LL ~ &[true] => {}, LL + &[] | &[_, _, ..] => todo!() | @@ -189,7 +189,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ CONST => {} +LL ~ CONST => {}, LL + &[] | &[_, _, ..] => todo!() | @@ -202,7 +202,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ &[false] => {} +LL ~ &[false] => {}, LL + &[] | &[_, _, ..] => todo!() | @@ -215,7 +215,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ CONST => {} +LL ~ CONST => {}, LL + &[] | &[_, _, ..] => todo!() | @@ -228,7 +228,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ CONST => {} +LL ~ CONST => {}, LL + &[_, _, ..] => todo!() | @@ -241,7 +241,7 @@ LL | match s { = note: the matched value is of type `&[bool]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ &[_, _, ..] => {} +LL ~ &[_, _, ..] => {}, LL + &[false] => todo!() | @@ -254,7 +254,7 @@ LL | match s1 { = note: the matched value is of type `&[bool; 1]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ CONST1 => {} +LL ~ CONST1 => {}, LL + &[false] => todo!() | diff --git a/tests/ui/pattern/usefulness/stable-gated-patterns.stderr b/tests/ui/pattern/usefulness/stable-gated-patterns.stderr index 7b8588a3c..f944c25a9 100644 --- a/tests/ui/pattern/usefulness/stable-gated-patterns.stderr +++ b/tests/ui/pattern/usefulness/stable-gated-patterns.stderr @@ -15,7 +15,7 @@ LL | Stable2, = note: the matched value is of type `UnstableEnum` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms | -LL ~ UnstableEnum::Stable => {} +LL ~ UnstableEnum::Stable => {}, LL + UnstableEnum::Stable2 | _ => todo!() | @@ -33,7 +33,7 @@ LL | pub enum UnstableEnum { = note: the matched value is of type `UnstableEnum` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ UnstableEnum::Stable2 => {} +LL ~ UnstableEnum::Stable2 => {}, LL + _ => todo!() | diff --git a/tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr b/tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr index 85c97be29..22425aa0d 100644 --- a/tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr +++ b/tests/ui/pattern/usefulness/struct-like-enum-nonexhaustive.stderr @@ -14,7 +14,7 @@ LL | B { x: Option<isize> }, = note: the matched value is of type `A` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ A::B { x: None } => {} +LL ~ A::B { x: None } => {}, LL + A::B { x: Some(_) } => todo!() | diff --git a/tests/ui/pattern/usefulness/unstable-gated-patterns.stderr b/tests/ui/pattern/usefulness/unstable-gated-patterns.stderr index 6dc9a4058..d776249b2 100644 --- a/tests/ui/pattern/usefulness/unstable-gated-patterns.stderr +++ b/tests/ui/pattern/usefulness/unstable-gated-patterns.stderr @@ -15,7 +15,7 @@ LL | Unstable, = note: the matched value is of type `UnstableEnum` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ UnstableEnum::Stable2 => {} +LL ~ UnstableEnum::Stable2 => {}, LL + UnstableEnum::Unstable => todo!() | diff --git a/tests/ui/auxiliary/xc-private-method-lib.rs b/tests/ui/privacy/auxiliary/xc-private-method-lib.rs index 4d5ec6de3..4d5ec6de3 100644 --- a/tests/ui/auxiliary/xc-private-method-lib.rs +++ b/tests/ui/privacy/auxiliary/xc-private-method-lib.rs diff --git a/tests/ui/privacy/effective_visibilities.rs b/tests/ui/privacy/effective_visibilities.rs index ff20e20d3..e9ac93160 100644 --- a/tests/ui/privacy/effective_visibilities.rs +++ b/tests/ui/privacy/effective_visibilities.rs @@ -1,3 +1,4 @@ +#![rustc_effective_visibility] //~ ERROR Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub #![feature(rustc_attrs)] #[rustc_effective_visibility] @@ -17,13 +18,13 @@ mod outer { //~ ERROR Direct: pub(crate), Reexported: pub(crate), Reachable: pub } #[rustc_effective_visibility] - struct PrivStruct; //~ ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) - //~| ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) + struct PrivStruct; //~ ERROR not in the table + //~| ERROR not in the table #[rustc_effective_visibility] pub union PubUnion { //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub #[rustc_effective_visibility] - a: u8, //~ ERROR Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) + a: u8, //~ ERROR not in the table #[rustc_effective_visibility] pub b: u8, //~ ERROR Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub } diff --git a/tests/ui/privacy/effective_visibilities.stderr b/tests/ui/privacy/effective_visibilities.stderr index 046b6095f..f74f812e1 100644 --- a/tests/ui/privacy/effective_visibilities.stderr +++ b/tests/ui/privacy/effective_visibilities.stderr @@ -1,140 +1,152 @@ +error: Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub + --> $DIR/effective_visibilities.rs:1:1 + | +LL | / #![rustc_effective_visibility] +LL | | #![feature(rustc_attrs)] +LL | | +LL | | #[rustc_effective_visibility] +... | +LL | | +LL | | fn main() {} + | |____________^ + error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) - --> $DIR/effective_visibilities.rs:4:1 + --> $DIR/effective_visibilities.rs:5:1 | LL | mod outer { | ^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:6:5 + --> $DIR/effective_visibilities.rs:7:5 | LL | pub mod inner1 { | ^^^^^^^^^^^^^^ error: not in the table - --> $DIR/effective_visibilities.rs:9:9 + --> $DIR/effective_visibilities.rs:10:9 | LL | extern "C" {} | ^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:12:9 + --> $DIR/effective_visibilities.rs:13:9 | LL | pub trait PubTrait { | ^^^^^^^^^^^^^^^^^^ -error: Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) - --> $DIR/effective_visibilities.rs:20:9 +error: not in the table + --> $DIR/effective_visibilities.rs:21:9 | LL | struct PrivStruct; | ^^^^^^^^^^^^^^^^^ -error: Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) - --> $DIR/effective_visibilities.rs:20:9 +error: not in the table + --> $DIR/effective_visibilities.rs:21:9 | LL | struct PrivStruct; | ^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:24:9 + --> $DIR/effective_visibilities.rs:25:9 | LL | pub union PubUnion { | ^^^^^^^^^^^^^^^^^^ -error: Direct: pub(self), Reexported: pub(self), Reachable: pub(self), ReachableThroughImplTrait: pub(self) - --> $DIR/effective_visibilities.rs:26:13 +error: not in the table + --> $DIR/effective_visibilities.rs:27:13 | LL | a: u8, | ^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:28:13 + --> $DIR/effective_visibilities.rs:29:13 | LL | pub b: u8, | ^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:32:9 + --> $DIR/effective_visibilities.rs:33:9 | LL | pub enum Enum { | ^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:34:13 + --> $DIR/effective_visibilities.rs:35:13 | LL | A( | ^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:34:13 + --> $DIR/effective_visibilities.rs:35:13 | LL | A( | ^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:37:17 + --> $DIR/effective_visibilities.rs:38:17 | LL | PubUnion, | ^^^^^^^^ error: not in the table - --> $DIR/effective_visibilities.rs:43:5 + --> $DIR/effective_visibilities.rs:44:5 | LL | macro_rules! none_macro { | ^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(self), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:49:5 + --> $DIR/effective_visibilities.rs:50:5 | LL | macro_rules! public_macro { | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:54:5 + --> $DIR/effective_visibilities.rs:55:5 | LL | pub struct ReachableStruct { | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:56:9 + --> $DIR/effective_visibilities.rs:57:9 | LL | pub a: u8, | ^^^^^^^^^ error: Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:61:9 + --> $DIR/effective_visibilities.rs:62:9 | LL | pub use outer::inner1; | ^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:67:5 + --> $DIR/effective_visibilities.rs:68:5 | LL | pub type HalfPublicImport = u8; | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub(crate), Reachable: pub(crate), ReachableThroughImplTrait: pub(crate) - --> $DIR/effective_visibilities.rs:70:5 + --> $DIR/effective_visibilities.rs:71:5 | LL | pub(crate) const HalfPublicImport: u8 = 0; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub, Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:74:9 + --> $DIR/effective_visibilities.rs:75:9 | LL | pub use half_public_import::HalfPublicImport; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:14:13 + --> $DIR/effective_visibilities.rs:15:13 | LL | const A: i32; | ^^^^^^^^^^^^ error: Direct: pub(crate), Reexported: pub, Reachable: pub, ReachableThroughImplTrait: pub - --> $DIR/effective_visibilities.rs:16:13 + --> $DIR/effective_visibilities.rs:17:13 | LL | type B; | ^^^^^^ -error: aborting due to 23 previous errors +error: aborting due to 24 previous errors diff --git a/tests/ui/privacy/issue-29161.rs b/tests/ui/privacy/issue-29161.rs index d80405aa8..5c926dee0 100644 --- a/tests/ui/privacy/issue-29161.rs +++ b/tests/ui/privacy/issue-29161.rs @@ -2,7 +2,7 @@ mod a { struct A; impl Default for A { - pub fn default() -> A { //~ ERROR unnecessary visibility qualifier + pub fn default() -> A { //~ ERROR visibility qualifiers are not permitted here A } } diff --git a/tests/ui/privacy/issue-29161.stderr b/tests/ui/privacy/issue-29161.stderr index 7ce95e4b0..1a6c80499 100644 --- a/tests/ui/privacy/issue-29161.stderr +++ b/tests/ui/privacy/issue-29161.stderr @@ -1,8 +1,10 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/issue-29161.rs:5:9 | LL | pub fn default() -> A { - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait error[E0603]: struct `A` is private --> $DIR/issue-29161.rs:13:8 diff --git a/tests/ui/privacy/priv-in-bad-locations.rs b/tests/ui/privacy/priv-in-bad-locations.rs index 76af8c6cd..32c5b801f 100644 --- a/tests/ui/privacy/priv-in-bad-locations.rs +++ b/tests/ui/privacy/priv-in-bad-locations.rs @@ -1,4 +1,4 @@ -pub extern "C" { //~ ERROR unnecessary visibility qualifier +pub extern "C" { //~ ERROR visibility qualifiers are not permitted here pub fn bar(); } @@ -8,10 +8,10 @@ trait A { struct B; -pub impl B {} //~ ERROR unnecessary visibility qualifier +pub impl B {} //~ ERROR visibility qualifiers are not permitted here -pub impl A for B { //~ ERROR unnecessary visibility qualifier - pub fn foo(&self) {} //~ ERROR unnecessary visibility qualifier +pub impl A for B { //~ ERROR visibility qualifiers are not permitted here + pub fn foo(&self) {} //~ ERROR visibility qualifiers are not permitted here } pub fn main() {} diff --git a/tests/ui/privacy/priv-in-bad-locations.stderr b/tests/ui/privacy/priv-in-bad-locations.stderr index 75bd2fe47..70dab5bfe 100644 --- a/tests/ui/privacy/priv-in-bad-locations.stderr +++ b/tests/ui/privacy/priv-in-bad-locations.stderr @@ -1,30 +1,34 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/priv-in-bad-locations.rs:1:1 | LL | pub extern "C" { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual foreign items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/priv-in-bad-locations.rs:11:1 | LL | pub impl B {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual impl items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/priv-in-bad-locations.rs:13:1 | LL | pub impl A for B { - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/priv-in-bad-locations.rs:14:5 | LL | pub fn foo(&self) {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait error: aborting due to 4 previous errors diff --git a/tests/ui/privacy/privacy-ns1.stderr b/tests/ui/privacy/privacy-ns1.stderr index 91bc84e70..9710cc486 100644 --- a/tests/ui/privacy/privacy-ns1.stderr +++ b/tests/ui/privacy/privacy-ns1.stderr @@ -13,7 +13,7 @@ LL | Baz(); | ~~~ help: consider importing this function instead | -LL | use foo2::Bar; +LL + use foo2::Bar; | error[E0425]: cannot find function, tuple struct or tuple variant `Bar` in this scope @@ -31,7 +31,7 @@ LL | Baz(); | ~~~ help: consider importing this function | -LL | use foo2::Bar; +LL + use foo2::Bar; | error[E0412]: cannot find type `Bar` in this scope @@ -49,7 +49,7 @@ LL | let _x: Box<Baz>; | ~~~ help: consider importing this trait | -LL | use foo1::Bar; +LL + use foo1::Bar; | error[E0747]: constant provided when a type was expected diff --git a/tests/ui/privacy/privacy-ns2.stderr b/tests/ui/privacy/privacy-ns2.stderr index 904e9013f..75e735e1e 100644 --- a/tests/ui/privacy/privacy-ns2.stderr +++ b/tests/ui/privacy/privacy-ns2.stderr @@ -6,7 +6,7 @@ LL | Bar(); | help: consider importing this function instead | -LL | use foo2::Bar; +LL + use foo2::Bar; | error[E0423]: expected function, tuple struct or tuple variant, found trait `Bar` @@ -24,7 +24,7 @@ LL | Baz(); | ~~~ help: consider importing this function instead | -LL | use foo2::Bar; +LL + use foo2::Bar; | error[E0573]: expected type, found function `Bar` @@ -39,7 +39,7 @@ LL | let _x = Bar(); | ~ help: consider importing this trait instead | -LL | use foo1::Bar; +LL + use foo1::Bar; | error[E0603]: trait `Bar` is private diff --git a/tests/ui/privacy/privacy-sanity.rs b/tests/ui/privacy/privacy-sanity.rs index 8bbf1ab5d..6622089dd 100644 --- a/tests/ui/privacy/privacy-sanity.rs +++ b/tests/ui/privacy/privacy-sanity.rs @@ -10,17 +10,17 @@ pub struct S { } struct Ts(pub u8); -pub impl Tr for S { //~ ERROR unnecessary visibility qualifier - pub fn f() {} //~ ERROR unnecessary visibility qualifier - pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier - pub type T = u8; //~ ERROR unnecessary visibility qualifier +pub impl Tr for S { //~ ERROR visibility qualifiers are not permitted here + pub fn f() {} //~ ERROR visibility qualifiers are not permitted here + pub const C: u8 = 0; //~ ERROR visibility qualifiers are not permitted here + pub type T = u8; //~ ERROR visibility qualifiers are not permitted here } -pub impl S { //~ ERROR unnecessary visibility qualifier +pub impl S { //~ ERROR visibility qualifiers are not permitted here pub fn f() {} pub const C: u8 = 0; // pub type T = u8; } -pub extern "C" { //~ ERROR unnecessary visibility qualifier +pub extern "C" { //~ ERROR visibility qualifiers are not permitted here pub fn f(); pub static St: u8; } @@ -36,17 +36,17 @@ const MAIN: u8 = { } struct Ts(pub u8); - pub impl Tr for S { //~ ERROR unnecessary visibility qualifier - pub fn f() {} //~ ERROR unnecessary visibility qualifier - pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier - pub type T = u8; //~ ERROR unnecessary visibility qualifier + pub impl Tr for S { //~ ERROR visibility qualifiers are not permitted here + pub fn f() {} //~ ERROR visibility qualifiers are not permitted here + pub const C: u8 = 0; //~ ERROR visibility qualifiers are not permitted here + pub type T = u8; //~ ERROR visibility qualifiers are not permitted here } - pub impl S { //~ ERROR unnecessary visibility qualifier + pub impl S { //~ ERROR visibility qualifiers are not permitted here pub fn f() {} pub const C: u8 = 0; // pub type T = u8; } - pub extern "C" { //~ ERROR unnecessary visibility qualifier + pub extern "C" { //~ ERROR visibility qualifiers are not permitted here pub fn f(); pub static St: u8; } @@ -65,17 +65,17 @@ fn main() { } struct Ts(pub u8); - pub impl Tr for S { //~ ERROR unnecessary visibility qualifier - pub fn f() {} //~ ERROR unnecessary visibility qualifier - pub const C: u8 = 0; //~ ERROR unnecessary visibility qualifier - pub type T = u8; //~ ERROR unnecessary visibility qualifier + pub impl Tr for S { //~ ERROR visibility qualifiers are not permitted here + pub fn f() {} //~ ERROR visibility qualifiers are not permitted here + pub const C: u8 = 0; //~ ERROR visibility qualifiers are not permitted here + pub type T = u8; //~ ERROR visibility qualifiers are not permitted here } - pub impl S { //~ ERROR unnecessary visibility qualifier + pub impl S { //~ ERROR visibility qualifiers are not permitted here pub fn f() {} pub const C: u8 = 0; // pub type T = u8; } - pub extern "C" { //~ ERROR unnecessary visibility qualifier + pub extern "C" { //~ ERROR visibility qualifiers are not permitted here pub fn f(); pub static St: u8; } diff --git a/tests/ui/privacy/privacy-sanity.stderr b/tests/ui/privacy/privacy-sanity.stderr index c92553fd1..a537f8c19 100644 --- a/tests/ui/privacy/privacy-sanity.stderr +++ b/tests/ui/privacy/privacy-sanity.stderr @@ -1,120 +1,144 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:13:1 | LL | pub impl Tr for S { - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:14:5 | LL | pub fn f() {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:15:5 | LL | pub const C: u8 = 0; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:16:5 | LL | pub type T = u8; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:18:1 | LL | pub impl S { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual impl items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:23:1 | LL | pub extern "C" { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual foreign items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:39:5 | LL | pub impl Tr for S { - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:40:9 | LL | pub fn f() {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:41:9 | LL | pub const C: u8 = 0; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:42:9 | LL | pub type T = u8; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:44:5 | LL | pub impl S { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual impl items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:49:5 | LL | pub extern "C" { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual foreign items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:68:5 | LL | pub impl Tr for S { - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:69:9 | LL | pub fn f() {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:70:9 | LL | pub const C: u8 = 0; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:71:9 | LL | pub type T = u8; - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:73:5 | LL | pub impl S { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual impl items instead -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/privacy-sanity.rs:78:5 | LL | pub extern "C" { - | ^^^ `pub` not permitted here because it's implied + | ^^^ | = note: place qualifiers on individual foreign items instead diff --git a/tests/ui/privacy/private-in-public-assoc-ty.rs b/tests/ui/privacy/private-in-public-assoc-ty.rs index fba72c131..d4d379bdb 100644 --- a/tests/ui/privacy/private-in-public-assoc-ty.rs +++ b/tests/ui/privacy/private-in-public-assoc-ty.rs @@ -2,7 +2,7 @@ // This test also ensures that the checks are performed even inside private modules. #![feature(associated_type_defaults)] -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] mod m { struct Priv; diff --git a/tests/ui/privacy/private-in-public-type-alias-impl-trait.rs b/tests/ui/privacy/private-in-public-type-alias-impl-trait.rs index c7df31529..fe6ed4673 100644 --- a/tests/ui/privacy/private-in-public-type-alias-impl-trait.rs +++ b/tests/ui/privacy/private-in-public-type-alias-impl-trait.rs @@ -1,5 +1,5 @@ // build-pass (FIXME(62277): could be check-pass?) - +#![feature(impl_trait_in_assoc_type)] #![feature(type_alias_impl_trait)] #![deny(private_in_public)] diff --git a/tests/ui/privacy/useless-pub.rs b/tests/ui/privacy/useless-pub.rs index fde7cd5d8..e4b671142 100644 --- a/tests/ui/privacy/useless-pub.rs +++ b/tests/ui/privacy/useless-pub.rs @@ -5,12 +5,12 @@ pub trait E { } impl E for A { - pub fn foo(&self) {} //~ ERROR: unnecessary visibility qualifier + pub fn foo(&self) {} //~ ERROR: visibility qualifiers are not permitted here } enum Foo { - V1 { pub f: i32 }, //~ ERROR unnecessary visibility qualifier - V2(pub i32), //~ ERROR unnecessary visibility qualifier + V1 { pub f: i32 }, //~ ERROR visibility qualifiers are not permitted here + V2(pub i32), //~ ERROR visibility qualifiers are not permitted here } fn main() {} diff --git a/tests/ui/privacy/useless-pub.stderr b/tests/ui/privacy/useless-pub.stderr index 14c4983ae..73497e3fe 100644 --- a/tests/ui/privacy/useless-pub.stderr +++ b/tests/ui/privacy/useless-pub.stderr @@ -1,20 +1,26 @@ -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/useless-pub.rs:8:5 | LL | pub fn foo(&self) {} - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: trait items always share the visibility of their trait -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/useless-pub.rs:12:10 | LL | V1 { pub f: i32 }, - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: enum variants and their fields always share the visibility of the enum they are in -error[E0449]: unnecessary visibility qualifier +error[E0449]: visibility qualifiers are not permitted here --> $DIR/useless-pub.rs:13:8 | LL | V2(pub i32), - | ^^^ `pub` not permitted here because it's implied + | ^^^ + | + = note: enum variants and their fields always share the visibility of the enum they are in error: aborting due to 3 previous errors diff --git a/tests/ui/xc-private-method.rs b/tests/ui/privacy/xc-private-method.rs index f05994646..f05994646 100644 --- a/tests/ui/xc-private-method.rs +++ b/tests/ui/privacy/xc-private-method.rs diff --git a/tests/ui/xc-private-method.stderr b/tests/ui/privacy/xc-private-method.stderr index 0eabc592a..0eabc592a 100644 --- a/tests/ui/xc-private-method.stderr +++ b/tests/ui/privacy/xc-private-method.stderr diff --git a/tests/ui/xc-private-method2.rs b/tests/ui/privacy/xc-private-method2.rs index f11b25108..f11b25108 100644 --- a/tests/ui/xc-private-method2.rs +++ b/tests/ui/privacy/xc-private-method2.rs diff --git a/tests/ui/xc-private-method2.stderr b/tests/ui/privacy/xc-private-method2.stderr index af0c3cfcb..af0c3cfcb 100644 --- a/tests/ui/xc-private-method2.stderr +++ b/tests/ui/privacy/xc-private-method2.stderr diff --git a/tests/ui/proc-macro/amputate-span.stderr b/tests/ui/proc-macro/amputate-span.stderr index ab4670411..aa797339b 100644 --- a/tests/ui/proc-macro/amputate-span.stderr +++ b/tests/ui/proc-macro/amputate-span.stderr @@ -6,7 +6,7 @@ LL | Command::new("git"); | help: consider importing this struct | -LL | use std::process::Command; +LL + use std::process::Command; | error[E0433]: failed to resolve: use of undeclared type `Command` @@ -17,7 +17,7 @@ LL | Command::new("git"); | help: consider importing this struct | -LL | use std::process::Command; +LL + use std::process::Command; | error: aborting due to 2 previous errors diff --git a/tests/ui/proc-macro/attributes-on-modules-fail.stderr b/tests/ui/proc-macro/attributes-on-modules-fail.stderr index bb6cbb698..97521f23a 100644 --- a/tests/ui/proc-macro/attributes-on-modules-fail.stderr +++ b/tests/ui/proc-macro/attributes-on-modules-fail.stderr @@ -50,7 +50,7 @@ LL | type A = Y; | help: consider importing this struct | -LL | use Y; +LL + use Y; | error[E0412]: cannot find type `X` in this scope @@ -61,7 +61,7 @@ LL | type A = X; | help: consider importing this struct | -LL | use m::X; +LL + use m::X; | error: aborting due to 7 previous errors diff --git a/tests/ui/proc-macro/bad-projection.rs b/tests/ui/proc-macro/bad-projection.rs new file mode 100644 index 000000000..d214c7ac8 --- /dev/null +++ b/tests/ui/proc-macro/bad-projection.rs @@ -0,0 +1,15 @@ +// force-host +// no-prefer-dynamic + +#![crate_type = "proc-macro"] +#![allow(warnings)] + +extern crate proc_macro; + +trait Project { + type Assoc; +} + +#[proc_macro] +pub fn uwu() -> <() as Project>::Assoc {} +//~^ ERROR the trait bound `(): Project` is not satisfied diff --git a/tests/ui/proc-macro/bad-projection.stderr b/tests/ui/proc-macro/bad-projection.stderr new file mode 100644 index 000000000..8a8246376 --- /dev/null +++ b/tests/ui/proc-macro/bad-projection.stderr @@ -0,0 +1,9 @@ +error[E0277]: the trait bound `(): Project` is not satisfied + --> $DIR/bad-projection.rs:14:17 + | +LL | pub fn uwu() -> <() as Project>::Assoc {} + | ^^^^^^^^^^^^^^^^^^^^^^ the trait `Project` is not implemented for `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/proc-macro/derive-bad.rs b/tests/ui/proc-macro/derive-bad.rs index cb5188b5f..92d35f537 100644 --- a/tests/ui/proc-macro/derive-bad.rs +++ b/tests/ui/proc-macro/derive-bad.rs @@ -4,7 +4,7 @@ extern crate derive_bad; #[derive(A)] -//~^ ERROR proc-macro derive produced unparseable tokens +//~^ ERROR proc-macro derive produced unparsable tokens //~| ERROR expected `:`, found `}` struct A; //~ ERROR the name `A` is defined multiple times diff --git a/tests/ui/proc-macro/derive-bad.stderr b/tests/ui/proc-macro/derive-bad.stderr index 241f99b28..43e97f40b 100644 --- a/tests/ui/proc-macro/derive-bad.stderr +++ b/tests/ui/proc-macro/derive-bad.stderr @@ -9,7 +9,7 @@ LL | #[derive(A)] | = note: this error originates in the derive macro `A` (in Nightly builds, run with -Z macro-backtrace for more info) -error: proc-macro derive produced unparseable tokens +error: proc-macro derive produced unparsable tokens --> $DIR/derive-bad.rs:6:10 | LL | #[derive(A)] diff --git a/tests/ui/proc-macro/issue-91800.rs b/tests/ui/proc-macro/issue-91800.rs index 0c1281de4..f48c8bf72 100644 --- a/tests/ui/proc-macro/issue-91800.rs +++ b/tests/ui/proc-macro/issue-91800.rs @@ -5,7 +5,7 @@ extern crate issue_91800_macro; #[derive(MyTrait)] //~^ ERROR macros that expand to items must be delimited with braces or followed by a semicolon -//~| ERROR proc-macro derive produced unparseable tokens +//~| ERROR proc-macro derive produced unparsable tokens #[attribute_macro] //~^ ERROR macros that expand to items must be delimited with braces or followed by a semicolon struct MyStruct; diff --git a/tests/ui/proc-macro/issue-91800.stderr b/tests/ui/proc-macro/issue-91800.stderr index 9c356263a..d831d62e9 100644 --- a/tests/ui/proc-macro/issue-91800.stderr +++ b/tests/ui/proc-macro/issue-91800.stderr @@ -6,7 +6,7 @@ LL | #[derive(MyTrait)] | = note: this error originates in the derive macro `MyTrait` (in Nightly builds, run with -Z macro-backtrace for more info) -error: proc-macro derive produced unparseable tokens +error: proc-macro derive produced unparsable tokens --> $DIR/issue-91800.rs:6:10 | LL | #[derive(MyTrait)] diff --git a/tests/ui/proc-macro/macro-namespace-reserved-2.stderr b/tests/ui/proc-macro/macro-namespace-reserved-2.stderr index 633a6c6a0..b9effe7cf 100644 --- a/tests/ui/proc-macro/macro-namespace-reserved-2.stderr +++ b/tests/ui/proc-macro/macro-namespace-reserved-2.stderr @@ -57,6 +57,14 @@ error: expected derive macro, found attribute macro `my_macro_attr` | LL | #[derive(my_macro_attr)] | ^^^^^^^^^^^^^ not a derive macro + | +help: remove from the surrounding `derive()` + --> $DIR/macro-namespace-reserved-2.rs:53:10 + | +LL | #[derive(my_macro_attr)] + | ^^^^^^^^^^^^^ + = help: add as non-Derive macro + `#[my_macro_attr]` error: can't use a procedural macro from the same crate that defines it --> $DIR/macro-namespace-reserved-2.rs:56:10 @@ -87,6 +95,14 @@ error: expected derive macro, found macro `crate::my_macro` | LL | #[derive(crate::my_macro)] | ^^^^^^^^^^^^^^^ not a derive macro + | +help: remove from the surrounding `derive()` + --> $DIR/macro-namespace-reserved-2.rs:50:10 + | +LL | #[derive(crate::my_macro)] + | ^^^^^^^^^^^^^^^ + = help: add as non-Derive macro + `#[crate::my_macro]` error: cannot find macro `my_macro_attr` in this scope --> $DIR/macro-namespace-reserved-2.rs:28:5 diff --git a/tests/ui/proc-macro/proc-macro-abi.rs b/tests/ui/proc-macro/proc-macro-abi.rs index 873660a5b..93a613e8b 100644 --- a/tests/ui/proc-macro/proc-macro-abi.rs +++ b/tests/ui/proc-macro/proc-macro-abi.rs @@ -9,19 +9,19 @@ use proc_macro::TokenStream; #[proc_macro] pub extern "C" fn abi(a: TokenStream) -> TokenStream { - //~^ ERROR proc macro functions may not be `extern "C"` + //~^ ERROR function-like proc macro has incorrect signature a } #[proc_macro] pub extern "system" fn abi2(a: TokenStream) -> TokenStream { - //~^ ERROR proc macro functions may not be `extern "system"` + //~^ ERROR function-like proc macro has incorrect signature a } #[proc_macro] pub extern fn abi3(a: TokenStream) -> TokenStream { - //~^ ERROR proc macro functions may not be `extern "C"` + //~^ ERROR function-like proc macro has incorrect signature a } diff --git a/tests/ui/proc-macro/proc-macro-abi.stderr b/tests/ui/proc-macro/proc-macro-abi.stderr index 9a781be09..ccc72e518 100644 --- a/tests/ui/proc-macro/proc-macro-abi.stderr +++ b/tests/ui/proc-macro/proc-macro-abi.stderr @@ -1,20 +1,29 @@ -error: proc macro functions may not be `extern "C"` +error: function-like proc macro has incorrect signature --> $DIR/proc-macro-abi.rs:11:1 | LL | pub extern "C" fn abi(a: TokenStream) -> TokenStream { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "Rust" fn, found "C" fn + | + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `extern "C" fn(proc_macro::TokenStream) -> proc_macro::TokenStream` -error: proc macro functions may not be `extern "system"` +error: function-like proc macro has incorrect signature --> $DIR/proc-macro-abi.rs:17:1 | LL | pub extern "system" fn abi2(a: TokenStream) -> TokenStream { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "Rust" fn, found "system" fn + | + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `extern "system" fn(proc_macro::TokenStream) -> proc_macro::TokenStream` -error: proc macro functions may not be `extern "C"` +error: function-like proc macro has incorrect signature --> $DIR/proc-macro-abi.rs:23:1 | LL | pub extern fn abi3(a: TokenStream) -> TokenStream { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected "Rust" fn, found "C" fn + | + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `extern "C" fn(proc_macro::TokenStream) -> proc_macro::TokenStream` error: aborting due to 3 previous errors diff --git a/tests/ui/proc-macro/signature-proc-macro-attribute.rs b/tests/ui/proc-macro/signature-proc-macro-attribute.rs index 51abc8e7d..fb48f748c 100644 --- a/tests/ui/proc-macro/signature-proc-macro-attribute.rs +++ b/tests/ui/proc-macro/signature-proc-macro-attribute.rs @@ -8,25 +8,23 @@ use proc_macro::TokenStream; #[proc_macro_attribute] pub fn bad_input(input: String) -> TokenStream { - //~^ ERROR mismatched attribute proc macro signature + //~^ ERROR attribute proc macro has incorrect signature ::proc_macro::TokenStream::new() } #[proc_macro_attribute] pub fn bad_output(input: TokenStream) -> String { - //~^ ERROR mismatched attribute proc macro signature - //~| ERROR mismatched attribute proc macro signature + //~^ ERROR attribute proc macro has incorrect signature String::from("blah") } #[proc_macro_attribute] pub fn bad_everything(input: String) -> String { - //~^ ERROR mismatched attribute proc macro signature - //~| ERROR mismatched attribute proc macro signature + //~^ ERROR attribute proc macro has incorrect signature input } #[proc_macro_attribute] pub fn too_many(a: TokenStream, b: TokenStream, c: String) -> TokenStream { - //~^ ERROR mismatched attribute proc macro signature + //~^ ERROR attribute proc macro has incorrect signature } diff --git a/tests/ui/proc-macro/signature-proc-macro-attribute.stderr b/tests/ui/proc-macro/signature-proc-macro-attribute.stderr index abf7a6f3c..ce832eaa5 100644 --- a/tests/ui/proc-macro/signature-proc-macro-attribute.stderr +++ b/tests/ui/proc-macro/signature-proc-macro-attribute.stderr @@ -1,42 +1,38 @@ -error: mismatched attribute proc macro signature +error: attribute proc macro has incorrect signature --> $DIR/signature-proc-macro-attribute.rs:10:1 | LL | pub fn bad_input(input: String) -> TokenStream { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attribute proc macro must have two arguments of type `proc_macro::TokenStream` - -error: mismatched attribute proc macro signature - --> $DIR/signature-proc-macro-attribute.rs:16:42 - | -LL | pub fn bad_output(input: TokenStream) -> String { - | ^^^^^^ found std::string::String, expected type `proc_macro::TokenStream` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters | - = note: attribute proc macros must have a signature of `fn(TokenStream, TokenStream) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(std::string::String) -> proc_macro::TokenStream` -error: mismatched attribute proc macro signature +error: attribute proc macro has incorrect signature --> $DIR/signature-proc-macro-attribute.rs:16:1 | LL | pub fn bad_output(input: TokenStream) -> String { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attribute proc macro must have two arguments of type `proc_macro::TokenStream` - -error: mismatched attribute proc macro signature - --> $DIR/signature-proc-macro-attribute.rs:23:41 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters | -LL | pub fn bad_everything(input: String) -> String { - | ^^^^^^ found std::string::String, expected type `proc_macro::TokenStream` - | - = note: attribute proc macros must have a signature of `fn(TokenStream, TokenStream) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(proc_macro::TokenStream) -> std::string::String` -error: mismatched attribute proc macro signature - --> $DIR/signature-proc-macro-attribute.rs:23:1 +error: attribute proc macro has incorrect signature + --> $DIR/signature-proc-macro-attribute.rs:22:1 | LL | pub fn bad_everything(input: String) -> String { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ attribute proc macro must have two arguments of type `proc_macro::TokenStream` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ incorrect number of function parameters + | + = note: expected signature `fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(std::string::String) -> std::string::String` -error: mismatched attribute proc macro signature - --> $DIR/signature-proc-macro-attribute.rs:30:49 +error: attribute proc macro has incorrect signature + --> $DIR/signature-proc-macro-attribute.rs:28:52 | LL | pub fn too_many(a: TokenStream, b: TokenStream, c: String) -> TokenStream { - | ^^^^^^^^^ found unexpected argument + | ^^^^^^ incorrect number of function parameters + | + = note: expected signature `fn(proc_macro::TokenStream, proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(proc_macro::TokenStream, proc_macro::TokenStream, std::string::String) -> proc_macro::TokenStream` -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/proc-macro/signature-proc-macro-derive.rs b/tests/ui/proc-macro/signature-proc-macro-derive.rs index f2fd824b6..d294b1591 100644 --- a/tests/ui/proc-macro/signature-proc-macro-derive.rs +++ b/tests/ui/proc-macro/signature-proc-macro-derive.rs @@ -8,24 +8,23 @@ use proc_macro::TokenStream; #[proc_macro_derive(Blah)] pub fn bad_input(input: String) -> TokenStream { - //~^ ERROR mismatched derive proc macro signature + //~^ ERROR derive proc macro has incorrect signature TokenStream::new() } #[proc_macro_derive(Bleh)] pub fn bad_output(input: TokenStream) -> String { - //~^ ERROR mismatched derive proc macro signature + //~^ ERROR derive proc macro has incorrect signature String::from("blah") } #[proc_macro_derive(Bluh)] pub fn bad_everything(input: String) -> String { - //~^ ERROR mismatched derive proc macro signature - //~| ERROR mismatched derive proc macro signature + //~^ ERROR derive proc macro has incorrect signature input } #[proc_macro_derive(Blih)] pub fn too_many(a: TokenStream, b: TokenStream, c: String) -> TokenStream { - //~^ ERROR mismatched derive proc macro signature + //~^ ERROR derive proc macro has incorrect signature } diff --git a/tests/ui/proc-macro/signature-proc-macro-derive.stderr b/tests/ui/proc-macro/signature-proc-macro-derive.stderr index a358ae277..03c6abad1 100644 --- a/tests/ui/proc-macro/signature-proc-macro-derive.stderr +++ b/tests/ui/proc-macro/signature-proc-macro-derive.stderr @@ -1,40 +1,38 @@ -error: mismatched derive proc macro signature +error: derive proc macro has incorrect signature --> $DIR/signature-proc-macro-derive.rs:10:25 | LL | pub fn bad_input(input: String) -> TokenStream { - | ^^^^^^ found std::string::String, expected type `proc_macro::TokenStream` + | ^^^^^^ expected `proc_macro::TokenStream`, found `std::string::String` | - = note: derive proc macros must have a signature of `fn(TokenStream) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(std::string::String) -> proc_macro::TokenStream` -error: mismatched derive proc macro signature +error: derive proc macro has incorrect signature --> $DIR/signature-proc-macro-derive.rs:16:42 | LL | pub fn bad_output(input: TokenStream) -> String { - | ^^^^^^ found std::string::String, expected type `proc_macro::TokenStream` + | ^^^^^^ expected `proc_macro::TokenStream`, found `std::string::String` | - = note: derive proc macros must have a signature of `fn(TokenStream) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(proc_macro::TokenStream) -> std::string::String` -error: mismatched derive proc macro signature - --> $DIR/signature-proc-macro-derive.rs:22:41 - | -LL | pub fn bad_everything(input: String) -> String { - | ^^^^^^ found std::string::String, expected type `proc_macro::TokenStream` - | - = note: derive proc macros must have a signature of `fn(TokenStream) -> TokenStream` - -error: mismatched derive proc macro signature +error: derive proc macro has incorrect signature --> $DIR/signature-proc-macro-derive.rs:22:30 | LL | pub fn bad_everything(input: String) -> String { - | ^^^^^^ found std::string::String, expected type `proc_macro::TokenStream` + | ^^^^^^ expected `proc_macro::TokenStream`, found `std::string::String` | - = note: derive proc macros must have a signature of `fn(TokenStream) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(std::string::String) -> std::string::String` -error: mismatched derive proc macro signature - --> $DIR/signature-proc-macro-derive.rs:29:33 +error: derive proc macro has incorrect signature + --> $DIR/signature-proc-macro-derive.rs:28:36 | LL | pub fn too_many(a: TokenStream, b: TokenStream, c: String) -> TokenStream { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ found unexpected arguments + | ^^^^^^^^^^^ incorrect number of function parameters + | + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(proc_macro::TokenStream, proc_macro::TokenStream, std::string::String) -> proc_macro::TokenStream` -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/proc-macro/signature-proc-macro.rs b/tests/ui/proc-macro/signature-proc-macro.rs index 54770aacd..ca2509ed8 100644 --- a/tests/ui/proc-macro/signature-proc-macro.rs +++ b/tests/ui/proc-macro/signature-proc-macro.rs @@ -8,24 +8,23 @@ use proc_macro::TokenStream; #[proc_macro] pub fn bad_input(input: String) -> TokenStream { - //~^ ERROR mismatched function-like proc macro signature + //~^ ERROR function-like proc macro has incorrect signature ::proc_macro::TokenStream::new() } #[proc_macro] pub fn bad_output(input: TokenStream) -> String { - //~^ ERROR mismatched function-like proc macro signature + //~^ ERROR function-like proc macro has incorrect signature String::from("blah") } #[proc_macro] pub fn bad_everything(input: String) -> String { - //~^ ERROR mismatched function-like proc macro signature - //~| ERROR mismatched function-like proc macro signature + //~^ ERROR function-like proc macro has incorrect signature input } #[proc_macro] pub fn too_many(a: TokenStream, b: TokenStream, c: String) -> TokenStream { - //~^ ERROR mismatched function-like proc macro signature + //~^ ERROR function-like proc macro has incorrect signature } diff --git a/tests/ui/proc-macro/signature-proc-macro.stderr b/tests/ui/proc-macro/signature-proc-macro.stderr index 4b14a54e6..dd2cb0570 100644 --- a/tests/ui/proc-macro/signature-proc-macro.stderr +++ b/tests/ui/proc-macro/signature-proc-macro.stderr @@ -1,40 +1,38 @@ -error: mismatched function-like proc macro signature +error: function-like proc macro has incorrect signature --> $DIR/signature-proc-macro.rs:10:25 | LL | pub fn bad_input(input: String) -> TokenStream { - | ^^^^^^ found std::string::String, expected type `proc_macro::TokenStream` + | ^^^^^^ expected `proc_macro::TokenStream`, found `std::string::String` | - = note: function-like proc macros must have a signature of `fn(TokenStream) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(std::string::String) -> proc_macro::TokenStream` -error: mismatched function-like proc macro signature +error: function-like proc macro has incorrect signature --> $DIR/signature-proc-macro.rs:16:42 | LL | pub fn bad_output(input: TokenStream) -> String { - | ^^^^^^ found std::string::String, expected type `proc_macro::TokenStream` + | ^^^^^^ expected `proc_macro::TokenStream`, found `std::string::String` | - = note: function-like proc macros must have a signature of `fn(TokenStream) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(proc_macro::TokenStream) -> std::string::String` -error: mismatched function-like proc macro signature - --> $DIR/signature-proc-macro.rs:22:41 - | -LL | pub fn bad_everything(input: String) -> String { - | ^^^^^^ found std::string::String, expected type `proc_macro::TokenStream` - | - = note: function-like proc macros must have a signature of `fn(TokenStream) -> TokenStream` - -error: mismatched function-like proc macro signature +error: function-like proc macro has incorrect signature --> $DIR/signature-proc-macro.rs:22:30 | LL | pub fn bad_everything(input: String) -> String { - | ^^^^^^ found std::string::String, expected type `proc_macro::TokenStream` + | ^^^^^^ expected `proc_macro::TokenStream`, found `std::string::String` | - = note: function-like proc macros must have a signature of `fn(TokenStream) -> TokenStream` + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(std::string::String) -> std::string::String` -error: mismatched function-like proc macro signature - --> $DIR/signature-proc-macro.rs:29:33 +error: function-like proc macro has incorrect signature + --> $DIR/signature-proc-macro.rs:28:36 | LL | pub fn too_many(a: TokenStream, b: TokenStream, c: String) -> TokenStream { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ found unexpected arguments + | ^^^^^^^^^^^ incorrect number of function parameters + | + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `fn(proc_macro::TokenStream, proc_macro::TokenStream, std::string::String) -> proc_macro::TokenStream` -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors diff --git a/tests/ui/proc-macro/signature.rs b/tests/ui/proc-macro/signature.rs index 11187aa31..7b4982a61 100644 --- a/tests/ui/proc-macro/signature.rs +++ b/tests/ui/proc-macro/signature.rs @@ -8,10 +8,6 @@ extern crate proc_macro; #[proc_macro_derive(A)] pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 { - //~^ ERROR: mismatched derive proc macro signature - //~| mismatched derive proc macro signature - //~| mismatched derive proc macro signature - //~| proc macro functions may not be `extern - //~| proc macro functions may not be `unsafe + //~^ ERROR: derive proc macro has incorrect signature loop {} } diff --git a/tests/ui/proc-macro/signature.stderr b/tests/ui/proc-macro/signature.stderr index 3dbe3f22a..ba5c8c157 100644 --- a/tests/ui/proc-macro/signature.stderr +++ b/tests/ui/proc-macro/signature.stderr @@ -1,36 +1,11 @@ -error: proc macro functions may not be `extern "C"` +error: derive proc macro has incorrect signature --> $DIR/signature.rs:10:1 | LL | pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: proc macro functions may not be `unsafe` - --> $DIR/signature.rs:10:1 - | -LL | pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: mismatched derive proc macro signature - --> $DIR/signature.rs:10:49 - | -LL | pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 { - | ^^^ found u32, expected type `proc_macro::TokenStream` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected normal fn, found unsafe fn | - = note: derive proc macros must have a signature of `fn(TokenStream) -> TokenStream` - -error: mismatched derive proc macro signature - --> $DIR/signature.rs:10:33 - | -LL | pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 { - | ^^^ found i32, expected type `proc_macro::TokenStream` - | - = note: derive proc macros must have a signature of `fn(TokenStream) -> TokenStream` - -error: mismatched derive proc macro signature - --> $DIR/signature.rs:10:38 - | -LL | pub unsafe extern "C" fn foo(a: i32, b: u32) -> u32 { - | ^^^^^^ found unexpected argument + = note: expected signature `fn(proc_macro::TokenStream) -> proc_macro::TokenStream` + found signature `unsafe extern "C" fn(i32, u32) -> u32` -error: aborting due to 5 previous errors +error: aborting due to previous error diff --git a/tests/ui/proc-macro/span-api-tests.rs b/tests/ui/proc-macro/span-api-tests.rs index 3f04ba866..7493f9cdb 100644 --- a/tests/ui/proc-macro/span-api-tests.rs +++ b/tests/ui/proc-macro/span-api-tests.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty // aux-build:span-api-tests.rs // aux-build:span-test-macros.rs // compile-flags: -Ztranslate-remapped-path-to-local-path=yes diff --git a/tests/ui/process/signal-exit-status.rs b/tests/ui/process/signal-exit-status.rs index 9519ed7b4..0f05f916c 100644 --- a/tests/ui/process/signal-exit-status.rs +++ b/tests/ui/process/signal-exit-status.rs @@ -4,14 +4,16 @@ // ignore-windows // ignore-fuchsia code returned as ZX_TASK_RETCODE_EXCEPTION_KILL, FIXME (#58590) +#![feature(core_intrinsics)] + use std::env; use std::process::Command; pub fn main() { let args: Vec<String> = env::args().collect(); if args.len() >= 2 && args[1] == "signal" { - // Raise a segfault. - unsafe { *(1 as *mut isize) = 0; } + // Raise an aborting signal without UB + core::intrinsics::abort(); } else { let status = Command::new(&args[0]).arg("signal").status().unwrap(); assert!(status.code().is_none()); diff --git a/tests/ui/range/range-pattern-out-of-bounds-issue-68972.rs b/tests/ui/range/range-pattern-out-of-bounds-issue-68972.rs index d02caff1f..206f05d0d 100644 --- a/tests/ui/range/range-pattern-out-of-bounds-issue-68972.rs +++ b/tests/ui/range/range-pattern-out-of-bounds-issue-68972.rs @@ -4,10 +4,8 @@ fn main() { match 0u8 { 251..257 => {} //~^ ERROR literal out of range - //~| ERROR literal out of range 251..=256 => {} //~^ ERROR literal out of range - //~| ERROR literal out of range _ => {} } } diff --git a/tests/ui/range/range-pattern-out-of-bounds-issue-68972.stderr b/tests/ui/range/range-pattern-out-of-bounds-issue-68972.stderr index 7b8309b9b..4f3f9d1eb 100644 --- a/tests/ui/range/range-pattern-out-of-bounds-issue-68972.stderr +++ b/tests/ui/range/range-pattern-out-of-bounds-issue-68972.stderr @@ -5,22 +5,10 @@ LL | 251..257 => {} | ^^^ this value doesn't fit in `u8` whose maximum value is `255` error: literal out of range for `u8` - --> $DIR/range-pattern-out-of-bounds-issue-68972.rs:8:15 + --> $DIR/range-pattern-out-of-bounds-issue-68972.rs:7:15 | LL | 251..=256 => {} | ^^^ this value doesn't fit in `u8` whose maximum value is `255` -error: literal out of range for `u8` - --> $DIR/range-pattern-out-of-bounds-issue-68972.rs:5:14 - | -LL | 251..257 => {} - | ^^^ this value doesn't fit in `u8` whose maximum value is `255` - -error: literal out of range for `u8` - --> $DIR/range-pattern-out-of-bounds-issue-68972.rs:8:15 - | -LL | 251..=256 => {} - | ^^^ this value doesn't fit in `u8` whose maximum value is `255` - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors diff --git a/tests/ui/range/range_traits-2.stderr b/tests/ui/range/range_traits-2.stderr index 61facba53..0829fc2ce 100644 --- a/tests/ui/range/range_traits-2.stderr +++ b/tests/ui/range/range_traits-2.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/range_traits-2.rs:3:10 | LL | #[derive(Copy, Clone)] diff --git a/tests/ui/range/range_traits-3.stderr b/tests/ui/range/range_traits-3.stderr index e54d17b32..db19d1bae 100644 --- a/tests/ui/range/range_traits-3.stderr +++ b/tests/ui/range/range_traits-3.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/range_traits-3.rs:3:10 | LL | #[derive(Copy, Clone)] diff --git a/tests/ui/range/range_traits-6.stderr b/tests/ui/range/range_traits-6.stderr index addc525f1..dfc74f87c 100644 --- a/tests/ui/range/range_traits-6.stderr +++ b/tests/ui/range/range_traits-6.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/range_traits-6.rs:3:10 | LL | #[derive(Copy, Clone)] diff --git a/tests/ui/reachable/expr_box.rs b/tests/ui/reachable/expr_box.rs deleted file mode 100644 index 00328ea01..000000000 --- a/tests/ui/reachable/expr_box.rs +++ /dev/null @@ -1,8 +0,0 @@ -#![feature(box_syntax)] -#![allow(unused_variables)] -#![deny(unreachable_code)] - -fn main() { - let x = box return; //~ ERROR unreachable - println!("hi"); -} diff --git a/tests/ui/reachable/expr_box.stderr b/tests/ui/reachable/expr_box.stderr deleted file mode 100644 index ea6472cbe..000000000 --- a/tests/ui/reachable/expr_box.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error: unreachable expression - --> $DIR/expr_box.rs:6:13 - | -LL | let x = box return; - | ^^^^------ - | | | - | | any code following this expression is unreachable - | unreachable expression - | -note: the lint level is defined here - --> $DIR/expr_box.rs:3:9 - | -LL | #![deny(unreachable_code)] - | ^^^^^^^^^^^^^^^^ - -error: aborting due to previous error - diff --git a/tests/ui/reachable-unnameable-type-alias.rs b/tests/ui/reachable/reachable-unnameable-type-alias.rs index 461355f87..461355f87 100644 --- a/tests/ui/reachable-unnameable-type-alias.rs +++ b/tests/ui/reachable/reachable-unnameable-type-alias.rs diff --git a/tests/ui/recursion/issue-95134.rs b/tests/ui/recursion/issue-95134.rs index fdc4d5369..2f1cffa2f 100644 --- a/tests/ui/recursion/issue-95134.rs +++ b/tests/ui/recursion/issue-95134.rs @@ -1,7 +1,7 @@ // build-fail // known-bug: #95134 // compile-flags: -Copt-level=0 -// failure-status: 101 +// dont-check-failure-status // dont-check-compiler-stderr pub fn encode_num<Writer: ExampleWriter>(n: u32, mut writer: Writer) -> Result<(), Writer::Error> { diff --git a/tests/ui/regions/issue-2718.rs b/tests/ui/regions/issue-2718.rs deleted file mode 100644 index 6449337ee..000000000 --- a/tests/ui/regions/issue-2718.rs +++ /dev/null @@ -1,327 +0,0 @@ -// run-pass -#![allow(dead_code)] -#![allow(unused_unsafe)] -#![allow(unused_imports)] -#![allow(non_camel_case_types)] - -pub type Task = isize; - -// tjc: I don't know why -pub mod pipes { - use self::state::{empty, full, blocked, terminated}; - use super::Task; - use std::mem::{forget, transmute}; - use std::mem::{replace, swap}; - use std::mem; - use std::thread; - use std::marker::Send; - - pub struct Stuff<T> { - state: state, - blocked_task: Option<Task>, - payload: Option<T> - } - - #[derive(PartialEq, Debug)] - #[repr(isize)] - pub enum state { - empty, - full, - blocked, - terminated - } - - pub struct packet<T> { - state: state, - blocked_task: Option<Task>, - payload: Option<T> - } - - unsafe impl<T:Send> Send for packet<T> {} - - pub fn packet<T:Send>() -> *const packet<T> { - unsafe { - let p: *const packet<T> = mem::transmute(Box::new(Stuff{ - state: empty, - blocked_task: None::<Task>, - payload: None::<T> - })); - p - } - } - - mod rusti { - pub fn atomic_xchg(_dst: &mut isize, _src: isize) -> isize { panic!(); } - pub fn atomic_xchg_acq(_dst: &mut isize, _src: isize) -> isize { panic!(); } - pub fn atomic_xchg_rel(_dst: &mut isize, _src: isize) -> isize { panic!(); } - } - - // We should consider moving this to ::std::unsafe, although I - // suspect graydon would want us to use void pointers instead. - pub unsafe fn uniquify<T>(x: *const T) -> Box<T> { - mem::transmute(x) - } - - pub fn swap_state_acq(dst: &mut state, src: state) -> state { - unsafe { - transmute(rusti::atomic_xchg_acq(transmute(dst), src as isize)) - } - } - - pub fn swap_state_rel(dst: &mut state, src: state) -> state { - unsafe { - transmute(rusti::atomic_xchg_rel(transmute(dst), src as isize)) - } - } - - pub fn send<T:Send>(mut p: send_packet<T>, payload: T) { - let p = p.unwrap(); - let mut p = unsafe { uniquify(p) }; - assert!((*p).payload.is_none()); - (*p).payload = Some(payload); - let old_state = swap_state_rel(&mut (*p).state, full); - match old_state { - empty => { - // Yay, fastpath. - - // The receiver will eventually clean this up. - unsafe { forget(p); } - } - full => { panic!("duplicate send") } - blocked => { - - // The receiver will eventually clean this up. - unsafe { forget(p); } - } - terminated => { - // The receiver will never receive this. Rely on drop_glue - // to clean everything up. - } - } - } - - pub fn recv<T:Send>(mut p: recv_packet<T>) -> Option<T> { - let p = p.unwrap(); - let mut p = unsafe { uniquify(p) }; - loop { - let old_state = swap_state_acq(&mut (*p).state, - blocked); - match old_state { - empty | blocked => { thread::yield_now(); } - full => { - let payload = replace(&mut p.payload, None); - return Some(payload.unwrap()) - } - terminated => { - assert_eq!(old_state, terminated); - return None; - } - } - } - } - - pub fn sender_terminate<T:Send>(p: *const packet<T>) { - let mut p = unsafe { uniquify(p) }; - match swap_state_rel(&mut (*p).state, terminated) { - empty | blocked => { - // The receiver will eventually clean up. - unsafe { forget(p) } - } - full => { - // This is impossible - panic!("you dun goofed") - } - terminated => { - // I have to clean up, use drop_glue - } - } - } - - pub fn receiver_terminate<T:Send>(p: *const packet<T>) { - let mut p = unsafe { uniquify(p) }; - match swap_state_rel(&mut (*p).state, terminated) { - empty => { - // the sender will clean up - unsafe { forget(p) } - } - blocked => { - // this shouldn't happen. - panic!("terminating a blocked packet") - } - terminated | full => { - // I have to clean up, use drop_glue - } - } - } - - pub struct send_packet<T:Send> { - p: Option<*const packet<T>>, - } - - impl<T:Send> Drop for send_packet<T> { - fn drop(&mut self) { - unsafe { - if self.p != None { - let self_p: &mut Option<*const packet<T>> = - mem::transmute(&mut self.p); - let p = replace(self_p, None); - sender_terminate(p.unwrap()) - } - } - } - } - - impl<T:Send> send_packet<T> { - pub fn unwrap(&mut self) -> *const packet<T> { - replace(&mut self.p, None).unwrap() - } - } - - pub fn send_packet<T:Send>(p: *const packet<T>) -> send_packet<T> { - send_packet { - p: Some(p) - } - } - - pub struct recv_packet<T:Send> { - p: Option<*const packet<T>>, - } - - impl<T:Send> Drop for recv_packet<T> { - fn drop(&mut self) { - unsafe { - if self.p != None { - let self_p: &mut Option<*const packet<T>> = - mem::transmute(&mut self.p); - let p = replace(self_p, None); - receiver_terminate(p.unwrap()) - } - } - } - } - - impl<T:Send> recv_packet<T> { - pub fn unwrap(&mut self) -> *const packet<T> { - replace(&mut self.p, None).unwrap() - } - } - - pub fn recv_packet<T:Send>(p: *const packet<T>) -> recv_packet<T> { - recv_packet { - p: Some(p) - } - } - - pub fn entangle<T:Send>() -> (send_packet<T>, recv_packet<T>) { - let p = packet(); - (send_packet(p), recv_packet(p)) - } -} - -pub mod pingpong { - use std::mem; - - pub struct ping(::pipes::send_packet<pong>); - - unsafe impl Send for ping {} - - pub struct pong(::pipes::send_packet<ping>); - - unsafe impl Send for pong {} - - pub fn liberate_ping(p: ping) -> ::pipes::send_packet<pong> { - unsafe { - let _addr : *const ::pipes::send_packet<pong> = match &p { - &ping(ref x) => { mem::transmute(x) } - }; - panic!() - } - } - - pub fn liberate_pong(p: pong) -> ::pipes::send_packet<ping> { - unsafe { - let _addr : *const ::pipes::send_packet<ping> = match &p { - &pong(ref x) => { mem::transmute(x) } - }; - panic!() - } - } - - pub fn init() -> (client::ping, server::ping) { - ::pipes::entangle() - } - - pub mod client { - use pingpong; - - pub type ping = ::pipes::send_packet<pingpong::ping>; - pub type pong = ::pipes::recv_packet<pingpong::pong>; - - pub fn do_ping(c: ping) -> pong { - let (sp, rp) = ::pipes::entangle(); - - ::pipes::send(c, pingpong::ping(sp)); - rp - } - - pub fn do_pong(c: pong) -> (ping, ()) { - let packet = ::pipes::recv(c); - if packet.is_none() { - panic!("sender closed the connection") - } - (pingpong::liberate_pong(packet.unwrap()), ()) - } - } - - pub mod server { - use pingpong; - - pub type ping = ::pipes::recv_packet<pingpong::ping>; - pub type pong = ::pipes::send_packet<pingpong::pong>; - - pub fn do_ping(c: ping) -> (pong, ()) { - let packet = ::pipes::recv(c); - if packet.is_none() { - panic!("sender closed the connection") - } - (pingpong::liberate_ping(packet.unwrap()), ()) - } - - pub fn do_pong(c: pong) -> ping { - let (sp, rp) = ::pipes::entangle(); - ::pipes::send(c, pingpong::pong(sp)); - rp - } - } -} - -fn client(chan: pingpong::client::ping) { - let chan = pingpong::client::do_ping(chan); - println!("Sent ping"); - let (_chan, _data) = pingpong::client::do_pong(chan); - println!("Received pong"); -} - -fn server(chan: pingpong::server::ping) { - let (chan, _data) = pingpong::server::do_ping(chan); - println!("Received ping"); - let _chan = pingpong::server::do_pong(chan); - println!("Sent pong"); -} - -pub fn main() { - /* -// Commented out because of option::get error - - let (client_, server_) = pingpong::init(); - - task::spawn {|client_| - let client__ = client_.take(); - client(client__); - }; - task::spawn {|server_| - let server__ = server_.take(); - server(server_ˊ); - }; - */ -} diff --git a/tests/ui/repeat-expr/repeat-to-run-dtor-twice.stderr b/tests/ui/repeat-expr/repeat-to-run-dtor-twice.stderr index 36b936163..1bf8e6e06 100644 --- a/tests/ui/repeat-expr/repeat-to-run-dtor-twice.stderr +++ b/tests/ui/repeat-expr/repeat-to-run-dtor-twice.stderr @@ -7,7 +7,8 @@ LL | let _ = [ a; 5 ]; = note: the `Copy` trait is required because this value will be copied for each element of the array help: consider annotating `Foo` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | struct Foo { | error: aborting due to previous error diff --git a/tests/ui/resolve/crate-in-paths.stderr b/tests/ui/resolve/crate-in-paths.stderr index b7cf49507..07fb5dcc0 100644 --- a/tests/ui/resolve/crate-in-paths.stderr +++ b/tests/ui/resolve/crate-in-paths.stderr @@ -6,7 +6,7 @@ LL | Foo; | help: consider importing this unit struct | -LL | use crate::bar::Foo; +LL + use crate::bar::Foo; | error: aborting due to previous error diff --git a/tests/ui/disambiguate-identical-names.rs b/tests/ui/resolve/disambiguate-identical-names.rs index 708d2cd76..708d2cd76 100644 --- a/tests/ui/disambiguate-identical-names.rs +++ b/tests/ui/resolve/disambiguate-identical-names.rs diff --git a/tests/ui/disambiguate-identical-names.stderr b/tests/ui/resolve/disambiguate-identical-names.stderr index 7d8293018..7d8293018 100644 --- a/tests/ui/disambiguate-identical-names.stderr +++ b/tests/ui/resolve/disambiguate-identical-names.stderr diff --git a/tests/ui/resolve/enums-are-namespaced-xc.stderr b/tests/ui/resolve/enums-are-namespaced-xc.stderr index 6448e596d..5af6cb042 100644 --- a/tests/ui/resolve/enums-are-namespaced-xc.stderr +++ b/tests/ui/resolve/enums-are-namespaced-xc.stderr @@ -6,7 +6,7 @@ LL | let _ = namespaced_enums::A; | help: consider importing this unit variant | -LL | use namespaced_enums::Foo::A; +LL + use namespaced_enums::Foo::A; | help: if you import `A`, refer to it directly | @@ -22,7 +22,7 @@ LL | let _ = namespaced_enums::B(10); | help: consider importing this tuple variant | -LL | use namespaced_enums::Foo::B; +LL + use namespaced_enums::Foo::B; | help: if you import `B`, refer to it directly | @@ -38,7 +38,7 @@ LL | let _ = namespaced_enums::C { a: 10 }; | help: consider importing this variant | -LL | use namespaced_enums::Foo::C; +LL + use namespaced_enums::Foo::C; | help: if you import `C`, refer to it directly | diff --git a/tests/ui/resolve/filter-intrinsics.stderr b/tests/ui/resolve/filter-intrinsics.stderr index 955070891..cc1092dd0 100644 --- a/tests/ui/resolve/filter-intrinsics.stderr +++ b/tests/ui/resolve/filter-intrinsics.stderr @@ -6,7 +6,7 @@ LL | let _ = size_of::<usize>(); | help: consider importing this function | -LL | use std::mem::size_of; +LL + use std::mem::size_of; | error[E0425]: cannot find function `fabsf64` in this scope @@ -17,7 +17,7 @@ LL | let _ = fabsf64(1.0); | help: consider importing this function | -LL | use std::intrinsics::fabsf64; +LL + use std::intrinsics::fabsf64; | error: aborting due to 2 previous errors diff --git a/tests/ui/resolve/issue-102946.stderr b/tests/ui/resolve/issue-102946.stderr index 65be0258e..b2cdcb25c 100644 --- a/tests/ui/resolve/issue-102946.stderr +++ b/tests/ui/resolve/issue-102946.stderr @@ -6,7 +6,7 @@ LL | impl Error for str::Utf8Error { | help: consider importing this trait | -LL | use std::error::Error; +LL + use std::error::Error; | error[E0223]: ambiguous associated type diff --git a/tests/ui/resolve/issue-107563-ambiguous-glob-reexports.rs b/tests/ui/resolve/issue-107563-ambiguous-glob-reexports.rs new file mode 100644 index 000000000..431213e25 --- /dev/null +++ b/tests/ui/resolve/issue-107563-ambiguous-glob-reexports.rs @@ -0,0 +1,33 @@ +#![deny(ambiguous_glob_reexports)] + +pub mod foo { + pub type X = u8; +} + +pub mod bar { + pub type X = u8; + pub type Y = u8; +} + +pub use foo::*; +//~^ ERROR ambiguous glob re-exports +pub use bar::*; + +mod ambiguous { + mod m1 { pub type A = u8; } + mod m2 { pub type A = u8; } + pub use self::m1::*; + //~^ ERROR ambiguous glob re-exports + pub use self::m2::*; +} + +pub mod single { + pub use ambiguous::A; + //~^ ERROR `A` is ambiguous +} + +pub mod glob { + pub use ambiguous::*; +} + +pub fn main() {} diff --git a/tests/ui/resolve/issue-107563-ambiguous-glob-reexports.stderr b/tests/ui/resolve/issue-107563-ambiguous-glob-reexports.stderr new file mode 100644 index 000000000..07e61dd86 --- /dev/null +++ b/tests/ui/resolve/issue-107563-ambiguous-glob-reexports.stderr @@ -0,0 +1,47 @@ +error[E0659]: `A` is ambiguous + --> $DIR/issue-107563-ambiguous-glob-reexports.rs:25:24 + | +LL | pub use ambiguous::A; + | ^ ambiguous name + | + = note: ambiguous because of multiple glob imports of a name in the same module +note: `A` could refer to the type alias imported here + --> $DIR/issue-107563-ambiguous-glob-reexports.rs:19:13 + | +LL | pub use self::m1::*; + | ^^^^^^^^^^^ + = help: consider adding an explicit import of `A` to disambiguate +note: `A` could also refer to the type alias imported here + --> $DIR/issue-107563-ambiguous-glob-reexports.rs:21:13 + | +LL | pub use self::m2::*; + | ^^^^^^^^^^^ + = help: consider adding an explicit import of `A` to disambiguate + +error: ambiguous glob re-exports + --> $DIR/issue-107563-ambiguous-glob-reexports.rs:12:9 + | +LL | pub use foo::*; + | ^^^^^^ the name `X` in the type namespace is first re-exported here +LL | +LL | pub use bar::*; + | ------ but the name `X` in the type namespace is also re-exported here + | +note: the lint level is defined here + --> $DIR/issue-107563-ambiguous-glob-reexports.rs:1:9 + | +LL | #![deny(ambiguous_glob_reexports)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error: ambiguous glob re-exports + --> $DIR/issue-107563-ambiguous-glob-reexports.rs:19:13 + | +LL | pub use self::m1::*; + | ^^^^^^^^^^^ the name `A` in the type namespace is first re-exported here +LL | +LL | pub use self::m2::*; + | ----------- but the name `A` in the type namespace is also re-exported here + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0659`. diff --git a/tests/ui/resolve/issue-16058.stderr b/tests/ui/resolve/issue-16058.stderr index c47d22cef..710002a15 100644 --- a/tests/ui/resolve/issue-16058.stderr +++ b/tests/ui/resolve/issue-16058.stderr @@ -6,11 +6,11 @@ LL | Result { | help: consider importing one of these items instead | -LL | use std::fmt::Result; +LL + use std::fmt::Result; | -LL | use std::io::Result; +LL + use std::io::Result; | -LL | use std::thread::Result; +LL + use std::thread::Result; | error: aborting due to previous error diff --git a/tests/ui/resolve/issue-17518.stderr b/tests/ui/resolve/issue-17518.stderr index 034d0d01b..492e3b34a 100644 --- a/tests/ui/resolve/issue-17518.stderr +++ b/tests/ui/resolve/issue-17518.stderr @@ -6,7 +6,7 @@ LL | E { name: "foobar" }; | help: consider importing this variant | -LL | use SomeEnum::E; +LL + use SomeEnum::E; | error: aborting due to previous error diff --git a/tests/ui/resolve/issue-21221-1.stderr b/tests/ui/resolve/issue-21221-1.stderr index 538eeead9..a38116cd7 100644 --- a/tests/ui/resolve/issue-21221-1.stderr +++ b/tests/ui/resolve/issue-21221-1.stderr @@ -6,11 +6,11 @@ LL | impl Mul for Foo { | help: consider importing one of these items | -LL | use mul1::Mul; +LL + use mul1::Mul; | -LL | use mul2::Mul; +LL + use mul2::Mul; | -LL | use std::ops::Mul; +LL + use std::ops::Mul; | error[E0412]: cannot find type `Mul` in this scope @@ -21,11 +21,11 @@ LL | fn getMul() -> Mul { | help: consider importing one of these items | -LL | use mul1::Mul; +LL + use mul1::Mul; | -LL | use mul2::Mul; +LL + use mul2::Mul; | -LL | use std::ops::Mul; +LL + use std::ops::Mul; | error[E0405]: cannot find trait `ThisTraitReallyDoesntExistInAnyModuleReally` in this scope @@ -42,7 +42,7 @@ LL | impl Div for Foo { | help: consider importing this trait | -LL | use std::ops::Div; +LL + use std::ops::Div; | error: aborting due to 4 previous errors diff --git a/tests/ui/resolve/issue-21221-2.stderr b/tests/ui/resolve/issue-21221-2.stderr index d4fd7cb12..9beb62662 100644 --- a/tests/ui/resolve/issue-21221-2.stderr +++ b/tests/ui/resolve/issue-21221-2.stderr @@ -6,9 +6,9 @@ LL | impl T for Foo { } | help: consider importing one of these items | -LL | use baz::T; +LL + use baz::T; | -LL | use foo::bar::T; +LL + use foo::bar::T; | error: aborting due to previous error diff --git a/tests/ui/resolve/issue-21221-3.stderr b/tests/ui/resolve/issue-21221-3.stderr index f12e5b09b..0dabdfd9b 100644 --- a/tests/ui/resolve/issue-21221-3.stderr +++ b/tests/ui/resolve/issue-21221-3.stderr @@ -6,7 +6,7 @@ LL | impl OuterTrait for Foo {} | help: consider importing this trait | -LL | use issue_21221_3::outer::OuterTrait; +LL + use issue_21221_3::outer::OuterTrait; | error: aborting due to previous error diff --git a/tests/ui/resolve/issue-21221-4.stderr b/tests/ui/resolve/issue-21221-4.stderr index fc15444d0..5af14b1b6 100644 --- a/tests/ui/resolve/issue-21221-4.stderr +++ b/tests/ui/resolve/issue-21221-4.stderr @@ -6,7 +6,7 @@ LL | impl T for Foo {} | help: consider importing this trait | -LL | use issue_21221_4::T; +LL + use issue_21221_4::T; | error: aborting due to previous error diff --git a/tests/ui/resolve/issue-2356.stderr b/tests/ui/resolve/issue-2356.stderr index 36f3da7c9..313b3e30d 100644 --- a/tests/ui/resolve/issue-2356.stderr +++ b/tests/ui/resolve/issue-2356.stderr @@ -10,7 +10,7 @@ LL | Self::default(); | ~~~~~~~~~~~~~ help: consider importing this function | -LL | use std::default::default; +LL + use std::default::default; | error[E0425]: cannot find value `whiskers` in this scope diff --git a/tests/ui/resolve/issue-26545.stderr b/tests/ui/resolve/issue-26545.stderr index d3c866925..42a7531c5 100644 --- a/tests/ui/resolve/issue-26545.stderr +++ b/tests/ui/resolve/issue-26545.stderr @@ -6,7 +6,7 @@ LL | B(()); | help: consider importing this tuple struct | -LL | use foo::B; +LL + use foo::B; | error: aborting due to previous error diff --git a/tests/ui/resolve/issue-35675.stderr b/tests/ui/resolve/issue-35675.stderr index 4a06196d5..44af65b07 100644 --- a/tests/ui/resolve/issue-35675.stderr +++ b/tests/ui/resolve/issue-35675.stderr @@ -17,7 +17,7 @@ LL | Apple(5) | help: consider importing this tuple variant | -LL | use Fruit::Apple; +LL + use Fruit::Apple; | error[E0573]: expected type, found variant `Fruit::Apple` @@ -37,7 +37,7 @@ LL | Apple(5) | help: consider importing this tuple variant | -LL | use Fruit::Apple; +LL + use Fruit::Apple; | error[E0573]: expected type, found variant `Ok` diff --git a/tests/ui/resolve/issue-3907.stderr b/tests/ui/resolve/issue-3907.stderr index 6fc61cae8..70631a13c 100644 --- a/tests/ui/resolve/issue-3907.stderr +++ b/tests/ui/resolve/issue-3907.stderr @@ -10,7 +10,7 @@ LL | trait Foo = dyn issue_3907::Foo; | help: consider importing this trait instead | -LL | use issue_3907::Foo; +LL + use issue_3907::Foo; | error: aborting due to previous error diff --git a/tests/ui/resolve/issue-50599.stderr b/tests/ui/resolve/issue-50599.stderr index b07482c83..d7419b64f 100644 --- a/tests/ui/resolve/issue-50599.stderr +++ b/tests/ui/resolve/issue-50599.stderr @@ -6,9 +6,9 @@ LL | const M: usize = (f64::from(N) * std::f64::LOG10_2) as usize; | help: consider importing one of these items | -LL | use std::f32::consts::LOG10_2; +LL + use std::f32::consts::LOG10_2; | -LL | use std::f64::consts::LOG10_2; +LL + use std::f64::consts::LOG10_2; | help: if you import `LOG10_2`, refer to it directly | diff --git a/tests/ui/resolve/issue-73427.stderr b/tests/ui/resolve/issue-73427.stderr index 4af5f29d8..622de9b39 100644 --- a/tests/ui/resolve/issue-73427.stderr +++ b/tests/ui/resolve/issue-73427.stderr @@ -107,9 +107,9 @@ LL | (E::TupleWithFields(/* fields */)).foo(); | ~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~~ help: consider importing one of these items instead | -LL | use std::f32::consts::E; +LL + use std::f32::consts::E; | -LL | use std::f64::consts::E; +LL + use std::f64::consts::E; | error[E0532]: expected tuple struct or tuple variant, found enum `A` diff --git a/tests/ui/resolve/issue-90113.stderr b/tests/ui/resolve/issue-90113.stderr index 1b7872057..5f55d9c24 100644 --- a/tests/ui/resolve/issue-90113.stderr +++ b/tests/ui/resolve/issue-90113.stderr @@ -6,7 +6,7 @@ LL | Cons(..) => {} | help: consider importing this tuple variant | -LL | use list::List::Cons; +LL + use list::List::Cons; | error: aborting due to previous error diff --git a/tests/ui/resolve/missing-in-namespace.stderr b/tests/ui/resolve/missing-in-namespace.stderr index fc925ba3b..7a7b749ae 100644 --- a/tests/ui/resolve/missing-in-namespace.stderr +++ b/tests/ui/resolve/missing-in-namespace.stderr @@ -6,7 +6,7 @@ LL | let _map = std::hahmap::HashMap::new(); | help: consider importing this struct | -LL | use std::collections::HashMap; +LL + use std::collections::HashMap; | help: if you import `HashMap`, refer to it directly | diff --git a/tests/ui/resolve/no-implicit-prelude-nested.stderr b/tests/ui/resolve/no-implicit-prelude-nested.stderr index 198b630c5..49cf72bfe 100644 --- a/tests/ui/resolve/no-implicit-prelude-nested.stderr +++ b/tests/ui/resolve/no-implicit-prelude-nested.stderr @@ -6,7 +6,7 @@ LL | impl Add for Test {} | help: consider importing this trait | -LL | use std::ops::Add; +LL + use std::ops::Add; | error[E0404]: expected trait, found derive macro `Clone` @@ -17,7 +17,7 @@ LL | impl Clone for Test {} | help: consider importing this trait instead | -LL | use std::clone::Clone; +LL + use std::clone::Clone; | error[E0405]: cannot find trait `Iterator` in this scope @@ -28,7 +28,7 @@ LL | impl Iterator for Test {} | help: consider importing this trait | -LL | use std::iter::Iterator; +LL + use std::iter::Iterator; | error[E0405]: cannot find trait `ToString` in this scope @@ -39,7 +39,7 @@ LL | impl ToString for Test {} | help: consider importing this trait | -LL | use std::string::ToString; +LL + use std::string::ToString; | error[E0405]: cannot find trait `Writer` in this scope @@ -56,7 +56,7 @@ LL | drop(2) | help: consider importing this function | -LL | use std::mem::drop; +LL + use std::mem::drop; | error[E0405]: cannot find trait `Add` in this scope @@ -67,7 +67,7 @@ LL | impl Add for Test {} | help: consider importing this trait | -LL | use std::ops::Add; +LL + use std::ops::Add; | error[E0404]: expected trait, found derive macro `Clone` @@ -78,7 +78,7 @@ LL | impl Clone for Test {} | help: consider importing this trait instead | -LL | use std::clone::Clone; +LL + use std::clone::Clone; | error[E0405]: cannot find trait `Iterator` in this scope @@ -89,7 +89,7 @@ LL | impl Iterator for Test {} | help: consider importing this trait | -LL | use std::iter::Iterator; +LL + use std::iter::Iterator; | error[E0405]: cannot find trait `ToString` in this scope @@ -100,7 +100,7 @@ LL | impl ToString for Test {} | help: consider importing this trait | -LL | use std::string::ToString; +LL + use std::string::ToString; | error[E0405]: cannot find trait `Writer` in this scope @@ -117,7 +117,7 @@ LL | drop(2) | help: consider importing this function | -LL | use std::mem::drop; +LL + use std::mem::drop; | error[E0405]: cannot find trait `Add` in this scope @@ -128,7 +128,7 @@ LL | impl Add for Test {} | help: consider importing this trait | -LL | use std::ops::Add; +LL + use std::ops::Add; | error[E0404]: expected trait, found derive macro `Clone` @@ -139,7 +139,7 @@ LL | impl Clone for Test {} | help: consider importing this trait instead | -LL | use std::clone::Clone; +LL + use std::clone::Clone; | error[E0405]: cannot find trait `Iterator` in this scope @@ -150,7 +150,7 @@ LL | impl Iterator for Test {} | help: consider importing this trait | -LL | use std::iter::Iterator; +LL + use std::iter::Iterator; | error[E0405]: cannot find trait `ToString` in this scope @@ -161,7 +161,7 @@ LL | impl ToString for Test {} | help: consider importing this trait | -LL | use std::string::ToString; +LL + use std::string::ToString; | error[E0405]: cannot find trait `Writer` in this scope @@ -178,7 +178,7 @@ LL | drop(2) | help: consider importing this function | -LL | use std::mem::drop; +LL + use std::mem::drop; | error: aborting due to 18 previous errors diff --git a/tests/ui/resolve/no-implicit-prelude.stderr b/tests/ui/resolve/no-implicit-prelude.stderr index 36a9b65b7..5a759743f 100644 --- a/tests/ui/resolve/no-implicit-prelude.stderr +++ b/tests/ui/resolve/no-implicit-prelude.stderr @@ -6,7 +6,7 @@ LL | impl Add for Test {} | help: consider importing this trait | -LL | use std::ops::Add; +LL + use std::ops::Add; | error[E0404]: expected trait, found derive macro `Clone` @@ -17,7 +17,7 @@ LL | impl Clone for Test {} | help: consider importing this trait instead | -LL | use std::clone::Clone; +LL + use std::clone::Clone; | error[E0405]: cannot find trait `Iterator` in this scope @@ -28,7 +28,7 @@ LL | impl Iterator for Test {} | help: consider importing this trait | -LL | use std::iter::Iterator; +LL + use std::iter::Iterator; | error[E0405]: cannot find trait `ToString` in this scope @@ -39,7 +39,7 @@ LL | impl ToString for Test {} | help: consider importing this trait | -LL | use std::string::ToString; +LL + use std::string::ToString; | error[E0405]: cannot find trait `Writer` in this scope @@ -56,7 +56,7 @@ LL | drop(2) | help: consider importing this function | -LL | use std::mem::drop; +LL + use std::mem::drop; | error: aborting due to 6 previous errors diff --git a/tests/ui/resolve/privacy-enum-ctor.stderr b/tests/ui/resolve/privacy-enum-ctor.stderr index 3c051429f..0bb090905 100644 --- a/tests/ui/resolve/privacy-enum-ctor.stderr +++ b/tests/ui/resolve/privacy-enum-ctor.stderr @@ -84,9 +84,9 @@ LL | let _: E = m::f; | ~ help: consider importing one of these items instead | -LL | use std::f32::consts::E; +LL + use std::f32::consts::E; | -LL | use std::f64::consts::E; +LL + use std::f64::consts::E; | help: if you import `E`, refer to it directly | @@ -121,9 +121,9 @@ LL | let _: E = (E::Fn(/* fields */)); | ~~~~~~~~~~~~~~~~~~~~~ help: consider importing one of these items instead | -LL | use std::f32::consts::E; +LL + use std::f32::consts::E; | -LL | use std::f64::consts::E; +LL + use std::f64::consts::E; | error[E0412]: cannot find type `Z` in this scope diff --git a/tests/ui/resolve/resolve-primitive-fallback.stderr b/tests/ui/resolve/resolve-primitive-fallback.stderr index f803f9da2..e3a5d4edc 100644 --- a/tests/ui/resolve/resolve-primitive-fallback.stderr +++ b/tests/ui/resolve/resolve-primitive-fallback.stderr @@ -12,7 +12,7 @@ LL | let _: ::u8; | help: consider importing this builtin type | -LL | use std::primitive::u8; +LL + use std::primitive::u8; | help: if you import `u8`, refer to it directly | diff --git a/tests/ui/resolve/tool-import.rs b/tests/ui/resolve/tool-import.rs new file mode 100644 index 000000000..971993332 --- /dev/null +++ b/tests/ui/resolve/tool-import.rs @@ -0,0 +1,8 @@ +// edition: 2018 + +use clippy::time::Instant; +//~^ `clippy` is a tool module + +fn main() { + Instant::now(); +} diff --git a/tests/ui/resolve/tool-import.stderr b/tests/ui/resolve/tool-import.stderr new file mode 100644 index 000000000..d3bdfc93d --- /dev/null +++ b/tests/ui/resolve/tool-import.stderr @@ -0,0 +1,9 @@ +error[E0433]: failed to resolve: `clippy` is a tool module, not a module + --> $DIR/tool-import.rs:3:5 + | +LL | use clippy::time::Instant; + | ^^^^^^ `clippy` is a tool module, not a module + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0433`. diff --git a/tests/ui/resolve/use_suggestion.stderr b/tests/ui/resolve/use_suggestion.stderr index 54ad85383..1155f5caa 100644 --- a/tests/ui/resolve/use_suggestion.stderr +++ b/tests/ui/resolve/use_suggestion.stderr @@ -6,7 +6,7 @@ LL | let x1 = HashMap::new(); | help: consider importing this struct | -LL | use std::collections::HashMap; +LL + use std::collections::HashMap; | error[E0412]: cannot find type `HashMap` in this scope @@ -17,7 +17,7 @@ LL | let y1: HashMap; | help: consider importing this struct | -LL | use std::collections::HashMap; +LL + use std::collections::HashMap; | error[E0412]: cannot find type `GooMap` in this scope diff --git a/tests/ui/resolve/use_suggestion_placement.stderr b/tests/ui/resolve/use_suggestion_placement.stderr index 0aadd82f6..3611f9ae6 100644 --- a/tests/ui/resolve/use_suggestion_placement.stderr +++ b/tests/ui/resolve/use_suggestion_placement.stderr @@ -6,7 +6,7 @@ LL | type Bar = Path; | help: consider importing this struct | -LL | use std::path::Path; +LL + use std::path::Path; | error[E0425]: cannot find value `A` in this scope @@ -17,7 +17,7 @@ LL | let _ = A; | help: consider importing this constant | -LL | use m::A; +LL + use m::A; | error[E0412]: cannot find type `HashMap` in this scope @@ -28,7 +28,7 @@ LL | type Dict<K, V> = HashMap<K, V>; | help: consider importing this struct | -LL | use std::collections::HashMap; +LL + use std::collections::HashMap; | error: aborting due to 3 previous errors diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr index c73a6cf13..f08ba522a 100644 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr +++ b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-embedded.stderr @@ -3,6 +3,9 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be ann | LL | WRAP_DIRECT_INLINE => { panic!("WRAP_DIRECT_INLINE matched itself"); } | ^^^^^^^^^^^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: aborting due to previous error diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr index 6fdf9db89..012ccab17 100644 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr +++ b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-direct-struct-param.stderr @@ -3,6 +3,9 @@ error: to use a constant of type `NoDerive` in a pattern, `NoDerive` must be ann | LL | WRAP_DIRECT_PARAM => { panic!("WRAP_DIRECT_PARAM matched itself"); } | ^^^^^^^^^^^^^^^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: aborting due to previous error diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr index 10dd635ff..94ee2216e 100644 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr +++ b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-embedded.stderr @@ -6,6 +6,8 @@ LL | WRAP_DOUBLY_INDIRECT_INLINE => { panic!("WRAP_DOUBLY_INDIRECT_INLIN | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details note: the lint level is defined here --> $DIR/cant-hide-behind-doubly-indirect-embedded.rs:7:9 | diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr index 66aecbc4f..666b7b95e 100644 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr +++ b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-doubly-indirect-param.stderr @@ -6,6 +6,8 @@ LL | WRAP_DOUBLY_INDIRECT_PARAM => { panic!("WRAP_DOUBLY_INDIRECT_PARAM | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details note: the lint level is defined here --> $DIR/cant-hide-behind-doubly-indirect-param.rs:7:9 | diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr index ee92954a6..ecbe83f3d 100644 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr +++ b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-embedded.stderr @@ -6,6 +6,8 @@ LL | WRAP_INDIRECT_INLINE => { panic!("WRAP_INDIRECT_INLINE matched itse | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details note: the lint level is defined here --> $DIR/cant-hide-behind-indirect-struct-embedded.rs:7:9 | diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr index f0c492d6a..211990801 100644 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr +++ b/tests/ui/rfc-1445-restrict-constants-in-patterns/cant-hide-behind-indirect-struct-param.stderr @@ -6,6 +6,8 @@ LL | WRAP_INDIRECT_PARAM => { panic!("WRAP_INDIRECT_PARAM matched itself | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details note: the lint level is defined here --> $DIR/cant-hide-behind-indirect-struct-param.rs:7:9 | diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr index 0bf369fa8..46600e7b2 100644 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr +++ b/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-61188-match-slice-forbidden-without-eq.stderr @@ -3,6 +3,9 @@ error: to use a constant of type `B` in a pattern, `B` must be annotated with `# | LL | A => (), | ^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: aborting due to previous error diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr index 955ab4b54..435812306 100644 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr +++ b/tests/ui/rfc-1445-restrict-constants-in-patterns/issue-62307-match-ref-ref-forbidden-without-eq.stderr @@ -6,6 +6,8 @@ LL | RR_B1 => { println!("CLAIM RR0: {:?} matches {:?}", RR_B1, RR_B0); | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details note: the lint level is defined here --> $DIR/issue-62307-match-ref-ref-forbidden-without-eq.rs:13:9 | @@ -20,6 +22,8 @@ LL | RR_B1 => { println!("CLAIM RR1: {:?} matches {:?}", RR_B1, RR_B1); | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #62411 <https://github.com/rust-lang/rust/issues/62411> + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details warning: 2 warnings emitted diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr index 616ed9e48..1c4fb9146 100644 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr +++ b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-forbidden-without-eq.stderr @@ -3,6 +3,9 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated wit | LL | FOO => { } | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details warning: floating-point types cannot be used in patterns --> $DIR/match-forbidden-without-eq.rs:18:9 diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr index 371f8a0aa..6adebada0 100644 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr +++ b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-nonempty-array-forbidden-without-eq.stderr @@ -3,6 +3,9 @@ error: to use a constant of type `B` in a pattern, `B` must be annotated with `# | LL | FOO => { } | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: aborting due to previous error diff --git a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr index 4157cf652..f5b10f062 100644 --- a/tests/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr +++ b/tests/ui/rfc-1445-restrict-constants-in-patterns/match-requires-both-partialeq-and-eq.stderr @@ -3,6 +3,9 @@ error: to use a constant of type `Foo` in a pattern, `Foo` must be annotated wit | LL | FOO => { } | ^^^ + | + = note: the traits must be derived, manual `impl`s are not sufficient + = note: see https://doc.rust-lang.org/stable/std/marker/trait.StructuralEq.html for details error: aborting due to previous error diff --git a/tests/ui/rfc-1937-termination-trait/issue-103052-2.stderr b/tests/ui/rfc-1937-termination-trait/issue-103052-2.current.stderr index a700c72ea..f72b3ab02 100644 --- a/tests/ui/rfc-1937-termination-trait/issue-103052-2.stderr +++ b/tests/ui/rfc-1937-termination-trait/issue-103052-2.current.stderr @@ -1,11 +1,11 @@ error[E0277]: the trait bound `Something: Termination` is not satisfied - --> $DIR/issue-103052-2.rs:12:22 + --> $DIR/issue-103052-2.rs:15:22 | LL | fn main() -> Something { | ^^^^^^^^^ the trait `Termination` is not implemented for `Something` | note: required by a bound in `Main::main::{opaque#0}` - --> $DIR/issue-103052-2.rs:6:27 + --> $DIR/issue-103052-2.rs:9:27 | LL | fn main() -> impl std::process::Termination; | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::main::{opaque#0}` diff --git a/tests/ui/rfc-1937-termination-trait/issue-103052-2.next.stderr b/tests/ui/rfc-1937-termination-trait/issue-103052-2.next.stderr new file mode 100644 index 000000000..8b01941b4 --- /dev/null +++ b/tests/ui/rfc-1937-termination-trait/issue-103052-2.next.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `Something: Termination` is not satisfied + --> $DIR/issue-103052-2.rs:15:22 + | +LL | fn main() -> Something { + | ^^^^^^^^^ the trait `Termination` is not implemented for `Something` + | +note: required by a bound in `Main::{opaque#0}` + --> $DIR/issue-103052-2.rs:9:27 + | +LL | fn main() -> impl std::process::Termination; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Main::{opaque#0}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-1937-termination-trait/issue-103052-2.rs b/tests/ui/rfc-1937-termination-trait/issue-103052-2.rs index fa9182b6d..ca5fa6df2 100644 --- a/tests/ui/rfc-1937-termination-trait/issue-103052-2.rs +++ b/tests/ui/rfc-1937-termination-trait/issue-103052-2.rs @@ -1,3 +1,6 @@ +// [next] compile-flags: -Zlower-impl-trait-in-trait-to-assoc-ty +// revisions: current next + #![feature(return_position_impl_trait_in_trait)] #![allow(incomplete_features)] @@ -9,7 +12,8 @@ mod child { struct Something; impl Main for () { - fn main() -> Something { //~ ERROR the trait bound `Something: Termination` is not satisfied + fn main() -> Something { + //~^ ERROR the trait bound `Something: Termination` is not satisfied Something } } diff --git a/tests/ui/rfc-2005-default-binding-mode/slice.stderr b/tests/ui/rfc-2005-default-binding-mode/slice.stderr index 60c1f5420..5b51dc5ac 100644 --- a/tests/ui/rfc-2005-default-binding-mode/slice.stderr +++ b/tests/ui/rfc-2005-default-binding-mode/slice.stderr @@ -7,7 +7,7 @@ LL | match sl { = note: the matched value is of type `&[u8]` help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown | -LL ~ [first, remainder @ ..] => {} +LL ~ [first, remainder @ ..] => {}, LL ~ &[] => todo!(), | diff --git a/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.rs b/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.rs index d8f07bb8f..3482af747 100644 --- a/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.rs +++ b/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.rs @@ -184,4 +184,28 @@ fn main() { // OK: both unstable and stable fields are matched with feature on #[warn(non_exhaustive_omitted_patterns)] let UnstableStruct { stable, stable2, unstable, .. } = UnstableStruct::default(); + + // Ok: local bindings are allowed + #[deny(non_exhaustive_omitted_patterns)] + let local = NonExhaustiveEnum::Unit; + + // Ok: missing patterns will be blocked by the pattern being refutable + #[deny(non_exhaustive_omitted_patterns)] + let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit; + //~^ refutable pattern in local binding + + // Check that matching on a reference results in a correctly spanned diagnostic + #[deny(non_exhaustive_omitted_patterns)] + match &non_enum { + NonExhaustiveEnum::Unit => {} + NonExhaustiveEnum::Tuple(_) => {} + _ => {} + } + //~^^ some variants are not matched explicitly +} + +#[deny(non_exhaustive_omitted_patterns)] +// Ok: Pattern in a param is always wildcard +pub fn takes_non_exhaustive(_: NonExhaustiveEnum) { + let _closure = |_: NonExhaustiveEnum| {}; } diff --git a/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.stderr b/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.stderr index 996bd4a12..923394474 100644 --- a/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.stderr +++ b/tests/ui/rfc-2008-non-exhaustive/omitted-patterns.stderr @@ -184,5 +184,34 @@ note: the lint level is defined here LL | #[deny(non_exhaustive_omitted_patterns)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 8 previous errors; 6 warnings emitted +error[E0005]: refutable pattern in local binding + --> $DIR/omitted-patterns.rs:194:9 + | +LL | let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit; + | ^^^^^^^^^^^^^^^ pattern `_` not covered + | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html + = note: the matched value is of type `NonExhaustiveEnum` +help: you might want to use `let else` to handle the variant that isn't matched + | +LL | let local_refutable @ NonExhaustiveEnum::Unit = NonExhaustiveEnum::Unit else { todo!() }; + | ++++++++++++++++ + +error: some variants are not matched explicitly + --> $DIR/omitted-patterns.rs:202:9 + | +LL | _ => {} + | ^ pattern `NonExhaustiveEnum::Struct { .. }` not covered + | + = help: ensure that all variants are matched explicitly by adding the suggested match arms + = note: the matched value is of type `NonExhaustiveEnum` and the `non_exhaustive_omitted_patterns` attribute was found +note: the lint level is defined here + --> $DIR/omitted-patterns.rs:198:12 + | +LL | #[deny(non_exhaustive_omitted_patterns)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 10 previous errors; 6 warnings emitted +For more information about this error, try `rustc --explain E0005`. diff --git a/tests/ui/rfc-2008-non-exhaustive/struct.stderr b/tests/ui/rfc-2008-non-exhaustive/struct.stderr index 2cb9ba0d1..39b1ef1e0 100644 --- a/tests/ui/rfc-2008-non-exhaustive/struct.stderr +++ b/tests/ui/rfc-2008-non-exhaustive/struct.stderr @@ -10,14 +10,11 @@ error[E0603]: tuple struct constructor `TupleStruct` is private LL | let ts_explicit = structs::TupleStruct(640, 480); | ^^^^^^^^^^^ private tuple struct constructor | - ::: $DIR/auxiliary/structs.rs:12:24 - | -LL | pub struct TupleStruct(pub u16, pub u16); - | ---------------- a constructor is private if any of the fields is private - | note: the tuple struct constructor `TupleStruct` is defined here --> $DIR/auxiliary/structs.rs:12:1 | +LL | #[non_exhaustive] + | ----------------- cannot be constructed because it is `#[non_exhaustive]` LL | pub struct TupleStruct(pub u16, pub u16); | ^^^^^^^^^^^^^^^^^^^^^^ @@ -30,6 +27,8 @@ LL | let us_explicit = structs::UnitStruct; note: the unit struct `UnitStruct` is defined here --> $DIR/auxiliary/structs.rs:9:1 | +LL | #[non_exhaustive] + | ----------------- cannot be constructed because it is `#[non_exhaustive]` LL | pub struct UnitStruct; | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfc-2008-non-exhaustive/variant.stderr b/tests/ui/rfc-2008-non-exhaustive/variant.stderr index 720b7b119..4083f57a9 100644 --- a/tests/ui/rfc-2008-non-exhaustive/variant.stderr +++ b/tests/ui/rfc-2008-non-exhaustive/variant.stderr @@ -8,7 +8,9 @@ note: the tuple variant `Tuple` is defined here --> $DIR/auxiliary/variants.rs:5:23 | LL | #[non_exhaustive] Tuple(u32), - | ^^^^^ + | ----------------- ^^^^^ + | | + | cannot be constructed because it is `#[non_exhaustive]` error[E0603]: unit variant `Unit` is private --> $DIR/variant.rs:14:47 @@ -20,7 +22,9 @@ note: the unit variant `Unit` is defined here --> $DIR/auxiliary/variants.rs:4:23 | LL | #[non_exhaustive] Unit, - | ^^^^ + | ----------------- ^^^^ + | | + | cannot be constructed because it is `#[non_exhaustive]` error[E0603]: unit variant `Unit` is private --> $DIR/variant.rs:18:32 @@ -32,7 +36,9 @@ note: the unit variant `Unit` is defined here --> $DIR/auxiliary/variants.rs:4:23 | LL | #[non_exhaustive] Unit, - | ^^^^ + | ----------------- ^^^^ + | | + | cannot be constructed because it is `#[non_exhaustive]` error[E0603]: tuple variant `Tuple` is private --> $DIR/variant.rs:20:32 @@ -44,7 +50,9 @@ note: the tuple variant `Tuple` is defined here --> $DIR/auxiliary/variants.rs:5:23 | LL | #[non_exhaustive] Tuple(u32), - | ^^^^^ + | ----------------- ^^^^^ + | | + | cannot be constructed because it is `#[non_exhaustive]` error[E0603]: tuple variant `Tuple` is private --> $DIR/variant.rs:26:35 @@ -56,7 +64,9 @@ note: the tuple variant `Tuple` is defined here --> $DIR/auxiliary/variants.rs:5:23 | LL | #[non_exhaustive] Tuple(u32), - | ^^^^^ + | ----------------- ^^^^^ + | | + | cannot be constructed because it is `#[non_exhaustive]` error[E0639]: cannot create non-exhaustive variant using struct expression --> $DIR/variant.rs:8:26 diff --git a/tests/ui/rfc-2091-track-caller/intrinsic-wrapper.rs b/tests/ui/rfc-2091-track-caller/intrinsic-wrapper.rs index 87e52881c..23d2a4b0a 100644 --- a/tests/ui/rfc-2091-track-caller/intrinsic-wrapper.rs +++ b/tests/ui/rfc-2091-track-caller/intrinsic-wrapper.rs @@ -1,5 +1,6 @@ // run-pass // revisions: default mir-opt +//[default] compile-flags: -Zinline-mir=no //[mir-opt] compile-flags: -Zmir-opt-level=4 macro_rules! caller_location_from_macro { @@ -9,13 +10,13 @@ macro_rules! caller_location_from_macro { fn main() { let loc = core::panic::Location::caller(); assert_eq!(loc.file(), file!()); - assert_eq!(loc.line(), 10); + assert_eq!(loc.line(), 11); assert_eq!(loc.column(), 15); // `Location::caller()` in a macro should behave similarly to `file!` and `line!`, // i.e. point to where the macro was invoked, instead of the macro itself. let loc2 = caller_location_from_macro!(); assert_eq!(loc2.file(), file!()); - assert_eq!(loc2.line(), 17); + assert_eq!(loc2.line(), 18); assert_eq!(loc2.column(), 16); } diff --git a/tests/ui/rfc-2091-track-caller/mir-inlined-macro.rs b/tests/ui/rfc-2091-track-caller/mir-inlined-macro.rs new file mode 100644 index 000000000..a2e8eb27e --- /dev/null +++ b/tests/ui/rfc-2091-track-caller/mir-inlined-macro.rs @@ -0,0 +1,23 @@ +// run-pass +// revisions: default mir-opt +//[default] compile-flags: -Zinline-mir=no +//[mir-opt] compile-flags: -Zmir-opt-level=4 + +use std::panic::Location; + +macro_rules! f { + () => { + Location::caller() + }; +} + +#[inline(always)] +fn g() -> &'static Location<'static> { + f!() +} + +fn main() { + let loc = g(); + assert_eq!(loc.line(), 16); + assert_eq!(loc.column(), 5); +} diff --git a/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr b/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr index d8b5a9e63..ce165e646 100644 --- a/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr +++ b/tests/ui/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr @@ -9,7 +9,8 @@ LL | let _: NotDebug = dbg!(NotDebug); = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `NotDebug` with `#[derive(Debug)]` | -LL | #[derive(Debug)] +LL + #[derive(Debug)] +LL | struct NotDebug; | error: aborting due to previous error diff --git a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr index 706f52343..a28d6ce05 100644 --- a/tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/call-generic-method-nonconst.stderr @@ -1,21 +1,14 @@ error[E0277]: the trait bound `S: ~const Foo` is not satisfied - --> $DIR/call-generic-method-nonconst.rs:23:34 + --> $DIR/call-generic-method-nonconst.rs:23:22 | LL | pub const EQ: bool = equals_self(&S); - | ----------- ^^ the trait `~const Foo` is not implemented for `S` - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^ the trait `~const Foo` is not implemented for `S` | note: the trait `Foo` is implemented for `S`, but that implementation is not `const` - --> $DIR/call-generic-method-nonconst.rs:23:34 + --> $DIR/call-generic-method-nonconst.rs:23:22 | LL | pub const EQ: bool = equals_self(&S); - | ^^ -note: required by a bound in `equals_self` - --> $DIR/call-generic-method-nonconst.rs:16:25 - | -LL | const fn equals_self<T: ~const Foo>(t: &T) -> bool { - | ^^^^^^^^^^ required by this bound in `equals_self` + | ^^^^^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr b/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr index 4470e287c..ffc24ec6e 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const-closure-trait-method-fail.stderr @@ -1,22 +1,15 @@ error[E0277]: the trait bound `(): ~const Tr` is not satisfied in `fn(()) -> i32 {<() as Tr>::a}` - --> $DIR/const-closure-trait-method-fail.rs:16:42 + --> $DIR/const-closure-trait-method-fail.rs:16:23 | LL | const _: () = assert!(need_const_closure(Tr::a) == 42); - | ------------------ ^^^^^ within `fn(()) -> i32 {<() as Tr>::a}`, the trait `~const Tr` is not implemented for `()` - | | - | required by a bound introduced by this call + | ^^^^^^^^^^^^^^^^^^^^^^^^^ within `fn(()) -> i32 {<() as Tr>::a}`, the trait `~const Tr` is not implemented for `()` | note: the trait `Tr` is implemented for `()`, but that implementation is not `const` - --> $DIR/const-closure-trait-method-fail.rs:16:42 + --> $DIR/const-closure-trait-method-fail.rs:16:23 | LL | const _: () = assert!(need_const_closure(Tr::a) == 42); - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^ = note: required because it appears within the type `fn(()) -> i32 {<() as Tr>::a}` -note: required by a bound in `need_const_closure` - --> $DIR/const-closure-trait-method-fail.rs:12:32 - | -LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `need_const_closure` error: aborting due to previous error diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr new file mode 100644 index 000000000..bcdc80f82 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.precise.stderr @@ -0,0 +1,50 @@ +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail-2.rs:31:23 + | +LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` + --> $DIR/const-drop-fail-2.rs:31:23 + | +LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail-2.rs:21:35 + | +LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail-2.rs:33:5 + | +LL | ConstDropImplWithBounds(PhantomData) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` + --> $DIR/const-drop-fail-2.rs:33:5 + | +LL | ConstDropImplWithBounds(PhantomData) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail-2.rs:21:35 + | +LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not + --> $DIR/const-drop-fail-2.rs:39:9 + | +LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { + | ^^^^^^^^ + | +note: the implementor must specify the same requirement + --> $DIR/const-drop-fail-2.rs:37:1 + | +LL | struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0277, E0367. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.rs b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.rs new file mode 100644 index 000000000..6a252c5d3 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.rs @@ -0,0 +1,46 @@ +// revisions: stock precise +#![feature(const_trait_impl)] +#![feature(const_mut_refs)] +#![cfg_attr(precise, feature(const_precise_live_drops))] + +use std::marker::{Destruct, PhantomData}; + +struct NonTrivialDrop; + +impl Drop for NonTrivialDrop { + fn drop(&mut self) { + println!("Non trivial drop"); + } +} + +#[const_trait] +trait A { fn a() { } } + +impl A for NonTrivialDrop {} + +struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); + +impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { + fn drop(&mut self) { + T::a(); + } +} + +const fn check<T: ~const Destruct>(_: T) {} + +const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( + //~^ ERROR the trait bound + ConstDropImplWithBounds(PhantomData) + //~^ ERROR the trait bound +); + +struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); + +impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { +//~^ ERROR `Drop` impl requires `T: ~const A` but the struct it is implemented for does not + fn drop(&mut self) { + T::a(); + } +} + +fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr new file mode 100644 index 000000000..bcdc80f82 --- /dev/null +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail-2.stock.stderr @@ -0,0 +1,50 @@ +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail-2.rs:31:23 + | +LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` + --> $DIR/const-drop-fail-2.rs:31:23 + | +LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail-2.rs:21:35 + | +LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied + --> $DIR/const-drop-fail-2.rs:33:5 + | +LL | ConstDropImplWithBounds(PhantomData) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` + | +note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` + --> $DIR/const-drop-fail-2.rs:33:5 + | +LL | ConstDropImplWithBounds(PhantomData) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: required by a bound in `ConstDropImplWithBounds` + --> $DIR/const-drop-fail-2.rs:21:35 + | +LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); + | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` + +error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not + --> $DIR/const-drop-fail-2.rs:39:9 + | +LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { + | ^^^^^^^^ + | +note: the implementor must specify the same requirement + --> $DIR/const-drop-fail-2.rs:37:1 + | +LL | struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0277, E0367. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr index 796c0d388..40caada51 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.precise.stderr @@ -1,99 +1,58 @@ error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:44:5 + --> $DIR/const-drop-fail.rs:26:23 | -LL | const _: () = check($exp); - | ----- required by a bound introduced by this call +LL | const _: () = check($exp); + | ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop` ... -LL | NonTrivialDrop, - | ^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop` +LL | / check_all! { +LL | | NonTrivialDrop, +LL | | ConstImplWithDropGlue(NonTrivialDrop), +LL | | } + | |_- in this macro invocation | - = note: the trait bound `NonTrivialDrop: ~const Destruct` is not satisfied -note: required by a bound in `check` - --> $DIR/const-drop-fail.rs:35:19 - | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` -help: consider borrowing here +note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` + --> $DIR/const-drop-fail.rs:26:23 | -LL | &NonTrivialDrop, - | + -LL | &mut NonTrivialDrop, - | ++++ +LL | const _: () = check($exp); + | ^^^^^^^^^^^ +... +LL | / check_all! { +LL | | NonTrivialDrop, +LL | | ConstImplWithDropGlue(NonTrivialDrop), +LL | | } + | |_- in this macro invocation + = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:46:5 + --> $DIR/const-drop-fail.rs:26:23 | -LL | const _: () = check($exp); - | ----- required by a bound introduced by this call +LL | const _: () = check($exp); + | ^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop` ... -LL | ConstImplWithDropGlue(NonTrivialDrop), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop` +LL | / check_all! { +LL | | NonTrivialDrop, +LL | | ConstImplWithDropGlue(NonTrivialDrop), +LL | | } + | |_- in this macro invocation | note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:46:5 + --> $DIR/const-drop-fail.rs:26:23 | -LL | ConstImplWithDropGlue(NonTrivialDrop), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const _: () = check($exp); + | ^^^^^^^^^^^ +... +LL | / check_all! { +LL | | NonTrivialDrop, +LL | | ConstImplWithDropGlue(NonTrivialDrop), +LL | | } + | |_- in this macro invocation note: required because it appears within the type `ConstImplWithDropGlue` --> $DIR/const-drop-fail.rs:16:8 | LL | struct ConstImplWithDropGlue(NonTrivialDrop); | ^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `check` - --> $DIR/const-drop-fail.rs:35:19 - | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` - -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail.rs:48:47 - | -LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | ----------------------------------------- ^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` - | | - | required by a bound introduced by this call - | -note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:48:47 - | -LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | ^^^^^^^^^^^ -note: required by a bound in `ConstDropImplWithBounds` - --> $DIR/const-drop-fail.rs:27:35 - | -LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); - | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` - -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail.rs:48:5 - | -LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` - | -note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:48:5 - | -LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `ConstDropImplWithBounds` - --> $DIR/const-drop-fail.rs:27:35 - | -LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); - | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` - -error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not - --> $DIR/const-drop-fail.rs:55:9 - | -LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { - | ^^^^^^^^ - | -note: the implementor must specify the same requirement - --> $DIR/const-drop-fail.rs:53:1 - | -LL | struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0367. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.rs b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.rs index d36c7f81c..c4bdb9ef5 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.rs +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.rs @@ -19,44 +19,19 @@ impl const Drop for ConstImplWithDropGlue { fn drop(&mut self) {} } -#[const_trait] -trait A { fn a() { } } - -impl A for NonTrivialDrop {} - -struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); - -impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { - fn drop(&mut self) { - T::a(); - } -} - const fn check<T: ~const Destruct>(_: T) {} macro_rules! check_all { ($($exp:expr),*$(,)?) => {$( const _: () = check($exp); + //~^ ERROR can't drop + //~| ERROR can't drop )*}; } check_all! { NonTrivialDrop, - //~^ ERROR can't drop ConstImplWithDropGlue(NonTrivialDrop), - //~^ ERROR can't drop - ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - //~^ ERROR the trait bound - //~| ERROR the trait bound -} - -struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); - -impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { -//~^ ERROR `Drop` impl requires `T: ~const A` but the struct it is implemented for does not - fn drop(&mut self) { - T::a(); - } } fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr index 796c0d388..40caada51 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const-drop-fail.stock.stderr @@ -1,99 +1,58 @@ error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:44:5 + --> $DIR/const-drop-fail.rs:26:23 | -LL | const _: () = check($exp); - | ----- required by a bound introduced by this call +LL | const _: () = check($exp); + | ^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop` ... -LL | NonTrivialDrop, - | ^^^^^^^^^^^^^^ the trait `~const Destruct` is not implemented for `NonTrivialDrop` +LL | / check_all! { +LL | | NonTrivialDrop, +LL | | ConstImplWithDropGlue(NonTrivialDrop), +LL | | } + | |_- in this macro invocation | - = note: the trait bound `NonTrivialDrop: ~const Destruct` is not satisfied -note: required by a bound in `check` - --> $DIR/const-drop-fail.rs:35:19 - | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` -help: consider borrowing here +note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` + --> $DIR/const-drop-fail.rs:26:23 | -LL | &NonTrivialDrop, - | + -LL | &mut NonTrivialDrop, - | ++++ +LL | const _: () = check($exp); + | ^^^^^^^^^^^ +... +LL | / check_all! { +LL | | NonTrivialDrop, +LL | | ConstImplWithDropGlue(NonTrivialDrop), +LL | | } + | |_- in this macro invocation + = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: can't drop `NonTrivialDrop` in const contexts - --> $DIR/const-drop-fail.rs:46:5 + --> $DIR/const-drop-fail.rs:26:23 | -LL | const _: () = check($exp); - | ----- required by a bound introduced by this call +LL | const _: () = check($exp); + | ^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop` ... -LL | ConstImplWithDropGlue(NonTrivialDrop), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ within `ConstImplWithDropGlue`, the trait `~const Destruct` is not implemented for `NonTrivialDrop` +LL | / check_all! { +LL | | NonTrivialDrop, +LL | | ConstImplWithDropGlue(NonTrivialDrop), +LL | | } + | |_- in this macro invocation | note: the trait `Destruct` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:46:5 + --> $DIR/const-drop-fail.rs:26:23 | -LL | ConstImplWithDropGlue(NonTrivialDrop), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const _: () = check($exp); + | ^^^^^^^^^^^ +... +LL | / check_all! { +LL | | NonTrivialDrop, +LL | | ConstImplWithDropGlue(NonTrivialDrop), +LL | | } + | |_- in this macro invocation note: required because it appears within the type `ConstImplWithDropGlue` --> $DIR/const-drop-fail.rs:16:8 | LL | struct ConstImplWithDropGlue(NonTrivialDrop); | ^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `check` - --> $DIR/const-drop-fail.rs:35:19 - | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` - -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail.rs:48:47 - | -LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | ----------------------------------------- ^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` - | | - | required by a bound introduced by this call - | -note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:48:47 - | -LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | ^^^^^^^^^^^ -note: required by a bound in `ConstDropImplWithBounds` - --> $DIR/const-drop-fail.rs:27:35 - | -LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); - | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` - -error[E0277]: the trait bound `NonTrivialDrop: ~const A` is not satisfied - --> $DIR/const-drop-fail.rs:48:5 - | -LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `~const A` is not implemented for `NonTrivialDrop` - | -note: the trait `A` is implemented for `NonTrivialDrop`, but that implementation is not `const` - --> $DIR/const-drop-fail.rs:48:5 - | -LL | ConstDropImplWithBounds::<NonTrivialDrop>(PhantomData), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -note: required by a bound in `ConstDropImplWithBounds` - --> $DIR/const-drop-fail.rs:27:35 - | -LL | struct ConstDropImplWithBounds<T: ~const A>(PhantomData<T>); - | ^^^^^^^^ required by this bound in `ConstDropImplWithBounds` - -error[E0367]: `Drop` impl requires `T: ~const A` but the struct it is implemented for does not - --> $DIR/const-drop-fail.rs:55:9 - | -LL | impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { - | ^^^^^^^^ - | -note: the implementor must specify the same requirement - --> $DIR/const-drop-fail.rs:53:1 - | -LL | struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the macro `check_all` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 5 previous errors +error: aborting due to 2 previous errors -Some errors have detailed explanations: E0277, E0367. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs index 92843a8a2..ed6699f37 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs +++ b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.rs @@ -9,5 +9,6 @@ impl Default for A { #[derive_const(Default)] pub struct S(A); //~^ cannot call non-const fn +//~| the trait bound fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr index 96e0c78b9..653037ef3 100644 --- a/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/const_derives/derive-const-non-const-type.stderr @@ -1,3 +1,25 @@ +error[E0277]: the trait bound `A: Default` is not satisfied + --> $DIR/derive-const-non-const-type.rs:10:14 + | +LL | #[derive_const(Default)] + | ------- in this derive macro expansion +LL | pub struct S(A); + | ^ the trait `~const Default` is not implemented for `A` + | +note: the trait `Default` is implemented for `A`, but that implementation is not `const` + --> $DIR/derive-const-non-const-type.rs:10:14 + | +LL | #[derive_const(Default)] + | ------- in this derive macro expansion +LL | pub struct S(A); + | ^ + = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `A` with `#[derive(Default)]` + | +LL + #[derive(Default)] +LL | pub struct A; + | + error[E0015]: cannot call non-const fn `<A as Default>::default` in constant functions --> $DIR/derive-const-non-const-type.rs:10:14 | @@ -10,6 +32,7 @@ LL | pub struct S(A); = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable = note: this error originates in the derive macro `Default` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0015`. +Some errors have detailed explanations: E0015, E0277. +For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr b/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr index a244ab10c..26644f72c 100644 --- a/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/default-method-body-is-const-body-checking.stderr @@ -1,19 +1,14 @@ error[E0277]: the trait bound `(): ~const Tr` is not satisfied - --> $DIR/default-method-body-is-const-body-checking.rs:12:15 + --> $DIR/default-method-body-is-const-body-checking.rs:12:9 | LL | foo::<()>(); - | ^^ the trait `~const Tr` is not implemented for `()` + | ^^^^^^^^^^^ the trait `~const Tr` is not implemented for `()` | note: the trait `Tr` is implemented for `()`, but that implementation is not `const` - --> $DIR/default-method-body-is-const-body-checking.rs:12:15 + --> $DIR/default-method-body-is-const-body-checking.rs:12:9 | LL | foo::<()>(); - | ^^ -note: required by a bound in `foo` - --> $DIR/default-method-body-is-const-body-checking.rs:7:28 - | -LL | const fn foo<T>() where T: ~const Tr {} - | ^^^^^^^^^ required by this bound in `foo` + | ^^^^^^^^^^^ error: aborting due to previous error diff --git a/tests/ui/rfc-2632-const-trait-impl/function-pointer-does-not-require-const.rs b/tests/ui/rfc-2632-const-trait-impl/function-pointer-does-not-require-const.rs index 1726cf82e..60790e297 100644 --- a/tests/ui/rfc-2632-const-trait-impl/function-pointer-does-not-require-const.rs +++ b/tests/ui/rfc-2632-const-trait-impl/function-pointer-does-not-require-const.rs @@ -1,8 +1,15 @@ // check-pass +#![feature(const_trait_impl)] -type I32Cmp = fn(&i32, &i32) -> core::cmp::Ordering; -pub const fn min_by_i32() -> fn(i32, i32, I32Cmp) -> i32 { - core::cmp::min_by +#[const_trait] +pub trait Test {} + +impl Test for () {} + +pub const fn test<T: ~const Test>() {} + +pub const fn min_by_i32() -> fn() { + test::<()> } fn main() {} diff --git a/tests/ui/rfc-2632-const-trait-impl/gate.rs b/tests/ui/rfc-2632-const-trait-impl/gate.rs index f2cd26c91..d1c93ab9f 100644 --- a/tests/ui/rfc-2632-const-trait-impl/gate.rs +++ b/tests/ui/rfc-2632-const-trait-impl/gate.rs @@ -1,5 +1,13 @@ // gate-test-const_closures + fn main() { (const || {})(); //~^ ERROR: const closures are experimental } + +macro_rules! e { + ($e:expr) => {} +} + +e!((const || {})); +//~^ ERROR const closures are experimental diff --git a/tests/ui/rfc-2632-const-trait-impl/gate.stderr b/tests/ui/rfc-2632-const-trait-impl/gate.stderr index 30edc4127..11cc2cd56 100644 --- a/tests/ui/rfc-2632-const-trait-impl/gate.stderr +++ b/tests/ui/rfc-2632-const-trait-impl/gate.stderr @@ -1,12 +1,21 @@ error[E0658]: const closures are experimental - --> $DIR/gate.rs:3:6 + --> $DIR/gate.rs:4:6 | LL | (const || {})(); - | ^^^^^^^^^^^ + | ^^^^^ | = note: see issue #106003 <https://github.com/rust-lang/rust/issues/106003> for more information = help: add `#![feature(const_closures)]` to the crate attributes to enable -error: aborting due to previous error +error[E0658]: const closures are experimental + --> $DIR/gate.rs:12:5 + | +LL | e!((const || {})); + | ^^^^^ + | + = note: see issue #106003 <https://github.com/rust-lang/rust/issues/106003> for more information + = help: add `#![feature(const_closures)]` to the crate attributes to enable + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfc-2632-const-trait-impl/nested-closure.rs b/tests/ui/rfc-2632-const-trait-impl/nested-closure.rs index a85113600..0b423b340 100644 --- a/tests/ui/rfc-2632-const-trait-impl/nested-closure.rs +++ b/tests/ui/rfc-2632-const-trait-impl/nested-closure.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(const_trait_impl, once_cell)] +#![feature(const_trait_impl, lazy_cell)] use std::sync::LazyLock; diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-main.rs b/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-main.rs new file mode 100644 index 000000000..0d59e5026 --- /dev/null +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-main.rs @@ -0,0 +1,7 @@ +// only-x86_64 + +#![feature(target_feature_11)] + +#[target_feature(enable = "avx2")] +fn main() {} +//~^ ERROR `main` function is not allowed to have `#[target_feature]` diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-main.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-main.stderr new file mode 100644 index 000000000..cfafbd522 --- /dev/null +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-main.stderr @@ -0,0 +1,8 @@ +error: `main` function is not allowed to have `#[target_feature]` + --> $DIR/issue-108645-target-feature-on-main.rs:6:1 + | +LL | fn main() {} + | ^^^^^^^^^ `main` function is not allowed to have `#[target_feature]` + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-start.rs b/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-start.rs new file mode 100644 index 000000000..50e8ce2fd --- /dev/null +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-start.rs @@ -0,0 +1,9 @@ +// only-x86_64 + +#![feature(start)] +#![feature(target_feature_11)] + +#[start] +#[target_feature(enable = "avx2")] +//~^ ERROR `start` is not allowed to have `#[target_feature]` +fn start(_argc: isize, _argv: *const *const u8) -> isize { 0 } diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-start.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-start.stderr new file mode 100644 index 000000000..07687f3c7 --- /dev/null +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/issue-108645-target-feature-on-start.stderr @@ -0,0 +1,11 @@ +error: `start` is not allowed to have `#[target_feature]` + --> $DIR/issue-108645-target-feature-on-start.rs:7:1 + | +LL | #[target_feature(enable = "avx2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | fn start(_argc: isize, _argv: *const *const u8) -> isize { 0 } + | -------------------------------------------------------- `start` is not allowed to have `#[target_feature]` + +error: aborting due to previous error + diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs b/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs index 7314fa8cc..9108f27b5 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.rs @@ -18,4 +18,10 @@ impl Foo for Bar { unsafe fn unsf_foo(&self) {} } +trait Qux { + #[target_feature(enable = "sse2")] + //~^ ERROR cannot be applied to safe trait method + fn foo(&self) {} +} + fn main() {} diff --git a/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr b/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr index 07d6e0900..eb0f18edd 100644 --- a/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr +++ b/tests/ui/rfcs/rfc-2396-target_feature-11/trait-impl.stderr @@ -1,4 +1,13 @@ error: `#[target_feature(..)]` cannot be applied to safe trait method + --> $DIR/trait-impl.rs:22:5 + | +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method +LL | +LL | fn foo(&self) {} + | ------------- not an `unsafe` function + +error: `#[target_feature(..)]` cannot be applied to safe trait method --> $DIR/trait-impl.rs:13:5 | LL | #[target_feature(enable = "sse2")] @@ -7,5 +16,5 @@ LL | LL | fn foo(&self) {} | ------------- not an `unsafe` function -error: aborting due to previous error +error: aborting due to 2 previous errors diff --git a/tests/ui/runtime/backtrace-debuginfo.rs b/tests/ui/runtime/backtrace-debuginfo.rs index 8b5466b6c..5d233b38d 100644 --- a/tests/ui/runtime/backtrace-debuginfo.rs +++ b/tests/ui/runtime/backtrace-debuginfo.rs @@ -9,7 +9,6 @@ // compile-flags:-g -Copt-level=0 -Cllvm-args=-enable-tail-merge=0 // compile-flags:-Cforce-frame-pointers=yes // compile-flags:-Cstrip=none -// ignore-pretty issue #37195 // ignore-emscripten spawning processes is not supported // ignore-sgx no processes // ignore-fuchsia Backtrace not symbolized, trace different line alignment diff --git a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed index 85d106bc1..ede0c2e8e 100644 --- a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed +++ b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.fixed @@ -18,9 +18,11 @@ mod foo { fn main() { let _: <foo::Baz as crate::foo::Foo>::Bar = (); //~^ ERROR absolute paths must start with - //~| this is accepted in the current edition + //~| WARN this is accepted in the current edition + //~| ERROR absolute paths must start with + //~| WARN this is accepted in the current edition let _: <crate::foo::Baz as foo::Foo>::Bar = (); //~^ ERROR absolute paths must start with - //~| this is accepted in the current edition + //~| WARN this is accepted in the current edition } diff --git a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs index 9ff3c2e5f..48b091ddb 100644 --- a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs +++ b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.rs @@ -18,9 +18,11 @@ mod foo { fn main() { let _: <foo::Baz as ::foo::Foo>::Bar = (); //~^ ERROR absolute paths must start with - //~| this is accepted in the current edition + //~| WARN this is accepted in the current edition + //~| ERROR absolute paths must start with + //~| WARN this is accepted in the current edition let _: <::foo::Baz as foo::Foo>::Bar = (); //~^ ERROR absolute paths must start with - //~| this is accepted in the current edition + //~| WARN this is accepted in the current edition } diff --git a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr index e1709db09..497ee440d 100644 --- a/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr +++ b/tests/ui/rust-2018/edition-lint-fully-qualified-paths.stderr @@ -13,7 +13,16 @@ LL | #![deny(absolute_paths_not_starting_with_crate)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition - --> $DIR/edition-lint-fully-qualified-paths.rs:23:13 + --> $DIR/edition-lint-fully-qualified-paths.rs:19:25 + | +LL | let _: <foo::Baz as ::foo::Foo>::Bar = (); + | ^^^^^^^^^^ help: use `crate`: `crate::foo::Foo` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> + +error: absolute paths must start with `self`, `super`, `crate`, or an external crate name in the 2018 edition + --> $DIR/edition-lint-fully-qualified-paths.rs:25:13 | LL | let _: <::foo::Baz as foo::Foo>::Bar = (); | ^^^^^^^^^^ help: use `crate`: `crate::foo::Baz` @@ -21,5 +30,5 @@ LL | let _: <::foo::Baz as foo::Foo>::Bar = (); = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! = note: for more information, see issue #53130 <https://github.com/rust-lang/rust/issues/53130> -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/rust-2018/issue-52202-use-suggestions.stderr b/tests/ui/rust-2018/issue-52202-use-suggestions.stderr index 38cd9713d..9933b9243 100644 --- a/tests/ui/rust-2018/issue-52202-use-suggestions.stderr +++ b/tests/ui/rust-2018/issue-52202-use-suggestions.stderr @@ -6,13 +6,13 @@ LL | let _d = Drain {}; | help: consider importing one of these items | -LL | use crate::plumbing::Drain; +LL + use crate::plumbing::Drain; | -LL | use std::collections::binary_heap::Drain; +LL + use std::collections::binary_heap::Drain; | -LL | use std::collections::hash_map::Drain; +LL + use std::collections::hash_map::Drain; | -LL | use std::collections::hash_set::Drain; +LL + use std::collections::hash_set::Drain; | and 3 other candidates diff --git a/tests/ui/rust-2018/trait-import-suggestions.stderr b/tests/ui/rust-2018/trait-import-suggestions.stderr index 6454b6045..325c5976e 100644 --- a/tests/ui/rust-2018/trait-import-suggestions.stderr +++ b/tests/ui/rust-2018/trait-import-suggestions.stderr @@ -10,7 +10,7 @@ LL | x.foobar(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use crate::foo::foobar::Foobar; +LL + use crate::foo::foobar::Foobar; | error[E0599]: no method named `bar` found for type `u32` in the current scope @@ -25,7 +25,7 @@ LL | x.bar(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use crate::foo::Bar; +LL + use crate::foo::Bar; | error[E0599]: no method named `baz` found for type `u32` in the current scope @@ -43,7 +43,7 @@ LL | let y = u32::from_str("33"); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use std::str::FromStr; +LL + use std::str::FromStr; | help: there is an associated function with a similar name | diff --git a/tests/ui/rust-2018/uniform-paths/issue-87932.stderr b/tests/ui/rust-2018/uniform-paths/issue-87932.stderr index b52720ae3..ac2baa359 100644 --- a/tests/ui/rust-2018/uniform-paths/issue-87932.stderr +++ b/tests/ui/rust-2018/uniform-paths/issue-87932.stderr @@ -10,7 +10,7 @@ LL | A::deserialize(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use <crate::A as issue_87932_a::Deserialize>::deserialize::_a::Deserialize; +LL + use <crate::A as issue_87932_a::Deserialize>::deserialize::_a::Deserialize; | error: aborting due to previous error diff --git a/tests/ui/rust-2021/future-prelude-collision-shadow.stderr b/tests/ui/rust-2021/future-prelude-collision-shadow.stderr index 3d21b735a..9dfaf13e2 100644 --- a/tests/ui/rust-2021/future-prelude-collision-shadow.stderr +++ b/tests/ui/rust-2021/future-prelude-collision-shadow.stderr @@ -8,9 +8,9 @@ LL | let _: u32 = 3u8.try_into().unwrap(); = note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021 help: the following traits are implemented but not in scope; perhaps add a `use` for one of them: | -LL | use crate::m::TryIntoU32; +LL + use crate::m::TryIntoU32; | -LL | use std::convert::TryInto; +LL + use std::convert::TryInto; | error: aborting due to previous error diff --git a/tests/ui/rustdoc/doc-primitive.rs b/tests/ui/rustdoc/doc-primitive.rs new file mode 100644 index 000000000..4336961e3 --- /dev/null +++ b/tests/ui/rustdoc/doc-primitive.rs @@ -0,0 +1,8 @@ +#![deny(invalid_doc_attributes)] + +#[doc(primitive = "foo")] +//~^ ERROR unknown `doc` attribute `primitive` +//~| WARN +mod bar {} + +fn main() {} diff --git a/tests/ui/rustdoc/doc-primitive.stderr b/tests/ui/rustdoc/doc-primitive.stderr new file mode 100644 index 000000000..d61eb3816 --- /dev/null +++ b/tests/ui/rustdoc/doc-primitive.stderr @@ -0,0 +1,16 @@ +error: unknown `doc` attribute `primitive` + --> $DIR/doc-primitive.rs:3:7 + | +LL | #[doc(primitive = "foo")] + | ^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> +note: the lint level is defined here + --> $DIR/doc-primitive.rs:1:9 + | +LL | #![deny(invalid_doc_attributes)] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/rustdoc/feature-gate-doc_primitive.rs b/tests/ui/rustdoc/feature-gate-doc_primitive.rs index 18e99e72f..78fcd9075 100644 --- a/tests/ui/rustdoc/feature-gate-doc_primitive.rs +++ b/tests/ui/rustdoc/feature-gate-doc_primitive.rs @@ -1,7 +1,5 @@ -// check-pass -#[doc(primitive = "usize")] -//~^ WARNING `doc(primitive)` should never have been stable -//~| WARNING hard error in a future release +#[rustc_doc_primitive = "usize"] +//~^ ERROR `rustc_doc_primitive` is a rustc internal attribute /// Some docs mod usize {} diff --git a/tests/ui/rustdoc/feature-gate-doc_primitive.stderr b/tests/ui/rustdoc/feature-gate-doc_primitive.stderr index 194b2d87d..592088067 100644 --- a/tests/ui/rustdoc/feature-gate-doc_primitive.stderr +++ b/tests/ui/rustdoc/feature-gate-doc_primitive.stderr @@ -1,12 +1,11 @@ -warning: `doc(primitive)` should never have been stable - --> $DIR/feature-gate-doc_primitive.rs:2:7 +error[E0658]: `rustc_doc_primitive` is a rustc internal attribute + --> $DIR/feature-gate-doc_primitive.rs:1:1 | -LL | #[doc(primitive = "usize")] - | ^^^^^^^^^^^^^^^^^^^ +LL | #[rustc_doc_primitive = "usize"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #82730 <https://github.com/rust-lang/rust/issues/82730> - = note: `#[warn(invalid_doc_attributes)]` on by default + = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable -warning: 1 warning emitted +error: aborting due to previous error +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/self/arbitrary_self_types_trait.rs b/tests/ui/self/arbitrary_self_types_trait.rs index 973c7cae8..c4651ec71 100644 --- a/tests/ui/self/arbitrary_self_types_trait.rs +++ b/tests/ui/self/arbitrary_self_types_trait.rs @@ -1,4 +1,5 @@ // run-pass +#![allow(unused_allocation)] use std::rc::Rc; @@ -13,7 +14,7 @@ impl Trait for Vec<i32> { } fn main() { - let v = vec![1,2,3]; + let v = vec![1, 2, 3]; - assert_eq!(&[1,2,3], Box::new(Rc::new(v)).trait_method()); + assert_eq!(&[1, 2, 3], Box::new(Rc::new(v)).trait_method()); } diff --git a/tests/ui/self/class-missing-self.stderr b/tests/ui/self/class-missing-self.stderr index 063c3f013..3c37d8197 100644 --- a/tests/ui/self/class-missing-self.stderr +++ b/tests/ui/self/class-missing-self.stderr @@ -16,7 +16,7 @@ LL | self.sleep(); | +++++ help: consider importing this function | -LL | use std::thread::sleep; +LL + use std::thread::sleep; | error: aborting due to 2 previous errors diff --git a/tests/ui/shadowed/shadowed-trait-methods.stderr b/tests/ui/shadowed/shadowed-trait-methods.stderr index c3b9084af..1af0400c8 100644 --- a/tests/ui/shadowed/shadowed-trait-methods.stderr +++ b/tests/ui/shadowed/shadowed-trait-methods.stderr @@ -10,7 +10,7 @@ LL | ().f() = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use foo::T; +LL + use foo::T; | error: aborting due to previous error diff --git a/tests/ui/simd/monomorphize-heterogeneous.rs b/tests/ui/simd/monomorphize-heterogeneous.rs new file mode 100644 index 000000000..42e380dbb --- /dev/null +++ b/tests/ui/simd/monomorphize-heterogeneous.rs @@ -0,0 +1,9 @@ +#![feature(repr_simd)] + +#[repr(simd)] +struct I64F64(i64, f64); +//~^ ERROR SIMD vector should be homogeneous + +static X: I64F64 = I64F64(1, 2.0); + +fn main() {} diff --git a/tests/ui/simd/monomorphize-heterogeneous.stderr b/tests/ui/simd/monomorphize-heterogeneous.stderr new file mode 100644 index 000000000..e7b41cd78 --- /dev/null +++ b/tests/ui/simd/monomorphize-heterogeneous.stderr @@ -0,0 +1,9 @@ +error[E0076]: SIMD vector should be homogeneous + --> $DIR/monomorphize-heterogeneous.rs:4:1 + | +LL | struct I64F64(i64, f64); + | ^^^^^^^^^^^^^ SIMD elements must have the same type + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0076`. diff --git a/tests/ui/simple_global_asm.rs b/tests/ui/simple_global_asm.rs index 3c69379ff..c3b2f2e0b 100644 --- a/tests/ui/simple_global_asm.rs +++ b/tests/ui/simple_global_asm.rs @@ -1,4 +1,5 @@ // run-pass +// needs-asm-support #![feature(naked_functions)] #![allow(dead_code)] diff --git a/tests/ui/span/E0204.rs b/tests/ui/span/E0204.rs index 174de8cdd..8793a05c8 100644 --- a/tests/ui/span/E0204.rs +++ b/tests/ui/span/E0204.rs @@ -2,9 +2,9 @@ struct Foo { foo: Vec<u32>, } -impl Copy for Foo { } //~ ERROR may not be implemented for this type +impl Copy for Foo { } //~ ERROR cannot be implemented for this type -#[derive(Copy)] //~ ERROR may not be implemented for this type +#[derive(Copy)] //~ ERROR cannot be implemented for this type struct Foo2<'a> { ty: &'a mut bool, } @@ -14,9 +14,9 @@ enum EFoo { Baz, } -impl Copy for EFoo { } //~ ERROR may not be implemented for this type +impl Copy for EFoo { } //~ ERROR cannot be implemented for this type -#[derive(Copy)] //~ ERROR may not be implemented for this type +#[derive(Copy)] //~ ERROR cannot be implemented for this type enum EFoo2<'a> { Bar(&'a mut bool), Baz, diff --git a/tests/ui/span/E0204.stderr b/tests/ui/span/E0204.stderr index 0b2166eed..3a0afb541 100644 --- a/tests/ui/span/E0204.stderr +++ b/tests/ui/span/E0204.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/E0204.rs:5:15 | LL | foo: Vec<u32>, @@ -7,7 +7,7 @@ LL | foo: Vec<u32>, LL | impl Copy for Foo { } | ^^^ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/E0204.rs:7:10 | LL | #[derive(Copy)] @@ -18,7 +18,7 @@ LL | ty: &'a mut bool, | = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/E0204.rs:17:15 | LL | Bar { x: Vec<u32> }, @@ -27,7 +27,7 @@ LL | Bar { x: Vec<u32> }, LL | impl Copy for EFoo { } | ^^^^ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/E0204.rs:19:10 | LL | #[derive(Copy)] diff --git a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr index 37b2f4138..60433e1c2 100644 --- a/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr +++ b/tests/ui/span/drop-location-span-error-rust-2021-incompatible-closure-captures-96258.stderr @@ -15,7 +15,7 @@ LL | interval: Duration, | help: consider importing this struct | -LL | use std::time::Duration; +LL + use std::time::Duration; | error: aborting due to 2 previous errors diff --git a/tests/ui/span/issue-35987.stderr b/tests/ui/span/issue-35987.stderr index 057d40ac0..88c86d2a9 100644 --- a/tests/ui/span/issue-35987.stderr +++ b/tests/ui/span/issue-35987.stderr @@ -11,7 +11,7 @@ LL | impl<T: Clone, Add> Add for Foo<T> { | help: consider importing this trait instead | -LL | use std::ops::Add; +LL + use std::ops::Add; | error: aborting due to previous error diff --git a/tests/ui/span/issue-71363.stderr b/tests/ui/span/issue-71363.stderr index cb5cc3202..90b623e89 100644 --- a/tests/ui/span/issue-71363.stderr +++ b/tests/ui/span/issue-71363.stderr @@ -21,7 +21,8 @@ note: required by a bound in `std::error::Error` --> $SRC_DIR/core/src/error.rs:LL:COL help: consider annotating `MyError` with `#[derive(Debug)]` | -3 | #[derive(Debug)] +3 + #[derive(Debug)] +4 | struct MyError; | error: aborting due to 2 previous errors diff --git a/tests/ui/specialization/issue-59435.stderr b/tests/ui/specialization/issue-59435.stderr index 211459406..e8a12e4d9 100644 --- a/tests/ui/specialization/issue-59435.stderr +++ b/tests/ui/specialization/issue-59435.stderr @@ -11,7 +11,8 @@ LL | type MyType: Default; | ^^^^^^^ required by this bound in `MyTrait::MyType` help: consider annotating `MyStruct` with `#[derive(Default)]` | -LL | #[derive(Default)] +LL + #[derive(Default)] +LL | struct MyStruct {} | error: aborting due to previous error diff --git a/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs b/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs new file mode 100644 index 000000000..5fd7c647c --- /dev/null +++ b/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.rs @@ -0,0 +1,12 @@ +#![feature(min_specialization)] + +// An impl that has an erroneous const substitution should not specialize one +// that is well-formed. +#[derive(Clone)] +struct S<const L: usize>; + +impl<const N: i32> Copy for S<N> {} +//~^ ERROR the constant `N` is not of type `usize` +impl<const M: usize> Copy for S<M> {} + +fn main() {} diff --git a/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.stderr b/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.stderr new file mode 100644 index 000000000..83f311efd --- /dev/null +++ b/tests/ui/specialization/min_specialization/bad-const-wf-doesnt-specialize.stderr @@ -0,0 +1,14 @@ +error: the constant `N` is not of type `usize` + --> $DIR/bad-const-wf-doesnt-specialize.rs:8:29 + | +LL | impl<const N: i32> Copy for S<N> {} + | ^^^^ expected `usize`, found `i32` + | +note: required by a bound in `S` + --> $DIR/bad-const-wf-doesnt-specialize.rs:6:10 + | +LL | struct S<const L: usize>; + | ^^^^^^^^^^^^^^ required by this bound in `S` + +error: aborting due to previous error + diff --git a/tests/ui/stability-attribute/auxiliary/const-stability-attribute-implies.rs b/tests/ui/stability-attribute/auxiliary/const-stability-attribute-implies.rs new file mode 100644 index 000000000..f78871b5a --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/const-stability-attribute-implies.rs @@ -0,0 +1,12 @@ +#![crate_type = "lib"] +#![feature(staged_api)] +#![stable(feature = "stability_attribute_implies", since = "1.0.0")] +#![rustc_const_stable(feature = "stability_attribute_implies", since = "1.0.0")] + +#[stable(feature = "stability_attribute_implies", since = "1.0.0")] +#[rustc_const_stable(feature = "const_foo", since = "1.62.0")] +pub const fn foo() {} + +#[stable(feature = "stability_attribute_implies", since = "1.0.0")] +#[rustc_const_unstable(feature = "const_foobar", issue = "1", implied_by = "const_foo")] +pub const fn foobar() {} diff --git a/tests/ui/stability-attribute/auxiliary/similar-unstable-method.rs b/tests/ui/stability-attribute/auxiliary/similar-unstable-method.rs new file mode 100644 index 000000000..8804186ee --- /dev/null +++ b/tests/ui/stability-attribute/auxiliary/similar-unstable-method.rs @@ -0,0 +1,13 @@ +#![feature(staged_api)] +#![stable(feature = "libfoo", since = "1.0.0")] + +#[unstable(feature = "foo", reason = "...", issue = "none")] +pub fn foo() {} + +#[stable(feature = "libfoo", since = "1.0.0")] +pub struct Foo; + +impl Foo { + #[unstable(feature = "foo", reason = "...", issue = "none")] + pub fn foo(&self) {} +} diff --git a/tests/ui/stability-attribute/const-stability-attribute-implies-missing.rs b/tests/ui/stability-attribute/const-stability-attribute-implies-missing.rs new file mode 100644 index 000000000..6d6d793c6 --- /dev/null +++ b/tests/ui/stability-attribute/const-stability-attribute-implies-missing.rs @@ -0,0 +1,16 @@ +#![crate_type = "lib"] +#![feature(staged_api)] +#![stable(feature = "stability_attribute_implies", since = "1.0.0")] +#![rustc_const_stable(feature = "stability_attribute_implies", since = "1.0.0")] + +// Tests that `implied_by = "const_bar"` results in an error being emitted if `const_bar` does not +// exist. + +#[stable(feature = "stability_attribute_implies", since = "1.0.0")] +#[rustc_const_unstable(feature = "const_foobar", issue = "1", implied_by = "const_bar")] +//~^ ERROR feature `const_bar` implying `const_foobar` does not exist +pub const fn foobar() -> u32 { + 0 +} + +const VAR: u32 = foobar(); diff --git a/tests/ui/stability-attribute/const-stability-attribute-implies-missing.stderr b/tests/ui/stability-attribute/const-stability-attribute-implies-missing.stderr new file mode 100644 index 000000000..6d8b01a54 --- /dev/null +++ b/tests/ui/stability-attribute/const-stability-attribute-implies-missing.stderr @@ -0,0 +1,8 @@ +error: feature `const_bar` implying `const_foobar` does not exist + --> $DIR/const-stability-attribute-implies-missing.rs:10:1 + | +LL | #[rustc_const_unstable(feature = "const_foobar", issue = "1", implied_by = "const_bar")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to previous error + diff --git a/tests/ui/stability-attribute/const-stability-attribute-implies-no-feature.rs b/tests/ui/stability-attribute/const-stability-attribute-implies-no-feature.rs new file mode 100644 index 000000000..47e8d2b36 --- /dev/null +++ b/tests/ui/stability-attribute/const-stability-attribute-implies-no-feature.rs @@ -0,0 +1,16 @@ +// aux-build:const-stability-attribute-implies.rs +#![crate_type = "lib"] + +// Tests that despite the `const_foobar` feature being implied by now-stable feature `const_foo`, +// if `const_foobar` isn't allowed in this crate then an error will be emitted. + +extern crate const_stability_attribute_implies; +use const_stability_attribute_implies::{foo, foobar}; + +pub const fn bar() -> u32 { + foo(); // no error - stable + foobar(); //~ ERROR `foobar` is not yet stable as a const fn + 0 +} + +pub const VAR: u32 = bar(); diff --git a/tests/ui/stability-attribute/const-stability-attribute-implies-no-feature.stderr b/tests/ui/stability-attribute/const-stability-attribute-implies-no-feature.stderr new file mode 100644 index 000000000..8ef5a364e --- /dev/null +++ b/tests/ui/stability-attribute/const-stability-attribute-implies-no-feature.stderr @@ -0,0 +1,10 @@ +error: `foobar` is not yet stable as a const fn + --> $DIR/const-stability-attribute-implies-no-feature.rs:12:5 + | +LL | foobar(); + | ^^^^^^^^ + | + = help: add `#![feature(const_foobar)]` to the crate attributes to enable + +error: aborting due to previous error + diff --git a/tests/ui/stability-attribute/const-stability-attribute-implies-using-stable.rs b/tests/ui/stability-attribute/const-stability-attribute-implies-using-stable.rs new file mode 100644 index 000000000..ffaa171d8 --- /dev/null +++ b/tests/ui/stability-attribute/const-stability-attribute-implies-using-stable.rs @@ -0,0 +1,19 @@ +// aux-build:const-stability-attribute-implies.rs +#![crate_type = "lib"] +#![deny(stable_features)] +#![feature(const_foo)] +//~^ ERROR the feature `const_foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `const_foobar` + +// Tests that the use of `implied_by` in the `#[rustc_const_unstable]` attribute results in a +// diagnostic mentioning partial stabilization, and that given the implied unstable feature is +// unused (there is no `foobar` call), that the compiler suggests removing the flag. + +extern crate const_stability_attribute_implies; +use const_stability_attribute_implies::foo; + +pub const fn bar() -> u32 { + foo(); + 0 +} + +pub const VAR: u32 = bar(); diff --git a/tests/ui/stability-attribute/const-stability-attribute-implies-using-stable.stderr b/tests/ui/stability-attribute/const-stability-attribute-implies-using-stable.stderr new file mode 100644 index 000000000..f6a099cd2 --- /dev/null +++ b/tests/ui/stability-attribute/const-stability-attribute-implies-using-stable.stderr @@ -0,0 +1,22 @@ +error: the feature `const_foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `const_foobar` + --> $DIR/const-stability-attribute-implies-using-stable.rs:4:12 + | +LL | #![feature(const_foo)] + | ^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/const-stability-attribute-implies-using-stable.rs:3:9 + | +LL | #![deny(stable_features)] + | ^^^^^^^^^^^^^^^ +help: if you are using features which are still unstable, change to using `const_foobar` + | +LL | #![feature(const_foobar)] + | ~~~~~~~~~~~~ +help: if you are using features which are now stable, remove this line + | +LL - #![feature(const_foo)] + | + +error: aborting due to previous error + diff --git a/tests/ui/stability-attribute/const-stability-attribute-implies-using-unstable.rs b/tests/ui/stability-attribute/const-stability-attribute-implies-using-unstable.rs new file mode 100644 index 000000000..2061c5c75 --- /dev/null +++ b/tests/ui/stability-attribute/const-stability-attribute-implies-using-unstable.rs @@ -0,0 +1,21 @@ +// aux-build:const-stability-attribute-implies.rs +#![crate_type = "lib"] +#![deny(stable_features)] +#![feature(const_foo)] +//~^ ERROR the feature `const_foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `const_foobar` + +// Tests that the use of `implied_by` in the `#[rustc_const_unstable]` attribute results in a +// diagnostic mentioning partial stabilization and that given the implied unstable feature is +// used (there is a `const_foobar` call), that the compiler suggests changing to that feature and +// doesn't error about its use. + +extern crate const_stability_attribute_implies; +use const_stability_attribute_implies::{foo, foobar}; + +pub const fn bar() -> u32 { + foo(); + foobar(); // no error! + 0 +} + +pub const VAR: u32 = bar(); diff --git a/tests/ui/stability-attribute/const-stability-attribute-implies-using-unstable.stderr b/tests/ui/stability-attribute/const-stability-attribute-implies-using-unstable.stderr new file mode 100644 index 000000000..063856676 --- /dev/null +++ b/tests/ui/stability-attribute/const-stability-attribute-implies-using-unstable.stderr @@ -0,0 +1,22 @@ +error: the feature `const_foo` has been partially stabilized since 1.62.0 and is succeeded by the feature `const_foobar` + --> $DIR/const-stability-attribute-implies-using-unstable.rs:4:12 + | +LL | #![feature(const_foo)] + | ^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/const-stability-attribute-implies-using-unstable.rs:3:9 + | +LL | #![deny(stable_features)] + | ^^^^^^^^^^^^^^^ +help: if you are using features which are still unstable, change to using `const_foobar` + | +LL | #![feature(const_foobar)] + | ~~~~~~~~~~~~ +help: if you are using features which are now stable, remove this line + | +LL - #![feature(const_foo)] + | + +error: aborting due to previous error + diff --git a/tests/ui/stability-attribute/issue-109177.rs b/tests/ui/stability-attribute/issue-109177.rs new file mode 100644 index 000000000..6d052779c --- /dev/null +++ b/tests/ui/stability-attribute/issue-109177.rs @@ -0,0 +1,13 @@ +// aux-build: similar-unstable-method.rs + +extern crate similar_unstable_method; + +fn main() { + // FIXME: this function should not suggest the `foo` function. + similar_unstable_method::foo1(); + //~^ ERROR cannot find function `foo1` in crate `similar_unstable_method` [E0425] + + let foo = similar_unstable_method::Foo; + foo.foo1(); + //~^ ERROR no method named `foo1` found for struct `Foo` in the current scope [E0599] +} diff --git a/tests/ui/stability-attribute/issue-109177.stderr b/tests/ui/stability-attribute/issue-109177.stderr new file mode 100644 index 000000000..9c2ac591a --- /dev/null +++ b/tests/ui/stability-attribute/issue-109177.stderr @@ -0,0 +1,21 @@ +error[E0425]: cannot find function `foo1` in crate `similar_unstable_method` + --> $DIR/issue-109177.rs:7:30 + | +LL | similar_unstable_method::foo1(); + | ^^^^ help: a function with a similar name exists: `foo` + | + ::: $DIR/auxiliary/similar-unstable-method.rs:5:1 + | +LL | pub fn foo() {} + | ------------ similarly named function `foo` defined here + +error[E0599]: no method named `foo1` found for struct `Foo` in the current scope + --> $DIR/issue-109177.rs:11:9 + | +LL | foo.foo1(); + | ^^^^ method not found in `Foo` + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0425, E0599. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/static/static-mut-not-constant.rs b/tests/ui/static/static-mut-not-constant.rs index 2091fffd4..d501e5c29 100644 --- a/tests/ui/static/static-mut-not-constant.rs +++ b/tests/ui/static/static-mut-not-constant.rs @@ -1,6 +1,4 @@ -#![feature(box_syntax)] - -static mut a: Box<isize> = box 3; -//~^ ERROR allocations are not allowed in statics +static mut a: Box<isize> = Box::new(3); +//~^ ERROR cannot call non-const fn fn main() {} diff --git a/tests/ui/static/static-mut-not-constant.stderr b/tests/ui/static/static-mut-not-constant.stderr index a0fa24515..8411a1557 100644 --- a/tests/ui/static/static-mut-not-constant.stderr +++ b/tests/ui/static/static-mut-not-constant.stderr @@ -1,9 +1,12 @@ -error[E0010]: allocations are not allowed in statics - --> $DIR/static-mut-not-constant.rs:3:28 +error[E0015]: cannot call non-const fn `Box::<isize>::new` in statics + --> $DIR/static-mut-not-constant.rs:1:28 | -LL | static mut a: Box<isize> = box 3; - | ^^^^^ allocation not allowed in statics +LL | static mut a: Box<isize> = Box::new(3); + | ^^^^^^^^^^^ + | + = note: calls in statics are limited to constant functions, tuple structs and tuple variants + = note: consider wrapping this expression in `Lazy::new(|| ...)` from the `once_cell` crate: https://crates.io/crates/once_cell error: aborting due to previous error -For more information about this error, try `rustc --explain E0010`. +For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/statics/uninhabited-static.stderr b/tests/ui/statics/uninhabited-static.stderr index 437053a44..35fdcae6a 100644 --- a/tests/ui/statics/uninhabited-static.stderr +++ b/tests/ui/statics/uninhabited-static.stderr @@ -47,7 +47,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/uninhabited-static.rs:12:31 | LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Void warning: the type `Void` does not permit zero-initialization --> $DIR/uninhabited-static.rs:12:31 @@ -66,7 +66,7 @@ error[E0080]: could not evaluate static initializer --> $DIR/uninhabited-static.rs:16:32 | LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^^^^^ transmuting to uninhabited type + | ^^^^^^^^^^^^^^^^^^^^^^^ constructing invalid value: encountered a value of uninhabited type Void warning: the type `Void` does not permit zero-initialization --> $DIR/uninhabited-static.rs:16:32 diff --git a/tests/ui/stats/hir-stats.stderr b/tests/ui/stats/hir-stats.stderr index ee62d8f2d..d723ff538 100644 --- a/tests/ui/stats/hir-stats.stderr +++ b/tests/ui/stats/hir-stats.stderr @@ -15,45 +15,45 @@ ast-stats-1 Arm 96 ( 1.5%) 2 48 ast-stats-1 ForeignItem 96 ( 1.5%) 1 96 ast-stats-1 - Fn 96 ( 1.5%) 1 ast-stats-1 FnDecl 120 ( 1.8%) 5 24 -ast-stats-1 FieldDef 160 ( 2.4%) 2 80 -ast-stats-1 Stmt 160 ( 2.4%) 5 32 +ast-stats-1 FieldDef 160 ( 2.5%) 2 80 +ast-stats-1 Stmt 160 ( 2.5%) 5 32 ast-stats-1 - Local 32 ( 0.5%) 1 ast-stats-1 - MacCall 32 ( 0.5%) 1 ast-stats-1 - Expr 96 ( 1.5%) 3 -ast-stats-1 Param 160 ( 2.4%) 4 40 -ast-stats-1 Block 192 ( 2.9%) 6 32 +ast-stats-1 Param 160 ( 2.5%) 4 40 +ast-stats-1 Block 192 ( 3.0%) 6 32 ast-stats-1 Variant 208 ( 3.2%) 2 104 -ast-stats-1 GenericBound 224 ( 3.4%) 4 56 -ast-stats-1 - Trait 224 ( 3.4%) 4 -ast-stats-1 AssocItem 416 ( 6.3%) 4 104 -ast-stats-1 - Type 208 ( 3.2%) 2 -ast-stats-1 - Fn 208 ( 3.2%) 2 -ast-stats-1 GenericParam 480 ( 7.3%) 5 96 -ast-stats-1 Pat 504 ( 7.7%) 7 72 +ast-stats-1 GenericBound 224 ( 3.5%) 4 56 +ast-stats-1 - Trait 224 ( 3.5%) 4 +ast-stats-1 AssocItem 352 ( 5.4%) 4 88 +ast-stats-1 - Type 176 ( 2.7%) 2 +ast-stats-1 - Fn 176 ( 2.7%) 2 +ast-stats-1 GenericParam 480 ( 7.4%) 5 96 +ast-stats-1 Pat 504 ( 7.8%) 7 72 ast-stats-1 - Struct 72 ( 1.1%) 1 ast-stats-1 - Wild 72 ( 1.1%) 1 ast-stats-1 - Ident 360 ( 5.5%) 5 -ast-stats-1 Expr 576 ( 8.8%) 8 72 +ast-stats-1 Expr 576 ( 8.9%) 8 72 ast-stats-1 - Path 72 ( 1.1%) 1 ast-stats-1 - Match 72 ( 1.1%) 1 ast-stats-1 - Struct 72 ( 1.1%) 1 ast-stats-1 - Lit 144 ( 2.2%) 2 ast-stats-1 - Block 216 ( 3.3%) 3 -ast-stats-1 PathSegment 720 (11.0%) 30 24 -ast-stats-1 Ty 896 (13.7%) 14 64 +ast-stats-1 PathSegment 720 (11.1%) 30 24 +ast-stats-1 Ty 896 (13.8%) 14 64 ast-stats-1 - Ptr 64 ( 1.0%) 1 ast-stats-1 - Ref 64 ( 1.0%) 1 ast-stats-1 - ImplicitSelf 128 ( 2.0%) 2 -ast-stats-1 - Path 640 ( 9.8%) 10 -ast-stats-1 Item 1_224 (18.7%) 9 136 +ast-stats-1 - Path 640 ( 9.9%) 10 +ast-stats-1 Item 1_224 (18.9%) 9 136 ast-stats-1 - Trait 136 ( 2.1%) 1 ast-stats-1 - Enum 136 ( 2.1%) 1 ast-stats-1 - ForeignMod 136 ( 2.1%) 1 ast-stats-1 - Impl 136 ( 2.1%) 1 ast-stats-1 - Fn 272 ( 4.2%) 2 -ast-stats-1 - Use 408 ( 6.2%) 3 +ast-stats-1 - Use 408 ( 6.3%) 3 ast-stats-1 ---------------------------------------------------------------- -ast-stats-1 Total 6_552 +ast-stats-1 Total 6_488 ast-stats-1 ast-stats-2 POST EXPANSION AST STATS ast-stats-2 Name Accumulated Size Count Item Size @@ -65,32 +65,32 @@ ast-stats-2 ExprField 48 ( 0.7%) 1 48 ast-stats-2 WherePredicate 56 ( 0.8%) 1 56 ast-stats-2 - BoundPredicate 56 ( 0.8%) 1 ast-stats-2 Local 72 ( 1.0%) 1 72 -ast-stats-2 Arm 96 ( 1.3%) 2 48 -ast-stats-2 ForeignItem 96 ( 1.3%) 1 96 -ast-stats-2 - Fn 96 ( 1.3%) 1 +ast-stats-2 Arm 96 ( 1.4%) 2 48 +ast-stats-2 ForeignItem 96 ( 1.4%) 1 96 +ast-stats-2 - Fn 96 ( 1.4%) 1 ast-stats-2 InlineAsm 120 ( 1.7%) 1 120 ast-stats-2 FnDecl 120 ( 1.7%) 5 24 ast-stats-2 Attribute 128 ( 1.8%) 4 32 -ast-stats-2 - DocComment 32 ( 0.4%) 1 -ast-stats-2 - Normal 96 ( 1.3%) 3 -ast-stats-2 FieldDef 160 ( 2.2%) 2 80 -ast-stats-2 Stmt 160 ( 2.2%) 5 32 -ast-stats-2 - Local 32 ( 0.4%) 1 -ast-stats-2 - Semi 32 ( 0.4%) 1 -ast-stats-2 - Expr 96 ( 1.3%) 3 -ast-stats-2 Param 160 ( 2.2%) 4 40 +ast-stats-2 - DocComment 32 ( 0.5%) 1 +ast-stats-2 - Normal 96 ( 1.4%) 3 +ast-stats-2 FieldDef 160 ( 2.3%) 2 80 +ast-stats-2 Stmt 160 ( 2.3%) 5 32 +ast-stats-2 - Local 32 ( 0.5%) 1 +ast-stats-2 - Semi 32 ( 0.5%) 1 +ast-stats-2 - Expr 96 ( 1.4%) 3 +ast-stats-2 Param 160 ( 2.3%) 4 40 ast-stats-2 Block 192 ( 2.7%) 6 32 ast-stats-2 Variant 208 ( 2.9%) 2 104 -ast-stats-2 GenericBound 224 ( 3.1%) 4 56 -ast-stats-2 - Trait 224 ( 3.1%) 4 -ast-stats-2 AssocItem 416 ( 5.8%) 4 104 -ast-stats-2 - Type 208 ( 2.9%) 2 -ast-stats-2 - Fn 208 ( 2.9%) 2 -ast-stats-2 GenericParam 480 ( 6.7%) 5 96 -ast-stats-2 Pat 504 ( 7.0%) 7 72 +ast-stats-2 GenericBound 224 ( 3.2%) 4 56 +ast-stats-2 - Trait 224 ( 3.2%) 4 +ast-stats-2 AssocItem 352 ( 5.0%) 4 88 +ast-stats-2 - Type 176 ( 2.5%) 2 +ast-stats-2 - Fn 176 ( 2.5%) 2 +ast-stats-2 GenericParam 480 ( 6.8%) 5 96 +ast-stats-2 Pat 504 ( 7.1%) 7 72 ast-stats-2 - Struct 72 ( 1.0%) 1 ast-stats-2 - Wild 72 ( 1.0%) 1 -ast-stats-2 - Ident 360 ( 5.0%) 5 +ast-stats-2 - Ident 360 ( 5.1%) 5 ast-stats-2 Expr 648 ( 9.1%) 9 72 ast-stats-2 - Path 72 ( 1.0%) 1 ast-stats-2 - Match 72 ( 1.0%) 1 @@ -98,22 +98,22 @@ ast-stats-2 - Struct 72 ( 1.0%) 1 ast-stats-2 - InlineAsm 72 ( 1.0%) 1 ast-stats-2 - Lit 144 ( 2.0%) 2 ast-stats-2 - Block 216 ( 3.0%) 3 -ast-stats-2 PathSegment 792 (11.1%) 33 24 -ast-stats-2 Ty 896 (12.5%) 14 64 +ast-stats-2 PathSegment 792 (11.2%) 33 24 +ast-stats-2 Ty 896 (12.6%) 14 64 ast-stats-2 - Ptr 64 ( 0.9%) 1 ast-stats-2 - Ref 64 ( 0.9%) 1 ast-stats-2 - ImplicitSelf 128 ( 1.8%) 2 -ast-stats-2 - Path 640 ( 8.9%) 10 -ast-stats-2 Item 1_496 (20.9%) 11 136 +ast-stats-2 - Path 640 ( 9.0%) 10 +ast-stats-2 Item 1_496 (21.1%) 11 136 ast-stats-2 - Trait 136 ( 1.9%) 1 ast-stats-2 - Enum 136 ( 1.9%) 1 ast-stats-2 - ExternCrate 136 ( 1.9%) 1 ast-stats-2 - ForeignMod 136 ( 1.9%) 1 ast-stats-2 - Impl 136 ( 1.9%) 1 ast-stats-2 - Fn 272 ( 3.8%) 2 -ast-stats-2 - Use 544 ( 7.6%) 4 +ast-stats-2 - Use 544 ( 7.7%) 4 ast-stats-2 ---------------------------------------------------------------- -ast-stats-2 Total 7_152 +ast-stats-2 Total 7_088 ast-stats-2 hir-stats HIR STATS hir-stats Name Accumulated Size Count Item Size diff --git a/tests/ui/std/issue-15149.rs b/tests/ui/std/issue-15149.rs new file mode 100644 index 000000000..064472f57 --- /dev/null +++ b/tests/ui/std/issue-15149.rs @@ -0,0 +1,57 @@ +// run-pass + +#![allow(unused_variables)] +// no-prefer-dynamic +// ignore-cross-compile + +use std::env; +use std::ffi::OsStr; +use std::fs; +use std::path::PathBuf; +use std::process; +use std::str; + +fn main() { + // If we're the child, make sure we were invoked correctly + let args: Vec<String> = env::args().collect(); + if args.len() > 1 && args[1] == "child" { + // FIXME: This should check the whole `args[0]` instead of just + // checking that it ends_with the executable name. This + // is needed because of Windows, which has a different behavior. + // See #15149 for more info. + let my_path = env::current_exe().unwrap(); + return assert_eq!(my_path.file_stem(), Some(OsStr::new("mytest"))); + } + + test(); +} + +fn test() { + // If we're the parent, copy our own binary to a new directory. + let my_path = env::current_exe().unwrap(); + let my_dir = my_path.parent().unwrap(); + + let child_dir = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); + let child_dir = child_dir.join("issue-15140-child"); + fs::create_dir_all(&child_dir).unwrap(); + + let child_path = child_dir.join(&format!("mytest{}", env::consts::EXE_SUFFIX)); + fs::copy(&my_path, &child_path).unwrap(); + + // Append the new directory to our own PATH. + let path = { + let mut paths: Vec<_> = env::split_paths(&env::var_os("PATH").unwrap()).collect(); + paths.push(child_dir.to_path_buf()); + env::join_paths(paths).unwrap() + }; + + let child_output = + process::Command::new("mytest").env("PATH", &path).arg("child").output().unwrap(); + + assert!( + child_output.status.success(), + "child assertion failed\n child stdout:\n {}\n child stderr:\n {}", + str::from_utf8(&child_output.stdout).unwrap(), + str::from_utf8(&child_output.stderr).unwrap() + ); +} diff --git a/tests/ui/std/issue-81357-unsound-file-methods.rs b/tests/ui/std/issue-81357-unsound-file-methods.rs new file mode 100644 index 000000000..fdf1150f8 --- /dev/null +++ b/tests/ui/std/issue-81357-unsound-file-methods.rs @@ -0,0 +1,81 @@ +// run-fail +// only-windows + +fn main() { + use std::fs; + use std::io::prelude::*; + use std::os::windows::prelude::*; + use std::ptr; + use std::sync::Arc; + use std::thread; + use std::time::Duration; + + const FILE_FLAG_OVERLAPPED: u32 = 0x40000000; + + fn create_pipe_server(path: &str) -> fs::File { + let mut path0 = path.as_bytes().to_owned(); + path0.push(0); + extern "system" { + fn CreateNamedPipeA( + lpName: *const u8, + dwOpenMode: u32, + dwPipeMode: u32, + nMaxInstances: u32, + nOutBufferSize: u32, + nInBufferSize: u32, + nDefaultTimeOut: u32, + lpSecurityAttributes: *mut u8, + ) -> RawHandle; + } + + unsafe { + let h = CreateNamedPipeA(path0.as_ptr(), 3, 0, 1, 0, 0, 0, ptr::null_mut()); + assert_ne!(h as isize, -1); + fs::File::from_raw_handle(h) + } + } + + let path = "\\\\.\\pipe\\repro"; + let mut server = create_pipe_server(path); + + let client = Arc::new( + fs::OpenOptions::new().custom_flags(FILE_FLAG_OVERLAPPED).read(true).open(path).unwrap(), + ); + + let spawn_read = |is_first: bool| { + thread::spawn({ + let f = client.clone(); + move || { + let mut buf = [0xcc; 1]; + let mut f = f.as_ref(); + f.read(&mut buf).unwrap(); + if is_first { + assert_ne!(buf[0], 0xcc); + } else { + let b = buf[0]; // capture buf[0] + thread::sleep(Duration::from_millis(200)); + + // Check the buffer hasn't been written to after read. + dbg!(buf[0], b); + assert_eq!(buf[0], b); + } + } + }) + }; + + let t1 = spawn_read(true); + thread::sleep(Duration::from_millis(20)); + let t2 = spawn_read(false); + thread::sleep(Duration::from_millis(100)); + let _ = server.write(b"x"); + thread::sleep(Duration::from_millis(100)); + let _ = server.write(b"y"); + + // This is run fail because we need to test for the `abort`. + // That failing to run is the success case. + if t1.join().is_err() || t2.join().is_err() { + return; + } else { + panic!("success"); + } +} diff --git a/tests/ui/std/stdio-from.rs b/tests/ui/std/stdio-from.rs new file mode 100644 index 000000000..fef9f27fc --- /dev/null +++ b/tests/ui/std/stdio-from.rs @@ -0,0 +1,69 @@ +// run-pass +// ignore-cross-compile + +use std::env; +use std::fs::File; +use std::io; +use std::io::{Read, Write}; +use std::process::{Command, Stdio}; +use std::path::PathBuf; + +fn main() { + if env::args().len() > 1 { + child().unwrap() + } else { + parent().unwrap() + } +} + +fn parent() -> io::Result<()> { + let td = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); + let input = td.join("stdio-from-input"); + let output = td.join("stdio-from-output"); + + File::create(&input)?.write_all(b"foo\n")?; + + // Set up this chain: + // $ me <file | me | me >file + // ... to duplicate each line 8 times total. + + let mut child1 = Command::new(env::current_exe()?) + .arg("first") + .stdin(File::open(&input)?) // tests File::into() + .stdout(Stdio::piped()) + .spawn()?; + + let mut child3 = Command::new(env::current_exe()?) + .arg("third") + .stdin(Stdio::piped()) + .stdout(File::create(&output)?) // tests File::into() + .spawn()?; + + // Started out of order so we can test both `ChildStdin` and `ChildStdout`. + let mut child2 = Command::new(env::current_exe()?) + .arg("second") + .stdin(child1.stdout.take().unwrap()) // tests ChildStdout::into() + .stdout(child3.stdin.take().unwrap()) // tests ChildStdin::into() + .spawn()?; + + assert!(child1.wait()?.success()); + assert!(child2.wait()?.success()); + assert!(child3.wait()?.success()); + + let mut data = String::new(); + File::open(&output)?.read_to_string(&mut data)?; + for line in data.lines() { + assert_eq!(line, "foo"); + } + assert_eq!(data.lines().count(), 8); + Ok(()) +} + +fn child() -> io::Result<()> { + // double everything + let mut input = vec![]; + io::stdin().read_to_end(&mut input)?; + io::stdout().write_all(&input)?; + io::stdout().write_all(&input)?; + Ok(()) +} diff --git a/tests/ui/std/switch-stdout.rs b/tests/ui/std/switch-stdout.rs new file mode 100644 index 000000000..2d936d96b --- /dev/null +++ b/tests/ui/std/switch-stdout.rs @@ -0,0 +1,52 @@ +// run-pass +// ignore-wasm (needs file descriptors and env variables) + +use std::env; +use std::fs::File; +use std::io::{Read, Write}; +use std::path::PathBuf; + +#[cfg(unix)] +fn switch_stdout_to(file: File) { + use std::os::unix::prelude::*; + + extern "C" { + fn dup2(old: i32, new: i32) -> i32; + } + + unsafe { + assert_eq!(dup2(file.as_raw_fd(), 1), 1); + } +} + +#[cfg(windows)] +fn switch_stdout_to(file: File) { + use std::os::windows::prelude::*; + + extern "system" { + fn SetStdHandle(nStdHandle: u32, handle: *mut u8) -> i32; + } + + const STD_OUTPUT_HANDLE: u32 = (-11i32) as u32; + + unsafe { + let rc = SetStdHandle(STD_OUTPUT_HANDLE, file.into_raw_handle() as *mut _); + assert!(rc != 0); + } +} + +fn main() { + let path = PathBuf::from(env::var_os("RUST_TEST_TMPDIR").unwrap()); + let path = path.join("switch-stdout-output"); + let f = File::create(&path).unwrap(); + + println!("foo"); + std::io::stdout().flush().unwrap(); + switch_stdout_to(f); + println!("bar"); + std::io::stdout().flush().unwrap(); + + let mut contents = String::new(); + File::open(&path).unwrap().read_to_string(&mut contents).unwrap(); + assert_eq!(contents, "bar\n"); +} diff --git a/tests/ui/str/str-escape.rs b/tests/ui/str/str-escape.rs index 0264632fd..10a72421f 100644 --- a/tests/ui/str/str-escape.rs +++ b/tests/ui/str/str-escape.rs @@ -1,11 +1,31 @@ // check-pass +// ignore-tidy-tab + fn main() { let s = "\ "; //~^^^ WARNING multiple lines skipped by escaped newline + assert_eq!(s, ""); + let s = "foo\  bar "; - //~^^^ WARNING non-ASCII whitespace symbol '\u{a0}' is not skipped + //~^^^ WARNING whitespace symbol '\u{a0}' is not skipped + assert_eq!(s, "foo bar\n "); + + let s = "a\ + b"; + assert_eq!(s, "ab"); + + let s = "a\ + b"; + assert_eq!(s, "ab"); + + let s = "a\ + b"; + //~^^ WARNING whitespace symbol '\u{c}' is not skipped + // '\x0c' is ASCII whitespace, but it may not need skipped + // discussion: https://github.com/rust-lang/rust/pull/108403 + assert_eq!(s, "a\x0cb"); } diff --git a/tests/ui/str/str-escape.stderr b/tests/ui/str/str-escape.stderr index b2501f1a2..43b4f7e36 100644 --- a/tests/ui/str/str-escape.stderr +++ b/tests/ui/str/str-escape.stderr @@ -1,5 +1,5 @@ warning: multiple lines skipped by escaped newline - --> $DIR/str-escape.rs:3:14 + --> $DIR/str-escape.rs:5:14 | LL | let s = "\ | ______________^ @@ -7,15 +7,25 @@ LL | | LL | | "; | |_____________^ skipping everything up to and including this point -warning: non-ASCII whitespace symbol '\u{a0}' is not skipped - --> $DIR/str-escape.rs:7:17 +warning: whitespace symbol '\u{a0}' is not skipped + --> $DIR/str-escape.rs:11:17 | LL | let s = "foo\ | _________________^ LL | |  bar - | | ^ non-ASCII whitespace symbol '\u{a0}' is not skipped + | | ^ whitespace symbol '\u{a0}' is not skipped | |___| | -warning: 2 warnings emitted +warning: whitespace symbol '\u{c}' is not skipped + --> $DIR/str-escape.rs:25:15 + | +LL | let s = "a\ + | _______________^ +LL | | b"; + | | ^- whitespace symbol '\u{c}' is not skipped + | |____| + | + +warning: 3 warnings emitted diff --git a/tests/ui/structs-enums/align-struct.rs b/tests/ui/structs-enums/align-struct.rs index f5418e754..54092542f 100644 --- a/tests/ui/structs-enums/align-struct.rs +++ b/tests/ui/structs-enums/align-struct.rs @@ -1,5 +1,5 @@ // run-pass -#![allow(dead_code)] +#![allow(dead_code, unused_allocation)] use std::mem; @@ -20,7 +20,6 @@ struct AlignMany(i32); // Raising alignment may not alter size. #[repr(align(8))] -#[allow(dead_code)] struct Align8Many { a: i32, b: i32, @@ -29,9 +28,8 @@ struct Align8Many { } enum Enum { - #[allow(dead_code)] A(i32), - B(Align16) + B(Align16), } // Nested alignment - use `#[repr(C)]` to suppress field reordering for sizeof test @@ -73,7 +71,7 @@ struct AlignLarge { union UnionContainsAlign { a: Align16, - b: f32 + b: f32, } impl Align16 { @@ -158,7 +156,7 @@ pub fn main() { // Note that the size of Nested may change if struct field re-ordering is enabled assert_eq!(mem::align_of::<Nested>(), 16); assert_eq!(mem::size_of::<Nested>(), 48); - let a = Nested{ a: 1, b: 2, c: Align16(3), d: 4}; + let a = Nested { a: 1, b: 2, c: Align16(3), d: 4 }; assert_eq!(mem::align_of_val(&a), 16); assert_eq!(mem::align_of_val(&a.b), 4); assert_eq!(mem::align_of_val(&a.c), 16); @@ -179,8 +177,8 @@ pub fn main() { assert_eq!(a.0, 15); assert_eq!(mem::align_of_val(a), 16); assert_eq!(mem::size_of_val(a), 16); - }, - _ => () + } + _ => (), } assert!(is_aligned_to(&e, 16)); @@ -197,8 +195,8 @@ pub fn main() { } // arrays of aligned elements should also be aligned - assert_eq!(mem::align_of::<[Align16;2]>(), 16); - assert_eq!(mem::size_of::<[Align16;2]>(), 32); + assert_eq!(mem::align_of::<[Align16; 2]>(), 16); + assert_eq!(mem::size_of::<[Align16; 2]>(), 32); let a = [Align16(0), Align16(1)]; assert_eq!(mem::align_of_val(&a[0]), 16); @@ -209,7 +207,7 @@ pub fn main() { assert_eq!(mem::align_of_val(Box::new(Align16(0)).as_ref()), 16); // check heap array is aligned - let a = vec!(Align16(0), Align16(1)); + let a = vec![Align16(0), Align16(1)]; assert_eq!(mem::align_of_val(&a[0]), 16); assert_eq!(mem::align_of_val(&a[1]), 16); @@ -224,16 +222,14 @@ pub fn main() { assert_eq!(mem::align_of::<AlignContainsPacked4C>(), 16); assert_eq!(mem::size_of::<AlignContainsPacked4C>(), 32); - let a = AlignContainsPacked4C { a: Packed4C{ a: 1, b: 2 }, b: 3 }; + let a = AlignContainsPacked4C { a: Packed4C { a: 1, b: 2 }, b: 3 }; assert_eq!(mem::align_of_val(&a), 16); assert_eq!(mem::align_of_val(&a.a), 4); assert_eq!(mem::align_of_val(&a.b), mem::align_of::<u64>()); assert_eq!(mem::size_of_val(&a), 32); assert!(is_aligned_to(&a, 16)); - let mut large = Box::new(AlignLarge { - stuff: [0; 0x10000], - }); + let mut large = Box::new(AlignLarge { stuff: [0; 0x10000] }); large.stuff[0] = 132; *large.stuff.last_mut().unwrap() = 102; assert_eq!(large.stuff[0], 132); diff --git a/tests/ui/structs/struct-path-alias-bounds.stderr b/tests/ui/structs/struct-path-alias-bounds.stderr index 266291f62..5b01208c5 100644 --- a/tests/ui/structs/struct-path-alias-bounds.stderr +++ b/tests/ui/structs/struct-path-alias-bounds.stderr @@ -11,7 +11,8 @@ LL | struct S<T: Clone> { a: T } | ^^^^^ required by this bound in `S` help: consider annotating `NoClone` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct NoClone; | error: aborting due to previous error diff --git a/tests/ui/structs/struct-tuple-field-names.rs b/tests/ui/structs/struct-tuple-field-names.rs index 7bd54af1d..33f264aa2 100644 --- a/tests/ui/structs/struct-tuple-field-names.rs +++ b/tests/ui/structs/struct-tuple-field-names.rs @@ -12,4 +12,7 @@ fn main() { match y { S { } => {} //~ ERROR: tuple variant `S` written as struct variant [E0769] } + + if let E::S { 0: a } = x { //~ ERROR: pattern does not mention field `1` + } } diff --git a/tests/ui/structs/struct-tuple-field-names.stderr b/tests/ui/structs/struct-tuple-field-names.stderr index 5494c29a6..0b837a47a 100644 --- a/tests/ui/structs/struct-tuple-field-names.stderr +++ b/tests/ui/structs/struct-tuple-field-names.stderr @@ -20,6 +20,22 @@ help: use the tuple variant pattern syntax instead LL | S(_, _) => {} | ~~~~~~ -error: aborting due to 2 previous errors +error[E0027]: pattern does not mention field `1` + --> $DIR/struct-tuple-field-names.rs:16:12 + | +LL | if let E::S { 0: a } = x { + | ^^^^^^^^^^^^^ missing field `1` + | +help: include the missing field in the pattern + | +LL | if let E::S { 0: a, 1: _ } = x { + | ~~~~~~~~ +help: if you don't care about this missing field, you can explicitly ignore it + | +LL | if let E::S { 0: a, .. } = x { + | ~~~~~~ + +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0769`. +Some errors have detailed explanations: E0027, E0769. +For more information about an error, try `rustc --explain E0027`. diff --git a/tests/ui/suggestions/bad-infer-in-trait-impl.rs b/tests/ui/suggestions/bad-infer-in-trait-impl.rs new file mode 100644 index 000000000..87db2636f --- /dev/null +++ b/tests/ui/suggestions/bad-infer-in-trait-impl.rs @@ -0,0 +1,10 @@ +trait Foo { + fn bar(); +} + +impl Foo for () { + fn bar(s: _) {} + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions +} + +fn main() {} diff --git a/tests/ui/suggestions/bad-infer-in-trait-impl.stderr b/tests/ui/suggestions/bad-infer-in-trait-impl.stderr new file mode 100644 index 000000000..418690ff8 --- /dev/null +++ b/tests/ui/suggestions/bad-infer-in-trait-impl.stderr @@ -0,0 +1,14 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/bad-infer-in-trait-impl.rs:6:15 + | +LL | fn bar(s: _) {} + | ^ not allowed in type signatures + | +help: use type parameters instead + | +LL | fn bar<T>(s: T) {} + | +++ ~ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/suggestions/chain-method-call-mutation-in-place.rs b/tests/ui/suggestions/chain-method-call-mutation-in-place.rs index cb92ab87a..7a4c74796 100644 --- a/tests/ui/suggestions/chain-method-call-mutation-in-place.rs +++ b/tests/ui/suggestions/chain-method-call-mutation-in-place.rs @@ -1,4 +1,8 @@ -fn main() {} +fn main() { + let x: Vec<i32> = vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i); //~ ERROR mismatched types + vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); //~ ERROR no method named `sort` found for unit type `()` in the current scope +} + fn foo(mut s: String) -> String { s.push_str("asdf") //~ ERROR mismatched types } diff --git a/tests/ui/suggestions/chain-method-call-mutation-in-place.stderr b/tests/ui/suggestions/chain-method-call-mutation-in-place.stderr index 11d9b8391..128160f10 100644 --- a/tests/ui/suggestions/chain-method-call-mutation-in-place.stderr +++ b/tests/ui/suggestions/chain-method-call-mutation-in-place.stderr @@ -1,5 +1,33 @@ error[E0308]: mismatched types - --> $DIR/chain-method-call-mutation-in-place.rs:3:5 + --> $DIR/chain-method-call-mutation-in-place.rs:2:23 + | +LL | let x: Vec<i32> = vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i); + | -------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Vec<i32>`, found `()` + | | + | expected due to this + | + = note: expected struct `Vec<i32>` + found unit type `()` +note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains. + --> $DIR/chain-method-call-mutation-in-place.rs:2:71 + | +LL | let x: Vec<i32> = vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i); + | ^^^^^^^^^^^ this call modifies its receiver in-place + +error[E0599]: no method named `sort` found for unit type `()` in the current scope + --> $DIR/chain-method-call-mutation-in-place.rs:3:72 + | +LL | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); + | ^^^^ method not found in `()` + | +note: method `sort_by_key` modifies its receiver in-place, it is not meant to be used in method chains. + --> $DIR/chain-method-call-mutation-in-place.rs:3:53 + | +LL | vec![1, 2, 3].into_iter().collect::<Vec<i32>>().sort_by_key(|i| i).sort(); + | ^^^^^^^^^^^ this call modifies its receiver in-place + +error[E0308]: mismatched types + --> $DIR/chain-method-call-mutation-in-place.rs:7:5 | LL | fn foo(mut s: String) -> String { | ------ expected `String` because of return type @@ -7,7 +35,7 @@ LL | s.push_str("asdf") | ^^^^^^^^^^^^^^^^^^ expected `String`, found `()` | note: method `push_str` modifies its receiver in-place - --> $DIR/chain-method-call-mutation-in-place.rs:3:7 + --> $DIR/chain-method-call-mutation-in-place.rs:7:7 | LL | s.push_str("asdf") | - ^^^^^^^^ this call modifies `s` in-place @@ -15,6 +43,7 @@ LL | s.push_str("asdf") | you probably want to use this value after calling the method... = note: ...instead of the `()` output of method `push_str` -error: aborting due to previous error +error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0308, E0599. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr b/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr index 45593035b..0716005c6 100644 --- a/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr +++ b/tests/ui/suggestions/clone-on-unconstrained-borrowed-type-param.stderr @@ -35,7 +35,8 @@ LL | t.clone() | ^ help: consider annotating `Foo` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct Foo; | error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs b/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs index 15f08486f..af47ba8ba 100644 --- a/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs +++ b/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.rs @@ -2,10 +2,9 @@ fn main() { let A = 3; //~^ ERROR refutable pattern in local binding //~| patterns `i32::MIN..=1_i32` and `3_i32..=i32::MAX` not covered - //~| missing patterns are not covered because `a` is interpreted as a constant pattern, not a new variable + //~| missing patterns are not covered because `A` is interpreted as a constant pattern, not a new variable //~| HELP introduce a variable instead - //~| SUGGESTION a_var + //~| SUGGESTION A_var const A: i32 = 2; - //~^ constant defined here } diff --git a/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr b/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr index 1c1cab25f..9ee3e6eb2 100644 --- a/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr +++ b/tests/ui/suggestions/const-pat-non-exaustive-let-new-var.stderr @@ -5,12 +5,11 @@ LL | let A = 3; | ^ | | | patterns `i32::MIN..=1_i32` and `3_i32..=i32::MAX` not covered - | missing patterns are not covered because `a` is interpreted as a constant pattern, not a new variable - | help: introduce a variable instead: `a_var` -... -LL | const A: i32 = 2; - | ------------ constant defined here + | missing patterns are not covered because `A` is interpreted as a constant pattern, not a new variable + | help: introduce a variable instead: `A_var` | + = note: `let` bindings require an "irrefutable pattern", like a `struct` or an `enum` with only one variant + = note: for more information, visit https://doc.rust-lang.org/book/ch18-02-refutability.html = note: the matched value is of type `i32` error: aborting due to previous error diff --git a/tests/ui/suggestions/core-std-import-order-issue-83564.stderr b/tests/ui/suggestions/core-std-import-order-issue-83564.stderr index e4e1fc591..48ee44a74 100644 --- a/tests/ui/suggestions/core-std-import-order-issue-83564.stderr +++ b/tests/ui/suggestions/core-std-import-order-issue-83564.stderr @@ -6,9 +6,9 @@ LL | let _x = NonZeroU32::new(5).unwrap(); | help: consider importing one of these items | -LL | use core::num::NonZeroU32; +LL + use core::num::NonZeroU32; | -LL | use std::num::NonZeroU32; +LL + use std::num::NonZeroU32; | error: aborting due to previous error diff --git a/tests/ui/suggestions/correct-binder-for-arbitrary-bound-sugg.rs b/tests/ui/suggestions/correct-binder-for-arbitrary-bound-sugg.rs new file mode 100644 index 000000000..e56c8622e --- /dev/null +++ b/tests/ui/suggestions/correct-binder-for-arbitrary-bound-sugg.rs @@ -0,0 +1,16 @@ +trait Foo +where + for<'a> &'a Self: Bar, +{ +} + +impl Foo for () {} + +trait Bar {} + +impl Bar for &() {} + +fn foo<T: Foo>() {} +//~^ ERROR the trait bound `for<'a> &'a T: Bar` is not satisfied + +fn main() {} diff --git a/tests/ui/suggestions/correct-binder-for-arbitrary-bound-sugg.stderr b/tests/ui/suggestions/correct-binder-for-arbitrary-bound-sugg.stderr new file mode 100644 index 000000000..2298e7f4e --- /dev/null +++ b/tests/ui/suggestions/correct-binder-for-arbitrary-bound-sugg.stderr @@ -0,0 +1,22 @@ +error[E0277]: the trait bound `for<'a> &'a T: Bar` is not satisfied + --> $DIR/correct-binder-for-arbitrary-bound-sugg.rs:13:11 + | +LL | fn foo<T: Foo>() {} + | ^^^ the trait `for<'a> Bar` is not implemented for `&'a T` + | +note: required by a bound in `Foo` + --> $DIR/correct-binder-for-arbitrary-bound-sugg.rs:3:23 + | +LL | trait Foo + | --- required by a bound in this trait +LL | where +LL | for<'a> &'a Self: Bar, + | ^^^ required by this bound in `Foo` +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn foo<T: Foo>() where for<'a> &'a T: Bar {} + | ++++++++++++++++++++++++ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/suggestions/derive-macro-missing-bounds.stderr b/tests/ui/suggestions/derive-macro-missing-bounds.stderr index 79036279d..c3f305c17 100644 --- a/tests/ui/suggestions/derive-macro-missing-bounds.stderr +++ b/tests/ui/suggestions/derive-macro-missing-bounds.stderr @@ -11,7 +11,8 @@ LL | struct Outer<T>(Inner<T>); = note: this error originates in the derive macro `Debug` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `a::Inner<T>` with `#[derive(Debug)]` | -LL | #[derive(Debug)] +LL + #[derive(Debug)] +LL | struct Inner<T>(T); | help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | diff --git a/tests/ui/suggestions/derive-trait-for-method-call.stderr b/tests/ui/suggestions/derive-trait-for-method-call.stderr index 924b26a8c..e2db0da74 100644 --- a/tests/ui/suggestions/derive-trait-for-method-call.stderr +++ b/tests/ui/suggestions/derive-trait-for-method-call.stderr @@ -32,7 +32,8 @@ note: the trait `Default` must be implemented --> $SRC_DIR/core/src/default.rs:LL:COL help: consider annotating `Enum` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | enum Enum { | error[E0599]: the method `test` exists for struct `Foo<Struct, CloneStruct>`, but its trait bounds were not satisfied @@ -67,11 +68,13 @@ LL | impl<X: Clone + Default + , Y: Clone + Default> Foo<X, Y> { | unsatisfied trait bound introduced here help: consider annotating `CloneStruct` with `#[derive(Default)]` | -LL | #[derive(Default)] +LL + #[derive(Default)] +LL | struct CloneStruct { | help: consider annotating `Struct` with `#[derive(Clone, Default)]` | -LL | #[derive(Clone, Default)] +LL + #[derive(Clone, Default)] +LL | struct Struct { | error[E0599]: the method `test` exists for struct `Foo<Vec<Enum>, Instant>`, but its trait bounds were not satisfied diff --git a/tests/ui/suggestions/dont-wrap-ambiguous-receivers.stderr b/tests/ui/suggestions/dont-wrap-ambiguous-receivers.stderr index 4658ecb3a..85fbb8b88 100644 --- a/tests/ui/suggestions/dont-wrap-ambiguous-receivers.stderr +++ b/tests/ui/suggestions/dont-wrap-ambiguous-receivers.stderr @@ -10,9 +10,9 @@ LL | banana::Chaenomeles.pick() = help: items from traits can only be used if the trait is in scope help: the following traits are implemented but not in scope; perhaps add a `use` for one of them: | -LL | use banana::Apple; +LL + use banana::Apple; | -LL | use banana::Peach; +LL + use banana::Peach; | error: aborting due to previous error diff --git a/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr b/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr index 90ea06239..0232d4c8d 100644 --- a/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr +++ b/tests/ui/suggestions/expected-boxed-future-isnt-pinned.stderr @@ -50,7 +50,8 @@ LL | Pin::new(x) | | | required by a bound introduced by this call | - = note: consider using `Box::pin` + = note: consider using the `pin!` macro + consider using `Box::pin` if you need to access the pinned value outside of the current scope note: required by a bound in `Pin::<P>::new` --> $SRC_DIR/core/src/pin.rs:LL:COL @@ -62,25 +63,23 @@ LL | Pin::new(Box::new(x)) | | | required by a bound introduced by this call | - = note: consider using `Box::pin` + = note: consider using the `pin!` macro + consider using `Box::pin` if you need to access the pinned value outside of the current scope note: required by a bound in `Pin::<P>::new` --> $SRC_DIR/core/src/pin.rs:LL:COL error[E0308]: mismatched types --> $DIR/expected-boxed-future-isnt-pinned.rs:28:5 | +LL | fn zap() -> BoxFuture<'static, i32> { + | ----------------------- expected `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` because of return type LL | / async { LL | | 42 LL | | } - | | ^ - | | | - | |_____expected `Pin<Box<...>>`, found `async` block - | arguments to this function are incorrect + | |_____^ expected `Pin<Box<...>>`, found `async` block | - = note: expected struct `Pin<Box<dyn Future<Output = i32> + Send>>` + = note: expected struct `Pin<Box<(dyn Future<Output = i32> + Send + 'static)>>` found `async` block `[async block@$DIR/expected-boxed-future-isnt-pinned.rs:28:5: 30:6]` -note: function defined here - --> $SRC_DIR/core/src/future/mod.rs:LL:COL help: you need to pin and box this expression | LL ~ Box::pin(async { diff --git a/tests/ui/suggestions/import-trait-for-method-call.stderr b/tests/ui/suggestions/import-trait-for-method-call.stderr index f159b51a2..3f54daf13 100644 --- a/tests/ui/suggestions/import-trait-for-method-call.stderr +++ b/tests/ui/suggestions/import-trait-for-method-call.stderr @@ -10,7 +10,7 @@ LL | h.finish() = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use std::hash::Hasher; +LL + use std::hash::Hasher; | error[E0599]: the method `as_ref` exists for reference `&dyn Bar`, but its trait bounds were not satisfied diff --git a/tests/ui/suggestions/invalid-bin-op.stderr b/tests/ui/suggestions/invalid-bin-op.stderr index 08502dfeb..e291cedb8 100644 --- a/tests/ui/suggestions/invalid-bin-op.stderr +++ b/tests/ui/suggestions/invalid-bin-op.stderr @@ -13,7 +13,8 @@ LL | struct S<T>(T); | ^^^^^^^^^^^ must implement `PartialEq<_>` help: consider annotating `S<T>` with `#[derive(PartialEq)]` | -LL | #[derive(PartialEq)] +LL + #[derive(PartialEq)] +LL | struct S<T>(T); | help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement | diff --git a/tests/ui/suggestions/issue-107860.rs b/tests/ui/suggestions/issue-107860.rs new file mode 100644 index 000000000..a6449cd44 --- /dev/null +++ b/tests/ui/suggestions/issue-107860.rs @@ -0,0 +1,6 @@ +// edition: 2021 + +async fn str<T>(T: &str) -> &str { &str } +//~^ ERROR mismatched types + +fn main() {} diff --git a/tests/ui/suggestions/issue-107860.stderr b/tests/ui/suggestions/issue-107860.stderr new file mode 100644 index 000000000..92e3cf8c4 --- /dev/null +++ b/tests/ui/suggestions/issue-107860.stderr @@ -0,0 +1,12 @@ +error[E0308]: mismatched types + --> $DIR/issue-107860.rs:3:36 + | +LL | async fn str<T>(T: &str) -> &str { &str } + | ^^^^ expected `&str`, found `&fn(&str) -> ... {str::<...>}` + | + = note: expected reference `&str` + found reference `&for<'a> fn(&'a str) -> impl Future<Output = &'a str> {str::<_>}` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/suggestions/issue-108470.fixed b/tests/ui/suggestions/issue-108470.fixed new file mode 100644 index 000000000..9d15c4a8f --- /dev/null +++ b/tests/ui/suggestions/issue-108470.fixed @@ -0,0 +1,29 @@ +// run-rustfix +#![allow(dead_code)] + +struct Foo { + t: Thing +} + +#[derive(Clone)] +struct Thing; + +fn test_clone() { + let t = &Thing; + let _f = Foo { + t: t.clone() //~ ERROR mismatched types + }; +} + +struct Bar { + t: bool +} + +fn test_is_some() { + let t = Option::<i32>::Some(1); + let _f = Bar { + t: t.is_some() //~ ERROR mismatched types + }; +} + +fn main() {} diff --git a/tests/ui/suggestions/issue-108470.rs b/tests/ui/suggestions/issue-108470.rs new file mode 100644 index 000000000..bda39085d --- /dev/null +++ b/tests/ui/suggestions/issue-108470.rs @@ -0,0 +1,29 @@ +// run-rustfix +#![allow(dead_code)] + +struct Foo { + t: Thing +} + +#[derive(Clone)] +struct Thing; + +fn test_clone() { + let t = &Thing; + let _f = Foo { + t //~ ERROR mismatched types + }; +} + +struct Bar { + t: bool +} + +fn test_is_some() { + let t = Option::<i32>::Some(1); + let _f = Bar { + t //~ ERROR mismatched types + }; +} + +fn main() {} diff --git a/tests/ui/suggestions/issue-108470.stderr b/tests/ui/suggestions/issue-108470.stderr new file mode 100644 index 000000000..4e561eca7 --- /dev/null +++ b/tests/ui/suggestions/issue-108470.stderr @@ -0,0 +1,27 @@ +error[E0308]: mismatched types + --> $DIR/issue-108470.rs:14:9 + | +LL | t + | ^ expected `Thing`, found `&Thing` + | +help: consider using clone here + | +LL | t: t.clone() + | +++++++++++ + +error[E0308]: mismatched types + --> $DIR/issue-108470.rs:25:9 + | +LL | t + | ^ expected `bool`, found `Option<i32>` + | + = note: expected type `bool` + found enum `Option<i32>` +help: use `Option::is_some` to test if the `Option` has a value + | +LL | t: t.is_some() + | +++++++++++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/suggestions/issue-109291.rs b/tests/ui/suggestions/issue-109291.rs new file mode 100644 index 000000000..1947b16a3 --- /dev/null +++ b/tests/ui/suggestions/issue-109291.rs @@ -0,0 +1,4 @@ +fn main() { + println!("Custom backtrace: {}", std::backtrace::Backtrace::forced_capture()); + //~^ ERROR no function or associated item name +} diff --git a/tests/ui/suggestions/issue-109291.stderr b/tests/ui/suggestions/issue-109291.stderr new file mode 100644 index 000000000..4ef5948d9 --- /dev/null +++ b/tests/ui/suggestions/issue-109291.stderr @@ -0,0 +1,12 @@ +error[E0599]: no function or associated item named `forced_capture` found for struct `Backtrace` in the current scope + --> $DIR/issue-109291.rs:2:65 + | +LL | println!("Custom backtrace: {}", std::backtrace::Backtrace::forced_capture()); + | ^^^^^^^^^^^^^^ + | | + | function or associated item not found in `Backtrace` + | help: there is an associated function with a similar name: `force_capture` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/suggestions/issue-109396.rs b/tests/ui/suggestions/issue-109396.rs new file mode 100644 index 000000000..b6c464d45 --- /dev/null +++ b/tests/ui/suggestions/issue-109396.rs @@ -0,0 +1,12 @@ +fn main() { + { + let mut mutex = std::mem::zeroed( + //~^ ERROR this function takes 0 arguments but 4 arguments were supplied + file.as_raw_fd(), + //~^ ERROR expected value, found macro `file` + 0, + 0, + 0, + ); + } +} diff --git a/tests/ui/suggestions/issue-109396.stderr b/tests/ui/suggestions/issue-109396.stderr new file mode 100644 index 000000000..d4956872a --- /dev/null +++ b/tests/ui/suggestions/issue-109396.stderr @@ -0,0 +1,34 @@ +error[E0423]: expected value, found macro `file` + --> $DIR/issue-109396.rs:5:13 + | +LL | file.as_raw_fd(), + | ^^^^ not a value + +error[E0061]: this function takes 0 arguments but 4 arguments were supplied + --> $DIR/issue-109396.rs:3:25 + | +LL | let mut mutex = std::mem::zeroed( + | ^^^^^^^^^^^^^^^^ +LL | +LL | file.as_raw_fd(), + | ---------------- unexpected argument +LL | +LL | 0, + | - unexpected argument of type `{integer}` +LL | 0, + | - unexpected argument of type `{integer}` +LL | 0, + | - unexpected argument of type `{integer}` + | +note: function defined here + --> $SRC_DIR/core/src/mem/mod.rs:LL:COL +help: remove the extra arguments + | +LL - file.as_raw_fd(), +LL + ); + | + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0061, E0423. +For more information about an error, try `rustc --explain E0061`. diff --git a/tests/ui/suggestions/issue-109436.rs b/tests/ui/suggestions/issue-109436.rs new file mode 100644 index 000000000..e45ee5991 --- /dev/null +++ b/tests/ui/suggestions/issue-109436.rs @@ -0,0 +1,13 @@ +struct Foo; +struct Bar; + +impl From<&Foo> for Bar { + fn from(foo: &Foo) -> Bar { + Bar + } +} + +fn main() { + let foo = Foo; + let b: Bar = foo.into(); //~ ERROR E0277 +} diff --git a/tests/ui/suggestions/issue-109436.stderr b/tests/ui/suggestions/issue-109436.stderr new file mode 100644 index 000000000..48518b33d --- /dev/null +++ b/tests/ui/suggestions/issue-109436.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `Foo: Into<_>` is not satisfied + --> $DIR/issue-109436.rs:12:22 + | +LL | let b: Bar = foo.into(); + | ^^^^ the trait `~const Into<_>` is not implemented for `Foo` + | + = note: required for `Foo` to implement `Into<Bar>` +help: consider borrowing here + | +LL | let b: Bar = (&foo).into(); + | ++ + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/suggestions/issue-84973-blacklist.stderr b/tests/ui/suggestions/issue-84973-blacklist.stderr index c20cc8164..4de9da89c 100644 --- a/tests/ui/suggestions/issue-84973-blacklist.stderr +++ b/tests/ui/suggestions/issue-84973-blacklist.stderr @@ -27,7 +27,8 @@ LL | fn f_clone<T: Clone>(t: T) {} | ^^^^^ required by this bound in `f_clone` help: consider annotating `S` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct S; | error[E0277]: `[static generator@$DIR/issue-84973-blacklist.rs:17:13: 17:22]` cannot be unpinned @@ -38,7 +39,8 @@ LL | f_unpin(static || { yield; }); | | | required by a bound introduced by this call | - = note: consider using `Box::pin` + = note: consider using the `pin!` macro + consider using `Box::pin` if you need to access the pinned value outside of the current scope note: required by a bound in `f_unpin` --> $DIR/issue-84973-blacklist.rs:8:15 | diff --git a/tests/ui/suggestions/issue-97760.stderr b/tests/ui/suggestions/issue-97760.stderr index bbcc3693f..5415c247c 100644 --- a/tests/ui/suggestions/issue-97760.stderr +++ b/tests/ui/suggestions/issue-97760.stderr @@ -1,8 +1,8 @@ error[E0277]: `<impl IntoIterator as IntoIterator>::Item` doesn't implement `std::fmt::Display` - --> $DIR/issue-97760.rs:4:20 + --> $DIR/issue-97760.rs:4:19 | LL | println!("{x}"); - | ^ `<impl IntoIterator as IntoIterator>::Item` cannot be formatted with the default formatter + | ^^^ `<impl IntoIterator as IntoIterator>::Item` cannot be formatted with the default formatter | = help: the trait `std::fmt::Display` is not implemented for `<impl IntoIterator as IntoIterator>::Item` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.fixed b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.fixed index 304360d48..47b35b412 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.fixed +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.fixed @@ -7,7 +7,7 @@ pub struct Vector2<T: Debug + Copy + Clone>{ pub y: T } -#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented for this type +#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented for this type pub struct AABB<K: Copy + Debug>{ pub loc: Vector2<K>, pub size: Vector2<K> diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.rs b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.rs index 14e1fbb33..771e9105c 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.rs +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.rs @@ -7,7 +7,7 @@ pub struct Vector2<T: Debug + Copy + Clone>{ pub y: T } -#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented for this type +#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented for this type pub struct AABB<K: Copy>{ pub loc: Vector2<K>, pub size: Vector2<K> diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr index faf730a5c..09696e061 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/missing-bound-in-derive-copy-impl-3.rs:10:17 | LL | #[derive(Debug, Copy, Clone)] @@ -6,16 +6,12 @@ LL | #[derive(Debug, Copy, Clone)] LL | pub struct AABB<K: Copy>{ LL | pub loc: Vector2<K>, | ------------------- this field does not implement `Copy` -LL | pub size: Vector2<K> - | -------------------- this field does not implement `Copy` | note: the `Copy` impl for `Vector2<K>` requires that `K: Debug` --> $DIR/missing-bound-in-derive-copy-impl-3.rs:12:14 | LL | pub loc: Vector2<K>, | ^^^^^^^^^^ -LL | pub size: Vector2<K> - | ^^^^^^^^^^ = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting this bound | diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl.rs b/tests/ui/suggestions/missing-bound-in-derive-copy-impl.rs index 52163bddd..9c7b7ba09 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl.rs +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl.rs @@ -6,7 +6,7 @@ pub struct Vector2<T: Debug + Copy + Clone>{ pub y: T } -#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` may not be implemented for this type +#[derive(Debug, Copy, Clone)] //~ ERROR the trait `Copy` cannot be implemented for this type pub struct AABB<K>{ pub loc: Vector2<K>, pub size: Vector2<K> diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr b/tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr index 11bc54099..8585fe47b 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/missing-bound-in-derive-copy-impl.rs:9:17 | LL | #[derive(Debug, Copy, Clone)] @@ -6,16 +6,12 @@ LL | #[derive(Debug, Copy, Clone)] LL | pub struct AABB<K>{ LL | pub loc: Vector2<K>, | ------------------- this field does not implement `Copy` -LL | pub size: Vector2<K> - | -------------------- this field does not implement `Copy` | note: the `Copy` impl for `Vector2<K>` requires that `K: Debug` --> $DIR/missing-bound-in-derive-copy-impl.rs:11:14 | LL | pub loc: Vector2<K>, | ^^^^^^^^^^ -LL | pub size: Vector2<K> - | ^^^^^^^^^^ = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `K` | diff --git a/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.fixed b/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.fixed index 691e7553a..f32c61a99 100644 --- a/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.fixed +++ b/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.fixed @@ -14,6 +14,6 @@ impl<T: std::fmt::Display> Clone for OnlyCopyIfDisplay<T> { impl<T: std::fmt::Display> Copy for OnlyCopyIfDisplay<T> {} impl<S: std::fmt::Display> Copy for Wrapper<OnlyCopyIfDisplay<S>> {} -//~^ ERROR the trait `Copy` may not be implemented for this type +//~^ ERROR the trait `Copy` cannot be implemented for this type fn main() {} diff --git a/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.rs b/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.rs index e3185e7ef..d7725f4a3 100644 --- a/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.rs +++ b/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.rs @@ -14,6 +14,6 @@ impl<T: std::fmt::Display> Clone for OnlyCopyIfDisplay<T> { impl<T: std::fmt::Display> Copy for OnlyCopyIfDisplay<T> {} impl<S> Copy for Wrapper<OnlyCopyIfDisplay<S>> {} -//~^ ERROR the trait `Copy` may not be implemented for this type +//~^ ERROR the trait `Copy` cannot be implemented for this type fn main() {} diff --git a/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr b/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr index 9e6f0d9eb..856d8db38 100644 --- a/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr +++ b/tests/ui/suggestions/missing-bound-in-manual-copy-impl-2.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/missing-bound-in-manual-copy-impl-2.rs:16:18 | LL | struct Wrapper<T>(T); diff --git a/tests/ui/suggestions/missing-bound-in-manual-copy-impl.fixed b/tests/ui/suggestions/missing-bound-in-manual-copy-impl.fixed index 32a7215c5..1139b3153 100644 --- a/tests/ui/suggestions/missing-bound-in-manual-copy-impl.fixed +++ b/tests/ui/suggestions/missing-bound-in-manual-copy-impl.fixed @@ -4,6 +4,6 @@ struct Wrapper<T>(T); impl<S: Copy> Copy for Wrapper<S> {} -//~^ ERROR the trait `Copy` may not be implemented for this type +//~^ ERROR the trait `Copy` cannot be implemented for this type fn main() {} diff --git a/tests/ui/suggestions/missing-bound-in-manual-copy-impl.rs b/tests/ui/suggestions/missing-bound-in-manual-copy-impl.rs index c688f4d41..19549248e 100644 --- a/tests/ui/suggestions/missing-bound-in-manual-copy-impl.rs +++ b/tests/ui/suggestions/missing-bound-in-manual-copy-impl.rs @@ -4,6 +4,6 @@ struct Wrapper<T>(T); impl<S> Copy for Wrapper<S> {} -//~^ ERROR the trait `Copy` may not be implemented for this type +//~^ ERROR the trait `Copy` cannot be implemented for this type fn main() {} diff --git a/tests/ui/suggestions/missing-bound-in-manual-copy-impl.stderr b/tests/ui/suggestions/missing-bound-in-manual-copy-impl.stderr index fe2d133c8..ec3e4f23a 100644 --- a/tests/ui/suggestions/missing-bound-in-manual-copy-impl.stderr +++ b/tests/ui/suggestions/missing-bound-in-manual-copy-impl.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/missing-bound-in-manual-copy-impl.rs:6:18 | LL | struct Wrapper<T>(T); diff --git a/tests/ui/suggestions/multiline-multipart-suggestion.rs b/tests/ui/suggestions/multiline-multipart-suggestion.rs new file mode 100644 index 000000000..77d0322d0 --- /dev/null +++ b/tests/ui/suggestions/multiline-multipart-suggestion.rs @@ -0,0 +1,19 @@ +// compile-flags: --error-format=human --color=always +// ignore-windows + +fn short(foo_bar: &Vec<&i32>) -> &i32 { //~ ERROR missing lifetime specifier + &12 +} + +fn long( //~ ERROR missing lifetime specifier + foo_bar: &Vec<&i32>, + something_very_long_so_that_the_line_will_wrap_around__________: i32, +) -> &i32 { + &12 +} + +fn long2( //~ ERROR missing lifetime specifier + foo_bar: &Vec<&i32>) -> &i32 { + &12 +} +fn main() {} diff --git a/tests/ui/suggestions/multiline-multipart-suggestion.stderr b/tests/ui/suggestions/multiline-multipart-suggestion.stderr new file mode 100644 index 000000000..045a86b4f --- /dev/null +++ b/tests/ui/suggestions/multiline-multipart-suggestion.stderr @@ -0,0 +1,46 @@ +[0m[1m[38;5;9merror[E0106][0m[0m[1m: missing lifetime specifier[0m +[0m [0m[0m[1m[38;5;12m--> [0m[0m$DIR/multiline-multipart-suggestion.rs:4:34[0m +[0m [0m[0m[1m[38;5;12m|[0m +[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m|[0m[0m [0m[0mfn short(foo_bar: &Vec<&i32>) -> &i32 { +[0m [0m[0m[1m[38;5;12m| [0m[0m [0m[0m[1m[38;5;12m----------[0m[0m [0m[0m[1m[38;5;9m^[0m[0m [0m[0m[1m[38;5;9mexpected named lifetime parameter[0m +[0m [0m[0m[1m[38;5;12m|[0m +[0m [0m[0m[1m[38;5;12m= [0m[0m[1mhelp[0m[0m: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from[0m +[0m[1m[38;5;14mhelp[0m[0m: consider introducing a named lifetime parameter[0m +[0m [0m[0m[1m[38;5;12m|[0m +[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m| [0m[0mfn short[0m[0m[38;5;10m<'a>[0m[0m(foo_bar: &[0m[0m[38;5;10m'a [0m[0mVec<&[0m[0m[38;5;10m'a [0m[0mi32>) -> &[0m[0m[38;5;10m'a [0m[0mi32 { +[0m [0m[0m[1m[38;5;12m|[0m[0m [0m[0m[38;5;10m++++[0m[0m [0m[0m[38;5;10m++[0m[0m [0m[0m[38;5;10m++[0m[0m [0m[0m[38;5;10m++[0m + +[0m[1m[38;5;9merror[E0106][0m[0m[1m: missing lifetime specifier[0m +[0m [0m[0m[1m[38;5;12m--> [0m[0m$DIR/multiline-multipart-suggestion.rs:11:6[0m +[0m [0m[0m[1m[38;5;12m|[0m +[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m|[0m[0m [0m[0m foo_bar: &Vec<&i32>,[0m +[0m [0m[0m[1m[38;5;12m| [0m[0m [0m[0m[1m[38;5;12m----------[0m +[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m|[0m[0m [0m[0m something_very_long_so_that_the_line_will_wrap_around__________: i32,[0m +[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m|[0m[0m [0m[0m) -> &i32 {[0m +[0m [0m[0m[1m[38;5;12m| [0m[0m [0m[0m[1m[38;5;9m^[0m[0m [0m[0m[1m[38;5;9mexpected named lifetime parameter[0m +[0m [0m[0m[1m[38;5;12m|[0m +[0m [0m[0m[1m[38;5;12m= [0m[0m[1mhelp[0m[0m: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from[0m +[0m[1m[38;5;14mhelp[0m[0m: consider introducing a named lifetime parameter[0m +[0m [0m[0m[1m[38;5;12m|[0m +[0m[1m[38;5;12mLL[0m[0m [0m[0m[38;5;10m~ [0m[0mfn long[0m[0m[38;5;10m<'a>[0m[0m( +[0m[1m[38;5;12mLL[0m[0m [0m[0m[38;5;10m~ [0m[0m foo_bar: &[0m[0m[38;5;10m'a [0m[0mVec<&[0m[0m[38;5;10m'a [0m[0mi32>,[0m +[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m| [0m[0m something_very_long_so_that_the_line_will_wrap_around__________: i32,[0m +[0m[1m[38;5;12mLL[0m[0m [0m[0m[38;5;10m~ [0m[0m) -> &[0m[0m[38;5;10m'a [0m[0mi32 {[0m +[0m [0m[0m[1m[38;5;12m|[0m + +[0m[1m[38;5;9merror[E0106][0m[0m[1m: missing lifetime specifier[0m +[0m [0m[0m[1m[38;5;12m--> [0m[0m$DIR/multiline-multipart-suggestion.rs:16:29[0m +[0m [0m[0m[1m[38;5;12m|[0m +[0m[1m[38;5;12mLL[0m[0m [0m[0m[1m[38;5;12m|[0m[0m [0m[0m foo_bar: &Vec<&i32>) -> &i32 {[0m +[0m [0m[0m[1m[38;5;12m| [0m[0m [0m[0m[1m[38;5;12m----------[0m[0m [0m[0m[1m[38;5;9m^[0m[0m [0m[0m[1m[38;5;9mexpected named lifetime parameter[0m +[0m [0m[0m[1m[38;5;12m|[0m +[0m [0m[0m[1m[38;5;12m= [0m[0m[1mhelp[0m[0m: this function's return type contains a borrowed value, but the signature does not say which one of `foo_bar`'s 2 lifetimes it is borrowed from[0m +[0m[1m[38;5;14mhelp[0m[0m: consider introducing a named lifetime parameter[0m +[0m [0m[0m[1m[38;5;12m|[0m +[0m[1m[38;5;12mLL[0m[0m [0m[0m[38;5;10m~ [0m[0mfn long2[0m[0m[38;5;10m<'a>[0m[0m( +[0m[1m[38;5;12mLL[0m[0m [0m[0m[38;5;10m~ [0m[0m foo_bar: &[0m[0m[38;5;10m'a [0m[0mVec<&[0m[0m[38;5;10m'a [0m[0mi32>) -> &[0m[0m[38;5;10m'a [0m[0mi32 {[0m +[0m [0m[0m[1m[38;5;12m|[0m + +[0m[1m[38;5;9merror[0m[0m[1m: aborting due to 3 previous errors[0m + +[0m[1mFor more information about this error, try `rustc --explain E0106`.[0m diff --git a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr index 6910b77d9..94710f450 100644 --- a/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr +++ b/tests/ui/suggestions/mut-borrow-needed-by-trait.stderr @@ -21,18 +21,22 @@ note: required by a bound in `BufWriter` --> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL error[E0599]: the method `write_fmt` exists for struct `BufWriter<&dyn Write>`, but its trait bounds were not satisfied - --> $DIR/mut-borrow-needed-by-trait.rs:21:5 + --> $DIR/mut-borrow-needed-by-trait.rs:21:14 | LL | writeln!(fp, "hello world").unwrap(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ method cannot be called on `BufWriter<&dyn Write>` due to unsatisfied trait bounds + | ---------^^---------------- method cannot be called on `BufWriter<&dyn Write>` due to unsatisfied trait bounds --> $SRC_DIR/std/src/io/buffered/bufwriter.rs:LL:COL | = note: doesn't satisfy `BufWriter<&dyn std::io::Write>: std::io::Write` | +note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method + --> $DIR/mut-borrow-needed-by-trait.rs:21:14 + | +LL | writeln!(fp, "hello world").unwrap(); + | ^^ = note: the following trait bounds were not satisfied: `&dyn std::io::Write: std::io::Write` which is required by `BufWriter<&dyn std::io::Write>: std::io::Write` - = note: this error originates in the macro `writeln` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 3 previous errors diff --git a/tests/ui/suggestions/no-extern-crate-in-type.stderr b/tests/ui/suggestions/no-extern-crate-in-type.stderr index 876eef2b6..68100e56c 100644 --- a/tests/ui/suggestions/no-extern-crate-in-type.stderr +++ b/tests/ui/suggestions/no-extern-crate-in-type.stderr @@ -6,7 +6,7 @@ LL | type Output = Option<Foo>; | help: consider importing this struct | -LL | use foo::Foo; +LL + use foo::Foo; | error: aborting due to previous error diff --git a/tests/ui/suggestions/raw-name-use-suggestion.stderr b/tests/ui/suggestions/raw-name-use-suggestion.stderr index 95c26b9ad..fb070ffc3 100644 --- a/tests/ui/suggestions/raw-name-use-suggestion.stderr +++ b/tests/ui/suggestions/raw-name-use-suggestion.stderr @@ -28,7 +28,7 @@ LL | r#break(); | help: consider importing this function | -LL | use foo::r#break; +LL + use foo::r#break; | error: aborting due to 3 previous errors diff --git a/tests/ui/suggestions/ref-pattern-binding.stderr b/tests/ui/suggestions/ref-pattern-binding.stderr index 7b1942593..69ce5d440 100644 --- a/tests/ui/suggestions/ref-pattern-binding.stderr +++ b/tests/ui/suggestions/ref-pattern-binding.stderr @@ -2,9 +2,8 @@ error: borrow of moved value --> $DIR/ref-pattern-binding.rs:10:9 | LL | let _moved @ ref _from = String::from("foo"); - | ------^^^--------- - | | | - | | value borrowed here after move + | ^^^^^^ --------- value borrowed here after move + | | | value moved into `_moved` here | move occurs because `_moved` has type `String` which does not implement the `Copy` trait | @@ -17,27 +16,24 @@ error: cannot move out of value because it is borrowed --> $DIR/ref-pattern-binding.rs:11:9 | LL | let ref _moved @ _from = String::from("foo"); - | ----------^^^----- - | | | - | | value is moved into `_from` here + | ^^^^^^^^^^ ----- value is moved into `_from` here + | | | value is borrowed by `_moved` here error: cannot move out of value because it is borrowed --> $DIR/ref-pattern-binding.rs:15:9 | LL | let ref _moved @ S { f } = S { f: String::from("foo") }; - | ----------^^^^^^^-^^ - | | | - | | value is moved into `f` here + | ^^^^^^^^^^ - value is moved into `f` here + | | | value is borrowed by `_moved` here error: borrow of moved value --> $DIR/ref-pattern-binding.rs:18:9 | LL | let _moved @ S { ref f } = S { f: String::from("foo") }; - | ------^^^^^^^-----^^ - | | | - | | value borrowed here after move + | ^^^^^^ ----- value borrowed here after move + | | | value moved into `_moved` here | move occurs because `_moved` has type `S` which does not implement the `Copy` trait | diff --git a/tests/ui/suggestions/suggest-pin-macro.rs b/tests/ui/suggestions/suggest-pin-macro.rs new file mode 100644 index 000000000..f5b962159 --- /dev/null +++ b/tests/ui/suggestions/suggest-pin-macro.rs @@ -0,0 +1,23 @@ +use std::pin::Pin; +use std::marker::PhantomPinned; + +#[derive(Debug)] +struct Test { + _marker: PhantomPinned, +} +impl Test { + fn new() -> Self { + Test { + _marker: PhantomPinned, // This makes our type `!Unpin` + } + } +} + +fn dummy(_: &mut Test) {} + +pub fn main() { + let mut test1 = Test::new(); + let mut test1 = unsafe { Pin::new_unchecked(&mut test1) }; + + dummy(test1.get_mut()); //~ ERROR E0277 +} diff --git a/tests/ui/suggestions/suggest-pin-macro.stderr b/tests/ui/suggestions/suggest-pin-macro.stderr new file mode 100644 index 000000000..1220cf650 --- /dev/null +++ b/tests/ui/suggestions/suggest-pin-macro.stderr @@ -0,0 +1,19 @@ +error[E0277]: `PhantomPinned` cannot be unpinned + --> $DIR/suggest-pin-macro.rs:22:17 + | +LL | dummy(test1.get_mut()); + | ^^^^^^^ within `Test`, the trait `Unpin` is not implemented for `PhantomPinned` + | + = note: consider using the `pin!` macro + consider using `Box::pin` if you need to access the pinned value outside of the current scope +note: required because it appears within the type `Test` + --> $DIR/suggest-pin-macro.rs:5:8 + | +LL | struct Test { + | ^^^^ +note: required by a bound in `Pin::<&'a mut T>::get_mut` + --> $SRC_DIR/core/src/pin.rs:LL:COL + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/suggestions/suggest-ret-on-async-w-late.rs b/tests/ui/suggestions/suggest-ret-on-async-w-late.rs new file mode 100644 index 000000000..459b94f94 --- /dev/null +++ b/tests/ui/suggestions/suggest-ret-on-async-w-late.rs @@ -0,0 +1,11 @@ +// edition: 2021 + +// Make sure we don't ICE when suggesting a return type +// for an async fn that has late-bound vars... + +async fn ice(_: &i32) { + true + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/suggestions/suggest-ret-on-async-w-late.stderr b/tests/ui/suggestions/suggest-ret-on-async-w-late.stderr new file mode 100644 index 000000000..bff864b22 --- /dev/null +++ b/tests/ui/suggestions/suggest-ret-on-async-w-late.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/suggest-ret-on-async-w-late.rs:7:5 + | +LL | async fn ice(_: &i32) { + | - help: try adding a return type: `-> bool` +LL | true + | ^^^^ expected `()`, found `bool` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/suggestions/suggest-tryinto-edition-change.stderr b/tests/ui/suggestions/suggest-tryinto-edition-change.stderr index 018083f9e..671f5efdd 100644 --- a/tests/ui/suggestions/suggest-tryinto-edition-change.stderr +++ b/tests/ui/suggestions/suggest-tryinto-edition-change.stderr @@ -8,9 +8,9 @@ LL | let _i: i16 = TryFrom::try_from(0_i32).unwrap(); = note: 'core::convert::TryFrom' is included in the prelude starting in Edition 2021 help: consider importing one of these items | -LL | use core::convert::TryFrom; +LL + use core::convert::TryFrom; | -LL | use std::convert::TryFrom; +LL + use std::convert::TryFrom; | error[E0433]: failed to resolve: use of undeclared type `TryInto` @@ -23,9 +23,9 @@ LL | let _i: i16 = TryInto::try_into(0_i32).unwrap(); = note: 'core::convert::TryInto' is included in the prelude starting in Edition 2021 help: consider importing one of these items | -LL | use core::convert::TryInto; +LL + use core::convert::TryInto; | -LL | use std::convert::TryInto; +LL + use std::convert::TryInto; | error[E0433]: failed to resolve: use of undeclared type `FromIterator` @@ -42,9 +42,9 @@ LL | let _v: Vec<_> = IntoIterator::from_iter(&[1]); | ~~~~~~~~~~~~ help: consider importing one of these items | -LL | use core::iter::FromIterator; +LL + use core::iter::FromIterator; | -LL | use std::iter::FromIterator; +LL + use std::iter::FromIterator; | error[E0599]: no method named `try_into` found for type `i32` in the current scope @@ -60,7 +60,7 @@ LL | let _i: i16 = 0_i32.try_into().unwrap(); = note: 'std::convert::TryInto' is included in the prelude starting in Edition 2021 help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use std::convert::TryInto; +LL + use std::convert::TryInto; | error: aborting due to 4 previous errors diff --git a/tests/ui/suggestions/use-placement-resolve.stderr b/tests/ui/suggestions/use-placement-resolve.stderr index 9da9e8e27..77724e7e2 100644 --- a/tests/ui/suggestions/use-placement-resolve.stderr +++ b/tests/ui/suggestions/use-placement-resolve.stderr @@ -6,7 +6,7 @@ LL | fn foobar<T: Debug>(x: T) {} | help: consider importing this trait instead | -LL | use std::fmt::Debug; +LL + use std::fmt::Debug; | error: aborting due to previous error diff --git a/tests/ui/suggestions/use-placement-typeck.stderr b/tests/ui/suggestions/use-placement-typeck.stderr index 3b2749773..e900e12b7 100644 --- a/tests/ui/suggestions/use-placement-typeck.stderr +++ b/tests/ui/suggestions/use-placement-typeck.stderr @@ -13,7 +13,7 @@ LL | pub struct S; = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use m::Foo; +LL + use m::Foo; | error: aborting due to previous error diff --git a/tests/ui/symbol-names/basic.legacy.stderr b/tests/ui/symbol-names/basic.legacy.stderr index fe490a600..c1cbefac8 100644 --- a/tests/ui/symbol-names/basic.legacy.stderr +++ b/tests/ui/symbol-names/basic.legacy.stderr @@ -1,10 +1,10 @@ -error: symbol-name(_ZN5basic4main17he9f658e438f1cac0E) +error: symbol-name(_ZN5basic4main17h6fc0c8d27b1a289fE) --> $DIR/basic.rs:8:1 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(basic::main::he9f658e438f1cac0) +error: demangling(basic::main::h6fc0c8d27b1a289f) --> $DIR/basic.rs:8:1 | LL | #[rustc_symbol_name] diff --git a/tests/ui/symbol-names/basic.v0.stderr b/tests/ui/symbol-names/basic.v0.stderr index 1f0278136..17c6d0ce7 100644 --- a/tests/ui/symbol-names/basic.v0.stderr +++ b/tests/ui/symbol-names/basic.v0.stderr @@ -4,7 +4,7 @@ error: symbol-name(_RNvCsCRATE_HASH_5basic4main) LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(basic[b751b4a00e2291d9]::main) +error: demangling(basic[a90d658f4748b9d1]::main) --> $DIR/basic.rs:8:1 | LL | #[rustc_symbol_name] diff --git a/tests/ui/symbol-names/foreign-types.stderr b/tests/ui/symbol-names/foreign-types.stderr index d6ee388dd..9c8633742 100644 --- a/tests/ui/symbol-names/foreign-types.stderr +++ b/tests/ui/symbol-names/foreign-types.stderr @@ -4,7 +4,7 @@ error: symbol-name(_RMCsCRATE_HASH_13foreign_typesINtB<REF>_5CheckNvB<REF>_11For LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<foreign_types[49eeeb51f120b431]::Check<foreign_types[49eeeb51f120b431]::ForeignType>>) +error: demangling(<foreign_types[fcdd87e190ad88e3]::Check<foreign_types[fcdd87e190ad88e3]::ForeignType>>) --> $DIR/foreign-types.rs:13:1 | LL | #[rustc_symbol_name] diff --git a/tests/ui/symbol-names/impl1.v0.stderr b/tests/ui/symbol-names/impl1.v0.stderr index 33caad71f..a7cc5fc8e 100644 --- a/tests/ui/symbol-names/impl1.v0.stderr +++ b/tests/ui/symbol-names/impl1.v0.stderr @@ -4,7 +4,7 @@ error: symbol-name(_RNvMNtCsCRATE_HASH_5impl13fooNtB<REF>_3Foo3bar) LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<impl1[2c09c4f1c7c8e90c]::foo::Foo>::bar) +error: demangling(<impl1[d5591eb39db23cbb]::foo::Foo>::bar) --> $DIR/impl1.rs:14:9 | LL | #[rustc_symbol_name] @@ -28,7 +28,7 @@ error: symbol-name(_RNvMNtCsCRATE_HASH_5impl13barNtNtB<REF>_3foo3Foo3baz) LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<impl1[2c09c4f1c7c8e90c]::foo::Foo>::baz) +error: demangling(<impl1[d5591eb39db23cbb]::foo::Foo>::baz) --> $DIR/impl1.rs:32:9 | LL | #[rustc_symbol_name] @@ -52,7 +52,7 @@ error: symbol-name(_RNvXNCNvCsCRATE_HASH_5impl14mains_0ARDNtB<REF>_3Foop5AssocFG LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<[&dyn impl1[2c09c4f1c7c8e90c]::Foo<Assoc = for<'a> extern "C" fn(&'a u8, ...)> + impl1[2c09c4f1c7c8e90c]::AutoTrait; 3usize] as impl1[2c09c4f1c7c8e90c]::main::{closure#1}::Bar>::method) +error: demangling(<[&dyn impl1[d5591eb39db23cbb]::Foo<Assoc = for<'a> extern "C" fn(&'a u8, ...)> + impl1[d5591eb39db23cbb]::AutoTrait; 3usize] as impl1[d5591eb39db23cbb]::main::{closure#1}::Bar>::method) --> $DIR/impl1.rs:62:13 | LL | #[rustc_symbol_name] diff --git a/tests/ui/symbol-names/issue-60925.legacy.stderr b/tests/ui/symbol-names/issue-60925.legacy.stderr index 29b42f48d..7dd68e6e3 100644 --- a/tests/ui/symbol-names/issue-60925.legacy.stderr +++ b/tests/ui/symbol-names/issue-60925.legacy.stderr @@ -1,10 +1,10 @@ -error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17h13209029be24b923E) +error: symbol-name(_ZN11issue_609253foo37Foo$LT$issue_60925..llv$u6d$..Foo$GT$3foo17hab58a402db4ebf3aE) --> $DIR/issue-60925.rs:21:9 | LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo::h13209029be24b923) +error: demangling(issue_60925::foo::Foo<issue_60925::llvm::Foo>::foo::hab58a402db4ebf3a) --> $DIR/issue-60925.rs:21:9 | LL | #[rustc_symbol_name] diff --git a/tests/ui/symbol-names/issue-60925.v0.stderr b/tests/ui/symbol-names/issue-60925.v0.stderr index 408c957c6..77449becc 100644 --- a/tests/ui/symbol-names/issue-60925.v0.stderr +++ b/tests/ui/symbol-names/issue-60925.v0.stderr @@ -4,7 +4,7 @@ error: symbol-name(_RNvMNtCsCRATE_HASH_11issue_609253fooINtB<REF>_3FooNtNtB<REF> LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<issue_60925[775bc577f14ef671]::foo::Foo<issue_60925[775bc577f14ef671]::llvm::Foo>>::foo) +error: demangling(<issue_60925[294a1bee3c0c9a2f]::foo::Foo<issue_60925[294a1bee3c0c9a2f]::llvm::Foo>>::foo) --> $DIR/issue-60925.rs:21:9 | LL | #[rustc_symbol_name] diff --git a/tests/ui/symbol-names/issue-75326.v0.stderr b/tests/ui/symbol-names/issue-75326.v0.stderr index 3d7803a0c..fb742f5e4 100644 --- a/tests/ui/symbol-names/issue-75326.v0.stderr +++ b/tests/ui/symbol-names/issue-75326.v0.stderr @@ -4,7 +4,7 @@ error: symbol-name(_RNvXINICsCRATE_HASH_11issue_75326s_0pppEINtB<REF>_3FooppENtB LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<issue_75326[e8e253d78520f2a2]::Foo<_, _> as issue_75326[e8e253d78520f2a2]::Iterator2>::next) +error: demangling(<issue_75326[189ebc60e18860d7]::Foo<_, _> as issue_75326[189ebc60e18860d7]::Iterator2>::next) --> $DIR/issue-75326.rs:41:5 | LL | #[rustc_symbol_name] diff --git a/tests/ui/symbol-names/trait-objects.v0.stderr b/tests/ui/symbol-names/trait-objects.v0.stderr index 47192ce5b..84f2bce66 100644 --- a/tests/ui/symbol-names/trait-objects.v0.stderr +++ b/tests/ui/symbol-names/trait-objects.v0.stderr @@ -4,7 +4,7 @@ error: symbol-name(_RNvXCsCRATE_HASH_13trait_objectsRDG_INtNtNtCsCRATE_HASH_4cor LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<&dyn for<'a> core[HASH]::ops::function::FnMut<(&'a u8,), Output = ()> as trait_objects[7260a56bea9f357b]::Bar>::method) +error: demangling(<&dyn for<'a> core[HASH]::ops::function::FnMut<(&'a u8,), Output = ()> as trait_objects[3c073c57f94bedc2]::Bar>::method) --> $DIR/trait-objects.rs:15:5 | LL | #[rustc_symbol_name] @@ -22,7 +22,7 @@ error: symbol-name(_RNvXs_CsCRATE_HASH_13trait_objectsRDG_INtNtNtCsCRATE_HASH_4c LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<&dyn for<'a> core[HASH]::ops::function::FnMut<(&'a u8,), Output = ()> + core[HASH]::marker::Send as trait_objects[7260a56bea9f357b]::Foo>::method) +error: demangling(<&dyn for<'a> core[HASH]::ops::function::FnMut<(&'a u8,), Output = ()> + core[HASH]::marker::Send as trait_objects[3c073c57f94bedc2]::Foo>::method) --> $DIR/trait-objects.rs:27:5 | LL | #[rustc_symbol_name] @@ -40,7 +40,7 @@ error: symbol-name(_RNvXs0_CsCRATE_HASH_13trait_objectsRDG_INtNtNtCsCRATE_HASH_4 LL | #[rustc_symbol_name] | ^^^^^^^^^^^^^^^^^^^^ -error: demangling(<&dyn for<'a> core[HASH]::ops::function::FnMut<(&'a u8,), Output = ()> + core[HASH]::marker::Send as trait_objects[7260a56bea9f357b]::Baz>::method) +error: demangling(<&dyn for<'a> core[HASH]::ops::function::FnMut<(&'a u8,), Output = ()> + core[HASH]::marker::Send as trait_objects[3c073c57f94bedc2]::Baz>::method) --> $DIR/trait-objects.rs:39:5 | LL | #[rustc_symbol_name] diff --git a/tests/ui/symbol-names/x86-stdcall.rs b/tests/ui/symbol-names/x86-stdcall.rs index 9948488c0..43c086dc6 100644 --- a/tests/ui/symbol-names/x86-stdcall.rs +++ b/tests/ui/symbol-names/x86-stdcall.rs @@ -1,5 +1,7 @@ // build-pass -// only-x86-windows +// only-x86 +// only-windows +// ignore-gnu - vectorcall is not supported by GCC: https://gcc.gnu.org/bugzilla/show_bug.cgi?id=89485 #![crate_type = "cdylib"] #![feature(abi_vectorcall)] diff --git a/tests/ui/sync/suggest-once-cell.rs b/tests/ui/sync/suggest-once-cell.rs index 82fca45b1..14f40ad87 100644 --- a/tests/ui/sync/suggest-once-cell.rs +++ b/tests/ui/sync/suggest-once-cell.rs @@ -1,5 +1,3 @@ -#![feature(once_cell)] - fn require_sync<T: Sync>() {} //~^ NOTE required by this bound in `require_sync` //~| NOTE required by a bound in `require_sync` diff --git a/tests/ui/sync/suggest-once-cell.stderr b/tests/ui/sync/suggest-once-cell.stderr index fadf05374..20242f4b6 100644 --- a/tests/ui/sync/suggest-once-cell.stderr +++ b/tests/ui/sync/suggest-once-cell.stderr @@ -1,5 +1,5 @@ error[E0277]: `OnceCell<()>` cannot be shared between threads safely - --> $DIR/suggest-once-cell.rs:8:20 + --> $DIR/suggest-once-cell.rs:6:20 | LL | require_sync::<std::cell::OnceCell<()>>(); | ^^^^^^^^^^^^^^^^^^^^^^^ `OnceCell<()>` cannot be shared between threads safely @@ -7,7 +7,7 @@ LL | require_sync::<std::cell::OnceCell<()>>(); = help: the trait `Sync` is not implemented for `OnceCell<()>` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::OnceLock` instead note: required by a bound in `require_sync` - --> $DIR/suggest-once-cell.rs:3:20 + --> $DIR/suggest-once-cell.rs:1:20 | LL | fn require_sync<T: Sync>() {} | ^^^^ required by this bound in `require_sync` diff --git a/tests/ui/sync/suggest-ref-cell.rs b/tests/ui/sync/suggest-ref-cell.rs index 6b972ae09..093a4999c 100644 --- a/tests/ui/sync/suggest-ref-cell.rs +++ b/tests/ui/sync/suggest-ref-cell.rs @@ -1,5 +1,3 @@ -#![feature(once_cell)] - fn require_sync<T: Sync>() {} //~^ NOTE required by this bound in `require_sync` //~| NOTE required by a bound in `require_sync` diff --git a/tests/ui/sync/suggest-ref-cell.stderr b/tests/ui/sync/suggest-ref-cell.stderr index 9e8b8fcb4..ca3ae77b1 100644 --- a/tests/ui/sync/suggest-ref-cell.stderr +++ b/tests/ui/sync/suggest-ref-cell.stderr @@ -1,5 +1,5 @@ error[E0277]: `RefCell<()>` cannot be shared between threads safely - --> $DIR/suggest-ref-cell.rs:8:20 + --> $DIR/suggest-ref-cell.rs:6:20 | LL | require_sync::<std::cell::RefCell<()>>(); | ^^^^^^^^^^^^^^^^^^^^^^ `RefCell<()>` cannot be shared between threads safely @@ -7,7 +7,7 @@ LL | require_sync::<std::cell::RefCell<()>>(); = help: the trait `Sync` is not implemented for `RefCell<()>` = note: if you want to do aliasing and mutation between multiple threads, use `std::sync::RwLock` instead note: required by a bound in `require_sync` - --> $DIR/suggest-ref-cell.rs:3:20 + --> $DIR/suggest-ref-cell.rs:1:20 | LL | fn require_sync<T: Sync>() {} | ^^^^ required by this bound in `require_sync` diff --git a/tests/ui/target-feature/gate.rs b/tests/ui/target-feature/gate.rs index 2382c98f8..2eea087c7 100644 --- a/tests/ui/target-feature/gate.rs +++ b/tests/ui/target-feature/gate.rs @@ -6,7 +6,6 @@ // ignore-mips64 // ignore-powerpc // ignore-powerpc64 -// ignore-powerpc64le // ignore-riscv64 // ignore-sparc // ignore-sparc64 diff --git a/tests/ui/target-feature/gate.stderr b/tests/ui/target-feature/gate.stderr index ee542b60a..2d6abcc0a 100644 --- a/tests/ui/target-feature/gate.stderr +++ b/tests/ui/target-feature/gate.stderr @@ -1,5 +1,5 @@ error[E0658]: the target feature `avx512bw` is currently unstable - --> $DIR/gate.rs:32:18 + --> $DIR/gate.rs:31:18 | LL | #[target_feature(enable = "avx512bw")] | ^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/target-feature/invalid-attribute.rs b/tests/ui/target-feature/invalid-attribute.rs index ad1b6e96b..b59ed076f 100644 --- a/tests/ui/target-feature/invalid-attribute.rs +++ b/tests/ui/target-feature/invalid-attribute.rs @@ -6,7 +6,6 @@ // ignore-mips64 // ignore-powerpc // ignore-powerpc64 -// ignore-powerpc64le // ignore-riscv64 // ignore-s390x // ignore-sparc @@ -14,6 +13,21 @@ #![warn(unused_attributes)] +#[target_feature(enable = "sse2")] +//~^ ERROR attribute should be applied to a function +extern crate alloc; +//~^ NOTE not a function + +#[target_feature(enable = "sse2")] +//~^ ERROR attribute should be applied to a function +use alloc::alloc::alloc; +//~^ NOTE not a function + +#[target_feature(enable = "sse2")] +//~^ ERROR attribute should be applied to a function +extern "Rust" {} +//~^ NOTE not a function + #[target_feature = "+sse2"] //~^ ERROR malformed `target_feature` attribute #[target_feature(enable = "foo")] @@ -61,6 +75,11 @@ union Qux { #[target_feature(enable = "sse2")] //~^ ERROR attribute should be applied to a function +type Uwu = (); +//~^ NOTE not a function + +#[target_feature(enable = "sse2")] +//~^ ERROR attribute should be applied to a function trait Baz {} //~^ NOTE not a function @@ -69,6 +88,21 @@ trait Baz {} #[target_feature(enable = "sse2")] unsafe fn test() {} +#[target_feature(enable = "sse2")] +//~^ ERROR attribute should be applied to a function +static A: () = (); +//~^ NOTE not a function + +#[target_feature(enable = "sse2")] +//~^ ERROR attribute should be applied to a function +impl Quux for u8 {} +//~^ NOTE not a function + +#[target_feature(enable = "sse2")] +//~^ ERROR attribute should be applied to a function +impl Foo {} +//~^ NOTE not a function + trait Quux { fn foo(); } diff --git a/tests/ui/target-feature/invalid-attribute.stderr b/tests/ui/target-feature/invalid-attribute.stderr index a2adfc67f..c36392d43 100644 --- a/tests/ui/target-feature/invalid-attribute.stderr +++ b/tests/ui/target-feature/invalid-attribute.stderr @@ -1,11 +1,38 @@ error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:17:1 + --> $DIR/invalid-attribute.rs:31:1 | LL | #[target_feature = "+sse2"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[target_feature(enable = "name")]` error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:34:1 + --> $DIR/invalid-attribute.rs:16:1 + | +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | extern crate alloc; + | ------------------- not a function definition + +error: attribute should be applied to a function definition + --> $DIR/invalid-attribute.rs:21:1 + | +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | use alloc::alloc::alloc; + | ------------------------ not a function definition + +error: attribute should be applied to a function definition + --> $DIR/invalid-attribute.rs:26:1 + | +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | extern "Rust" {} + | ---------------- not a function definition + +error: attribute should be applied to a function definition + --> $DIR/invalid-attribute.rs:48:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -14,7 +41,7 @@ LL | mod another {} | -------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:39:1 + --> $DIR/invalid-attribute.rs:53:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -23,7 +50,7 @@ LL | const FOO: usize = 7; | --------------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:44:1 + --> $DIR/invalid-attribute.rs:58:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -32,7 +59,7 @@ LL | struct Foo; | ----------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:49:1 + --> $DIR/invalid-attribute.rs:63:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +68,7 @@ LL | enum Bar {} | ----------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:54:1 + --> $DIR/invalid-attribute.rs:68:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -54,7 +81,16 @@ LL | | } | |_- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:62:1 + --> $DIR/invalid-attribute.rs:76:1 + | +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | type Uwu = (); + | -------------- not a function definition + +error: attribute should be applied to a function definition + --> $DIR/invalid-attribute.rs:81:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -63,7 +99,34 @@ LL | trait Baz {} | ------------ not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:85:5 + --> $DIR/invalid-attribute.rs:91:1 + | +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | static A: () = (); + | ------------------ not a function definition + +error: attribute should be applied to a function definition + --> $DIR/invalid-attribute.rs:96:1 + | +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | impl Quux for u8 {} + | ------------------- not a function definition + +error: attribute should be applied to a function definition + --> $DIR/invalid-attribute.rs:101:1 + | +LL | #[target_feature(enable = "sse2")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | impl Foo {} + | ----------- not a function definition + +error: attribute should be applied to a function definition + --> $DIR/invalid-attribute.rs:119:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -75,7 +138,7 @@ LL | | } | |_____- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:93:5 + --> $DIR/invalid-attribute.rs:127:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -84,25 +147,25 @@ LL | || {}; | ----- not a function definition error: the feature named `foo` is not valid for this target - --> $DIR/invalid-attribute.rs:19:18 + --> $DIR/invalid-attribute.rs:33:18 | LL | #[target_feature(enable = "foo")] | ^^^^^^^^^^^^^^ `foo` is not valid for this target error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:22:18 + --> $DIR/invalid-attribute.rs:36:18 | LL | #[target_feature(bar)] | ^^^ help: must be of the form: `enable = ".."` error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:24:18 + --> $DIR/invalid-attribute.rs:38:18 | LL | #[target_feature(disable = "baz")] | ^^^^^^^^^^^^^^^ help: must be of the form: `enable = ".."` error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions - --> $DIR/invalid-attribute.rs:28:1 + --> $DIR/invalid-attribute.rs:42:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,13 +177,13 @@ LL | fn bar() {} = help: add `#![feature(target_feature_11)]` to the crate attributes to enable error: cannot use `#[inline(always)]` with `#[target_feature]` - --> $DIR/invalid-attribute.rs:67:1 + --> $DIR/invalid-attribute.rs:86:1 | LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^ error[E0658]: `#[target_feature(..)]` can only be applied to `unsafe` functions - --> $DIR/invalid-attribute.rs:77:5 + --> $DIR/invalid-attribute.rs:111:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -131,6 +194,6 @@ LL | fn foo() {} = note: see issue #69098 <https://github.com/rust-lang/rust/issues/69098> for more information = help: add `#![feature(target_feature_11)]` to the crate attributes to enable -error: aborting due to 15 previous errors +error: aborting due to 22 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/test-attrs/custom-test-frameworks/issue-107454.rs b/tests/ui/test-attrs/custom-test-frameworks/issue-107454.rs new file mode 100644 index 000000000..2bb133e8b --- /dev/null +++ b/tests/ui/test-attrs/custom-test-frameworks/issue-107454.rs @@ -0,0 +1,10 @@ +// compile-flags: --test + +#![feature(custom_test_frameworks)] +#![deny(unnameable_test_items)] + +fn foo() { + #[test_case] + //~^ ERROR cannot test inner items [unnameable_test_items] + fn test2() {} +} diff --git a/tests/ui/test-attrs/custom-test-frameworks/issue-107454.stderr b/tests/ui/test-attrs/custom-test-frameworks/issue-107454.stderr new file mode 100644 index 000000000..bd604afb7 --- /dev/null +++ b/tests/ui/test-attrs/custom-test-frameworks/issue-107454.stderr @@ -0,0 +1,15 @@ +error: cannot test inner items + --> $DIR/issue-107454.rs:7:5 + | +LL | #[test_case] + | ^^^^^^^^^^^^ + | +note: the lint level is defined here + --> $DIR/issue-107454.rs:4:9 + | +LL | #![deny(unnameable_test_items)] + | ^^^^^^^^^^^^^^^^^^^^^ + = note: this error originates in the attribute macro `test_case` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to previous error + diff --git a/tests/ui/test-attrs/issue-109816.rs b/tests/ui/test-attrs/issue-109816.rs new file mode 100644 index 000000000..21fe5bc53 --- /dev/null +++ b/tests/ui/test-attrs/issue-109816.rs @@ -0,0 +1,7 @@ +// compile-flags: --test + +fn align_offset_weird_strides() { + #[test] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function + struct A5(u32, u8); +} diff --git a/tests/ui/test-attrs/issue-109816.stderr b/tests/ui/test-attrs/issue-109816.stderr new file mode 100644 index 000000000..e69932875 --- /dev/null +++ b/tests/ui/test-attrs/issue-109816.stderr @@ -0,0 +1,16 @@ +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/issue-109816.rs:4:5 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions +LL | +LL | struct A5(u32, u8); + | ------------------- expected a non-associated function, found a struct + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL | #[cfg(test)] + | + +error: aborting due to previous error + diff --git a/tests/ui/test-attrs/test-attr-non-associated-functions.rs b/tests/ui/test-attrs/test-attr-non-associated-functions.rs index 31e567c39..2481919b6 100644 --- a/tests/ui/test-attrs/test-attr-non-associated-functions.rs +++ b/tests/ui/test-attrs/test-attr-non-associated-functions.rs @@ -1,18 +1,16 @@ -// #[test] attribute is not allowed on associated functions or methods -// reworded error message // compile-flags:--test struct A {} impl A { #[test] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function fn new() -> A { - //~^ ERROR `#[test]` attribute is only allowed on non associated functions A {} } #[test] + //~^ ERROR the `#[test]` attribute may only be used on a non-associated function fn recovery_witness() -> A { - //~^ ERROR `#[test]` attribute is only allowed on non associated functions A {} } } diff --git a/tests/ui/test-attrs/test-attr-non-associated-functions.stderr b/tests/ui/test-attrs/test-attr-non-associated-functions.stderr index a81b8f398..3e3a951af 100644 --- a/tests/ui/test-attrs/test-attr-non-associated-functions.stderr +++ b/tests/ui/test-attrs/test-attr-non-associated-functions.stderr @@ -1,20 +1,24 @@ -error: `#[test]` attribute is only allowed on non associated functions - --> $DIR/test-attr-non-associated-functions.rs:9:5 - | -LL | / fn new() -> A { -LL | | -LL | | A {} -LL | | } - | |_____^ +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/test-attr-non-associated-functions.rs:6:5 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL | #[cfg(test)] + | -error: `#[test]` attribute is only allowed on non associated functions - --> $DIR/test-attr-non-associated-functions.rs:14:5 - | -LL | / fn recovery_witness() -> A { -LL | | -LL | | A {} -LL | | } - | |_____^ +error: the `#[test]` attribute may only be used on a non-associated function + --> $DIR/test-attr-non-associated-functions.rs:11:5 + | +LL | #[test] + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions + | +help: replace with conditional compilation to make the item only exist when tests are being run + | +LL | #[cfg(test)] + | error: aborting due to 2 previous errors diff --git a/tests/ui/test-attrs/test-on-not-fn.stderr b/tests/ui/test-attrs/test-on-not-fn.stderr index fc2c5f62b..7a9913fbc 100644 --- a/tests/ui/test-attrs/test-on-not-fn.stderr +++ b/tests/ui/test-attrs/test-on-not-fn.stderr @@ -2,7 +2,7 @@ error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:3:1 | LL | #[test] - | ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions LL | mod test {} | ----------- expected a non-associated function, found a module | @@ -15,7 +15,7 @@ error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:6:1 | LL | #[test] - | ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions LL | / mod loooooooooooooong_teeeeeeeeeest { LL | | /* LL | | this is a comment @@ -34,7 +34,7 @@ error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:20:1 | LL | #[test] - | ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions LL | extern "C" {} | ------------- expected a non-associated function, found an extern block | @@ -47,7 +47,7 @@ error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:23:1 | LL | #[test] - | ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions LL | trait Foo {} | ------------ expected a non-associated function, found a trait | @@ -60,7 +60,7 @@ error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:26:1 | LL | #[test] - | ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions LL | impl Foo for i32 {} | ------------------- expected a non-associated function, found an implementation | @@ -73,7 +73,7 @@ error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:29:1 | LL | #[test] - | ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions LL | const FOO: i32 = -1_i32; | ------------------------ expected a non-associated function, found a constant item | @@ -86,7 +86,7 @@ error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:32:1 | LL | #[test] - | ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions LL | static BAR: u64 = 10_000_u64; | ----------------------------- expected a non-associated function, found a static item | @@ -99,7 +99,7 @@ error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:35:1 | LL | #[test] - | ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions LL | / enum MyUnit { LL | | Unit, LL | | } @@ -114,7 +114,7 @@ error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:40:1 | LL | #[test] - | ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions LL | struct NewI32(i32); | ------------------- expected a non-associated function, found a struct | @@ -127,7 +127,7 @@ error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:43:1 | LL | #[test] - | ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions LL | / union Spooky { LL | | x: i32, LL | | y: u32, @@ -143,7 +143,7 @@ error: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:50:1 | LL | #[test] - | ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions LL | #[derive(Copy, Clone, Debug)] LL | / struct MoreAttrs { LL | | a: i32, @@ -160,7 +160,7 @@ warning: the `#[test]` attribute may only be used on a non-associated function --> $DIR/test-on-not-fn.rs:61:1 | LL | #[test] - | ^^^^^^^ the `#[test]` macro causes a function to be run on a test and has no effect on non-functions + | ^^^^^^^ the `#[test]` macro causes a function to be run as a test and has no effect on non-functions LL | foo!(); | ------- expected a non-associated function, found an item macro invocation | diff --git a/tests/ui/test-attrs/tests-listing-format-default.rs b/tests/ui/test-attrs/tests-listing-format-default.rs new file mode 100644 index 000000000..d5df4b57b --- /dev/null +++ b/tests/ui/test-attrs/tests-listing-format-default.rs @@ -0,0 +1,18 @@ +// no-prefer-dynamic +// compile-flags: --test +// run-flags: --list +// run-pass +// check-run-results + +// Checks the listing of tests with no --format arguments. + +#![cfg(test)] +#[test] +fn m_test() {} + +#[test] +#[ignore = "not yet implemented"] +fn z_test() {} + +#[test] +fn a_test() {} diff --git a/tests/ui/test-attrs/tests-listing-format-default.run.stdout b/tests/ui/test-attrs/tests-listing-format-default.run.stdout new file mode 100644 index 000000000..72337daf0 --- /dev/null +++ b/tests/ui/test-attrs/tests-listing-format-default.run.stdout @@ -0,0 +1,5 @@ +a_test: test +m_test: test +z_test: test + +3 tests, 0 benchmarks diff --git a/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.rs b/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.rs new file mode 100644 index 000000000..5247f1f8f --- /dev/null +++ b/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.rs @@ -0,0 +1,18 @@ +// no-prefer-dynamic +// compile-flags: --test +// run-flags: --list --format json +// run-fail +// check-run-results + +// Checks that --format json does not work without -Zunstable-options. + +#![cfg(test)] +#[test] +fn m_test() {} + +#[test] +#[ignore = "not yet implemented"] +fn z_test() {} + +#[test] +fn a_test() {} diff --git a/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.run.stderr b/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.run.stderr new file mode 100644 index 000000000..9f6276300 --- /dev/null +++ b/tests/ui/test-attrs/tests-listing-format-json-without-unstableopts.run.stderr @@ -0,0 +1 @@ +error: The "json" format is only accepted on the nightly compiler diff --git a/tests/ui/test-attrs/tests-listing-format-json.rs b/tests/ui/test-attrs/tests-listing-format-json.rs new file mode 100644 index 000000000..5afc2746f --- /dev/null +++ b/tests/ui/test-attrs/tests-listing-format-json.rs @@ -0,0 +1,21 @@ +// no-prefer-dynamic +// compile-flags: --test +// run-flags: --list --format json -Zunstable-options +// run-pass +// check-run-results +// only-nightly +// normalize-stdout-test: "fake-test-src-base/test-attrs/" -> "$$DIR/" +// normalize-stdout-test: "fake-test-src-base\\test-attrs\\" -> "$$DIR/" + +// Checks the listing of tests with --format json. + +#![cfg(test)] +#[test] +fn m_test() {} + +#[test] +#[ignore = "not yet implemented"] +fn z_test() {} + +#[test] +fn a_test() {} diff --git a/tests/ui/test-attrs/tests-listing-format-json.run.stdout b/tests/ui/test-attrs/tests-listing-format-json.run.stdout new file mode 100644 index 000000000..b4131e97c --- /dev/null +++ b/tests/ui/test-attrs/tests-listing-format-json.run.stdout @@ -0,0 +1,5 @@ +{ "type": "suite", "event": "discovery" } +{ "type": "test", "event": "discovered", "name": "a_test", "ignore": false, "ignore_message": "", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 20, "start_col": 4, "end_line": 20, "end_col": 10 } +{ "type": "test", "event": "discovered", "name": "m_test", "ignore": false, "ignore_message": "", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 13, "start_col": 4, "end_line": 13, "end_col": 10 } +{ "type": "test", "event": "discovered", "name": "z_test", "ignore": true, "ignore_message": "not yet implemented", "source_path": "$DIR/tests-listing-format-json.rs", "start_line": 17, "start_col": 4, "end_line": 17, "end_col": 10 } +{ "type": "suite", "event": "completed", "tests": 3, "benchmarks": 0, "total": 3, "ignored": 1 } diff --git a/tests/ui/test-attrs/tests-listing-format-terse.rs b/tests/ui/test-attrs/tests-listing-format-terse.rs new file mode 100644 index 000000000..7835f7175 --- /dev/null +++ b/tests/ui/test-attrs/tests-listing-format-terse.rs @@ -0,0 +1,18 @@ +// no-prefer-dynamic +// compile-flags: --test +// run-flags: --list --format terse +// run-pass +// check-run-results + +// Checks the listing of tests with --format terse. + +#![cfg(test)] +#[test] +fn m_test() {} + +#[test] +#[ignore = "not yet implemented"] +fn z_test() {} + +#[test] +fn a_test() {} diff --git a/tests/ui/test-attrs/tests-listing-format-terse.run.stdout b/tests/ui/test-attrs/tests-listing-format-terse.run.stdout new file mode 100644 index 000000000..22afe104b --- /dev/null +++ b/tests/ui/test-attrs/tests-listing-format-terse.run.stdout @@ -0,0 +1,3 @@ +a_test: test +m_test: test +z_test: test diff --git a/tests/ui/thir-print/thir-flat.stdout b/tests/ui/thir-print/thir-flat.stdout index 910c0da27..9d467f73d 100644 --- a/tests/ui/thir-print/thir-flat.stdout +++ b/tests/ui/thir-print/thir-flat.stdout @@ -1,4 +1,4 @@ -DefId(0:3 ~ thir_flat[45a6]::main): +DefId(0:3 ~ thir_flat[7b97]::main): Thir { body_type: Fn( ([]; c_variadic: false)->(), @@ -30,7 +30,7 @@ Thir { kind: Scope { region_scope: Node(2), lint_level: Explicit( - HirId(DefId(0:3 ~ thir_flat[45a6]::main).2), + HirId(DefId(0:3 ~ thir_flat[7b97]::main).2), ), value: e0, }, diff --git a/tests/ui/thir-print/thir-tree-match.stdout b/tests/ui/thir-print/thir-tree-match.stdout index d6174ec26..eea04c095 100644 --- a/tests/ui/thir-print/thir-tree-match.stdout +++ b/tests/ui/thir-print/thir-tree-match.stdout @@ -1,10 +1,10 @@ -DefId(0:16 ~ thir_tree_match[3c9a]::has_match): +DefId(0:16 ~ thir_tree_match[fcf8]::has_match): params: [ Param { ty: Foo ty_span: Some($DIR/thir-tree-match.rs:15:19: 15:22 (#0)) self_kind: None - hir_id: Some(HirId(DefId(0:16 ~ thir_tree_match[3c9a]::has_match).1)) + hir_id: Some(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).1)) param: Some( Pat: { ty: Foo @@ -14,7 +14,7 @@ params: [ mutability: Not name: "foo" mode: ByValue - var: LocalVarId(HirId(DefId(0:16 ~ thir_tree_match[3c9a]::has_match).2)) + var: LocalVarId(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).2)) ty: Foo is_primary: true subpattern: None @@ -41,7 +41,7 @@ body: kind: Scope { region_scope: Node(26) - lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[3c9a]::has_match).26)) + lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).26)) value: Expr { ty: bool @@ -63,7 +63,7 @@ body: kind: Scope { region_scope: Node(3) - lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[3c9a]::has_match).3)) + lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).3)) value: Expr { ty: bool @@ -79,7 +79,7 @@ body: kind: Scope { region_scope: Node(4) - lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[3c9a]::has_match).4)) + lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).4)) value: Expr { ty: Foo @@ -87,7 +87,7 @@ body: span: $DIR/thir-tree-match.rs:16:11: 16:14 (#0) kind: VarRef { - id: LocalVarId(HirId(DefId(0:16 ~ thir_tree_match[3c9a]::has_match).2)) + id: LocalVarId(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).2)) } } } @@ -102,10 +102,10 @@ body: Variant { adt_def: AdtDef { - did: DefId(0:10 ~ thir_tree_match[3c9a]::Foo) - variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[3c9a]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[3c9a]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[3c9a]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[3c9a])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[3c9a]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[3c9a]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }] + did: DefId(0:10 ~ thir_tree_match[fcf8]::Foo) + variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }] flags: IS_ENUM - repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 11573694388057581 } + repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3477539199540094892 } substs: [] variant_index: 0 subpatterns: [ @@ -116,10 +116,10 @@ body: Variant { adt_def: AdtDef { - did: DefId(0:3 ~ thir_tree_match[3c9a]::Bar) - variants: [VariantDef { def_id: DefId(0:4 ~ thir_tree_match[3c9a]::Bar::First), ctor: Some((Const, DefId(0:5 ~ thir_tree_match[3c9a]::Bar::First::{constructor#0}))), name: "First", discr: Relative(0), fields: [], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:6 ~ thir_tree_match[3c9a]::Bar::Second), ctor: Some((Const, DefId(0:7 ~ thir_tree_match[3c9a]::Bar::Second::{constructor#0}))), name: "Second", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:8 ~ thir_tree_match[3c9a]::Bar::Third), ctor: Some((Const, DefId(0:9 ~ thir_tree_match[3c9a]::Bar::Third::{constructor#0}))), name: "Third", discr: Relative(2), fields: [], flags: NO_VARIANT_FLAGS }] + did: DefId(0:3 ~ thir_tree_match[fcf8]::Bar) + variants: [VariantDef { def_id: DefId(0:4 ~ thir_tree_match[fcf8]::Bar::First), ctor: Some((Const, DefId(0:5 ~ thir_tree_match[fcf8]::Bar::First::{constructor#0}))), name: "First", discr: Relative(0), fields: [], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:6 ~ thir_tree_match[fcf8]::Bar::Second), ctor: Some((Const, DefId(0:7 ~ thir_tree_match[fcf8]::Bar::Second::{constructor#0}))), name: "Second", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:8 ~ thir_tree_match[fcf8]::Bar::Third), ctor: Some((Const, DefId(0:9 ~ thir_tree_match[fcf8]::Bar::Third::{constructor#0}))), name: "Third", discr: Relative(2), fields: [], flags: NO_VARIANT_FLAGS }] flags: IS_ENUM - repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3125160937860410723 } + repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 10333377570083945360 } substs: [] variant_index: 0 subpatterns: [] @@ -148,7 +148,7 @@ body: kind: Scope { region_scope: Node(13) - lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[3c9a]::has_match).13)) + lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).13)) value: Expr { ty: bool @@ -162,7 +162,7 @@ body: } } } - lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[3c9a]::has_match).12)) + lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).12)) scope: Node(12) span: $DIR/thir-tree-match.rs:17:9: 17:40 (#0) } @@ -175,10 +175,10 @@ body: Variant { adt_def: AdtDef { - did: DefId(0:10 ~ thir_tree_match[3c9a]::Foo) - variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[3c9a]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[3c9a]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[3c9a]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[3c9a])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[3c9a]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[3c9a]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }] + did: DefId(0:10 ~ thir_tree_match[fcf8]::Foo) + variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }] flags: IS_ENUM - repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 11573694388057581 } + repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3477539199540094892 } substs: [] variant_index: 0 subpatterns: [ @@ -211,7 +211,7 @@ body: kind: Scope { region_scope: Node(19) - lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[3c9a]::has_match).19)) + lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).19)) value: Expr { ty: bool @@ -225,7 +225,7 @@ body: } } } - lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[3c9a]::has_match).18)) + lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).18)) scope: Node(18) span: $DIR/thir-tree-match.rs:18:9: 18:32 (#0) } @@ -238,10 +238,10 @@ body: Variant { adt_def: AdtDef { - did: DefId(0:10 ~ thir_tree_match[3c9a]::Foo) - variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[3c9a]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[3c9a]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[3c9a]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[3c9a])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[3c9a]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[3c9a]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }] + did: DefId(0:10 ~ thir_tree_match[fcf8]::Foo) + variants: [VariantDef { def_id: DefId(0:11 ~ thir_tree_match[fcf8]::Foo::FooOne), ctor: Some((Fn, DefId(0:12 ~ thir_tree_match[fcf8]::Foo::FooOne::{constructor#0}))), name: "FooOne", discr: Relative(0), fields: [FieldDef { did: DefId(0:13 ~ thir_tree_match[fcf8]::Foo::FooOne::0), name: "0", vis: Restricted(DefId(0:0 ~ thir_tree_match[fcf8])) }], flags: NO_VARIANT_FLAGS }, VariantDef { def_id: DefId(0:14 ~ thir_tree_match[fcf8]::Foo::FooTwo), ctor: Some((Const, DefId(0:15 ~ thir_tree_match[fcf8]::Foo::FooTwo::{constructor#0}))), name: "FooTwo", discr: Relative(1), fields: [], flags: NO_VARIANT_FLAGS }] flags: IS_ENUM - repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 11573694388057581 } + repr: ReprOptions { int: None, align: None, pack: None, flags: (empty), field_shuffle_seed: 3477539199540094892 } substs: [] variant_index: 1 subpatterns: [] @@ -266,7 +266,7 @@ body: kind: Scope { region_scope: Node(24) - lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[3c9a]::has_match).24)) + lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).24)) value: Expr { ty: bool @@ -280,7 +280,7 @@ body: } } } - lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[3c9a]::has_match).23)) + lint_level: Explicit(HirId(DefId(0:16 ~ thir_tree_match[fcf8]::has_match).23)) scope: Node(23) span: $DIR/thir-tree-match.rs:19:9: 19:28 (#0) } @@ -297,7 +297,7 @@ body: } -DefId(0:17 ~ thir_tree_match[3c9a]::main): +DefId(0:17 ~ thir_tree_match[fcf8]::main): params: [ ] body: @@ -317,7 +317,7 @@ body: kind: Scope { region_scope: Node(2) - lint_level: Explicit(HirId(DefId(0:17 ~ thir_tree_match[3c9a]::main).2)) + lint_level: Explicit(HirId(DefId(0:17 ~ thir_tree_match[fcf8]::main).2)) value: Expr { ty: () diff --git a/tests/ui/thir-print/thir-tree.stdout b/tests/ui/thir-print/thir-tree.stdout index 0a35d9fb7..1b478dbef 100644 --- a/tests/ui/thir-print/thir-tree.stdout +++ b/tests/ui/thir-print/thir-tree.stdout @@ -1,4 +1,4 @@ -DefId(0:3 ~ thir_tree[8f1d]::main): +DefId(0:3 ~ thir_tree[7aaa]::main): params: [ ] body: @@ -18,7 +18,7 @@ body: kind: Scope { region_scope: Node(2) - lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree[8f1d]::main).2)) + lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree[7aaa]::main).2)) value: Expr { ty: () diff --git a/tests/ui/thread-local/auxiliary/tls-export.rs b/tests/ui/thread-local/auxiliary/tls-export.rs new file mode 100644 index 000000000..027213bc0 --- /dev/null +++ b/tests/ui/thread-local/auxiliary/tls-export.rs @@ -0,0 +1,17 @@ +#![crate_type = "dylib"] +#![feature(thread_local)] +#![feature(cfg_target_thread_local)] + +extern crate tls_rlib; + +pub use tls_rlib::*; + +#[cfg(target_thread_local)] +#[thread_local] +pub static FOO: bool = true; + +#[cfg(target_thread_local)] +#[inline(never)] +pub fn foo_addr() -> usize { + &FOO as *const bool as usize +} diff --git a/tests/ui/thread-local/auxiliary/tls-rlib.rs b/tests/ui/thread-local/auxiliary/tls-rlib.rs new file mode 100644 index 000000000..20bc998ec --- /dev/null +++ b/tests/ui/thread-local/auxiliary/tls-rlib.rs @@ -0,0 +1,15 @@ +// no-prefer-dynamic + +#![crate_type = "rlib"] +#![feature(thread_local)] +#![feature(cfg_target_thread_local)] + +#[cfg(target_thread_local)] +#[thread_local] +pub static BAR: bool = true; + +#[cfg(target_thread_local)] +#[inline(never)] +pub fn bar_addr() -> usize { + &BAR as *const bool as usize +} diff --git a/tests/ui/thread-local-mutation.rs b/tests/ui/thread-local/thread-local-mutation.rs index e738225ce..e738225ce 100644 --- a/tests/ui/thread-local-mutation.rs +++ b/tests/ui/thread-local/thread-local-mutation.rs diff --git a/tests/ui/thread-local-mutation.stderr b/tests/ui/thread-local/thread-local-mutation.stderr index e5dc0e72e..e5dc0e72e 100644 --- a/tests/ui/thread-local-mutation.stderr +++ b/tests/ui/thread-local/thread-local-mutation.stderr diff --git a/tests/ui/thread-local-static.rs b/tests/ui/thread-local/thread-local-static.rs index c7fee9e6b..c7fee9e6b 100644 --- a/tests/ui/thread-local-static.rs +++ b/tests/ui/thread-local/thread-local-static.rs diff --git a/tests/ui/thread-local-static.stderr b/tests/ui/thread-local/thread-local-static.stderr index 712050a25..712050a25 100644 --- a/tests/ui/thread-local-static.stderr +++ b/tests/ui/thread-local/thread-local-static.stderr diff --git a/tests/ui/thread-local/tls-dylib-access.rs b/tests/ui/thread-local/tls-dylib-access.rs new file mode 100644 index 000000000..12c46113c --- /dev/null +++ b/tests/ui/thread-local/tls-dylib-access.rs @@ -0,0 +1,19 @@ +// aux-build: tls-rlib.rs +// aux-build: tls-export.rs +// run-pass + +#![feature(cfg_target_thread_local)] + +#[cfg(target_thread_local)] +extern crate tls_export; + +fn main() { + #[cfg(target_thread_local)] + { + // Check that we get the real address of the `FOO` TLS in the dylib + assert_eq!(&tls_export::FOO as *const bool as usize, tls_export::foo_addr()); + + // Check that we get the real address of the `BAR` TLS in the rlib linked into the dylib + assert_eq!(&tls_export::BAR as *const bool as usize, tls_export::bar_addr()); + } +} diff --git a/tests/ui/threads-sendsync/issue-43733-2.rs b/tests/ui/threads-sendsync/issue-43733-2.rs index 32baeec43..8f7a9c083 100644 --- a/tests/ui/threads-sendsync/issue-43733-2.rs +++ b/tests/ui/threads-sendsync/issue-43733-2.rs @@ -21,7 +21,7 @@ impl<T> Key<T> { } #[cfg(target_thread_local)] -use std::thread::__FastLocalKeyInner as Key; +use std::thread::__LocalKeyInner as Key; static __KEY: Key<()> = Key::new(); //~^ ERROR `UnsafeCell<Option<()>>` cannot be shared between threads diff --git a/tests/ui/threads-sendsync/issue-43733.rs b/tests/ui/threads-sendsync/issue-43733.rs index 935e02944..0eadef3e3 100644 --- a/tests/ui/threads-sendsync/issue-43733.rs +++ b/tests/ui/threads-sendsync/issue-43733.rs @@ -1,8 +1,8 @@ // ignore-wasm32 // revisions: mir thir // [thir]compile-flags: -Z thir-unsafeck -// normalize-stderr-test: "__FastLocalKeyInner::<T>::get" -> "$$LOCALKEYINNER::<T>::get" -// normalize-stderr-test: "__OsLocalKeyInner::<T>::get" -> "$$LOCALKEYINNER::<T>::get" +// normalize-stderr-test: "__LocalKeyInner::<T>::get" -> "$$LOCALKEYINNER::<T>::get" +// normalize-stderr-test: "__LocalKeyInner::<T>::get" -> "$$LOCALKEYINNER::<T>::get" #![feature(thread_local)] #![feature(cfg_target_thread_local, thread_local_internals)] @@ -12,10 +12,10 @@ type Foo = std::cell::RefCell<String>; #[cfg(target_thread_local)] #[thread_local] -static __KEY: std::thread::__FastLocalKeyInner<Foo> = std::thread::__FastLocalKeyInner::new(); +static __KEY: std::thread::__LocalKeyInner<Foo> = std::thread::__LocalKeyInner::new(); #[cfg(not(target_thread_local))] -static __KEY: std::thread::__OsLocalKeyInner<Foo> = std::thread::__OsLocalKeyInner::new(); +static __KEY: std::thread::__LocalKeyInner<Foo> = std::thread::__LocalKeyInner::new(); fn __getit(_: Option<&mut Option<RefCell<String>>>) -> std::option::Option<&'static Foo> { __KEY.get(Default::default) diff --git a/tests/ui/tool-attributes/tool-attributes-misplaced-2.stderr b/tests/ui/tool-attributes/tool-attributes-misplaced-2.stderr index 6d0f826e6..06696b548 100644 --- a/tests/ui/tool-attributes/tool-attributes-misplaced-2.stderr +++ b/tests/ui/tool-attributes/tool-attributes-misplaced-2.stderr @@ -3,6 +3,14 @@ error: expected derive macro, found tool attribute `rustfmt::skip` | LL | #[derive(rustfmt::skip)] | ^^^^^^^^^^^^^ not a derive macro + | +help: remove from the surrounding `derive()` + --> $DIR/tool-attributes-misplaced-2.rs:1:10 + | +LL | #[derive(rustfmt::skip)] + | ^^^^^^^^^^^^^ + = help: add as non-Derive macro + `#[rustfmt::skip]` error: expected macro, found tool attribute `rustfmt::skip` --> $DIR/tool-attributes-misplaced-2.rs:5:5 diff --git a/tests/ui/trait-bounds/impl-bound-with-references-error.stderr b/tests/ui/trait-bounds/impl-bound-with-references-error.stderr index 95fd6bd50..b114d295d 100644 --- a/tests/ui/trait-bounds/impl-bound-with-references-error.stderr +++ b/tests/ui/trait-bounds/impl-bound-with-references-error.stderr @@ -6,7 +6,7 @@ LL | T: Into<Cow<'static, str>>, | help: consider importing this enum | -LL | use std::borrow::Cow; +LL + use std::borrow::Cow; | error[E0119]: conflicting implementations of trait `From<LabelText>` for type `LabelText` diff --git a/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr b/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr index b29766295..4547e1c98 100644 --- a/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr +++ b/tests/ui/trait-bounds/shadowed-path-in-trait-bound-suggestion.stderr @@ -6,7 +6,7 @@ LL | pub struct A<H: A::Trait>(pub H); | help: consider importing this trait | -LL | use A::Trait; +LL + use A::Trait; | help: if you import `Trait`, refer to it directly | diff --git a/tests/ui/traits/alias/dont-elaborate-non-self.rs b/tests/ui/traits/alias/dont-elaborate-non-self.rs new file mode 100644 index 000000000..4f9eaacb8 --- /dev/null +++ b/tests/ui/traits/alias/dont-elaborate-non-self.rs @@ -0,0 +1,10 @@ +#![feature(trait_alias)] + +use std::future::Future; + +trait F<Fut: Future<Output = usize>> = Fn() -> Fut; + +fn f<Fut>(a: dyn F<Fut>) {} +//~^ ERROR the size for values of type `(dyn Fn() -> Fut + 'static)` cannot be known at compilation time + +fn main() {} diff --git a/tests/ui/traits/alias/dont-elaborate-non-self.stderr b/tests/ui/traits/alias/dont-elaborate-non-self.stderr new file mode 100644 index 000000000..247a4f812 --- /dev/null +++ b/tests/ui/traits/alias/dont-elaborate-non-self.stderr @@ -0,0 +1,20 @@ +error[E0277]: the size for values of type `(dyn Fn() -> Fut + 'static)` cannot be known at compilation time + --> $DIR/dont-elaborate-non-self.rs:7:11 + | +LL | fn f<Fut>(a: dyn F<Fut>) {} + | ^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Fn() -> Fut + 'static)` + = help: unsized fn params are gated as an unstable feature +help: you can use `impl Trait` as the argument type + | +LL | fn f<Fut>(a: impl F<Fut>) {} + | ~~~~ +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | fn f<Fut>(a: &dyn F<Fut>) {} + | + + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.rs b/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.rs index 471a6b836..8e43b7249 100644 --- a/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.rs +++ b/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.rs @@ -18,6 +18,6 @@ fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: String { //~ ERROR expec fn issue_95327() where <u8 as Unresolved>::Assoc: String {} //~^ ERROR expected trait, found struct -//~| ERROR use of undeclared type `Unresolved` +//~| ERROR cannot find trait `Unresolved` in this scope fn main() {} diff --git a/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr b/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr index 5be334986..0020f9e41 100644 --- a/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr +++ b/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr @@ -1,9 +1,3 @@ -error[E0433]: failed to resolve: use of undeclared type `Unresolved` - --> $DIR/assoc_type_bound_with_struct.rs:19:31 - | -LL | fn issue_95327() where <u8 as Unresolved>::Assoc: String {} - | ^^^^^^^^^^ use of undeclared type `Unresolved` - error[E0404]: expected trait, found struct `String` --> $DIR/assoc_type_bound_with_struct.rs:5:46 | @@ -76,6 +70,12 @@ help: a trait with a similar name exists LL | fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: ToString { | ~~~~~~~~ +error[E0405]: cannot find trait `Unresolved` in this scope + --> $DIR/assoc_type_bound_with_struct.rs:19:31 + | +LL | fn issue_95327() where <u8 as Unresolved>::Assoc: String {} + | ^^^^^^^^^^ not found in this scope + error[E0404]: expected trait, found struct `String` --> $DIR/assoc_type_bound_with_struct.rs:19:51 | @@ -87,5 +87,5 @@ LL | fn issue_95327() where <u8 as Unresolved>::Assoc: String {} error: aborting due to 6 previous errors -Some errors have detailed explanations: E0404, E0433. +Some errors have detailed explanations: E0404, E0405. For more information about an error, try `rustc --explain E0404`. diff --git a/tests/ui/traits/copy-is-not-modulo-regions.not_static.stderr b/tests/ui/traits/copy-is-not-modulo-regions.not_static.stderr index edd94d201..130425211 100644 --- a/tests/ui/traits/copy-is-not-modulo-regions.not_static.stderr +++ b/tests/ui/traits/copy-is-not-modulo-regions.not_static.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/copy-is-not-modulo-regions.rs:13:21 | LL | struct Bar<'lt>(Foo<'lt>); diff --git a/tests/ui/traits/copy-is-not-modulo-regions.rs b/tests/ui/traits/copy-is-not-modulo-regions.rs index adb870237..b89908374 100644 --- a/tests/ui/traits/copy-is-not-modulo-regions.rs +++ b/tests/ui/traits/copy-is-not-modulo-regions.rs @@ -11,7 +11,7 @@ struct Bar<'lt>(Foo<'lt>); #[cfg(not_static)] impl<'any> Copy for Bar<'any> {} -//[not_static]~^ the trait `Copy` may not be implemented for this type +//[not_static]~^ the trait `Copy` cannot be implemented for this type #[cfg(yes_static)] impl<'any> Copy for Bar<'static> {} diff --git a/tests/ui/traits/dyn-trait.rs b/tests/ui/traits/dyn-trait.rs index e1c1a8de5..10e69105c 100644 --- a/tests/ui/traits/dyn-trait.rs +++ b/tests/ui/traits/dyn-trait.rs @@ -1,5 +1,4 @@ // run-pass -// ignore-pretty `dyn ::foo` parses differently in the current edition use std::fmt::Display; diff --git a/tests/ui/traits/inductive-overflow/lifetime.rs b/tests/ui/traits/inductive-overflow/lifetime.rs index bf536d21c..2f3c90dce 100644 --- a/tests/ui/traits/inductive-overflow/lifetime.rs +++ b/tests/ui/traits/inductive-overflow/lifetime.rs @@ -15,9 +15,9 @@ impl<'a> Y for C<'a> { struct C<'a>(&'a ()); struct X<T: Y>(T::P); -impl<T: NotAuto> NotAuto for Box<T> {} //~ NOTE: required +impl<T: NotAuto> NotAuto for Box<T> {} +impl<T: Y> NotAuto for X<T> where T::P: NotAuto {} //~ NOTE: required //~^ NOTE unsatisfied trait bound introduced here -impl<T: Y> NotAuto for X<T> where T::P: NotAuto {} impl<'a> NotAuto for C<'a> {} fn is_send<S: NotAuto>() {} @@ -28,6 +28,4 @@ fn main() { // Should only be a few notes. is_send::<X<C<'static>>>(); //~^ ERROR overflow evaluating - //~| 3 redundant requirements hidden - //~| required for } diff --git a/tests/ui/traits/inductive-overflow/lifetime.stderr b/tests/ui/traits/inductive-overflow/lifetime.stderr index 357e59991..7ab2864a8 100644 --- a/tests/ui/traits/inductive-overflow/lifetime.stderr +++ b/tests/ui/traits/inductive-overflow/lifetime.stderr @@ -1,18 +1,14 @@ -error[E0275]: overflow evaluating the requirement `X<C<'_>>: NotAuto` +error[E0275]: overflow evaluating the requirement `Box<X<C<'static>>>: NotAuto` --> $DIR/lifetime.rs:29:5 | LL | is_send::<X<C<'static>>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ | -note: required for `Box<X<C<'_>>>` to implement `NotAuto` - --> $DIR/lifetime.rs:18:18 +note: required for `X<C<'static>>` to implement `NotAuto` + --> $DIR/lifetime.rs:19:12 | -LL | impl<T: NotAuto> NotAuto for Box<T> {} - | ------- ^^^^^^^ ^^^^^^ - | | - | unsatisfied trait bound introduced here - = note: 3 redundant requirements hidden - = note: required for `X<C<'static>>` to implement `NotAuto` +LL | impl<T: Y> NotAuto for X<T> where T::P: NotAuto {} + | ^^^^^^^ ^^^^ ------- unsatisfied trait bound introduced here note: required by a bound in `is_send` --> $DIR/lifetime.rs:23:15 | diff --git a/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr b/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr index dc967d512..e723c7c51 100644 --- a/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr +++ b/tests/ui/traits/inductive-overflow/supertrait-auto-trait.stderr @@ -26,7 +26,8 @@ LL | fn copy<T: Magic>(x: T) -> (T, T) { (x, x) } | ^^^^^ required by this bound in `copy` help: consider annotating `NoClone` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | struct NoClone; | error: aborting due to 2 previous errors diff --git a/tests/ui/traits/issue-50480.rs b/tests/ui/traits/issue-50480.rs index 005939e0c..683a85a32 100644 --- a/tests/ui/traits/issue-50480.rs +++ b/tests/ui/traits/issue-50480.rs @@ -1,5 +1,5 @@ #[derive(Clone, Copy)] -//~^ ERROR the trait `Copy` may not be implemented for this type +//~^ ERROR the trait `Copy` cannot be implemented for this type struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String); //~^ ERROR cannot find type `NotDefined` in this scope //~| ERROR cannot find type `NotDefined` in this scope @@ -7,7 +7,7 @@ struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String); //~| ERROR cannot find type `N` in this scope #[derive(Clone, Copy)] -//~^ ERROR the trait `Copy` may not be implemented for this type +//~^ ERROR the trait `Copy` cannot be implemented for this type struct Bar<T>(T, N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String); //~^ ERROR cannot find type `NotDefined` in this scope //~| ERROR cannot find type `N` in this scope diff --git a/tests/ui/traits/issue-50480.stderr b/tests/ui/traits/issue-50480.stderr index 5063fdca0..4f72db60a 100644 --- a/tests/ui/traits/issue-50480.stderr +++ b/tests/ui/traits/issue-50480.stderr @@ -60,7 +60,7 @@ error[E0412]: cannot find type `NotDefined` in this scope LL | struct Bar<T>(T, N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String); | ^^^^^^^^^^ not found in this scope -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/issue-50480.rs:1:17 | LL | #[derive(Clone, Copy)] @@ -73,7 +73,7 @@ LL | struct Foo(N, NotDefined, <i32 as Iterator>::Item, Vec<i32>, String); | = note: this error originates in the derive macro `Copy` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/issue-50480.rs:9:17 | LL | #[derive(Clone, Copy)] diff --git a/tests/ui/traits/issue-71136.stderr b/tests/ui/traits/issue-71136.stderr index f54173392..ef5579618 100644 --- a/tests/ui/traits/issue-71136.stderr +++ b/tests/ui/traits/issue-71136.stderr @@ -11,7 +11,8 @@ LL | the_foos: Vec<Foo>, = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Foo` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct Foo(u8); | error: aborting due to previous error diff --git a/tests/ui/traits/issue-78372.stderr b/tests/ui/traits/issue-78372.stderr index 8e7fd5f25..ec692ff91 100644 --- a/tests/ui/traits/issue-78372.stderr +++ b/tests/ui/traits/issue-78372.stderr @@ -6,7 +6,7 @@ LL | struct Smaht<T, MISC>(PhantomData); | help: consider importing this struct | -LL | use std::marker::PhantomData; +LL + use std::marker::PhantomData; | error[E0412]: cannot find type `U` in this scope diff --git a/tests/ui/traits/issue-87558.stderr b/tests/ui/traits/issue-87558.stderr index 494274d8c..b647f9794 100644 --- a/tests/ui/traits/issue-87558.stderr +++ b/tests/ui/traits/issue-87558.stderr @@ -17,6 +17,12 @@ error[E0229]: associated type bindings are not allowed here | LL | impl Fn(&isize) for Error { | ^^^^^^^^^^ associated type not allowed here + | +help: parenthesized trait syntax expands to `Fn<(&isize,), Output=()>` + --> $DIR/issue-87558.rs:3:6 + | +LL | impl Fn(&isize) for Error { + | ^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.rs b/tests/ui/traits/issue-91949-hangs-on-recursion.rs index 6474b2b38..4eca643a9 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.rs +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.rs @@ -1,6 +1,6 @@ // build-fail // compile-flags: -Zinline-mir=no -// error-pattern: overflow evaluating the requirement `(): Sized` +// error-pattern: overflow evaluating the requirement `<std::iter::Empty<()> as Iterator>::Item == ()` // error-pattern: function cannot return without recursing // normalize-stderr-test: "long-type-\d+" -> "long-type-hash" diff --git a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr index 1f18c5daf..144990d50 100644 --- a/tests/ui/traits/issue-91949-hangs-on-recursion.stderr +++ b/tests/ui/traits/issue-91949-hangs-on-recursion.stderr @@ -12,11 +12,17 @@ LL | recurse(IteratorOfWrapped(elements).map(|t| t.0)) = help: a `loop` may express intention better if this is on purpose = note: `#[warn(unconditional_recursion)]` on by default -error[E0275]: overflow evaluating the requirement `(): Sized` +error[E0275]: overflow evaluating the requirement `<std::iter::Empty<()> as Iterator>::Item == ()` | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "512"]` attribute to your crate (`issue_91949_hangs_on_recursion`) - = note: required for `std::iter::Empty<()>` to implement `Iterator` - = note: 171 redundant requirements hidden +note: required for `IteratorOfWrapped<(), std::iter::Empty<()>>` to implement `Iterator` + --> $DIR/issue-91949-hangs-on-recursion.rs:16:32 + | +LL | impl<T, I: Iterator<Item = T>> Iterator for IteratorOfWrapped<T, I> { + | -------- ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ + | | + | unsatisfied trait bound introduced here + = note: 256 redundant requirements hidden = note: required for `IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<IteratorOfWrapped<(), Map<..., ...>>, ...>>, ...>>` to implement `Iterator` = note: the full type name has been written to '$TEST_BUILD_DIR/traits/issue-91949-hangs-on-recursion/issue-91949-hangs-on-recursion.long-type-hash.txt' diff --git a/tests/ui/traits/item-privacy.stderr b/tests/ui/traits/item-privacy.stderr index 04995b3a1..f53813189 100644 --- a/tests/ui/traits/item-privacy.stderr +++ b/tests/ui/traits/item-privacy.stderr @@ -29,7 +29,7 @@ LL | S.b(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use method::B; +LL + use method::B; | error[E0624]: method `a` is private @@ -69,7 +69,7 @@ LL | S::b(&S); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use method::B; +LL + use method::B; | error[E0624]: method `a` is private @@ -109,7 +109,7 @@ LL | S::B; = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use assoc_const::B; +LL + use assoc_const::B; | error[E0624]: associated constant `A` is private diff --git a/tests/ui/traits/method-private.stderr b/tests/ui/traits/method-private.stderr index 55656f21e..e11799308 100644 --- a/tests/ui/traits/method-private.stderr +++ b/tests/ui/traits/method-private.stderr @@ -10,7 +10,7 @@ LL | foo.method(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use inner::Bar; +LL + use inner::Bar; | error: aborting due to previous error diff --git a/tests/ui/traits/new-solver/alias-eq-in-canonical-response.rs b/tests/ui/traits/new-solver/alias-eq-in-canonical-response.rs new file mode 100644 index 000000000..4bfb6323a --- /dev/null +++ b/tests/ui/traits/new-solver/alias-eq-in-canonical-response.rs @@ -0,0 +1,40 @@ +// check-pass +// compile-flags: -Ztrait-solver=next + +trait Foo { + type Gat<'a> + where + Self: 'a; + fn bar(&self) -> Self::Gat<'_>; +} + +enum Option<T> { + Some(T), + None, +} + +impl<T> Option<T> { + fn as_ref(&self) -> Option<&T> { + match self { + Option::Some(t) => Option::Some(t), + Option::None => Option::None, + } + } + + fn map<U>(self, f: impl FnOnce(T) -> U) -> Option<U> { + match self { + Option::Some(t) => Option::Some(f(t)), + Option::None => Option::None, + } + } +} + +impl<T: Foo + 'static> Foo for Option<T> { + type Gat<'a> = Option<<T as Foo>::Gat<'a>> where Self: 'a; + + fn bar(&self) -> Self::Gat<'_> { + self.as_ref().map(Foo::bar) + } +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/alias-sub.rs b/tests/ui/traits/new-solver/alias-sub.rs new file mode 100644 index 000000000..30c1981a9 --- /dev/null +++ b/tests/ui/traits/new-solver/alias-sub.rs @@ -0,0 +1,34 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Trait { + type Assoc: Sized; +} + +impl Trait for &'static str { + type Assoc = &'static str; +} + +// Wrapper is just here to get around stupid `Sized` obligations in mir typeck +struct Wrapper<T: ?Sized>(std::marker::PhantomData<T>); +fn mk<T: Trait>(x: T) -> Wrapper<<T as Trait>::Assoc> { todo!() } + + +trait IsStaticStr {} +impl IsStaticStr for (&'static str,) {} +fn define<T: IsStaticStr>(_: T) {} + +fn foo<'a, T: Trait>() { + let y = Default::default(); + + // `<?0 as Trait>::Assoc <: &'a str` + // In the old solver, this would *equate* the LHS and RHS. + let _: Wrapper<&'a str> = mk(y); + + // ... then later on, we constrain `?0 = &'static str` + // but that should not mean that `'a = 'static`, because + // we should use *sub* above. + define((y,)); +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs b/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs index fd5d0e3b1..531203d9c 100644 --- a/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs +++ b/tests/ui/traits/new-solver/alias_eq_dont_use_normalizes_to_if_substs_eq.rs @@ -1,7 +1,7 @@ // compile-flags: -Ztrait-solver=next // check that when computing `alias-eq(<() as Foo<u16, T>>::Assoc, <() as Foo<?0, T>>::Assoc)` -// we do not infer `?0 = u8` via the `for<STOP> (): Foo<u8, STOP>` impl or `?0 = u16` by +// we do not infer `?0 = u8` via the `for<STOP> (): Foo<u8, STOP>` impl or `?0 = u16` by // relating substs as either could be a valid solution. trait Foo<T, STOP> { diff --git a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.fail.stderr b/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.fail.stderr new file mode 100644 index 000000000..6a926534e --- /dev/null +++ b/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.fail.stderr @@ -0,0 +1,18 @@ +error[E0277]: `impl Future<Output = ()>` cannot be sent between threads safely + --> $DIR/auto-with-drop_tracking_mir.rs:24:13 + | +LL | is_send(foo()); + | ------- ^^^^^ `impl Future<Output = ()>` cannot be sent between threads safely + | | + | required by a bound introduced by this call + | + = help: the trait `Send` is not implemented for `impl Future<Output = ()>` +note: required by a bound in `is_send` + --> $DIR/auto-with-drop_tracking_mir.rs:23:24 + | +LL | fn is_send(_: impl Send) {} + | ^^^^ required by this bound in `is_send` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs b/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs new file mode 100644 index 000000000..a5db7c463 --- /dev/null +++ b/tests/ui/traits/new-solver/auto-with-drop_tracking_mir.rs @@ -0,0 +1,26 @@ +// compile-flags: -Ztrait-solver=next -Zdrop-tracking-mir +// edition: 2021 +// revisions: pass fail +//[pass] check-pass + +#![feature(negative_impls)] + +struct NotSync; +impl !Sync for NotSync {} + +async fn foo() { + #[cfg(pass)] + let x = &(); + #[cfg(fail)] + let x = &NotSync; + bar().await; + drop(x); +} + +async fn bar() {} + +fn main() { + fn is_send(_: impl Send) {} + is_send(foo()); + //[fail]~^ ERROR `impl Future<Output = ()>` cannot be sent between threads safely +} diff --git a/tests/ui/traits/new-solver/canonical-int-var-eq-in-response.rs b/tests/ui/traits/new-solver/canonical-int-var-eq-in-response.rs new file mode 100644 index 000000000..4b013983a --- /dev/null +++ b/tests/ui/traits/new-solver/canonical-int-var-eq-in-response.rs @@ -0,0 +1,22 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Mirror { + type Assoc; +} + +impl<T> Mirror for T { + type Assoc = T; +} + +trait Test {} +impl Test for i64 {} +impl Test for u64 {} + +fn mirror_me<T: Mirror>(t: T, s: <T as Mirror>::Assoc) where <T as Mirror>::Assoc: Test {} + +fn main() { + let mut x = 0; + mirror_me(x, 1); + x = 1i64; +} diff --git a/tests/ui/traits/new-solver/canonical-ty-var-eq-in-response.rs b/tests/ui/traits/new-solver/canonical-ty-var-eq-in-response.rs new file mode 100644 index 000000000..d1c6b1077 --- /dev/null +++ b/tests/ui/traits/new-solver/canonical-ty-var-eq-in-response.rs @@ -0,0 +1,39 @@ +// check-pass +// compile-flags: -Ztrait-solver=next + +trait Mirror { + type Item; +} + +struct Wrapper<T>(T); +impl<T> Mirror for Wrapper<T> { + type Item = T; +} + +fn mirror<T>() +where + Wrapper<T>: Mirror<Item = i32>, +{ +} + +fn main() { + mirror::<_ /* ?0 */>(); + + // Solving `<Wrapper<?0> as Mirror>::Item = i32` + + // First, we replace the term with a fresh infer var: + // `<Wrapper<?0> as Mirror>::Item = ?1` + + // We select the impl candidate on line #6, which leads us to learn that + // `?0 == ?1`. + + // That should be reflected in our canonical response, which should have + // `^0 = ^0, ^1 = ^0` + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + // !! We used to return a totally unconstrained response here :< !! + // !!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!!! + + // Then, during the "equate term" part of the projection solving, we + // instantiate the response from the unconstrained projection predicate, + // and equate `?0 == i32`. +} diff --git a/tests/ui/typeck/lazy-norm/cast-checks-handling-projections.rs b/tests/ui/traits/new-solver/cast-checks-handling-projections.rs index 5ff567cd0..3b261062f 100644 --- a/tests/ui/typeck/lazy-norm/cast-checks-handling-projections.rs +++ b/tests/ui/traits/new-solver/cast-checks-handling-projections.rs @@ -1,5 +1,5 @@ // compile-flags: -Ztrait-solver=next -// known-bug: unknown +// check-pass fn main() { (0u8 + 0u8) as char; diff --git a/tests/ui/traits/new-solver/closure-inference-guidance.rs b/tests/ui/traits/new-solver/closure-inference-guidance.rs new file mode 100644 index 000000000..d2ad0cc03 --- /dev/null +++ b/tests/ui/traits/new-solver/closure-inference-guidance.rs @@ -0,0 +1,11 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +fn foo(i: isize) -> isize { i + 1 } + +fn apply<A, F>(f: F, v: A) -> A where F: FnOnce(A) -> A { f(v) } + +pub fn main() { + let f = |i| foo(i); + assert_eq!(apply(f, 2), 3); +} diff --git a/tests/ui/traits/new-solver/coherence/issue-102048.rs b/tests/ui/traits/new-solver/coherence/issue-102048.rs new file mode 100644 index 000000000..11636bfeb --- /dev/null +++ b/tests/ui/traits/new-solver/coherence/issue-102048.rs @@ -0,0 +1,44 @@ +// This must fail coherence. +// +// Getting this to pass was fairly difficult, so here's an explanation +// of what's happening: +// +// Normalizing projections currently tries to replace them with inference variables +// while emitting a nested `Projection` obligation. This cannot be done if the projection +// has bound variables which is the case here. +// +// So the projections stay until after normalization. When unifying two projections we +// currently treat them as if they are injective, so we **incorrectly** unify their +// substs. This means that coherence for the two impls ends up unifying `?T` and `?U` +// as it tries to unify `<?T as WithAssoc1<'a>>::Assoc` with `<?U as WithAssoc1<'a>>::Assoc`. +// +// `impl1` therefore has the projection `<?T as WithAssoc2<'a>>::Assoc` and we have the +// assumption `?T: for<'a> WithAssoc2<'a, Assoc = i32>` in the `param_env`, so we normalize +// that to `i32`. We then try to unify `i32` from `impl1` with `u32` from `impl2` which fails, +// causing coherence to consider these two impls distinct. + +// compile-flags: -Ztrait-solver=next +pub trait Trait<T> {} + +pub trait WithAssoc1<'a> { + type Assoc; +} +pub trait WithAssoc2<'a> { + type Assoc; +} + +// impl 1 +impl<T, U> Trait<for<'a> fn(<T as WithAssoc1<'a>>::Assoc, <U as WithAssoc2<'a>>::Assoc)> for (T, U) +where + T: for<'a> WithAssoc1<'a> + for<'a> WithAssoc2<'a, Assoc = i32>, + U: for<'a> WithAssoc2<'a>, +{ +} + +// impl 2 +impl<T, U> Trait<for<'a> fn(<U as WithAssoc1<'a>>::Assoc, u32)> for (T, U) where + U: for<'a> WithAssoc1<'a> //~^ ERROR conflicting implementations of trait +{ +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/coherence/issue-102048.stderr b/tests/ui/traits/new-solver/coherence/issue-102048.stderr new file mode 100644 index 000000000..17a43838f --- /dev/null +++ b/tests/ui/traits/new-solver/coherence/issue-102048.stderr @@ -0,0 +1,12 @@ +error[E0119]: conflicting implementations of trait `Trait<for<'a> fn(<_ as WithAssoc1<'a>>::Assoc, <_ as WithAssoc2<'a>>::Assoc)>` for type `(_, _)` + --> $DIR/issue-102048.rs:39:1 + | +LL | impl<T, U> Trait<for<'a> fn(<T as WithAssoc1<'a>>::Assoc, <U as WithAssoc2<'a>>::Assoc)> for (T, U) + | --------------------------------------------------------------------------------------------------- first implementation here +... +LL | impl<T, U> Trait<for<'a> fn(<U as WithAssoc1<'a>>::Assoc, u32)> for (T, U) where + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_, _)` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/traits/new-solver/const-param-placeholder.fail.stderr b/tests/ui/traits/new-solver/const-param-placeholder.fail.stderr new file mode 100644 index 000000000..4db6e22e5 --- /dev/null +++ b/tests/ui/traits/new-solver/const-param-placeholder.fail.stderr @@ -0,0 +1,16 @@ +error[E0277]: the trait bound `[T; N]: Foo` is not satisfied + --> $DIR/const-param-placeholder.rs:17:17 + | +LL | needs_foo::<[T; N]>(); + | ^^^^^^ the trait `Foo` is not implemented for `[T; N]` + | + = help: the trait `Foo` is implemented for `[T; 1]` +note: required by a bound in `needs_foo` + --> $DIR/const-param-placeholder.rs:8:17 + | +LL | fn needs_foo<F: Foo>() {} + | ^^^ required by this bound in `needs_foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/const-param-placeholder.rs b/tests/ui/traits/new-solver/const-param-placeholder.rs new file mode 100644 index 000000000..a83102a4c --- /dev/null +++ b/tests/ui/traits/new-solver/const-param-placeholder.rs @@ -0,0 +1,21 @@ +// compile-flags: -Ztrait-solver=next +// revisions: pass fail +//[pass] check-pass + +struct Wrapper<T, const N: usize>([T; N]); + +trait Foo {} +fn needs_foo<F: Foo>() {} + +#[cfg(fail)] +impl<T> Foo for [T; 1] {} + +#[cfg(pass)] +impl<T, const N: usize> Foo for [T; N] {} + +fn test<T, const N: usize>() { + needs_foo::<[T; N]>(); + //[fail]~^ ERROR the trait bound `[T; N]: Foo` is not satisfied +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/deduce-ty-from-object.rs b/tests/ui/traits/new-solver/deduce-ty-from-object.rs new file mode 100644 index 000000000..7398bce7b --- /dev/null +++ b/tests/ui/traits/new-solver/deduce-ty-from-object.rs @@ -0,0 +1,6 @@ +// check-pass +// compile-flags: -Ztrait-solver=next + +fn main() { + let x: Box<dyn Iterator<Item = ()>> = Box::new(std::iter::empty()); +} diff --git a/tests/ui/traits/new-solver/destruct.rs b/tests/ui/traits/new-solver/destruct.rs new file mode 100644 index 000000000..30d7777b7 --- /dev/null +++ b/tests/ui/traits/new-solver/destruct.rs @@ -0,0 +1,13 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +#![feature(const_trait_impl)] + +fn foo(_: impl std::marker::Destruct) {} + +struct MyAdt; + +fn main() { + foo(1); + foo(MyAdt); +} diff --git a/tests/ui/traits/new-solver/dont-elaborate-for-projections.rs b/tests/ui/traits/new-solver/dont-elaborate-for-projections.rs new file mode 100644 index 000000000..e60825006 --- /dev/null +++ b/tests/ui/traits/new-solver/dont-elaborate-for-projections.rs @@ -0,0 +1,12 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Iter<'a, I: 'a>: Iterator<Item = &'a I> {} + +fn needs_iter<'a, T: Iter<'a, I> + ?Sized, I: 'a>(_: &T) {} + +fn test(x: &dyn Iter<'_, ()>) { + needs_iter(x); +} + +fn main() {} diff --git a/tests/ui/typeck/lazy-norm/equating-projection-cyclically.rs b/tests/ui/traits/new-solver/equating-projection-cyclically.rs index 019c6e81c..019c6e81c 100644 --- a/tests/ui/typeck/lazy-norm/equating-projection-cyclically.rs +++ b/tests/ui/traits/new-solver/equating-projection-cyclically.rs diff --git a/tests/ui/typeck/lazy-norm/equating-projection-cyclically.stderr b/tests/ui/traits/new-solver/equating-projection-cyclically.stderr index 57cbc65a1..57cbc65a1 100644 --- a/tests/ui/typeck/lazy-norm/equating-projection-cyclically.stderr +++ b/tests/ui/traits/new-solver/equating-projection-cyclically.stderr diff --git a/tests/ui/traits/new-solver/float-canonical.rs b/tests/ui/traits/new-solver/float-canonical.rs new file mode 100644 index 000000000..b8748cd43 --- /dev/null +++ b/tests/ui/traits/new-solver/float-canonical.rs @@ -0,0 +1,8 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +fn foo(x: f64) { + let y = x + 1.0; +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/fn-trait.rs b/tests/ui/traits/new-solver/fn-trait.rs index d566ead10..0599e51d7 100644 --- a/tests/ui/traits/new-solver/fn-trait.rs +++ b/tests/ui/traits/new-solver/fn-trait.rs @@ -1,5 +1,4 @@ // compile-flags: -Ztrait-solver=next -// check-pass fn require_fn(_: impl Fn() -> i32) {} @@ -7,7 +6,27 @@ fn f() -> i32 { 1i32 } +extern "C" fn g() -> i32 { + 2i32 +} + +unsafe fn h() -> i32 { + 2i32 +} + fn main() { require_fn(f); require_fn(f as fn() -> i32); + require_fn(f as unsafe fn() -> i32); + //~^ ERROR: expected a `Fn<()>` closure, found `unsafe fn() -> i32` + //~| ERROR: type mismatch resolving `<unsafe fn() -> i32 as FnOnce<()>>::Output == i32` + require_fn(g); + //~^ ERROR: expected a `Fn<()>` closure, found `extern "C" fn() -> i32 {g}` + //~| ERROR: type mismatch resolving `<extern "C" fn() -> i32 {g} as FnOnce<()>>::Output == i32` + require_fn(g as extern "C" fn() -> i32); + //~^ ERROR: expected a `Fn<()>` closure, found `extern "C" fn() -> i32` + //~| ERROR: type mismatch resolving `<extern "C" fn() -> i32 as FnOnce<()>>::Output == i32` + require_fn(h); + //~^ ERROR: expected a `Fn<()>` closure, found `unsafe fn() -> i32 {h}` + //~| ERROR: type mismatch resolving `<unsafe fn() -> i32 {h} as FnOnce<()>>::Output == i32` } diff --git a/tests/ui/traits/new-solver/fn-trait.stderr b/tests/ui/traits/new-solver/fn-trait.stderr new file mode 100644 index 000000000..d52bcaf25 --- /dev/null +++ b/tests/ui/traits/new-solver/fn-trait.stderr @@ -0,0 +1,124 @@ +error[E0277]: expected a `Fn<()>` closure, found `unsafe fn() -> i32` + --> $DIR/fn-trait.rs:20:16 + | +LL | require_fn(f as unsafe fn() -> i32); + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^ call the function in a closure: `|| unsafe { /* code */ }` + | | + | required by a bound introduced by this call + | + = help: the trait `Fn<()>` is not implemented for `unsafe fn() -> i32` + = note: wrap the `unsafe fn() -> i32` in a closure with no arguments: `|| { /* code */ }` +note: required by a bound in `require_fn` + --> $DIR/fn-trait.rs:3:23 + | +LL | fn require_fn(_: impl Fn() -> i32) {} + | ^^^^^^^^^^^ required by this bound in `require_fn` + +error[E0271]: type mismatch resolving `<unsafe fn() -> i32 as FnOnce<()>>::Output == i32` + --> $DIR/fn-trait.rs:20:16 + | +LL | require_fn(f as unsafe fn() -> i32); + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^ types differ + | | + | required by a bound introduced by this call + | +note: required by a bound in `require_fn` + --> $DIR/fn-trait.rs:3:31 + | +LL | fn require_fn(_: impl Fn() -> i32) {} + | ^^^ required by this bound in `require_fn` + +error[E0277]: expected a `Fn<()>` closure, found `extern "C" fn() -> i32 {g}` + --> $DIR/fn-trait.rs:23:16 + | +LL | require_fn(g); + | ---------- ^ expected an `Fn<()>` closure, found `extern "C" fn() -> i32 {g}` + | | + | required by a bound introduced by this call + | + = help: the trait `Fn<()>` is not implemented for fn item `extern "C" fn() -> i32 {g}` + = note: wrap the `extern "C" fn() -> i32 {g}` in a closure with no arguments: `|| { /* code */ }` +note: required by a bound in `require_fn` + --> $DIR/fn-trait.rs:3:23 + | +LL | fn require_fn(_: impl Fn() -> i32) {} + | ^^^^^^^^^^^ required by this bound in `require_fn` + +error[E0271]: type mismatch resolving `<extern "C" fn() -> i32 {g} as FnOnce<()>>::Output == i32` + --> $DIR/fn-trait.rs:23:16 + | +LL | require_fn(g); + | ---------- ^ types differ + | | + | required by a bound introduced by this call + | +note: required by a bound in `require_fn` + --> $DIR/fn-trait.rs:3:31 + | +LL | fn require_fn(_: impl Fn() -> i32) {} + | ^^^ required by this bound in `require_fn` + +error[E0277]: expected a `Fn<()>` closure, found `extern "C" fn() -> i32` + --> $DIR/fn-trait.rs:26:16 + | +LL | require_fn(g as extern "C" fn() -> i32); + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `Fn<()>` closure, found `extern "C" fn() -> i32` + | | + | required by a bound introduced by this call + | + = help: the trait `Fn<()>` is not implemented for `extern "C" fn() -> i32` + = note: wrap the `extern "C" fn() -> i32` in a closure with no arguments: `|| { /* code */ }` +note: required by a bound in `require_fn` + --> $DIR/fn-trait.rs:3:23 + | +LL | fn require_fn(_: impl Fn() -> i32) {} + | ^^^^^^^^^^^ required by this bound in `require_fn` + +error[E0271]: type mismatch resolving `<extern "C" fn() -> i32 as FnOnce<()>>::Output == i32` + --> $DIR/fn-trait.rs:26:16 + | +LL | require_fn(g as extern "C" fn() -> i32); + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ types differ + | | + | required by a bound introduced by this call + | +note: required by a bound in `require_fn` + --> $DIR/fn-trait.rs:3:31 + | +LL | fn require_fn(_: impl Fn() -> i32) {} + | ^^^ required by this bound in `require_fn` + +error[E0277]: expected a `Fn<()>` closure, found `unsafe fn() -> i32 {h}` + --> $DIR/fn-trait.rs:29:16 + | +LL | require_fn(h); + | ---------- ^ call the function in a closure: `|| unsafe { /* code */ }` + | | + | required by a bound introduced by this call + | + = help: the trait `Fn<()>` is not implemented for fn item `unsafe fn() -> i32 {h}` + = note: wrap the `unsafe fn() -> i32 {h}` in a closure with no arguments: `|| { /* code */ }` +note: required by a bound in `require_fn` + --> $DIR/fn-trait.rs:3:23 + | +LL | fn require_fn(_: impl Fn() -> i32) {} + | ^^^^^^^^^^^ required by this bound in `require_fn` + +error[E0271]: type mismatch resolving `<unsafe fn() -> i32 {h} as FnOnce<()>>::Output == i32` + --> $DIR/fn-trait.rs:29:16 + | +LL | require_fn(h); + | ---------- ^ types differ + | | + | required by a bound introduced by this call + | +note: required by a bound in `require_fn` + --> $DIR/fn-trait.rs:3:31 + | +LL | fn require_fn(_: impl Fn() -> i32) {} + | ^^^ required by this bound in `require_fn` + +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0271, E0277. +For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/traits/new-solver/int-var-alias-eq.rs b/tests/ui/traits/new-solver/int-var-alias-eq.rs new file mode 100644 index 000000000..2da387db4 --- /dev/null +++ b/tests/ui/traits/new-solver/int-var-alias-eq.rs @@ -0,0 +1,18 @@ +// check-pass +// compile-flags: -Ztrait-solver=next + +// HIR typeck ends up equating `<_#0i as Add>::Output == _#0i`. +// Want to make sure that we emit an alias-eq goal for this, +// instead of treating it as a type error and bailing. + +fn test() { + // fallback + let x = 1 + 2; +} + +fn test2() -> u32 { + // expectation from return ty + 1 + 2 +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/int-var-is-send.rs b/tests/ui/traits/new-solver/int-var-is-send.rs new file mode 100644 index 000000000..083aa90e1 --- /dev/null +++ b/tests/ui/traits/new-solver/int-var-is-send.rs @@ -0,0 +1,8 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +fn needs_send(_: impl Send) {} + +fn main() { + needs_send(1); +} diff --git a/tests/ui/traits/new-solver/iter-filter-projection.rs b/tests/ui/traits/new-solver/iter-filter-projection.rs new file mode 100644 index 000000000..8fb62323a --- /dev/null +++ b/tests/ui/traits/new-solver/iter-filter-projection.rs @@ -0,0 +1,12 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +use std::{iter, slice}; + +struct Attr; + +fn test<'a, T: Iterator<Item = &'a Attr>>() {} + +fn main() { + test::<iter::Filter<slice::Iter<'_, Attr>, fn(&&Attr) -> bool>>(); +} diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-1.rs b/tests/ui/traits/new-solver/lazy-nested-obligations-1.rs new file mode 100644 index 000000000..af00cbb3b --- /dev/null +++ b/tests/ui/traits/new-solver/lazy-nested-obligations-1.rs @@ -0,0 +1,13 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 94358 + +fn foo<C>(_: C) +where + for <'a> &'a C: IntoIterator, + for <'a> <&'a C as IntoIterator>::IntoIter: ExactSizeIterator, +{} + +fn main() { + foo::<_>(vec![true, false]); +} diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs b/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs new file mode 100644 index 000000000..32addd829 --- /dev/null +++ b/tests/ui/traits/new-solver/lazy-nested-obligations-2.rs @@ -0,0 +1,23 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 95863 + +pub trait With { + type F; +} + +impl With for i32 { + type F = fn(&str); +} + +fn f(_: &str) {} + +fn main() { + let _: V<i32> = V(f); + pub struct V<T: With>(<T as With>::F); + + pub enum E3<T: With> { + Var(<T as With>::F), + } + let _: E3<i32> = E3::Var(f); +} diff --git a/tests/ui/traits/new-solver/lazy-nested-obligations-3.rs b/tests/ui/traits/new-solver/lazy-nested-obligations-3.rs new file mode 100644 index 000000000..baf399572 --- /dev/null +++ b/tests/ui/traits/new-solver/lazy-nested-obligations-3.rs @@ -0,0 +1,38 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 96750 + +use std::marker::PhantomData; + +trait AsyncFn<Arg> { + type Output; +} +trait RequestFamily { + type Type<'a>; +} +trait Service {} + +struct MyFn; +impl AsyncFn<String> for MyFn { + type Output = (); +} + +impl RequestFamily for String { + type Type<'a> = String; +} + +struct ServiceFromAsyncFn<F, Req>(F, PhantomData<Req>); + +impl<F, Req, O> Service for ServiceFromAsyncFn<F, Req> +where + Req: RequestFamily, + F: AsyncFn<Req>, + F: for<'a> AsyncFn<Req::Type<'a>, Output = O>, +{ +} + +fn assert_service() -> impl Service { + ServiceFromAsyncFn(MyFn, PhantomData) +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/more-object-bound.rs b/tests/ui/traits/new-solver/more-object-bound.rs index 712759ef0..bb730b18e 100644 --- a/tests/ui/traits/new-solver/more-object-bound.rs +++ b/tests/ui/traits/new-solver/more-object-bound.rs @@ -10,7 +10,7 @@ trait Trait: SuperTrait<A = <Self as SuperTrait>::B> {} fn transmute<A, B>(x: A) -> B { foo::<A, B, dyn Trait<A = A, B = B>>(x) - //~^ ERROR type annotations needed: cannot satisfy `dyn Trait<A = A, B = B>: Trait` + //~^ ERROR the trait bound `dyn Trait<A = A, B = B>: Trait` is not satisfied } fn foo<A, B, T: ?Sized>(x: T::A) -> B diff --git a/tests/ui/traits/new-solver/more-object-bound.stderr b/tests/ui/traits/new-solver/more-object-bound.stderr index 208fdecb0..4554b8c74 100644 --- a/tests/ui/traits/new-solver/more-object-bound.stderr +++ b/tests/ui/traits/new-solver/more-object-bound.stderr @@ -1,10 +1,9 @@ -error[E0283]: type annotations needed: cannot satisfy `dyn Trait<A = A, B = B>: Trait` - --> $DIR/more-object-bound.rs:12:5 +error[E0277]: the trait bound `dyn Trait<A = A, B = B>: Trait` is not satisfied + --> $DIR/more-object-bound.rs:12:17 | LL | foo::<A, B, dyn Trait<A = A, B = B>>(x) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `dyn Trait<A = A, B = B>` | - = note: cannot satisfy `dyn Trait<A = A, B = B>: Trait` note: required by a bound in `foo` --> $DIR/more-object-bound.rs:18:8 | @@ -13,7 +12,11 @@ LL | fn foo<A, B, T: ?Sized>(x: T::A) -> B LL | where LL | T: Trait<B = B>, | ^^^^^^^^^^^^ required by this bound in `foo` +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn transmute<A, B>(x: A) -> B where dyn Trait<A = A, B = B>: Trait { + | ++++++++++++++++++++++++++++++++++++ error: aborting due to previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/nested-obligations-with-bound-vars-gat.rs b/tests/ui/traits/new-solver/nested-obligations-with-bound-vars-gat.rs new file mode 100644 index 000000000..92bad9590 --- /dev/null +++ b/tests/ui/traits/new-solver/nested-obligations-with-bound-vars-gat.rs @@ -0,0 +1,43 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 96230 + +use std::fmt::Debug; + +trait Classic { + type Assoc; +} + +trait Gat { + type Assoc<'a>; +} + +struct Foo; + +impl Classic for Foo { + type Assoc = (); +} + +impl Gat for Foo { + type Assoc<'i> = (); +} + +fn classic_debug<T: Classic>(_: T) +where + T::Assoc: Debug, +{ +} + +fn gat_debug<T: Gat>(_: T) +where + for<'a> T::Assoc<'a>: Debug, +{ +} + +fn main() { + classic_debug::<Foo>(Foo); // fine + classic_debug(Foo); // fine + + gat_debug::<Foo>(Foo); // fine + gat_debug(Foo); // boom +} diff --git a/tests/ui/traits/new-solver/normalize-param-env-1.rs b/tests/ui/traits/new-solver/normalize-param-env-1.rs new file mode 100644 index 000000000..b02a5d623 --- /dev/null +++ b/tests/ui/traits/new-solver/normalize-param-env-1.rs @@ -0,0 +1,40 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 108933 + +trait Add<Rhs> { + type Sum; +} + +impl Add<()> for () { + type Sum = (); +} + +type Unit = <() as Add<()>>::Sum; + +trait Trait<C> { + type Output; +} + +fn f<T>() +where + T: Trait<()>, + <T as Trait<()>>::Output: Sized, +{ +} + +fn g<T>() +where + T: Trait<Unit>, + <T as Trait<()>>::Output: Sized, +{ +} + +fn h<T>() +where + T: Trait<()>, + <T as Trait<Unit>>::Output: Sized, +{ +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/normalize-param-env-2.rs b/tests/ui/traits/new-solver/normalize-param-env-2.rs new file mode 100644 index 000000000..7c2cebdd2 --- /dev/null +++ b/tests/ui/traits/new-solver/normalize-param-env-2.rs @@ -0,0 +1,26 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 92505 + +trait A<T> { + type I; + + fn f() + where + Self::I: A<T>, + { + } +} + +impl<T> A<T> for () { + type I = (); + + fn f() + where + Self::I: A<T>, + { + <() as A<T>>::f(); + } +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/normalize-param-env-3.rs b/tests/ui/traits/new-solver/normalize-param-env-3.rs new file mode 100644 index 000000000..ce2974b2a --- /dev/null +++ b/tests/ui/traits/new-solver/normalize-param-env-3.rs @@ -0,0 +1,32 @@ +// check-pass +// compile-flags: -Ztrait-solver=next +// Issue 100177 + +trait GenericTrait<T> {} + +trait Channel<I>: GenericTrait<Self::T> { + type T; +} + +trait Sender { + type Msg; + + fn send<C>() + where + C: Channel<Self::Msg>; +} + +impl<T> Sender for T { + type Msg = (); + + fn send<C>() + where + C: Channel<Self::Msg>, + { + } +} + +// This works +fn foo<I, C>(ch: C) where C: Channel<I> {} + +fn main() {} diff --git a/tests/ui/traits/new-solver/param-discr-kind.rs b/tests/ui/traits/new-solver/param-discr-kind.rs new file mode 100644 index 000000000..e319ddea1 --- /dev/null +++ b/tests/ui/traits/new-solver/param-discr-kind.rs @@ -0,0 +1,8 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +fn foo<T>(x: T) { + std::mem::discriminant(&x); +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/pointee.rs b/tests/ui/traits/new-solver/pointee.rs index fa6ee2e2d..93c0542ac 100644 --- a/tests/ui/traits/new-solver/pointee.rs +++ b/tests/ui/traits/new-solver/pointee.rs @@ -7,17 +7,15 @@ use std::ptr::{DynMetadata, Pointee}; trait Trait<U> {} struct MyDst<T: ?Sized>(T); -fn works<T>() { - let _: <T as Pointee>::Metadata = (); - let _: <[T] as Pointee>::Metadata = 1_usize; - let _: <str as Pointee>::Metadata = 1_usize; - let _: <dyn Trait<T> as Pointee>::Metadata = give::<DynMetadata<dyn Trait<T>>>(); - let _: <MyDst<T> as Pointee>::Metadata = (); - let _: <((((([u8],),),),),) as Pointee>::Metadata = 1_usize; -} +fn meta_is<T: Pointee<Metadata = U> + ?Sized, U>() {} -fn give<U>() -> U { - loop {} +fn works<T>() { + meta_is::<T, ()>(); + meta_is::<[T], usize>(); + meta_is::<str, usize>(); + meta_is::<dyn Trait<T>, DynMetadata<dyn Trait<T>>>(); + meta_is::<MyDst<T>, ()>(); + meta_is::<((((([u8],),),),),), usize>(); } fn main() {} diff --git a/tests/ui/traits/new-solver/pointer-like.rs b/tests/ui/traits/new-solver/pointer-like.rs index 3745a075e..986301769 100644 --- a/tests/ui/traits/new-solver/pointer-like.rs +++ b/tests/ui/traits/new-solver/pointer-like.rs @@ -9,6 +9,6 @@ fn require_(_: impl PointerLike) {} fn main() { require_(1usize); require_(1u16); - //~^ ERROR `u16` needs to have the same alignment and size as a pointer + //~^ ERROR `u16` needs to have the same ABI as a pointer require_(&1i16); } diff --git a/tests/ui/traits/new-solver/pointer-like.stderr b/tests/ui/traits/new-solver/pointer-like.stderr index f695e6418..215a81cc2 100644 --- a/tests/ui/traits/new-solver/pointer-like.stderr +++ b/tests/ui/traits/new-solver/pointer-like.stderr @@ -1,4 +1,4 @@ -error[E0277]: `u16` needs to have the same alignment and size as a pointer +error[E0277]: `u16` needs to have the same ABI as a pointer --> $DIR/pointer-like.rs:11:14 | LL | require_(1u16); diff --git a/tests/ui/traits/new-solver/prefer-candidate-no-constraints.rs b/tests/ui/traits/new-solver/prefer-candidate-no-constraints.rs new file mode 100644 index 000000000..6f8164f3a --- /dev/null +++ b/tests/ui/traits/new-solver/prefer-candidate-no-constraints.rs @@ -0,0 +1,22 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Foo {} + +impl<T> Foo for T {} + +trait Bar {} + +struct Wrapper<'a, T>(&'a T); + +impl<'a, T> Bar for Wrapper<'a, T> where &'a T: Foo {} +// We need to satisfy `&'a T: Foo` when checking that this impl is WF +// that can either be satisfied via the param-env, or via an impl. +// +// When satisfied via the param-env, since each lifetime is canonicalized +// separately, we end up getting extra region constraints. +// +// However, when satisfied via the impl, there are no region constraints, +// and we can short-circuit a response with no external constraints. + +fn main() {} diff --git a/tests/ui/traits/new-solver/prefer-param-env-on-ambiguity.rs b/tests/ui/traits/new-solver/prefer-param-env-on-ambiguity.rs new file mode 100644 index 000000000..909b33ec3 --- /dev/null +++ b/tests/ui/traits/new-solver/prefer-param-env-on-ambiguity.rs @@ -0,0 +1,10 @@ +// compile-flags: -Ztrait-solver=next +// check-pass + +trait Foo<'a> {} +trait Bar<'a> {} + +impl<'a, T: Bar<'a>> Foo<'a> for T {} +impl<T> Bar<'static> for T {} + +fn main() {} diff --git a/tests/ui/traits/new-solver/projection-discr-kind.rs b/tests/ui/traits/new-solver/projection-discr-kind.rs new file mode 100644 index 000000000..20296b287 --- /dev/null +++ b/tests/ui/traits/new-solver/projection-discr-kind.rs @@ -0,0 +1,18 @@ +// compile-flags: -Ztrait-solver=next + +// Check that `<T::Assoc as DiscriminantKind>::Discriminant` doesn't normalize +// to itself and cause overflow/ambiguity. + +trait Foo { + type Assoc; +} + +trait Bar {} +fn needs_bar(_: impl Bar) {} + +fn foo<T: Foo>(x: T::Assoc) { + needs_bar(std::mem::discriminant(&x)); + //~^ ERROR the trait bound `Discriminant<<T as Foo>::Assoc>: Bar` is not satisfied +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/projection-discr-kind.stderr b/tests/ui/traits/new-solver/projection-discr-kind.stderr new file mode 100644 index 000000000..03e28f993 --- /dev/null +++ b/tests/ui/traits/new-solver/projection-discr-kind.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `Discriminant<<T as Foo>::Assoc>: Bar` is not satisfied + --> $DIR/projection-discr-kind.rs:14:15 + | +LL | needs_bar(std::mem::discriminant(&x)); + | --------- ^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Bar` is not implemented for `Discriminant<<T as Foo>::Assoc>` + | | + | required by a bound introduced by this call + | +note: required by a bound in `needs_bar` + --> $DIR/projection-discr-kind.rs:11:22 + | +LL | fn needs_bar(_: impl Bar) {} + | ^^^ required by this bound in `needs_bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/recursive-self-normalization-2.rs b/tests/ui/traits/new-solver/recursive-self-normalization-2.rs new file mode 100644 index 000000000..8c029f517 --- /dev/null +++ b/tests/ui/traits/new-solver/recursive-self-normalization-2.rs @@ -0,0 +1,19 @@ +// compile-flags: -Ztrait-solver=next + +trait Foo1 { + type Assoc1; +} + +trait Foo2 { + type Assoc2; +} + +trait Bar {} +fn needs_bar<S: Bar>() {} + +fn test<T: Foo1<Assoc1 = <T as Foo2>::Assoc2> + Foo2<Assoc2 = <T as Foo1>::Assoc1>>() { + needs_bar::<T::Assoc1>(); + //~^ ERROR overflow evaluating the requirement `<T as Foo1>::Assoc1: Bar` +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr b/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr new file mode 100644 index 000000000..139b0a456 --- /dev/null +++ b/tests/ui/traits/new-solver/recursive-self-normalization-2.stderr @@ -0,0 +1,16 @@ +error[E0275]: overflow evaluating the requirement `<T as Foo1>::Assoc1: Bar` + --> $DIR/recursive-self-normalization-2.rs:15:5 + | +LL | needs_bar::<T::Assoc1>(); + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization_2`) +note: required by a bound in `needs_bar` + --> $DIR/recursive-self-normalization-2.rs:12:17 + | +LL | fn needs_bar<S: Bar>() {} + | ^^^ required by this bound in `needs_bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/new-solver/recursive-self-normalization.rs b/tests/ui/traits/new-solver/recursive-self-normalization.rs new file mode 100644 index 000000000..06d187b5f --- /dev/null +++ b/tests/ui/traits/new-solver/recursive-self-normalization.rs @@ -0,0 +1,15 @@ +// compile-flags: -Ztrait-solver=next + +trait Foo { + type Assoc; +} + +trait Bar {} +fn needs_bar<S: Bar>() {} + +fn test<T: Foo<Assoc = <T as Foo>::Assoc>>() { + needs_bar::<T::Assoc>(); + //~^ ERROR overflow evaluating the requirement `<T as Foo>::Assoc: Bar` +} + +fn main() {} diff --git a/tests/ui/traits/new-solver/recursive-self-normalization.stderr b/tests/ui/traits/new-solver/recursive-self-normalization.stderr new file mode 100644 index 000000000..8e9b9b4b4 --- /dev/null +++ b/tests/ui/traits/new-solver/recursive-self-normalization.stderr @@ -0,0 +1,16 @@ +error[E0275]: overflow evaluating the requirement `<T as Foo>::Assoc: Bar` + --> $DIR/recursive-self-normalization.rs:11:5 + | +LL | needs_bar::<T::Assoc>(); + | ^^^^^^^^^^^^^^^^^^^^^ + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`recursive_self_normalization`) +note: required by a bound in `needs_bar` + --> $DIR/recursive-self-normalization.rs:8:17 + | +LL | fn needs_bar<S: Bar>() {} + | ^^^ required by this bound in `needs_bar` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/new-solver/runaway-impl-candidate-selection.rs b/tests/ui/traits/new-solver/runaway-impl-candidate-selection.rs new file mode 100644 index 000000000..1dca86d36 --- /dev/null +++ b/tests/ui/traits/new-solver/runaway-impl-candidate-selection.rs @@ -0,0 +1,15 @@ +// compile-flags: -Ztrait-solver=next + +// In the new solver, we are trying to select `<?0 as Iterator>::Item: Debug`, +// which, naively can be unified with every impl of `Debug` if we're not careful. +// This test makes sure that we treat projections with inference var substs as +// placeholders during fast reject. + +fn iter<T: Iterator>() -> <T as Iterator>::Item { + todo!() +} + +fn main() { + println!("{:?}", iter::<_>()); + //~^ ERROR type annotations needed +} diff --git a/tests/ui/traits/new-solver/runaway-impl-candidate-selection.stderr b/tests/ui/traits/new-solver/runaway-impl-candidate-selection.stderr new file mode 100644 index 000000000..47004821a --- /dev/null +++ b/tests/ui/traits/new-solver/runaway-impl-candidate-selection.stderr @@ -0,0 +1,9 @@ +error[E0282]: type annotations needed + --> $DIR/runaway-impl-candidate-selection.rs:13:22 + | +LL | println!("{:?}", iter::<_>()); + | ^^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `iter` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/traits/new-solver/specialization-transmute.rs b/tests/ui/traits/new-solver/specialization-transmute.rs new file mode 100644 index 000000000..a54701df4 --- /dev/null +++ b/tests/ui/traits/new-solver/specialization-transmute.rs @@ -0,0 +1,30 @@ +// compile-flags: -Ztrait-solver=next + +#![feature(specialization)] +//~^ WARN the feature `specialization` is incomplete + +trait Default { + type Id; + + fn intu(&self) -> &Self::Id; +} + +impl<T> Default for T { + default type Id = T; + + fn intu(&self) -> &Self::Id { + self + //~^ ERROR cannot satisfy `T <: <T as Default>::Id` + } +} + +fn transmute<T: Default<Id = U>, U: Copy>(t: T) -> U { + *t.intu() +} + +use std::num::NonZeroU8; +fn main() { + let s = transmute::<u8, Option<NonZeroU8>>(0); + //~^ ERROR cannot satisfy `<u8 as Default>::Id == Option<NonZeroU8> + assert_eq!(s, None); +} diff --git a/tests/ui/traits/new-solver/specialization-transmute.stderr b/tests/ui/traits/new-solver/specialization-transmute.stderr new file mode 100644 index 000000000..e67c56afc --- /dev/null +++ b/tests/ui/traits/new-solver/specialization-transmute.stderr @@ -0,0 +1,31 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/specialization-transmute.rs:3:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information + = help: consider using `min_specialization` instead, which is more stable and complete + = note: `#[warn(incomplete_features)]` on by default + +error[E0284]: type annotations needed: cannot satisfy `T <: <T as Default>::Id` + --> $DIR/specialization-transmute.rs:16:9 + | +LL | self + | ^^^^ cannot satisfy `T <: <T as Default>::Id` + +error[E0284]: type annotations needed: cannot satisfy `<u8 as Default>::Id == Option<NonZeroU8>` + --> $DIR/specialization-transmute.rs:27:13 + | +LL | let s = transmute::<u8, Option<NonZeroU8>>(0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot satisfy `<u8 as Default>::Id == Option<NonZeroU8>` + | +note: required by a bound in `transmute` + --> $DIR/specialization-transmute.rs:21:25 + | +LL | fn transmute<T: Default<Id = U>, U: Copy>(t: T) -> U { + | ^^^^^^ required by this bound in `transmute` + +error: aborting due to 2 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/traits/new-solver/specialization-unconstrained.rs b/tests/ui/traits/new-solver/specialization-unconstrained.rs new file mode 100644 index 000000000..02150689e --- /dev/null +++ b/tests/ui/traits/new-solver/specialization-unconstrained.rs @@ -0,0 +1,22 @@ +// compile-flags: -Ztrait-solver=next + +#![feature(specialization)] +//~^ WARN the feature `specialization` is incomplete + +// Do not treat the RHS of a projection-goal as an unconstrained `Certainty::Yes` response +// if the impl is still further specializable. + +trait Default { + type Id; +} + +impl<T> Default for T { + default type Id = T; +} + +fn test<T: Default<Id = U>, U>() {} + +fn main() { + test::<u32, ()>(); + //~^ ERROR cannot satisfy `<u32 as Default>::Id == ()` +} diff --git a/tests/ui/traits/new-solver/specialization-unconstrained.stderr b/tests/ui/traits/new-solver/specialization-unconstrained.stderr new file mode 100644 index 000000000..910925cba --- /dev/null +++ b/tests/ui/traits/new-solver/specialization-unconstrained.stderr @@ -0,0 +1,25 @@ +warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/specialization-unconstrained.rs:3:12 + | +LL | #![feature(specialization)] + | ^^^^^^^^^^^^^^ + | + = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information + = help: consider using `min_specialization` instead, which is more stable and complete + = note: `#[warn(incomplete_features)]` on by default + +error[E0284]: type annotations needed: cannot satisfy `<u32 as Default>::Id == ()` + --> $DIR/specialization-unconstrained.rs:20:5 + | +LL | test::<u32, ()>(); + | ^^^^^^^^^^^^^^^ cannot satisfy `<u32 as Default>::Id == ()` + | +note: required by a bound in `test` + --> $DIR/specialization-unconstrained.rs:17:20 + | +LL | fn test<T: Default<Id = U>, U>() {} + | ^^^^^^ required by this bound in `test` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0284`. diff --git a/tests/ui/traits/new-solver/stall-num-var-auto-trait.fallback.stderr b/tests/ui/traits/new-solver/stall-num-var-auto-trait.fallback.stderr new file mode 100644 index 000000000..a3ab7836c --- /dev/null +++ b/tests/ui/traits/new-solver/stall-num-var-auto-trait.fallback.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `i32: Foo` is not satisfied + --> $DIR/stall-num-var-auto-trait.rs:18:15 + | +LL | needs_foo(x); + | --------- ^ the trait `Foo` is not implemented for `i32` + | | + | required by a bound introduced by this call + | +note: required by a bound in `needs_foo` + --> $DIR/stall-num-var-auto-trait.rs:14:22 + | +LL | fn needs_foo(x: impl Foo) {} + | ^^^ required by this bound in `needs_foo` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/new-solver/stall-num-var-auto-trait.rs b/tests/ui/traits/new-solver/stall-num-var-auto-trait.rs new file mode 100644 index 000000000..0539c3a42 --- /dev/null +++ b/tests/ui/traits/new-solver/stall-num-var-auto-trait.rs @@ -0,0 +1,25 @@ +// compile-flags: -Ztrait-solver=next +// revisions: fallback constrain +//[constrain] check-pass + +// Tests that we stall the `{integer}: Foo` obligation until after we +// constrain the int type (or fallback occurs). + +#![feature(negative_impls, auto_traits)] + +auto trait Foo {} + +impl !Foo for i32 {} + +fn needs_foo(x: impl Foo) {} + +fn main() { + let mut x = 0; + needs_foo(x); + //[fallback]~^ ERROR the trait bound `i32: Foo` is not satisfied + + #[cfg(constrain)] + { + x = 1u64; + } +} diff --git a/tests/ui/traits/non_lifetime_binders/bad-copy-cond.rs b/tests/ui/traits/non_lifetime_binders/bad-copy-cond.rs new file mode 100644 index 000000000..506cad25f --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/bad-copy-cond.rs @@ -0,0 +1,9 @@ +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +fn foo() where for<T> T: Copy {} + +fn main() { + foo(); + //~^ ERROR the trait bound `T: Copy` is not satisfied +} diff --git a/tests/ui/traits/non_lifetime_binders/bad-copy-cond.stderr b/tests/ui/traits/non_lifetime_binders/bad-copy-cond.stderr new file mode 100644 index 000000000..07e02d47f --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/bad-copy-cond.stderr @@ -0,0 +1,24 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/bad-copy-cond.rs:1:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: the trait bound `T: Copy` is not satisfied + --> $DIR/bad-copy-cond.rs:7:5 + | +LL | foo(); + | ^^^ the trait `Copy` is not implemented for `T` + | +note: required by a bound in `foo` + --> $DIR/bad-copy-cond.rs:4:26 + | +LL | fn foo() where for<T> T: Copy {} + | ^^^^ required by this bound in `foo` + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.rs b/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.rs new file mode 100644 index 000000000..91c6dfb8e --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.rs @@ -0,0 +1,11 @@ +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +fn b() +where + for<const C: usize> [(); C]: Copy, + //~^ ERROR cannot capture late-bound const parameter in a constant +{ +} + +fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.stderr b/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.stderr new file mode 100644 index 000000000..69bb605bf --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/capture-late-ct-in-anon.stderr @@ -0,0 +1,19 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/capture-late-ct-in-anon.rs:1:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: cannot capture late-bound const parameter in a constant + --> $DIR/capture-late-ct-in-anon.rs:6:30 + | +LL | for<const C: usize> [(); C]: Copy, + | -------------- ^ + | | + | parameter defined here + +error: aborting due to previous error; 1 warning emitted + diff --git a/tests/ui/traits/non_lifetime_binders/method-probe.rs b/tests/ui/traits/non_lifetime_binders/method-probe.rs new file mode 100644 index 000000000..8df240c20 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/method-probe.rs @@ -0,0 +1,16 @@ +// check-pass + +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +trait Foo: for<T> Bar<T> {} + +trait Bar<T> { + fn method() -> T; +} + +fn x<T: Foo>() { + let _: i32 = T::method(); +} + +fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/method-probe.stderr b/tests/ui/traits/non_lifetime_binders/method-probe.stderr new file mode 100644 index 000000000..8f61792e6 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/method-probe.stderr @@ -0,0 +1,11 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/method-probe.rs:3:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/traits/non_lifetime_binders/missing-assoc-item.rs b/tests/ui/traits/non_lifetime_binders/missing-assoc-item.rs new file mode 100644 index 000000000..50f0152e9 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/missing-assoc-item.rs @@ -0,0 +1,11 @@ +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +fn f() +where + for<B> B::Item: Send, + //~^ ERROR ambiguous associated type +{ +} + +fn main() {} diff --git a/tests/ui/traits/non_lifetime_binders/missing-assoc-item.stderr b/tests/ui/traits/non_lifetime_binders/missing-assoc-item.stderr new file mode 100644 index 000000000..d98538642 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/missing-assoc-item.stderr @@ -0,0 +1,23 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/missing-assoc-item.rs:1:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0223]: ambiguous associated type + --> $DIR/missing-assoc-item.rs:6:12 + | +LL | for<B> B::Item: Send, + | ^^^^^^^ + | +help: if there were a trait named `Example` with associated type `Item` implemented for `B`, you could use the fully-qualified path + | +LL | for<B> <B as Example>::Item: Send, + | ~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0223`. diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.rs b/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.rs new file mode 100644 index 000000000..a635edb44 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.rs @@ -0,0 +1,24 @@ +#![feature(non_lifetime_binders)] +//~^ WARN the feature `non_lifetime_binders` is incomplete + +trait Foo: for<T> Bar<T> {} + +trait Bar<T: ?Sized> { + fn method(&self) {} +} + +fn needs_bar(x: &(impl Bar<i32> + ?Sized)) { + x.method(); +} + +impl Foo for () {} + +impl<T: ?Sized> Bar<T> for () {} + +fn main() { + let x: &dyn Foo = &(); + //~^ ERROR the trait `Foo` cannot be made into an object + //~| ERROR the trait `Foo` cannot be made into an object + needs_bar(x); + //~^ ERROR the trait `Foo` cannot be made into an object +} diff --git a/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr b/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr new file mode 100644 index 000000000..47fa29b66 --- /dev/null +++ b/tests/ui/traits/non_lifetime_binders/supertrait-object-safety.stderr @@ -0,0 +1,56 @@ +warning: the feature `non_lifetime_binders` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/supertrait-object-safety.rs:1:12 + | +LL | #![feature(non_lifetime_binders)] + | ^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/supertrait-object-safety.rs:19:23 + | +LL | let x: &dyn Foo = &(); + | ^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/supertrait-object-safety.rs:4:12 + | +LL | trait Foo: for<T> Bar<T> {} + | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables + | | + | this trait cannot be made into an object... + = note: required for `&()` to implement `CoerceUnsized<&dyn Foo>` + = note: required by cast to type `&dyn Foo` + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/supertrait-object-safety.rs:19:12 + | +LL | let x: &dyn Foo = &(); + | ^^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/supertrait-object-safety.rs:4:12 + | +LL | trait Foo: for<T> Bar<T> {} + | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables + | | + | this trait cannot be made into an object... + +error[E0038]: the trait `Foo` cannot be made into an object + --> $DIR/supertrait-object-safety.rs:22:5 + | +LL | needs_bar(x); + | ^^^^^^^^^ `Foo` cannot be made into an object + | +note: for a trait to be "object safe" it needs to allow building a vtable to allow the call to be resolvable dynamically; for more information visit <https://doc.rust-lang.org/reference/items/traits.html#object-safety> + --> $DIR/supertrait-object-safety.rs:4:12 + | +LL | trait Foo: for<T> Bar<T> {} + | --- ^^^^^^^^^^^^^ ...because where clause cannot reference non-lifetime `for<...>` variables + | | + | this trait cannot be made into an object... + +error: aborting due to 3 previous errors; 1 warning emitted + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/traits/reservation-impl/coherence-conflict.next.stderr b/tests/ui/traits/reservation-impl/coherence-conflict.next.stderr new file mode 100644 index 000000000..e5a3c3f5c --- /dev/null +++ b/tests/ui/traits/reservation-impl/coherence-conflict.next.stderr @@ -0,0 +1,11 @@ +error[E0119]: conflicting implementations of trait `OtherTrait` for type `()` + --> $DIR/coherence-conflict.rs:12:1 + | +LL | impl OtherTrait for () {} + | ---------------------- first implementation here +LL | impl<T: MyTrait> OtherTrait for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/traits/reservation-impl/coherence-conflict.stderr b/tests/ui/traits/reservation-impl/coherence-conflict.old.stderr index a811d7e32..393350ea3 100644 --- a/tests/ui/traits/reservation-impl/coherence-conflict.stderr +++ b/tests/ui/traits/reservation-impl/coherence-conflict.old.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `OtherTrait` for type `()` - --> $DIR/coherence-conflict.rs:11:1 + --> $DIR/coherence-conflict.rs:12:1 | LL | impl OtherTrait for () {} | ---------------------- first implementation here diff --git a/tests/ui/traits/reservation-impl/coherence-conflict.rs b/tests/ui/traits/reservation-impl/coherence-conflict.rs index fa4a30931..6bbd90f94 100644 --- a/tests/ui/traits/reservation-impl/coherence-conflict.rs +++ b/tests/ui/traits/reservation-impl/coherence-conflict.rs @@ -1,5 +1,6 @@ // check that reservation impls are accounted for in negative reasoning. - +// revisions: old next +//[next] compile-flags: -Ztrait-solver=next #![feature(rustc_attrs)] trait MyTrait {} diff --git a/tests/ui/traits/reservation-impl/no-use.stderr b/tests/ui/traits/reservation-impl/no-use.next.stderr index cefb2a879..542e3a28a 100644 --- a/tests/ui/traits/reservation-impl/no-use.stderr +++ b/tests/ui/traits/reservation-impl/no-use.next.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `(): MyTrait` is not satisfied - --> $DIR/no-use.rs:10:26 + --> $DIR/no-use.rs:11:26 | LL | <() as MyTrait>::foo(&()); | -------------------- ^^^ the trait `MyTrait` is not implemented for `()` diff --git a/tests/ui/traits/reservation-impl/no-use.old.stderr b/tests/ui/traits/reservation-impl/no-use.old.stderr new file mode 100644 index 000000000..542e3a28a --- /dev/null +++ b/tests/ui/traits/reservation-impl/no-use.old.stderr @@ -0,0 +1,13 @@ +error[E0277]: the trait bound `(): MyTrait` is not satisfied + --> $DIR/no-use.rs:11:26 + | +LL | <() as MyTrait>::foo(&()); + | -------------------- ^^^ the trait `MyTrait` is not implemented for `()` + | | + | required by a bound introduced by this call + | + = help: the trait `MyTrait` is implemented for `()` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/reservation-impl/no-use.rs b/tests/ui/traits/reservation-impl/no-use.rs index 65a55d9e2..864f1791f 100644 --- a/tests/ui/traits/reservation-impl/no-use.rs +++ b/tests/ui/traits/reservation-impl/no-use.rs @@ -1,5 +1,6 @@ // check that reservation impls can't be used as normal impls in positive reasoning. - +// revisions: old next +//[next] compile-flags: -Ztrait-solver=next #![feature(rustc_attrs)] trait MyTrait { fn foo(&self); } diff --git a/tests/ui/traits/reservation-impl/non-lattice-ok.rs b/tests/ui/traits/reservation-impl/non-lattice-ok.rs index a71051243..7787904d9 100644 --- a/tests/ui/traits/reservation-impl/non-lattice-ok.rs +++ b/tests/ui/traits/reservation-impl/non-lattice-ok.rs @@ -30,6 +30,12 @@ // // [ii]: https://smallcultfollowing.com/babysteps/blog/2016/09/24/intersection-impls/ + +// check that reservation impls can't be used as normal impls in positive reasoning. + +// revisions: old next +//[next] compile-flags: -Ztrait-solver=next + #![feature(rustc_attrs, never_type)] trait MyTrait {} diff --git a/tests/ui/traits/reservation-impl/ok.rs b/tests/ui/traits/reservation-impl/ok.rs index 611c8d884..8ff6645a2 100644 --- a/tests/ui/traits/reservation-impl/ok.rs +++ b/tests/ui/traits/reservation-impl/ok.rs @@ -3,6 +3,9 @@ // rpass test for reservation impls. Not 100% required because `From` uses them, // but still. +// revisions: old next +//[next] compile-flags: -Ztrait-solver=next + #![feature(rustc_attrs)] use std::mem; diff --git a/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.rs b/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.rs new file mode 100644 index 000000000..d37943b92 --- /dev/null +++ b/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.rs @@ -0,0 +1,34 @@ +//~ ERROR overflow +// A regression test for #111729 checking that we correctly +// track recursion depth for obligations returned by confirmation. +use std::panic::RefUnwindSafe; + +trait Database { + type Storage; +} +trait Query<DB> { + type Data; +} +struct ParseQuery; +struct RootDatabase { + _runtime: Runtime<RootDatabase>, +} + +impl<T: RefUnwindSafe> Database for T { + type Storage = SalsaStorage; +} +impl Database for RootDatabase { + type Storage = SalsaStorage; +} + +struct Runtime<DB: Database> { + _storage: Box<DB::Storage>, +} +struct SalsaStorage { + _parse: <ParseQuery as Query<RootDatabase>>::Data, +} + +impl<DB: Database> Query<DB> for ParseQuery { + type Data = RootDatabase; +} +fn main() {} diff --git a/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.stderr b/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.stderr new file mode 100644 index 000000000..8f9ce3ef1 --- /dev/null +++ b/tests/ui/traits/solver-cycles/cycle-via-builtin-auto-trait-impl.stderr @@ -0,0 +1,24 @@ +error[E0275]: overflow evaluating the requirement `Runtime<RootDatabase>: RefUnwindSafe` + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`cycle_via_builtin_auto_trait_impl`) +note: required because it appears within the type `RootDatabase` + --> $DIR/cycle-via-builtin-auto-trait-impl.rs:13:8 + | +LL | struct RootDatabase { + | ^^^^^^^^^^^^ +note: required for `RootDatabase` to implement `Database` + --> $DIR/cycle-via-builtin-auto-trait-impl.rs:17:24 + | +LL | impl<T: RefUnwindSafe> Database for T { + | ------------- ^^^^^^^^ ^ + | | + | unsatisfied trait bound introduced here +note: required because it appears within the type `Runtime<RootDatabase>` + --> $DIR/cycle-via-builtin-auto-trait-impl.rs:24:8 + | +LL | struct Runtime<DB: Database> { + | ^^^^^^^ + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.rs b/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.rs new file mode 100644 index 000000000..4a5e445d1 --- /dev/null +++ b/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.rs @@ -0,0 +1,33 @@ +#![feature(trait_upcasting)] +#![feature(trait_alias)] + +// Although we *elaborate* `T: Alias` to `i32: B`, we should +// not consider `B` to be a supertrait of the type. +trait Alias = A where i32: B; + +trait A {} + +trait B { + fn test(&self); +} + +trait C: Alias {} + +impl A for () {} + +impl C for () {} + +impl B for i32 { + fn test(&self) { + println!("hi {self}"); + } +} + +fn test(x: &dyn C) -> &dyn B { + x + //~^ ERROR mismatched types +} + +fn main() { + let x: &dyn C = &(); +} diff --git a/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.stderr b/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.stderr new file mode 100644 index 000000000..5574a0320 --- /dev/null +++ b/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.stderr @@ -0,0 +1,14 @@ +error[E0308]: mismatched types + --> $DIR/alias-where-clause-isnt-supertrait.rs:27:5 + | +LL | fn test(x: &dyn C) -> &dyn B { + | ------ expected `&dyn B` because of return type +LL | x + | ^ expected trait `B`, found trait `C` + | + = note: expected reference `&dyn B` + found reference `&dyn C` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr b/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr index 15faab16a..ca98e1831 100644 --- a/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr +++ b/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr @@ -1,15 +1,10 @@ error[E0391]: cycle detected when computing the super predicates of `A` - --> $DIR/cyclic-trait-resolution.rs:1:1 - | -LL | trait A: B + A {} - | ^^^^^^^^^^^^^^ - | -note: ...which requires computing the super traits of `A`... --> $DIR/cyclic-trait-resolution.rs:1:14 | LL | trait A: B + A {} | ^ - = note: ...which again requires computing the super predicates of `A`, completing the cycle + | + = note: ...which immediately requires computing the super predicates of `A` again note: cycle used when collecting item types in top-level module --> $DIR/cyclic-trait-resolution.rs:1:1 | diff --git a/tests/ui/wrong-mul-method-signature.rs b/tests/ui/traits/wrong-mul-method-signature.rs index 1c2f86559..1c2f86559 100644 --- a/tests/ui/wrong-mul-method-signature.rs +++ b/tests/ui/traits/wrong-mul-method-signature.rs diff --git a/tests/ui/wrong-mul-method-signature.stderr b/tests/ui/traits/wrong-mul-method-signature.stderr index 25a92f5ec..25a92f5ec 100644 --- a/tests/ui/wrong-mul-method-signature.stderr +++ b/tests/ui/traits/wrong-mul-method-signature.stderr diff --git a/tests/ui/transmutability/arrays/should_require_well_defined_layout.stderr b/tests/ui/transmutability/arrays/should_require_well_defined_layout.stderr index 164e88ede..1a0a5d3ae 100644 --- a/tests/ui/transmutability/arrays/should_require_well_defined_layout.stderr +++ b/tests/ui/transmutability/arrays/should_require_well_defined_layout.stderr @@ -1,10 +1,9 @@ -error[E0277]: `[String; 0]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `[String; 0]` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:26:52 | LL | assert::is_maybe_transmutable::<repr_rust, ()>(); - | ^^ `[String; 0]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `[String; 0]` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<[String; 0], assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -20,13 +19,12 @@ LL | | .and(Assume::VALIDITY) LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `[String; 0]` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `[String; 0]` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:27:47 | LL | assert::is_maybe_transmutable::<u128, repr_rust>(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `[String; 0]` in the defining scope of `assert::Context`. + | ^^^^^^^^^ `[String; 0]` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `[String; 0]` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -42,13 +40,12 @@ LL | | .and(Assume::VALIDITY) LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `[String; 1]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `[String; 1]` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:32:52 | LL | assert::is_maybe_transmutable::<repr_rust, ()>(); - | ^^ `[String; 1]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `[String; 1]` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<[String; 1], assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -64,13 +61,12 @@ LL | | .and(Assume::VALIDITY) LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `[String; 1]` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `[String; 1]` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:33:47 | LL | assert::is_maybe_transmutable::<u128, repr_rust>(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `[String; 1]` in the defining scope of `assert::Context`. + | ^^^^^^^^^ `[String; 1]` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `[String; 1]` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -86,13 +82,12 @@ LL | | .and(Assume::VALIDITY) LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `[String; 2]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `[String; 2]` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:38:52 | LL | assert::is_maybe_transmutable::<repr_rust, ()>(); - | ^^ `[String; 2]` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `[String; 2]` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<[String; 2], assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -108,13 +103,12 @@ LL | | .and(Assume::VALIDITY) LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `[String; 2]` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `[String; 2]` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:39:47 | LL | assert::is_maybe_transmutable::<u128, repr_rust>(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `[String; 2]` in the defining scope of `assert::Context`. + | ^^^^^^^^^ `[String; 2]` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `[String; 2]` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | diff --git a/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr b/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr index 0f0f77f16..9877a6606 100644 --- a/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr +++ b/tests/ui/transmutability/enums/repr/primitive_reprs_should_have_correct_length.stderr @@ -1,10 +1,9 @@ -error[E0277]: `Zst` cannot be safely transmuted into `V0i8` in the defining scope of `n8::Context`. +error[E0277]: `Zst` cannot be safely transmuted into `V0i8` in the defining scope of `n8::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:48:44 | LL | assert::is_transmutable::<Smaller, Current, Context>(); - | ^^^^^^^ `Zst` cannot be safely transmuted into `V0i8` in the defining scope of `n8::Context`. + | ^^^^^^^ The size of `Zst` is smaller than the size of `V0i8` | - = help: the trait `BikeshedIntrinsicFrom<Zst, n8::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `V0i8` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -21,13 +20,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `V0i8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`. +error[E0277]: `V0i8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:50:44 | LL | assert::is_transmutable::<Current, Larger, Context>(); - | ^^^^^^ `V0i8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`. + | ^^^^^^ The size of `V0i8` is smaller than the size of `u16` | - = help: the trait `BikeshedIntrinsicFrom<V0i8, n8::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `u16` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -44,13 +42,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `Zst` cannot be safely transmuted into `V0u8` in the defining scope of `n8::Context`. +error[E0277]: `Zst` cannot be safely transmuted into `V0u8` in the defining scope of `n8::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:56:44 | LL | assert::is_transmutable::<Smaller, Current, Context>(); - | ^^^^^^^ `Zst` cannot be safely transmuted into `V0u8` in the defining scope of `n8::Context`. + | ^^^^^^^ The size of `Zst` is smaller than the size of `V0u8` | - = help: the trait `BikeshedIntrinsicFrom<Zst, n8::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `V0u8` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -67,13 +64,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `V0u8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`. +error[E0277]: `V0u8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:58:44 | LL | assert::is_transmutable::<Current, Larger, Context>(); - | ^^^^^^ `V0u8` cannot be safely transmuted into `u16` in the defining scope of `n8::Context`. + | ^^^^^^ The size of `V0u8` is smaller than the size of `u16` | - = help: the trait `BikeshedIntrinsicFrom<V0u8, n8::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `u16` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -90,13 +86,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `V0i16` in the defining scope of `n16::Context`. +error[E0277]: `u8` cannot be safely transmuted into `V0i16` in the defining scope of `n16::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:72:44 | LL | assert::is_transmutable::<Smaller, Current, Context>(); - | ^^^^^^^ `u8` cannot be safely transmuted into `V0i16` in the defining scope of `n16::Context`. + | ^^^^^^^ At least one value of `u8` isn't a bit-valid value of `V0i16` | - = help: the trait `BikeshedIntrinsicFrom<u8, n16::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `V0i16` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -113,13 +108,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `V0i16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`. +error[E0277]: `V0i16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:74:44 | LL | assert::is_transmutable::<Current, Larger, Context>(); - | ^^^^^^ `V0i16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`. + | ^^^^^^ The size of `V0i16` is smaller than the size of `u32` | - = help: the trait `BikeshedIntrinsicFrom<V0i16, n16::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `u32` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -136,13 +130,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `V0u16` in the defining scope of `n16::Context`. +error[E0277]: `u8` cannot be safely transmuted into `V0u16` in the defining scope of `n16::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:80:44 | LL | assert::is_transmutable::<Smaller, Current, Context>(); - | ^^^^^^^ `u8` cannot be safely transmuted into `V0u16` in the defining scope of `n16::Context`. + | ^^^^^^^ At least one value of `u8` isn't a bit-valid value of `V0u16` | - = help: the trait `BikeshedIntrinsicFrom<u8, n16::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `V0u16` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -159,13 +152,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `V0u16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`. +error[E0277]: `V0u16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:82:44 | LL | assert::is_transmutable::<Current, Larger, Context>(); - | ^^^^^^ `V0u16` cannot be safely transmuted into `u32` in the defining scope of `n16::Context`. + | ^^^^^^ The size of `V0u16` is smaller than the size of `u32` | - = help: the trait `BikeshedIntrinsicFrom<V0u16, n16::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `u32` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -182,13 +174,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `V0i32` in the defining scope of `n32::Context`. +error[E0277]: `u16` cannot be safely transmuted into `V0i32` in the defining scope of `n32::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:96:44 | LL | assert::is_transmutable::<Smaller, Current, Context>(); - | ^^^^^^^ `u16` cannot be safely transmuted into `V0i32` in the defining scope of `n32::Context`. + | ^^^^^^^ At least one value of `u16` isn't a bit-valid value of `V0i32` | - = help: the trait `BikeshedIntrinsicFrom<u16, n32::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `V0i32` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -205,13 +196,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `V0i32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`. +error[E0277]: `V0i32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:98:44 | LL | assert::is_transmutable::<Current, Larger, Context>(); - | ^^^^^^ `V0i32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`. + | ^^^^^^ The size of `V0i32` is smaller than the size of `u64` | - = help: the trait `BikeshedIntrinsicFrom<V0i32, n32::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `u64` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -228,13 +218,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `V0u32` in the defining scope of `n32::Context`. +error[E0277]: `u16` cannot be safely transmuted into `V0u32` in the defining scope of `n32::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:104:44 | LL | assert::is_transmutable::<Smaller, Current, Context>(); - | ^^^^^^^ `u16` cannot be safely transmuted into `V0u32` in the defining scope of `n32::Context`. + | ^^^^^^^ At least one value of `u16` isn't a bit-valid value of `V0u32` | - = help: the trait `BikeshedIntrinsicFrom<u16, n32::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `V0u32` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -251,13 +240,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `V0u32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`. +error[E0277]: `V0u32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:106:44 | LL | assert::is_transmutable::<Current, Larger, Context>(); - | ^^^^^^ `V0u32` cannot be safely transmuted into `u64` in the defining scope of `n32::Context`. + | ^^^^^^ The size of `V0u32` is smaller than the size of `u64` | - = help: the trait `BikeshedIntrinsicFrom<V0u32, n32::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `u64` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -274,13 +262,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `V0i64` in the defining scope of `n64::Context`. +error[E0277]: `u32` cannot be safely transmuted into `V0i64` in the defining scope of `n64::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:120:44 | LL | assert::is_transmutable::<Smaller, Current, Context>(); - | ^^^^^^^ `u32` cannot be safely transmuted into `V0i64` in the defining scope of `n64::Context`. + | ^^^^^^^ At least one value of `u32` isn't a bit-valid value of `V0i64` | - = help: the trait `BikeshedIntrinsicFrom<u32, n64::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `V0i64` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -297,13 +284,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `V0i64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`. +error[E0277]: `V0i64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:122:44 | LL | assert::is_transmutable::<Current, Larger, Context>(); - | ^^^^^^ `V0i64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`. + | ^^^^^^ The size of `V0i64` is smaller than the size of `u128` | - = help: the trait `BikeshedIntrinsicFrom<V0i64, n64::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -320,13 +306,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `V0u64` in the defining scope of `n64::Context`. +error[E0277]: `u32` cannot be safely transmuted into `V0u64` in the defining scope of `n64::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:128:44 | LL | assert::is_transmutable::<Smaller, Current, Context>(); - | ^^^^^^^ `u32` cannot be safely transmuted into `V0u64` in the defining scope of `n64::Context`. + | ^^^^^^^ At least one value of `u32` isn't a bit-valid value of `V0u64` | - = help: the trait `BikeshedIntrinsicFrom<u32, n64::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `V0u64` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -343,13 +328,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `V0u64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`. +error[E0277]: `V0u64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:130:44 | LL | assert::is_transmutable::<Current, Larger, Context>(); - | ^^^^^^ `V0u64` cannot be safely transmuted into `u128` in the defining scope of `n64::Context`. + | ^^^^^^ The size of `V0u64` is smaller than the size of `u128` | - = help: the trait `BikeshedIntrinsicFrom<V0u64, n64::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `u128` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -366,13 +350,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `V0isize` in the defining scope of `nsize::Context`. +error[E0277]: `u8` cannot be safely transmuted into `V0isize` in the defining scope of `nsize::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:144:44 | LL | assert::is_transmutable::<Smaller, Current, Context>(); - | ^^^^^^^ `u8` cannot be safely transmuted into `V0isize` in the defining scope of `nsize::Context`. + | ^^^^^^^ At least one value of `u8` isn't a bit-valid value of `V0isize` | - = help: the trait `BikeshedIntrinsicFrom<u8, nsize::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `V0isize` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -389,13 +372,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `V0isize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`. +error[E0277]: `V0isize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:146:44 | LL | assert::is_transmutable::<Current, Larger, Context>(); - | ^^^^^^ `V0isize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`. + | ^^^^^^ The size of `V0isize` is smaller than the size of `[usize; 2]` | - = help: the trait `BikeshedIntrinsicFrom<V0isize, nsize::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `[usize; 2]` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -412,13 +394,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `V0usize` in the defining scope of `nsize::Context`. +error[E0277]: `u8` cannot be safely transmuted into `V0usize` in the defining scope of `nsize::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:152:44 | LL | assert::is_transmutable::<Smaller, Current, Context>(); - | ^^^^^^^ `u8` cannot be safely transmuted into `V0usize` in the defining scope of `nsize::Context`. + | ^^^^^^^ At least one value of `u8` isn't a bit-valid value of `V0usize` | - = help: the trait `BikeshedIntrinsicFrom<u8, nsize::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `V0usize` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | @@ -435,13 +416,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_transmutable` -error[E0277]: `V0usize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`. +error[E0277]: `V0usize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context` --> $DIR/primitive_reprs_should_have_correct_length.rs:154:44 | LL | assert::is_transmutable::<Current, Larger, Context>(); - | ^^^^^^ `V0usize` cannot be safely transmuted into `[usize; 2]` in the defining scope of `nsize::Context`. + | ^^^^^^ The size of `V0usize` is smaller than the size of `[usize; 2]` | - = help: the trait `BikeshedIntrinsicFrom<V0usize, nsize::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `[usize; 2]` note: required by a bound in `is_transmutable` --> $DIR/primitive_reprs_should_have_correct_length.rs:12:14 | diff --git a/tests/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr b/tests/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr index d456a746f..1612b6b36 100644 --- a/tests/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr +++ b/tests/ui/transmutability/enums/repr/should_require_well_defined_layout.stderr @@ -1,10 +1,9 @@ -error[E0277]: `void::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `void::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:28:52 | LL | assert::is_maybe_transmutable::<repr_rust, ()>(); - | ^^ `void::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `void::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<void::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:14:14 | @@ -21,13 +20,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `void::repr_rust` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `void::repr_rust` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:29:47 | LL | assert::is_maybe_transmutable::<u128, repr_rust>(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `void::repr_rust` in the defining scope of `assert::Context`. + | ^^^^^^^^^ `void::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `void::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:14:14 | @@ -44,13 +42,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `singleton::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `singleton::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:34:52 | LL | assert::is_maybe_transmutable::<repr_rust, ()>(); - | ^^ `singleton::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `singleton::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<singleton::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:14:14 | @@ -67,13 +64,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `singleton::repr_rust` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `singleton::repr_rust` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:35:47 | LL | assert::is_maybe_transmutable::<u128, repr_rust>(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `singleton::repr_rust` in the defining scope of `assert::Context`. + | ^^^^^^^^^ `singleton::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `singleton::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:14:14 | @@ -90,13 +86,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `duplex::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `duplex::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:40:52 | LL | assert::is_maybe_transmutable::<repr_rust, ()>(); - | ^^ `duplex::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `duplex::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<duplex::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:14:14 | @@ -113,13 +108,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `duplex::repr_rust` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `duplex::repr_rust` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:41:47 | LL | assert::is_maybe_transmutable::<u128, repr_rust>(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `duplex::repr_rust` in the defining scope of `assert::Context`. + | ^^^^^^^^^ `duplex::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `duplex::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:14:14 | diff --git a/tests/ui/transmutability/enums/should_pad_variants.stderr b/tests/ui/transmutability/enums/should_pad_variants.stderr index f4988239d..bfbef8b25 100644 --- a/tests/ui/transmutability/enums/should_pad_variants.stderr +++ b/tests/ui/transmutability/enums/should_pad_variants.stderr @@ -1,10 +1,9 @@ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`. +error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context` --> $DIR/should_pad_variants.rs:44:36 | LL | assert::is_transmutable::<Src, Dst, Context>(); - | ^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`. + | ^^^ The size of `Src` is smaller than the size of `Dst` | - = help: the trait `BikeshedIntrinsicFrom<Src, should_pad_variants::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `Dst` note: required by a bound in `is_transmutable` --> $DIR/should_pad_variants.rs:13:14 | diff --git a/tests/ui/transmutability/enums/should_respect_endianness.stderr b/tests/ui/transmutability/enums/should_respect_endianness.stderr index 350583b0b..e59301a8c 100644 --- a/tests/ui/transmutability/enums/should_respect_endianness.stderr +++ b/tests/ui/transmutability/enums/should_respect_endianness.stderr @@ -1,10 +1,9 @@ -error[E0277]: `Src` cannot be safely transmuted into `Unexpected` in the defining scope of `assert::Context`. +error[E0277]: `Src` cannot be safely transmuted into `Unexpected` in the defining scope of `assert::Context` --> $DIR/should_respect_endianness.rs:36:36 | LL | assert::is_transmutable::<Src, Unexpected>(); - | ^^^^^^^^^^ `Src` cannot be safely transmuted into `Unexpected` in the defining scope of `assert::Context`. + | ^^^^^^^^^^ At least one value of `Src` isn't a bit-valid value of `Unexpected` | - = help: the trait `BikeshedIntrinsicFrom<Src, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `Unexpected` note: required by a bound in `is_transmutable` --> $DIR/should_respect_endianness.rs:14:14 | diff --git a/tests/ui/transmutability/issue-101739-1.rs b/tests/ui/transmutability/issue-101739-1.rs index bcb8b158e..2b9666091 100644 --- a/tests/ui/transmutability/issue-101739-1.rs +++ b/tests/ui/transmutability/issue-101739-1.rs @@ -6,7 +6,7 @@ mod assert { pub fn is_transmutable<Src, Context, const ASSUME_ALIGNMENT: bool>() where Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME_ALIGNMENT>, //~ ERROR cannot find type `Dst` in this scope - //~^ ERROR mismatched types + //~^ the constant `ASSUME_ALIGNMENT` is not of type `Assume` { } } diff --git a/tests/ui/transmutability/issue-101739-1.stderr b/tests/ui/transmutability/issue-101739-1.stderr index 7c6b533ef..bf947d0ea 100644 --- a/tests/ui/transmutability/issue-101739-1.stderr +++ b/tests/ui/transmutability/issue-101739-1.stderr @@ -4,13 +4,15 @@ error[E0412]: cannot find type `Dst` in this scope LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME_ALIGNMENT>, | ^^^ not found in this scope -error[E0308]: mismatched types - --> $DIR/issue-101739-1.rs:8:50 +error: the constant `ASSUME_ALIGNMENT` is not of type `Assume` + --> $DIR/issue-101739-1.rs:8:14 | LL | Dst: BikeshedIntrinsicFrom<Src, Context, ASSUME_ALIGNMENT>, - | ^^^^^^^^^^^^^^^^ expected `Assume`, found `bool` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `bool` + | +note: required by a bound in `BikeshedIntrinsicFrom` + --> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL error: aborting due to 2 previous errors -Some errors have detailed explanations: E0308, E0412. -For more information about an error, try `rustc --explain E0308`. +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/transmutability/primitives/bool.stderr b/tests/ui/transmutability/primitives/bool.current.stderr index 22decf15e..47c8438a2 100644 --- a/tests/ui/transmutability/primitives/bool.stderr +++ b/tests/ui/transmutability/primitives/bool.current.stderr @@ -1,12 +1,11 @@ -error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`. - --> $DIR/bool.rs:22:35 +error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context` + --> $DIR/bool.rs:24:35 | LL | assert::is_transmutable::<u8, bool>(); - | ^^^^ `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context`. + | ^^^^ At least one value of `u8` isn't a bit-valid value of `bool` | - = help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: false }>` is not implemented for `bool` note: required by a bound in `is_transmutable` - --> $DIR/bool.rs:12:14 + --> $DIR/bool.rs:14:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function diff --git a/tests/ui/transmutability/primitives/bool.next.stderr b/tests/ui/transmutability/primitives/bool.next.stderr new file mode 100644 index 000000000..47c8438a2 --- /dev/null +++ b/tests/ui/transmutability/primitives/bool.next.stderr @@ -0,0 +1,18 @@ +error[E0277]: `u8` cannot be safely transmuted into `bool` in the defining scope of `assert::Context` + --> $DIR/bool.rs:24:35 + | +LL | assert::is_transmutable::<u8, bool>(); + | ^^^^ At least one value of `u8` isn't a bit-valid value of `bool` + | +note: required by a bound in `is_transmutable` + --> $DIR/bool.rs:14:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/primitives/bool.rs b/tests/ui/transmutability/primitives/bool.rs index eebb74fff..de77cfc78 100644 --- a/tests/ui/transmutability/primitives/bool.rs +++ b/tests/ui/transmutability/primitives/bool.rs @@ -1,8 +1,10 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + #![crate_type = "lib"] #![feature(transmutability)] #![allow(dead_code)] #![allow(incomplete_features)] - mod assert { use std::mem::{Assume, BikeshedIntrinsicFrom}; pub struct Context; diff --git a/tests/ui/transmutability/primitives/numbers.stderr b/tests/ui/transmutability/primitives/numbers.current.stderr index c04a0e82a..d12e17297 100644 --- a/tests/ui/transmutability/primitives/numbers.stderr +++ b/tests/ui/transmutability/primitives/numbers.current.stderr @@ -1,12 +1,11 @@ -error[E0277]: `i8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:62:40 +error[E0277]: `i8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:65:40 | LL | assert::is_transmutable::< i8, i16>(); - | ^^^ `i8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context`. + | ^^^ The size of `i8` is smaller than the size of `i16` | - = help: the trait `BikeshedIntrinsicFrom<i8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i16` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -14,15 +13,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:63:40 +error[E0277]: `i8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:66:40 | LL | assert::is_transmutable::< i8, u16>(); - | ^^^ `i8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context`. + | ^^^ The size of `i8` is smaller than the size of `u16` | - = help: the trait `BikeshedIntrinsicFrom<i8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u16` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -30,15 +28,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:64:40 +error[E0277]: `i8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:67:40 | LL | assert::is_transmutable::< i8, i32>(); - | ^^^ `i8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. + | ^^^ The size of `i8` is smaller than the size of `i32` | - = help: the trait `BikeshedIntrinsicFrom<i8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i32` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -46,15 +43,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:65:40 +error[E0277]: `i8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:68:40 | LL | assert::is_transmutable::< i8, f32>(); - | ^^^ `i8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. + | ^^^ The size of `i8` is smaller than the size of `f32` | - = help: the trait `BikeshedIntrinsicFrom<i8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `f32` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -62,15 +58,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:66:40 +error[E0277]: `i8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:69:40 | LL | assert::is_transmutable::< i8, u32>(); - | ^^^ `i8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. + | ^^^ The size of `i8` is smaller than the size of `u32` | - = help: the trait `BikeshedIntrinsicFrom<i8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u32` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -78,15 +73,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:67:40 +error[E0277]: `i8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:70:40 | LL | assert::is_transmutable::< i8, u64>(); - | ^^^ `i8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. + | ^^^ The size of `i8` is smaller than the size of `u64` | - = help: the trait `BikeshedIntrinsicFrom<i8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -94,15 +88,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:68:40 +error[E0277]: `i8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:71:40 | LL | assert::is_transmutable::< i8, i64>(); - | ^^^ `i8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. + | ^^^ The size of `i8` is smaller than the size of `i64` | - = help: the trait `BikeshedIntrinsicFrom<i8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -110,15 +103,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:69:40 +error[E0277]: `i8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:72:40 | LL | assert::is_transmutable::< i8, f64>(); - | ^^^ `i8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. + | ^^^ The size of `i8` is smaller than the size of `f64` | - = help: the trait `BikeshedIntrinsicFrom<i8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `f64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -126,15 +118,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:70:39 +error[E0277]: `i8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:73:39 | LL | assert::is_transmutable::< i8, u128>(); - | ^^^^ `i8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. + | ^^^^ The size of `i8` is smaller than the size of `u128` | - = help: the trait `BikeshedIntrinsicFrom<i8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -142,15 +133,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:71:39 +error[E0277]: `i8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:74:39 | LL | assert::is_transmutable::< i8, i128>(); - | ^^^^ `i8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. + | ^^^^ The size of `i8` is smaller than the size of `i128` | - = help: the trait `BikeshedIntrinsicFrom<i8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -158,15 +148,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:73:40 +error[E0277]: `u8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:76:40 | LL | assert::is_transmutable::< u8, i16>(); - | ^^^ `u8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context`. + | ^^^ The size of `u8` is smaller than the size of `i16` | - = help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i16` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -174,15 +163,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:74:40 +error[E0277]: `u8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:77:40 | LL | assert::is_transmutable::< u8, u16>(); - | ^^^ `u8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context`. + | ^^^ The size of `u8` is smaller than the size of `u16` | - = help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u16` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -190,15 +178,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:75:40 +error[E0277]: `u8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:78:40 | LL | assert::is_transmutable::< u8, i32>(); - | ^^^ `u8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. + | ^^^ The size of `u8` is smaller than the size of `i32` | - = help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i32` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -206,15 +193,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:76:40 +error[E0277]: `u8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:79:40 | LL | assert::is_transmutable::< u8, f32>(); - | ^^^ `u8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. + | ^^^ The size of `u8` is smaller than the size of `f32` | - = help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `f32` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -222,15 +208,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:77:40 +error[E0277]: `u8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:80:40 | LL | assert::is_transmutable::< u8, u32>(); - | ^^^ `u8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. + | ^^^ The size of `u8` is smaller than the size of `u32` | - = help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u32` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -238,15 +223,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:78:40 +error[E0277]: `u8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:81:40 | LL | assert::is_transmutable::< u8, u64>(); - | ^^^ `u8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. + | ^^^ The size of `u8` is smaller than the size of `u64` | - = help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -254,15 +238,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:79:40 +error[E0277]: `u8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:82:40 | LL | assert::is_transmutable::< u8, i64>(); - | ^^^ `u8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. + | ^^^ The size of `u8` is smaller than the size of `i64` | - = help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -270,15 +253,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:80:40 +error[E0277]: `u8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:83:40 | LL | assert::is_transmutable::< u8, f64>(); - | ^^^ `u8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. + | ^^^ The size of `u8` is smaller than the size of `f64` | - = help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `f64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -286,15 +268,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:81:39 +error[E0277]: `u8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:84:39 | LL | assert::is_transmutable::< u8, u128>(); - | ^^^^ `u8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. + | ^^^^ The size of `u8` is smaller than the size of `u128` | - = help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -302,15 +283,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:82:39 +error[E0277]: `u8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:85:39 | LL | assert::is_transmutable::< u8, i128>(); - | ^^^^ `u8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. + | ^^^^ The size of `u8` is smaller than the size of `i128` | - = help: the trait `BikeshedIntrinsicFrom<u8, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -318,15 +298,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:84:40 +error[E0277]: `i16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:87:40 | LL | assert::is_transmutable::< i16, i32>(); - | ^^^ `i16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. + | ^^^ The size of `i16` is smaller than the size of `i32` | - = help: the trait `BikeshedIntrinsicFrom<i16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i32` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -334,15 +313,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:85:40 +error[E0277]: `i16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:88:40 | LL | assert::is_transmutable::< i16, f32>(); - | ^^^ `i16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. + | ^^^ The size of `i16` is smaller than the size of `f32` | - = help: the trait `BikeshedIntrinsicFrom<i16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `f32` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -350,15 +328,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:86:40 +error[E0277]: `i16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:89:40 | LL | assert::is_transmutable::< i16, u32>(); - | ^^^ `i16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. + | ^^^ The size of `i16` is smaller than the size of `u32` | - = help: the trait `BikeshedIntrinsicFrom<i16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u32` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -366,15 +343,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:87:40 +error[E0277]: `i16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:90:40 | LL | assert::is_transmutable::< i16, u64>(); - | ^^^ `i16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. + | ^^^ The size of `i16` is smaller than the size of `u64` | - = help: the trait `BikeshedIntrinsicFrom<i16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -382,15 +358,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:88:40 +error[E0277]: `i16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:91:40 | LL | assert::is_transmutable::< i16, i64>(); - | ^^^ `i16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. + | ^^^ The size of `i16` is smaller than the size of `i64` | - = help: the trait `BikeshedIntrinsicFrom<i16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -398,15 +373,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:89:40 +error[E0277]: `i16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:92:40 | LL | assert::is_transmutable::< i16, f64>(); - | ^^^ `i16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. + | ^^^ The size of `i16` is smaller than the size of `f64` | - = help: the trait `BikeshedIntrinsicFrom<i16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `f64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -414,15 +388,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:90:39 +error[E0277]: `i16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:93:39 | LL | assert::is_transmutable::< i16, u128>(); - | ^^^^ `i16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. + | ^^^^ The size of `i16` is smaller than the size of `u128` | - = help: the trait `BikeshedIntrinsicFrom<i16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -430,15 +403,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:91:39 +error[E0277]: `i16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:94:39 | LL | assert::is_transmutable::< i16, i128>(); - | ^^^^ `i16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. + | ^^^^ The size of `i16` is smaller than the size of `i128` | - = help: the trait `BikeshedIntrinsicFrom<i16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -446,15 +418,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:93:40 +error[E0277]: `u16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:96:40 | LL | assert::is_transmutable::< u16, i32>(); - | ^^^ `u16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context`. + | ^^^ The size of `u16` is smaller than the size of `i32` | - = help: the trait `BikeshedIntrinsicFrom<u16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i32` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -462,15 +433,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:94:40 +error[E0277]: `u16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:97:40 | LL | assert::is_transmutable::< u16, f32>(); - | ^^^ `u16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context`. + | ^^^ The size of `u16` is smaller than the size of `f32` | - = help: the trait `BikeshedIntrinsicFrom<u16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `f32` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -478,15 +448,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:95:40 +error[E0277]: `u16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:98:40 | LL | assert::is_transmutable::< u16, u32>(); - | ^^^ `u16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context`. + | ^^^ The size of `u16` is smaller than the size of `u32` | - = help: the trait `BikeshedIntrinsicFrom<u16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u32` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -494,15 +463,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:96:40 +error[E0277]: `u16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:99:40 | LL | assert::is_transmutable::< u16, u64>(); - | ^^^ `u16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. + | ^^^ The size of `u16` is smaller than the size of `u64` | - = help: the trait `BikeshedIntrinsicFrom<u16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -510,15 +478,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:97:40 +error[E0277]: `u16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:100:40 | LL | assert::is_transmutable::< u16, i64>(); - | ^^^ `u16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. + | ^^^ The size of `u16` is smaller than the size of `i64` | - = help: the trait `BikeshedIntrinsicFrom<u16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -526,15 +493,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:98:40 +error[E0277]: `u16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:101:40 | LL | assert::is_transmutable::< u16, f64>(); - | ^^^ `u16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. + | ^^^ The size of `u16` is smaller than the size of `f64` | - = help: the trait `BikeshedIntrinsicFrom<u16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `f64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -542,15 +508,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:99:39 +error[E0277]: `u16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:102:39 | LL | assert::is_transmutable::< u16, u128>(); - | ^^^^ `u16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. + | ^^^^ The size of `u16` is smaller than the size of `u128` | - = help: the trait `BikeshedIntrinsicFrom<u16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -558,15 +523,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:100:39 +error[E0277]: `u16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:103:39 | LL | assert::is_transmutable::< u16, i128>(); - | ^^^^ `u16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. + | ^^^^ The size of `u16` is smaller than the size of `i128` | - = help: the trait `BikeshedIntrinsicFrom<u16, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -574,15 +538,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:102:40 +error[E0277]: `i32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:105:40 | LL | assert::is_transmutable::< i32, u64>(); - | ^^^ `i32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. + | ^^^ The size of `i32` is smaller than the size of `u64` | - = help: the trait `BikeshedIntrinsicFrom<i32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -590,15 +553,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:103:40 +error[E0277]: `i32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:106:40 | LL | assert::is_transmutable::< i32, i64>(); - | ^^^ `i32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. + | ^^^ The size of `i32` is smaller than the size of `i64` | - = help: the trait `BikeshedIntrinsicFrom<i32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -606,15 +568,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:104:40 +error[E0277]: `i32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:107:40 | LL | assert::is_transmutable::< i32, f64>(); - | ^^^ `i32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. + | ^^^ The size of `i32` is smaller than the size of `f64` | - = help: the trait `BikeshedIntrinsicFrom<i32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `f64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -622,15 +583,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:105:39 +error[E0277]: `i32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:108:39 | LL | assert::is_transmutable::< i32, u128>(); - | ^^^^ `i32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. + | ^^^^ The size of `i32` is smaller than the size of `u128` | - = help: the trait `BikeshedIntrinsicFrom<i32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -638,15 +598,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:106:39 +error[E0277]: `i32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:109:39 | LL | assert::is_transmutable::< i32, i128>(); - | ^^^^ `i32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. + | ^^^^ The size of `i32` is smaller than the size of `i128` | - = help: the trait `BikeshedIntrinsicFrom<i32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -654,15 +613,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:108:40 +error[E0277]: `f32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:111:40 | LL | assert::is_transmutable::< f32, u64>(); - | ^^^ `f32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. + | ^^^ The size of `f32` is smaller than the size of `u64` | - = help: the trait `BikeshedIntrinsicFrom<f32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -670,15 +628,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:109:40 +error[E0277]: `f32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:112:40 | LL | assert::is_transmutable::< f32, i64>(); - | ^^^ `f32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. + | ^^^ The size of `f32` is smaller than the size of `i64` | - = help: the trait `BikeshedIntrinsicFrom<f32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -686,15 +643,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:110:40 +error[E0277]: `f32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:113:40 | LL | assert::is_transmutable::< f32, f64>(); - | ^^^ `f32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. + | ^^^ The size of `f32` is smaller than the size of `f64` | - = help: the trait `BikeshedIntrinsicFrom<f32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `f64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -702,15 +658,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:111:39 +error[E0277]: `f32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:114:39 | LL | assert::is_transmutable::< f32, u128>(); - | ^^^^ `f32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. + | ^^^^ The size of `f32` is smaller than the size of `u128` | - = help: the trait `BikeshedIntrinsicFrom<f32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -718,15 +673,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:112:39 +error[E0277]: `f32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:115:39 | LL | assert::is_transmutable::< f32, i128>(); - | ^^^^ `f32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. + | ^^^^ The size of `f32` is smaller than the size of `i128` | - = help: the trait `BikeshedIntrinsicFrom<f32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -734,15 +688,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:114:40 +error[E0277]: `u32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:117:40 | LL | assert::is_transmutable::< u32, u64>(); - | ^^^ `u32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context`. + | ^^^ The size of `u32` is smaller than the size of `u64` | - = help: the trait `BikeshedIntrinsicFrom<u32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -750,15 +703,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:115:40 +error[E0277]: `u32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:118:40 | LL | assert::is_transmutable::< u32, i64>(); - | ^^^ `u32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context`. + | ^^^ The size of `u32` is smaller than the size of `i64` | - = help: the trait `BikeshedIntrinsicFrom<u32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -766,15 +718,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:116:40 +error[E0277]: `u32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:119:40 | LL | assert::is_transmutable::< u32, f64>(); - | ^^^ `u32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context`. + | ^^^ The size of `u32` is smaller than the size of `f64` | - = help: the trait `BikeshedIntrinsicFrom<u32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `f64` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -782,15 +733,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:117:39 +error[E0277]: `u32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:120:39 | LL | assert::is_transmutable::< u32, u128>(); - | ^^^^ `u32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. + | ^^^^ The size of `u32` is smaller than the size of `u128` | - = help: the trait `BikeshedIntrinsicFrom<u32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -798,15 +748,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:118:39 +error[E0277]: `u32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:121:39 | LL | assert::is_transmutable::< u32, i128>(); - | ^^^^ `u32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. + | ^^^^ The size of `u32` is smaller than the size of `i128` | - = help: the trait `BikeshedIntrinsicFrom<u32, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -814,15 +763,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:120:39 +error[E0277]: `u64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:123:39 | LL | assert::is_transmutable::< u64, u128>(); - | ^^^^ `u64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. + | ^^^^ The size of `u64` is smaller than the size of `u128` | - = help: the trait `BikeshedIntrinsicFrom<u64, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -830,15 +778,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `u64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:121:39 +error[E0277]: `u64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:124:39 | LL | assert::is_transmutable::< u64, i128>(); - | ^^^^ `u64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. + | ^^^^ The size of `u64` is smaller than the size of `i128` | - = help: the trait `BikeshedIntrinsicFrom<u64, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -846,15 +793,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:123:39 +error[E0277]: `i64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:126:39 | LL | assert::is_transmutable::< i64, u128>(); - | ^^^^ `i64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. + | ^^^^ The size of `i64` is smaller than the size of `u128` | - = help: the trait `BikeshedIntrinsicFrom<i64, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -862,15 +808,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `i64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:124:39 +error[E0277]: `i64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:127:39 | LL | assert::is_transmutable::< i64, i128>(); - | ^^^^ `i64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. + | ^^^^ The size of `i64` is smaller than the size of `i128` | - = help: the trait `BikeshedIntrinsicFrom<i64, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -878,15 +823,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:126:39 +error[E0277]: `f64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:129:39 | LL | assert::is_transmutable::< f64, u128>(); - | ^^^^ `f64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context`. + | ^^^^ The size of `f64` is smaller than the size of `u128` | - = help: the trait `BikeshedIntrinsicFrom<f64, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `u128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function @@ -894,15 +838,14 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `f64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. - --> $DIR/numbers.rs:127:39 +error[E0277]: `f64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:130:39 | LL | assert::is_transmutable::< f64, i128>(); - | ^^^^ `f64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context`. + | ^^^^ The size of `f64` is smaller than the size of `i128` | - = help: the trait `BikeshedIntrinsicFrom<f64, assert::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `i128` note: required by a bound in `is_transmutable` - --> $DIR/numbers.rs:12:14 + --> $DIR/numbers.rs:15:14 | LL | pub fn is_transmutable<Src, Dst>() | --------------- required by a bound in this function diff --git a/tests/ui/transmutability/primitives/numbers.next.stderr b/tests/ui/transmutability/primitives/numbers.next.stderr new file mode 100644 index 000000000..d12e17297 --- /dev/null +++ b/tests/ui/transmutability/primitives/numbers.next.stderr @@ -0,0 +1,858 @@ +error[E0277]: `i8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:65:40 + | +LL | assert::is_transmutable::< i8, i16>(); + | ^^^ The size of `i8` is smaller than the size of `i16` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:66:40 + | +LL | assert::is_transmutable::< i8, u16>(); + | ^^^ The size of `i8` is smaller than the size of `u16` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:67:40 + | +LL | assert::is_transmutable::< i8, i32>(); + | ^^^ The size of `i8` is smaller than the size of `i32` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:68:40 + | +LL | assert::is_transmutable::< i8, f32>(); + | ^^^ The size of `i8` is smaller than the size of `f32` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:69:40 + | +LL | assert::is_transmutable::< i8, u32>(); + | ^^^ The size of `i8` is smaller than the size of `u32` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:70:40 + | +LL | assert::is_transmutable::< i8, u64>(); + | ^^^ The size of `i8` is smaller than the size of `u64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:71:40 + | +LL | assert::is_transmutable::< i8, i64>(); + | ^^^ The size of `i8` is smaller than the size of `i64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:72:40 + | +LL | assert::is_transmutable::< i8, f64>(); + | ^^^ The size of `i8` is smaller than the size of `f64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:73:39 + | +LL | assert::is_transmutable::< i8, u128>(); + | ^^^^ The size of `i8` is smaller than the size of `u128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:74:39 + | +LL | assert::is_transmutable::< i8, i128>(); + | ^^^^ The size of `i8` is smaller than the size of `i128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u8` cannot be safely transmuted into `i16` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:76:40 + | +LL | assert::is_transmutable::< u8, i16>(); + | ^^^ The size of `u8` is smaller than the size of `i16` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u8` cannot be safely transmuted into `u16` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:77:40 + | +LL | assert::is_transmutable::< u8, u16>(); + | ^^^ The size of `u8` is smaller than the size of `u16` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u8` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:78:40 + | +LL | assert::is_transmutable::< u8, i32>(); + | ^^^ The size of `u8` is smaller than the size of `i32` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u8` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:79:40 + | +LL | assert::is_transmutable::< u8, f32>(); + | ^^^ The size of `u8` is smaller than the size of `f32` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u8` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:80:40 + | +LL | assert::is_transmutable::< u8, u32>(); + | ^^^ The size of `u8` is smaller than the size of `u32` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u8` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:81:40 + | +LL | assert::is_transmutable::< u8, u64>(); + | ^^^ The size of `u8` is smaller than the size of `u64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u8` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:82:40 + | +LL | assert::is_transmutable::< u8, i64>(); + | ^^^ The size of `u8` is smaller than the size of `i64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u8` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:83:40 + | +LL | assert::is_transmutable::< u8, f64>(); + | ^^^ The size of `u8` is smaller than the size of `f64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u8` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:84:39 + | +LL | assert::is_transmutable::< u8, u128>(); + | ^^^^ The size of `u8` is smaller than the size of `u128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u8` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:85:39 + | +LL | assert::is_transmutable::< u8, i128>(); + | ^^^^ The size of `u8` is smaller than the size of `i128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:87:40 + | +LL | assert::is_transmutable::< i16, i32>(); + | ^^^ The size of `i16` is smaller than the size of `i32` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:88:40 + | +LL | assert::is_transmutable::< i16, f32>(); + | ^^^ The size of `i16` is smaller than the size of `f32` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:89:40 + | +LL | assert::is_transmutable::< i16, u32>(); + | ^^^ The size of `i16` is smaller than the size of `u32` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:90:40 + | +LL | assert::is_transmutable::< i16, u64>(); + | ^^^ The size of `i16` is smaller than the size of `u64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:91:40 + | +LL | assert::is_transmutable::< i16, i64>(); + | ^^^ The size of `i16` is smaller than the size of `i64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:92:40 + | +LL | assert::is_transmutable::< i16, f64>(); + | ^^^ The size of `i16` is smaller than the size of `f64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:93:39 + | +LL | assert::is_transmutable::< i16, u128>(); + | ^^^^ The size of `i16` is smaller than the size of `u128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:94:39 + | +LL | assert::is_transmutable::< i16, i128>(); + | ^^^^ The size of `i16` is smaller than the size of `i128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u16` cannot be safely transmuted into `i32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:96:40 + | +LL | assert::is_transmutable::< u16, i32>(); + | ^^^ The size of `u16` is smaller than the size of `i32` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u16` cannot be safely transmuted into `f32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:97:40 + | +LL | assert::is_transmutable::< u16, f32>(); + | ^^^ The size of `u16` is smaller than the size of `f32` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u16` cannot be safely transmuted into `u32` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:98:40 + | +LL | assert::is_transmutable::< u16, u32>(); + | ^^^ The size of `u16` is smaller than the size of `u32` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u16` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:99:40 + | +LL | assert::is_transmutable::< u16, u64>(); + | ^^^ The size of `u16` is smaller than the size of `u64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u16` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:100:40 + | +LL | assert::is_transmutable::< u16, i64>(); + | ^^^ The size of `u16` is smaller than the size of `i64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u16` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:101:40 + | +LL | assert::is_transmutable::< u16, f64>(); + | ^^^ The size of `u16` is smaller than the size of `f64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u16` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:102:39 + | +LL | assert::is_transmutable::< u16, u128>(); + | ^^^^ The size of `u16` is smaller than the size of `u128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u16` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:103:39 + | +LL | assert::is_transmutable::< u16, i128>(); + | ^^^^ The size of `u16` is smaller than the size of `i128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:105:40 + | +LL | assert::is_transmutable::< i32, u64>(); + | ^^^ The size of `i32` is smaller than the size of `u64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:106:40 + | +LL | assert::is_transmutable::< i32, i64>(); + | ^^^ The size of `i32` is smaller than the size of `i64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:107:40 + | +LL | assert::is_transmutable::< i32, f64>(); + | ^^^ The size of `i32` is smaller than the size of `f64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:108:39 + | +LL | assert::is_transmutable::< i32, u128>(); + | ^^^^ The size of `i32` is smaller than the size of `u128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:109:39 + | +LL | assert::is_transmutable::< i32, i128>(); + | ^^^^ The size of `i32` is smaller than the size of `i128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `f32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:111:40 + | +LL | assert::is_transmutable::< f32, u64>(); + | ^^^ The size of `f32` is smaller than the size of `u64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `f32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:112:40 + | +LL | assert::is_transmutable::< f32, i64>(); + | ^^^ The size of `f32` is smaller than the size of `i64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `f32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:113:40 + | +LL | assert::is_transmutable::< f32, f64>(); + | ^^^ The size of `f32` is smaller than the size of `f64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `f32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:114:39 + | +LL | assert::is_transmutable::< f32, u128>(); + | ^^^^ The size of `f32` is smaller than the size of `u128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `f32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:115:39 + | +LL | assert::is_transmutable::< f32, i128>(); + | ^^^^ The size of `f32` is smaller than the size of `i128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u32` cannot be safely transmuted into `u64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:117:40 + | +LL | assert::is_transmutable::< u32, u64>(); + | ^^^ The size of `u32` is smaller than the size of `u64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u32` cannot be safely transmuted into `i64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:118:40 + | +LL | assert::is_transmutable::< u32, i64>(); + | ^^^ The size of `u32` is smaller than the size of `i64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u32` cannot be safely transmuted into `f64` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:119:40 + | +LL | assert::is_transmutable::< u32, f64>(); + | ^^^ The size of `u32` is smaller than the size of `f64` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u32` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:120:39 + | +LL | assert::is_transmutable::< u32, u128>(); + | ^^^^ The size of `u32` is smaller than the size of `u128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u32` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:121:39 + | +LL | assert::is_transmutable::< u32, i128>(); + | ^^^^ The size of `u32` is smaller than the size of `i128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:123:39 + | +LL | assert::is_transmutable::< u64, u128>(); + | ^^^^ The size of `u64` is smaller than the size of `u128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `u64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:124:39 + | +LL | assert::is_transmutable::< u64, i128>(); + | ^^^^ The size of `u64` is smaller than the size of `i128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:126:39 + | +LL | assert::is_transmutable::< i64, u128>(); + | ^^^^ The size of `i64` is smaller than the size of `u128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `i64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:127:39 + | +LL | assert::is_transmutable::< i64, i128>(); + | ^^^^ The size of `i64` is smaller than the size of `i128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `f64` cannot be safely transmuted into `u128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:129:39 + | +LL | assert::is_transmutable::< f64, u128>(); + | ^^^^ The size of `f64` is smaller than the size of `u128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error[E0277]: `f64` cannot be safely transmuted into `i128` in the defining scope of `assert::Context` + --> $DIR/numbers.rs:130:39 + | +LL | assert::is_transmutable::< f64, i128>(); + | ^^^^ The size of `f64` is smaller than the size of `i128` + | +note: required by a bound in `is_transmutable` + --> $DIR/numbers.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` + +error: aborting due to 57 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/primitives/numbers.rs b/tests/ui/transmutability/primitives/numbers.rs index 0df43d204..e980e91ed 100644 --- a/tests/ui/transmutability/primitives/numbers.rs +++ b/tests/ui/transmutability/primitives/numbers.rs @@ -1,3 +1,6 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + #![crate_type = "lib"] #![feature(transmutability)] #![allow(dead_code)] diff --git a/tests/ui/transmutability/primitives/unit.stderr b/tests/ui/transmutability/primitives/unit.current.stderr index 988cd33b3..c49eb6097 100644 --- a/tests/ui/transmutability/primitives/unit.stderr +++ b/tests/ui/transmutability/primitives/unit.current.stderr @@ -1,12 +1,11 @@ -error[E0277]: `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context`. - --> $DIR/unit.rs:28:35 +error[E0277]: `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context` + --> $DIR/unit.rs:31:35 | LL | assert::is_transmutable::<(), u8, Context>(); - | ^^ `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context`. + | ^^ The size of `()` is smaller than the size of `u8` | - = help: the trait `BikeshedIntrinsicFrom<(), should_have_correct_size::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `u8` note: required by a bound in `is_transmutable` - --> $DIR/unit.rs:12:14 + --> $DIR/unit.rs:15:14 | LL | pub fn is_transmutable<Src, Dst, Context>() | --------------- required by a bound in this function diff --git a/tests/ui/transmutability/primitives/unit.next.stderr b/tests/ui/transmutability/primitives/unit.next.stderr new file mode 100644 index 000000000..c49eb6097 --- /dev/null +++ b/tests/ui/transmutability/primitives/unit.next.stderr @@ -0,0 +1,24 @@ +error[E0277]: `()` cannot be safely transmuted into `u8` in the defining scope of `should_have_correct_size::Context` + --> $DIR/unit.rs:31:35 + | +LL | assert::is_transmutable::<(), u8, Context>(); + | ^^ The size of `()` is smaller than the size of `u8` + | +note: required by a bound in `is_transmutable` + --> $DIR/unit.rs:15:14 + | +LL | pub fn is_transmutable<Src, Dst, Context>() + | --------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context, { + | ______________^ +LL | | Assume::ALIGNMENT +LL | | .and(Assume::LIFETIMES) +LL | | .and(Assume::SAFETY) +LL | | .and(Assume::VALIDITY) +LL | | }> + | |__________^ required by this bound in `is_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/primitives/unit.rs b/tests/ui/transmutability/primitives/unit.rs index 1975a61de..12eac1751 100644 --- a/tests/ui/transmutability/primitives/unit.rs +++ b/tests/ui/transmutability/primitives/unit.rs @@ -1,3 +1,6 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + //! The unit type, `()`, should be one byte. #![crate_type = "lib"] diff --git a/tests/ui/transmutability/references.stderr b/tests/ui/transmutability/references.current.stderr index eb3bd03fd..ecb095354 100644 --- a/tests/ui/transmutability/references.stderr +++ b/tests/ui/transmutability/references.current.stderr @@ -1,12 +1,11 @@ -error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`. - --> $DIR/references.rs:26:52 +error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context` + --> $DIR/references.rs:29:52 | LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>(); - | ^^^^^^^^^^^^^ `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context`. + | ^^^^^^^^^^^^^ `&'static Unit` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<&'static Unit, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `&'static Unit` note: required by a bound in `is_maybe_transmutable` - --> $DIR/references.rs:13:14 + --> $DIR/references.rs:16:14 | LL | pub fn is_maybe_transmutable<Src, Dst>() | --------------------- required by a bound in this function diff --git a/tests/ui/transmutability/references.next.stderr b/tests/ui/transmutability/references.next.stderr new file mode 100644 index 000000000..ecb095354 --- /dev/null +++ b/tests/ui/transmutability/references.next.stderr @@ -0,0 +1,25 @@ +error[E0277]: `&'static Unit` cannot be safely transmuted into `&'static Unit` in the defining scope of `assert::Context` + --> $DIR/references.rs:29:52 + | +LL | assert::is_maybe_transmutable::<&'static Unit, &'static Unit>(); + | ^^^^^^^^^^^^^ `&'static Unit` does not have a well-specified layout + | +note: required by a bound in `is_maybe_transmutable` + --> $DIR/references.rs:16:14 + | +LL | pub fn is_maybe_transmutable<Src, Dst>() + | --------------------- required by a bound in this function +LL | where +LL | Dst: BikeshedIntrinsicFrom<Src, Context, { + | ______________^ +LL | | Assume { +LL | | alignment: true, +LL | | lifetimes: true, +... | +LL | | } +LL | | }> + | |__________^ required by this bound in `is_maybe_transmutable` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/transmutability/references.rs b/tests/ui/transmutability/references.rs index af3ff0ec1..8c2b25ebb 100644 --- a/tests/ui/transmutability/references.rs +++ b/tests/ui/transmutability/references.rs @@ -1,3 +1,6 @@ +// revisions: current next +//[next] compile-flags: -Ztrait-solver=next + //! Transmutations involving references are not yet supported. #![crate_type = "lib"] diff --git a/tests/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr b/tests/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr index d9aebac64..4c5062cd3 100644 --- a/tests/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr +++ b/tests/ui/transmutability/structs/repr/should_require_well_defined_layout.stderr @@ -1,10 +1,9 @@ -error[E0277]: `should_reject_repr_rust::unit::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `should_reject_repr_rust::unit::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:28:52 | LL | assert::is_maybe_transmutable::<repr_rust, ()>(); - | ^^ `should_reject_repr_rust::unit::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `should_reject_repr_rust::unit::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<should_reject_repr_rust::unit::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -21,13 +20,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::unit::repr_rust` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::unit::repr_rust` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:29:47 | LL | assert::is_maybe_transmutable::<u128, repr_rust>(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::unit::repr_rust` in the defining scope of `assert::Context`. + | ^^^^^^^^^ `should_reject_repr_rust::unit::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `should_reject_repr_rust::unit::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -44,13 +42,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `should_reject_repr_rust::tuple::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `should_reject_repr_rust::tuple::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:34:52 | LL | assert::is_maybe_transmutable::<repr_rust, ()>(); - | ^^ `should_reject_repr_rust::tuple::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `should_reject_repr_rust::tuple::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<should_reject_repr_rust::tuple::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -67,13 +64,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::tuple::repr_rust` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::tuple::repr_rust` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:35:47 | LL | assert::is_maybe_transmutable::<u128, repr_rust>(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::tuple::repr_rust` in the defining scope of `assert::Context`. + | ^^^^^^^^^ `should_reject_repr_rust::tuple::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `should_reject_repr_rust::tuple::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -90,13 +86,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `should_reject_repr_rust::braces::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `should_reject_repr_rust::braces::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:40:52 | LL | assert::is_maybe_transmutable::<repr_rust, ()>(); - | ^^ `should_reject_repr_rust::braces::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `should_reject_repr_rust::braces::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<should_reject_repr_rust::braces::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -113,13 +108,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::braces::repr_rust` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::braces::repr_rust` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:41:47 | LL | assert::is_maybe_transmutable::<u128, repr_rust>(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::braces::repr_rust` in the defining scope of `assert::Context`. + | ^^^^^^^^^ `should_reject_repr_rust::braces::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `should_reject_repr_rust::braces::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -136,13 +130,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `aligned::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `aligned::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:46:52 | LL | assert::is_maybe_transmutable::<repr_rust, ()>(); - | ^^ `aligned::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `aligned::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<aligned::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -159,13 +152,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `aligned::repr_rust` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `aligned::repr_rust` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:47:47 | LL | assert::is_maybe_transmutable::<u128, repr_rust>(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `aligned::repr_rust` in the defining scope of `assert::Context`. + | ^^^^^^^^^ `aligned::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `aligned::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -182,13 +174,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `packed::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `packed::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:52:52 | LL | assert::is_maybe_transmutable::<repr_rust, ()>(); - | ^^ `packed::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `packed::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<packed::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -205,13 +196,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `packed::repr_rust` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `packed::repr_rust` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:53:47 | LL | assert::is_maybe_transmutable::<u128, repr_rust>(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `packed::repr_rust` in the defining scope of `assert::Context`. + | ^^^^^^^^^ `packed::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `packed::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -228,13 +218,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `nested::repr_c` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `nested::repr_c` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:59:49 | LL | assert::is_maybe_transmutable::<repr_c, ()>(); - | ^^ `nested::repr_c` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `nested::repr_c` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<nested::repr_c, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -251,13 +240,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `nested::repr_c` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `nested::repr_c` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:60:47 | LL | assert::is_maybe_transmutable::<u128, repr_c>(); - | ^^^^^^ `u128` cannot be safely transmuted into `nested::repr_c` in the defining scope of `assert::Context`. + | ^^^^^^ `nested::repr_c` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `nested::repr_c` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | diff --git a/tests/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr b/tests/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr index aa0cbc51b..4293d34f4 100644 --- a/tests/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr +++ b/tests/ui/transmutability/unions/repr/should_require_well_defined_layout.stderr @@ -1,10 +1,9 @@ -error[E0277]: `should_reject_repr_rust::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. +error[E0277]: `should_reject_repr_rust::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:30:48 | LL | assert::is_maybe_transmutable::<repr_rust, ()>(); - | ^^ `should_reject_repr_rust::repr_rust` cannot be safely transmuted into `()` in the defining scope of `assert::Context`. + | ^^ `should_reject_repr_rust::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<should_reject_repr_rust::repr_rust, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `()` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | @@ -21,13 +20,12 @@ LL | | } LL | | }> | |__________^ required by this bound in `is_maybe_transmutable` -error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::repr_rust` in the defining scope of `assert::Context`. +error[E0277]: `u128` cannot be safely transmuted into `should_reject_repr_rust::repr_rust` in the defining scope of `assert::Context` --> $DIR/should_require_well_defined_layout.rs:31:43 | LL | assert::is_maybe_transmutable::<u128, repr_rust>(); - | ^^^^^^^^^ `u128` cannot be safely transmuted into `should_reject_repr_rust::repr_rust` in the defining scope of `assert::Context`. + | ^^^^^^^^^ `should_reject_repr_rust::repr_rust` does not have a well-specified layout | - = help: the trait `BikeshedIntrinsicFrom<u128, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `should_reject_repr_rust::repr_rust` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_require_well_defined_layout.rs:13:14 | diff --git a/tests/ui/transmutability/unions/should_pad_variants.stderr b/tests/ui/transmutability/unions/should_pad_variants.stderr index f4988239d..bfbef8b25 100644 --- a/tests/ui/transmutability/unions/should_pad_variants.stderr +++ b/tests/ui/transmutability/unions/should_pad_variants.stderr @@ -1,10 +1,9 @@ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`. +error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context` --> $DIR/should_pad_variants.rs:44:36 | LL | assert::is_transmutable::<Src, Dst, Context>(); - | ^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `should_pad_variants::Context`. + | ^^^ The size of `Src` is smaller than the size of `Dst` | - = help: the trait `BikeshedIntrinsicFrom<Src, should_pad_variants::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `Dst` note: required by a bound in `is_transmutable` --> $DIR/should_pad_variants.rs:13:14 | diff --git a/tests/ui/transmutability/unions/should_reject_contraction.stderr b/tests/ui/transmutability/unions/should_reject_contraction.stderr index fa7dcc3d2..553f655a1 100644 --- a/tests/ui/transmutability/unions/should_reject_contraction.stderr +++ b/tests/ui/transmutability/unions/should_reject_contraction.stderr @@ -1,10 +1,9 @@ -error[E0277]: `Superset` cannot be safely transmuted into `Subset` in the defining scope of `assert::Context`. +error[E0277]: `Superset` cannot be safely transmuted into `Subset` in the defining scope of `assert::Context` --> $DIR/should_reject_contraction.rs:35:41 | LL | assert::is_transmutable::<Superset, Subset>(); - | ^^^^^^ `Superset` cannot be safely transmuted into `Subset` in the defining scope of `assert::Context`. + | ^^^^^^ At least one value of `Superset` isn't a bit-valid value of `Subset` | - = help: the trait `BikeshedIntrinsicFrom<Superset, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: false }>` is not implemented for `Subset` note: required by a bound in `is_transmutable` --> $DIR/should_reject_contraction.rs:13:14 | diff --git a/tests/ui/transmutability/unions/should_reject_disjoint.stderr b/tests/ui/transmutability/unions/should_reject_disjoint.stderr index 880e4cd89..178ae6f08 100644 --- a/tests/ui/transmutability/unions/should_reject_disjoint.stderr +++ b/tests/ui/transmutability/unions/should_reject_disjoint.stderr @@ -1,10 +1,9 @@ -error[E0277]: `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`. +error[E0277]: `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context` --> $DIR/should_reject_disjoint.rs:33:40 | LL | assert::is_maybe_transmutable::<A, B>(); - | ^ `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`. + | ^ At least one value of `A` isn't a bit-valid value of `B` | - = help: the trait `BikeshedIntrinsicFrom<A, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: true }>` is not implemented for `B` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_reject_disjoint.rs:13:14 | @@ -14,13 +13,12 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY.and(Assume::VALIDITY) }> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_maybe_transmutable` -error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`. +error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context` --> $DIR/should_reject_disjoint.rs:34:40 | LL | assert::is_maybe_transmutable::<B, A>(); - | ^ `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`. + | ^ At least one value of `B` isn't a bit-valid value of `A` | - = help: the trait `BikeshedIntrinsicFrom<B, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: true }>` is not implemented for `A` note: required by a bound in `is_maybe_transmutable` --> $DIR/should_reject_disjoint.rs:13:14 | diff --git a/tests/ui/transmutability/unions/should_reject_intersecting.stderr b/tests/ui/transmutability/unions/should_reject_intersecting.stderr index 501760b08..73c29ab1c 100644 --- a/tests/ui/transmutability/unions/should_reject_intersecting.stderr +++ b/tests/ui/transmutability/unions/should_reject_intersecting.stderr @@ -1,10 +1,9 @@ -error[E0277]: `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`. +error[E0277]: `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context` --> $DIR/should_reject_intersecting.rs:36:34 | LL | assert::is_transmutable::<A, B>(); - | ^ `A` cannot be safely transmuted into `B` in the defining scope of `assert::Context`. + | ^ At least one value of `A` isn't a bit-valid value of `B` | - = help: the trait `BikeshedIntrinsicFrom<A, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: false }>` is not implemented for `B` note: required by a bound in `is_transmutable` --> $DIR/should_reject_intersecting.rs:14:14 | @@ -14,13 +13,12 @@ LL | where LL | Dst: BikeshedIntrinsicFrom<Src, Context, { Assume::SAFETY }> | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `is_transmutable` -error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`. +error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context` --> $DIR/should_reject_intersecting.rs:37:34 | LL | assert::is_transmutable::<B, A>(); - | ^ `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`. + | ^ At least one value of `B` isn't a bit-valid value of `A` | - = help: the trait `BikeshedIntrinsicFrom<B, assert::Context, Assume { alignment: false, lifetimes: false, safety: true, validity: false }>` is not implemented for `A` note: required by a bound in `is_transmutable` --> $DIR/should_reject_intersecting.rs:14:14 | diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr b/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr index afbba653b..863ada3c2 100644 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr +++ b/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_field.stderr @@ -1,10 +1,9 @@ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. +error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context` --> $DIR/should_reject_if_dst_has_private_field.rs:35:41 | LL | assert::is_transmutable::<src::Src, dst::Dst, Context>(); - | ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. + | ^^^^^^^^ `Dst` is or contains a type or field that is not visible in that scope | - = help: the trait `BikeshedIntrinsicFrom<Src, test::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `Dst` note: required by a bound in `is_transmutable` --> $DIR/should_reject_if_dst_has_private_field.rs:13:14 | diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr b/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr index f14b5d8b2..7b0f1b4d5 100644 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr +++ b/tests/ui/transmutability/visibility/should_reject_if_dst_has_private_variant.stderr @@ -1,10 +1,9 @@ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. +error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context` --> $DIR/should_reject_if_dst_has_private_variant.rs:36:41 | LL | assert::is_transmutable::<src::Src, dst::Dst, Context>(); - | ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. + | ^^^^^^^^ `Dst` is or contains a type or field that is not visible in that scope | - = help: the trait `BikeshedIntrinsicFrom<Src, test::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `Dst` note: required by a bound in `is_transmutable` --> $DIR/should_reject_if_dst_has_private_variant.rs:13:14 | diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr b/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr index 01ae8bea2..df19477ef 100644 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr +++ b/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_field.stderr @@ -1,10 +1,9 @@ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. +error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context` --> $DIR/should_reject_if_dst_has_unreachable_field.rs:37:41 | LL | assert::is_transmutable::<src::Src, dst::Dst, Context>(); - | ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. + | ^^^^^^^^ `Dst` is or contains a type or field that is not visible in that scope | - = help: the trait `BikeshedIntrinsicFrom<Src, test::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `Dst` note: required by a bound in `is_transmutable` --> $DIR/should_reject_if_dst_has_unreachable_field.rs:15:14 | diff --git a/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr b/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr index 20a680a74..ea488980c 100644 --- a/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr +++ b/tests/ui/transmutability/visibility/should_reject_if_dst_has_unreachable_ty.stderr @@ -10,13 +10,12 @@ note: the struct `Dst` is defined here LL | #[repr(C)] pub(self) struct Dst { | ^^^^^^^^^^^^^^^^^^^^ -error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. +error[E0277]: `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context` --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:38:41 | LL | assert::is_transmutable::<src::Src, dst::Dst, Context>(); - | ^^^^^^^^ `Src` cannot be safely transmuted into `Dst` in the defining scope of `test::Context`. + | ^^^^^^^^ `Dst` is or contains a type or field that is not visible in that scope | - = help: the trait `BikeshedIntrinsicFrom<Src, test::Context, Assume { alignment: false, lifetimes: false, safety: false, validity: false }>` is not implemented for `Dst` note: required by a bound in `is_transmutable` --> $DIR/should_reject_if_dst_has_unreachable_ty.rs:15:14 | diff --git a/tests/ui/transmute/transmute-padding-ice.stderr b/tests/ui/transmute/transmute-padding-ice.stderr index 87fd4fb66..f5480e0b9 100644 --- a/tests/ui/transmute/transmute-padding-ice.stderr +++ b/tests/ui/transmute/transmute-padding-ice.stderr @@ -1,10 +1,9 @@ -error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`. +error[E0277]: `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context` --> $DIR/transmute-padding-ice.rs:27:40 | LL | assert::is_maybe_transmutable::<B, A>(); - | ^ `B` cannot be safely transmuted into `A` in the defining scope of `assert::Context`. + | ^ The size of `B` is smaller than the size of `A` | - = help: the trait `BikeshedIntrinsicFrom<B, assert::Context, Assume { alignment: true, lifetimes: true, safety: true, validity: true }>` is not implemented for `A` note: required by a bound in `is_maybe_transmutable` --> $DIR/transmute-padding-ice.rs:11:14 | diff --git a/tests/ui/tuple-index.rs b/tests/ui/tuple/tuple-index.rs index 3e1d92b42..3e1d92b42 100644 --- a/tests/ui/tuple-index.rs +++ b/tests/ui/tuple/tuple-index.rs diff --git a/tests/ui/type-alias-impl-trait/assoc-type-const.rs b/tests/ui/type-alias-impl-trait/assoc-type-const.rs index 0ade36daf..62f66914e 100644 --- a/tests/ui/type-alias-impl-trait/assoc-type-const.rs +++ b/tests/ui/type-alias-impl-trait/assoc-type-const.rs @@ -2,7 +2,7 @@ // const generics in an associated opaque type // check-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait UnwrapItemsExt<'a, const C: usize> { type Iter; diff --git a/tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.rs b/tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.rs index 3f34b00ec..7c7c68ad6 100644 --- a/tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.rs +++ b/tests/ui/type-alias-impl-trait/assoc-type-lifetime-unconstrained.rs @@ -1,7 +1,7 @@ // Tests that we don't allow unconstrained lifetime parameters in impls when // the lifetime is used in an associated opaque type. -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait UnwrapItemsExt { type Iter; diff --git a/tests/ui/type-alias-impl-trait/assoc-type-lifetime.rs b/tests/ui/type-alias-impl-trait/assoc-type-lifetime.rs index 39f785d8c..81dacbcfb 100644 --- a/tests/ui/type-alias-impl-trait/assoc-type-lifetime.rs +++ b/tests/ui/type-alias-impl-trait/assoc-type-lifetime.rs @@ -2,7 +2,7 @@ // lifetimes are used in an associated opaque type // check-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait UnwrapItemsExt<'a> { type Iter; diff --git a/tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs b/tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs index 962606508..551815d02 100644 --- a/tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs +++ b/tests/ui/type-alias-impl-trait/associated-type-impl-trait-lifetime.rs @@ -1,6 +1,6 @@ //check-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait Trait { type Opaque1; diff --git a/tests/ui/type-alias-impl-trait/auxiliary/collect_hidden_types.rs b/tests/ui/type-alias-impl-trait/auxiliary/collect_hidden_types.rs index 75d20a6fe..444a4e695 100644 --- a/tests/ui/type-alias-impl-trait/auxiliary/collect_hidden_types.rs +++ b/tests/ui/type-alias-impl-trait/auxiliary/collect_hidden_types.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] // edition:2018 diff --git a/tests/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs b/tests/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs index 119f7df1f..98c961503 100644 --- a/tests/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs +++ b/tests/ui/type-alias-impl-trait/auxiliary/cross_crate_ice2.rs @@ -1,7 +1,7 @@ // Crate that exports an opaque `impl Trait` type. Used for testing cross-crate. #![crate_type = "rlib"] -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] pub trait View { type Tmp: Iterator<Item = u32>; diff --git a/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.rs b/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.rs index 851c2f66c..1824ff5e2 100644 --- a/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.rs +++ b/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.rs @@ -1,7 +1,7 @@ // Ensure that we don't ICE if associated type impl trait is used in an impl // with an unconstrained type parameter. -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait X { type I; diff --git a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs index ee9bce15d..4f99236f4 100644 --- a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs +++ b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait Callable { type Output; diff --git a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs index ae21a9134..5d5645077 100644 --- a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs +++ b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait Callable { type Output; @@ -17,7 +17,9 @@ impl<'a> PlusOne for &'a mut i32 { impl<T: PlusOne> Callable for T { type Output = impl PlusOne; - fn call(t: T) -> Self::Output { t } + fn call(t: T) -> Self::Output { + t + } } fn test<'a>(y: &'a mut i32) -> impl PlusOne { diff --git a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr index e52d5f9de..66e478315 100644 --- a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr +++ b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl PlusOne` captures lifetime that does not appear in bounds - --> $DIR/imply_bounds_from_bounds_param.rs:24:5 + --> $DIR/imply_bounds_from_bounds_param.rs:26:5 | LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne { | -- ------------ opaque type defined here diff --git a/tests/ui/type-alias-impl-trait/incoherent-assoc-imp-trait.rs b/tests/ui/type-alias-impl-trait/incoherent-assoc-imp-trait.rs index 685d76ee3..8df59c68f 100644 --- a/tests/ui/type-alias-impl-trait/incoherent-assoc-imp-trait.rs +++ b/tests/ui/type-alias-impl-trait/incoherent-assoc-imp-trait.rs @@ -1,7 +1,7 @@ // Regression test for issue 67856 #![feature(unboxed_closures)] -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] #![feature(fn_traits)] trait MyTrait {} diff --git a/tests/ui/type-alias-impl-trait/issue-53598.rs b/tests/ui/type-alias-impl-trait/issue-53598.rs index 9c1cbf926..e3e2787b6 100644 --- a/tests/ui/type-alias-impl-trait/issue-53598.rs +++ b/tests/ui/type-alias-impl-trait/issue-53598.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] use std::fmt::Debug; diff --git a/tests/ui/type-alias-impl-trait/issue-57188-associate-impl-capture.rs b/tests/ui/type-alias-impl-trait/issue-57188-associate-impl-capture.rs index 3a7a5da07..3bdb3bf1d 100644 --- a/tests/ui/type-alias-impl-trait/issue-57188-associate-impl-capture.rs +++ b/tests/ui/type-alias-impl-trait/issue-57188-associate-impl-capture.rs @@ -2,7 +2,7 @@ // check-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] struct Baz<'a> { source: &'a str, diff --git a/tests/ui/type-alias-impl-trait/issue-57611-trait-alias.rs b/tests/ui/type-alias-impl-trait/issue-57611-trait-alias.rs index cad3e0f66..3917bb3b6 100644 --- a/tests/ui/type-alias-impl-trait/issue-57611-trait-alias.rs +++ b/tests/ui/type-alias-impl-trait/issue-57611-trait-alias.rs @@ -3,7 +3,7 @@ // Ensures that we don't ICE #![feature(trait_alias)] -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait Foo { type Bar: Baz<Self, Self>; diff --git a/tests/ui/type-alias-impl-trait/issue-57700.rs b/tests/ui/type-alias-impl-trait/issue-57700.rs index 484589387..8746545ec 100644 --- a/tests/ui/type-alias-impl-trait/issue-57700.rs +++ b/tests/ui/type-alias-impl-trait/issue-57700.rs @@ -1,5 +1,5 @@ #![feature(arbitrary_self_types)] -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] use std::ops::Deref; diff --git a/tests/ui/type-alias-impl-trait/issue-57807-associated-type.rs b/tests/ui/type-alias-impl-trait/issue-57807-associated-type.rs index fcab2c7db..841bac5f6 100644 --- a/tests/ui/type-alias-impl-trait/issue-57807-associated-type.rs +++ b/tests/ui/type-alias-impl-trait/issue-57807-associated-type.rs @@ -2,7 +2,7 @@ // that we properly unify associated types within // a type alias impl trait // check-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait Bar { type A; diff --git a/tests/ui/type-alias-impl-trait/issue-58887.rs b/tests/ui/type-alias-impl-trait/issue-58887.rs index 96ac78602..967586765 100644 --- a/tests/ui/type-alias-impl-trait/issue-58887.rs +++ b/tests/ui/type-alias-impl-trait/issue-58887.rs @@ -1,6 +1,6 @@ // run-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait UnwrapItemsExt { type Iter; diff --git a/tests/ui/type-alias-impl-trait/issue-60371.rs b/tests/ui/type-alias-impl-trait/issue-60371.rs index 9a40f3d9b..a61739673 100644 --- a/tests/ui/type-alias-impl-trait/issue-60371.rs +++ b/tests/ui/type-alias-impl-trait/issue-60371.rs @@ -5,7 +5,7 @@ trait Bug { } impl Bug for &() { - type Item = impl Bug; //~ ERROR `impl Trait` in type aliases is unstable + type Item = impl Bug; //~ ERROR `impl Trait` in associated types is unstable const FUN: fn() -> Self::Item = || (); //~^ ERROR the trait bound `(): Bug` is not satisfied diff --git a/tests/ui/type-alias-impl-trait/issue-60371.stderr b/tests/ui/type-alias-impl-trait/issue-60371.stderr index d0c04371b..ffc664736 100644 --- a/tests/ui/type-alias-impl-trait/issue-60371.stderr +++ b/tests/ui/type-alias-impl-trait/issue-60371.stderr @@ -1,11 +1,11 @@ -error[E0658]: `impl Trait` in type aliases is unstable +error[E0658]: `impl Trait` in associated types is unstable --> $DIR/issue-60371.rs:8:17 | LL | type Item = impl Bug; | ^^^^^^^^ | = note: see issue #63063 <https://github.com/rust-lang/rust/issues/63063> for more information - = help: add `#![feature(type_alias_impl_trait)]` to the crate attributes to enable + = help: add `#![feature(impl_trait_in_assoc_type)]` to the crate attributes to enable error[E0277]: the trait bound `(): Bug` is not satisfied --> $DIR/issue-60371.rs:10:40 diff --git a/tests/ui/type-alias-impl-trait/issue-60564-working.rs b/tests/ui/type-alias-impl-trait/issue-60564-working.rs index 38accc824..c4687c29d 100644 --- a/tests/ui/type-alias-impl-trait/issue-60564-working.rs +++ b/tests/ui/type-alias-impl-trait/issue-60564-working.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] // check-pass diff --git a/tests/ui/type-alias-impl-trait/issue-62000-associate-impl-trait-lifetimes.rs b/tests/ui/type-alias-impl-trait/issue-62000-associate-impl-trait-lifetimes.rs index 36779a0ce..0245eab79 100644 --- a/tests/ui/type-alias-impl-trait/issue-62000-associate-impl-trait-lifetimes.rs +++ b/tests/ui/type-alias-impl-trait/issue-62000-associate-impl-trait-lifetimes.rs @@ -2,7 +2,7 @@ // check-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait MyTrait { type AssocType: Send; diff --git a/tests/ui/type-alias-impl-trait/issue-74761-2.rs b/tests/ui/type-alias-impl-trait/issue-74761-2.rs index d26ca5c3e..f582592e9 100644 --- a/tests/ui/type-alias-impl-trait/issue-74761-2.rs +++ b/tests/ui/type-alias-impl-trait/issue-74761-2.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] pub trait A { type B; diff --git a/tests/ui/type-alias-impl-trait/issue-74761.rs b/tests/ui/type-alias-impl-trait/issue-74761.rs index d26ca5c3e..f582592e9 100644 --- a/tests/ui/type-alias-impl-trait/issue-74761.rs +++ b/tests/ui/type-alias-impl-trait/issue-74761.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] pub trait A { type B; diff --git a/tests/ui/type-alias-impl-trait/issue-78450.rs b/tests/ui/type-alias-impl-trait/issue-78450.rs index fccbfb74f..2a984c1ed 100644 --- a/tests/ui/type-alias-impl-trait/issue-78450.rs +++ b/tests/ui/type-alias-impl-trait/issue-78450.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] pub trait AssociatedImpl { type ImplTrait; diff --git a/tests/ui/type-alias-impl-trait/issue-89952.rs b/tests/ui/type-alias-impl-trait/issue-89952.rs index dc0f19c04..f0ba9fa7c 100644 --- a/tests/ui/type-alias-impl-trait/issue-89952.rs +++ b/tests/ui/type-alias-impl-trait/issue-89952.rs @@ -1,6 +1,6 @@ // check-pass -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait SomeTrait {} impl SomeTrait for () {} diff --git a/tests/ui/type-alias-impl-trait/issue-90400-1.rs b/tests/ui/type-alias-impl-trait/issue-90400-1.rs index 15aead2f6..502076057 100644 --- a/tests/ui/type-alias-impl-trait/issue-90400-1.rs +++ b/tests/ui/type-alias-impl-trait/issue-90400-1.rs @@ -1,7 +1,7 @@ // Regression test for #90400, // taken from https://github.com/rust-lang/rust/issues/90400#issuecomment-954927836 -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait Bar { fn bar(&self); diff --git a/tests/ui/type-alias-impl-trait/issue-90400-2.rs b/tests/ui/type-alias-impl-trait/issue-90400-2.rs index 4c6e893c1..60ff962ea 100644 --- a/tests/ui/type-alias-impl-trait/issue-90400-2.rs +++ b/tests/ui/type-alias-impl-trait/issue-90400-2.rs @@ -1,7 +1,7 @@ // Regression test for #90400, // taken from https://github.com/rust-lang/rust/issues/90400#issuecomment-954927836 -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait Bar { fn bar(&self); diff --git a/tests/ui/type-alias-impl-trait/issue-94429.rs b/tests/ui/type-alias-impl-trait/issue-94429.rs index 2c965b875..d764545f9 100644 --- a/tests/ui/type-alias-impl-trait/issue-94429.rs +++ b/tests/ui/type-alias-impl-trait/issue-94429.rs @@ -1,4 +1,4 @@ -#![feature(type_alias_impl_trait, generator_trait, generators)] +#![feature(impl_trait_in_assoc_type, generator_trait, generators)] use std::ops::Generator; trait Runnable { @@ -13,7 +13,7 @@ impl Runnable for Implementor { type Gen = impl Generator<Yield = (), Return = ()>; fn run(&mut self) -> Self::Gen { - //~^ ERROR: type mismatch resolving + //~^ ERROR: type mismatch resolving move || { yield 1; } diff --git a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.rs b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.rs index efbf4f1e3..296a3f3e3 100644 --- a/tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.rs +++ b/tests/ui/type-alias-impl-trait/type-alias-impl-trait-unconstrained-lifetime.rs @@ -1,6 +1,6 @@ // regression test for #74018 -#![feature(type_alias_impl_trait)] +#![feature(impl_trait_in_assoc_type)] trait Trait { type Associated; diff --git a/tests/ui/type/type-check/assignment-in-if.stderr b/tests/ui/type/type-check/assignment-in-if.stderr index de133e559..9f4558ada 100644 --- a/tests/ui/type/type-check/assignment-in-if.stderr +++ b/tests/ui/type/type-check/assignment-in-if.stderr @@ -67,9 +67,6 @@ LL | x == 5 error[E0308]: mismatched types --> $DIR/assignment-in-if.rs:44:18 | -LL | if y = (Foo { foo: x }) { - | - here the type of `x` is inferred to be `usize` -... LL | if x == x && x = x && x == x { | ------ ^ expected `bool`, found `usize` | | @@ -78,9 +75,6 @@ LL | if x == x && x = x && x == x { error[E0308]: mismatched types --> $DIR/assignment-in-if.rs:44:22 | -LL | if y = (Foo { foo: x }) { - | - here the type of `x` is inferred to be `usize` -... LL | if x == x && x = x && x == x { | ^ expected `bool`, found `usize` @@ -98,9 +92,6 @@ LL | if x == x && x == x && x == x { error[E0308]: mismatched types --> $DIR/assignment-in-if.rs:51:28 | -LL | if y = (Foo { foo: x }) { - | - here the type of `x` is inferred to be `usize` -... LL | if x == x && x == x && x = x { | ---------------- ^ expected `bool`, found `usize` | | diff --git a/tests/ui/type/type-check/point-at-inference-3.fixed b/tests/ui/type/type-check/point-at-inference-3.fixed index edd4adf8b..15a3b5805 100644 --- a/tests/ui/type/type-check/point-at-inference-3.fixed +++ b/tests/ui/type/type-check/point-at-inference-3.fixed @@ -2,7 +2,8 @@ fn main() { let mut v = Vec::new(); v.push(0i32); - //~^ NOTE this is of type `i32`, which causes `v` to be inferred as `Vec<i32>` + //~^ NOTE this argument has type `i32`... + //~| NOTE ... which causes `v` to have type `Vec<i32>` v.push(0); v.push(1i32); //~ ERROR mismatched types //~^ NOTE expected `i32`, found `u32` diff --git a/tests/ui/type/type-check/point-at-inference-3.rs b/tests/ui/type/type-check/point-at-inference-3.rs index 49d7b5007..a48c4f986 100644 --- a/tests/ui/type/type-check/point-at-inference-3.rs +++ b/tests/ui/type/type-check/point-at-inference-3.rs @@ -2,7 +2,8 @@ fn main() { let mut v = Vec::new(); v.push(0i32); - //~^ NOTE this is of type `i32`, which causes `v` to be inferred as `Vec<i32>` + //~^ NOTE this argument has type `i32`... + //~| NOTE ... which causes `v` to have type `Vec<i32>` v.push(0); v.push(1u32); //~ ERROR mismatched types //~^ NOTE expected `i32`, found `u32` diff --git a/tests/ui/type/type-check/point-at-inference-3.stderr b/tests/ui/type/type-check/point-at-inference-3.stderr index 2c4907ed2..238764812 100644 --- a/tests/ui/type/type-check/point-at-inference-3.stderr +++ b/tests/ui/type/type-check/point-at-inference-3.stderr @@ -1,8 +1,10 @@ error[E0308]: mismatched types - --> $DIR/point-at-inference-3.rs:7:12 + --> $DIR/point-at-inference-3.rs:8:12 | LL | v.push(0i32); - | ---- this is of type `i32`, which causes `v` to be inferred as `Vec<i32>` + | - ---- this argument has type `i32`... + | | + | ... which causes `v` to have type `Vec<i32>` ... LL | v.push(1u32); | ---- ^^^^ expected `i32`, found `u32` diff --git a/tests/ui/type/type-check/point-at-inference-4.rs b/tests/ui/type/type-check/point-at-inference-4.rs index aea9b2c6c..3deb234c2 100644 --- a/tests/ui/type/type-check/point-at-inference-4.rs +++ b/tests/ui/type/type-check/point-at-inference-4.rs @@ -11,8 +11,11 @@ fn main() { let s = S(None); s.infer(0i32); //~^ ERROR this method takes 2 arguments but 1 argument was supplied + //~| NOTE this argument has type `i32`... + //~| NOTE ... which causes `s` to have type `S<i32, _>` //~| NOTE an argument is missing //~| HELP provide the argument + //~| HELP change the type of the numeric literal from `i32` to `u32` let t: S<u32, _> = s; //~^ ERROR mismatched types //~| NOTE expected `S<u32, _>`, found `S<i32, _>` diff --git a/tests/ui/type/type-check/point-at-inference-4.stderr b/tests/ui/type/type-check/point-at-inference-4.stderr index 28833d2ed..5f7bb8b93 100644 --- a/tests/ui/type/type-check/point-at-inference-4.stderr +++ b/tests/ui/type/type-check/point-at-inference-4.stderr @@ -15,8 +15,13 @@ LL | s.infer(0i32, /* b */); | ~~~~~~~~~~~~~~~ error[E0308]: mismatched types - --> $DIR/point-at-inference-4.rs:16:24 + --> $DIR/point-at-inference-4.rs:19:24 | +LL | s.infer(0i32); + | - ---- this argument has type `i32`... + | | + | ... which causes `s` to have type `S<i32, _>` +... LL | let t: S<u32, _> = s; | --------- ^ expected `S<u32, _>`, found `S<i32, _>` | | @@ -24,6 +29,10 @@ LL | let t: S<u32, _> = s; | = note: expected struct `S<u32, _>` found struct `S<i32, _>` +help: change the type of the numeric literal from `i32` to `u32` + | +LL | s.infer(0u32); + | ~~~ error: aborting due to 2 previous errors diff --git a/tests/ui/type/type-check/point-at-inference.stderr b/tests/ui/type/type-check/point-at-inference.stderr index a76b4f90c..5fc94d4d1 100644 --- a/tests/ui/type/type-check/point-at-inference.stderr +++ b/tests/ui/type/type-check/point-at-inference.stderr @@ -2,7 +2,9 @@ error[E0308]: mismatched types --> $DIR/point-at-inference.rs:12:9 | LL | foo.push(i); - | - this is of type `&{integer}`, which causes `foo` to be inferred as `Vec<&{integer}>` + | --- - this argument has type `&{integer}`... + | | + | ... which causes `foo` to have type `Vec<&{integer}>` ... LL | bar(foo); | --- ^^^ expected `Vec<i32>`, found `Vec<&{integer}>` diff --git a/tests/ui/typeck/bad-type-in-vec-contains.stderr b/tests/ui/typeck/bad-type-in-vec-contains.stderr index 0e03388d2..72533ab1f 100644 --- a/tests/ui/typeck/bad-type-in-vec-contains.stderr +++ b/tests/ui/typeck/bad-type-in-vec-contains.stderr @@ -7,7 +7,6 @@ LL | primes.contains(3); | | expected `&_`, found integer | | help: consider borrowing here: `&3` | arguments to this method are incorrect - | here the type of `primes` is inferred to be `[_]` | = note: expected reference `&_` found type `{integer}` diff --git a/tests/ui/typeck/bad-type-in-vec-push.stderr b/tests/ui/typeck/bad-type-in-vec-push.stderr index ae46050c9..1d5337260 100644 --- a/tests/ui/typeck/bad-type-in-vec-push.stderr +++ b/tests/ui/typeck/bad-type-in-vec-push.stderr @@ -1,8 +1,6 @@ error[E0308]: mismatched types --> $DIR/bad-type-in-vec-push.rs:11:17 | -LL | vector.sort(); - | ------ here the type of `vector` is inferred to be `Vec<_>` LL | result.push(vector); | ---- ^^^^^^ expected integer, found `Vec<_>` | | diff --git a/tests/ui/typeck/explain_clone_autoref.stderr b/tests/ui/typeck/explain_clone_autoref.stderr index 4539da438..38cb7fe55 100644 --- a/tests/ui/typeck/explain_clone_autoref.stderr +++ b/tests/ui/typeck/explain_clone_autoref.stderr @@ -14,7 +14,8 @@ LL | nc.clone() | ^^ help: consider annotating `NotClone` with `#[derive(Clone)]` | -LL | #[derive(Clone)] +LL + #[derive(Clone)] +LL | struct NotClone; | error: aborting due to previous error diff --git a/tests/ui/typeck/issue-105946.rs b/tests/ui/typeck/issue-105946.rs index bf01751d5..f53f31138 100644 --- a/tests/ui/typeck/issue-105946.rs +++ b/tests/ui/typeck/issue-105946.rs @@ -1,12 +1,10 @@ fn digit() -> str { - return {}; - //~^ ERROR: mismatched types [E0308] + return {}; + //~^ ERROR: mismatched types [E0308] } fn main() { - let [_y..] = [box 1, box 2]; + let [_y..] = [Box::new(1), Box::new(2)]; //~^ ERROR: cannot find value `_y` in this scope [E0425] //~| ERROR: `X..` patterns in slices are experimental [E0658] - //~| ERROR: box expression syntax is experimental; you can call `Box::new` instead [E0658] - //~| ERROR: box expression syntax is experimental; you can call `Box::new` instead [E0658] //~| ERROR: pattern requires 1 element but array has 2 [E0527] } diff --git a/tests/ui/typeck/issue-105946.stderr b/tests/ui/typeck/issue-105946.stderr index d803de4df..26c3b7fbc 100644 --- a/tests/ui/typeck/issue-105946.stderr +++ b/tests/ui/typeck/issue-105946.stderr @@ -1,49 +1,31 @@ error[E0425]: cannot find value `_y` in this scope --> $DIR/issue-105946.rs:6:10 | -LL | let [_y..] = [box 1, box 2]; +LL | let [_y..] = [Box::new(1), Box::new(2)]; | ^^ not found in this scope error[E0658]: `X..` patterns in slices are experimental --> $DIR/issue-105946.rs:6:10 | -LL | let [_y..] = [box 1, box 2]; +LL | let [_y..] = [Box::new(1), Box::new(2)]; | ^^^^ | = note: see issue #67264 <https://github.com/rust-lang/rust/issues/67264> for more information = help: add `#![feature(half_open_range_patterns_in_slices)]` to the crate attributes to enable -error[E0658]: box expression syntax is experimental; you can call `Box::new` instead - --> $DIR/issue-105946.rs:6:19 - | -LL | let [_y..] = [box 1, box 2]; - | ^^^^^ - | - = note: see issue #49733 <https://github.com/rust-lang/rust/issues/49733> for more information - = help: add `#![feature(box_syntax)]` to the crate attributes to enable - -error[E0658]: box expression syntax is experimental; you can call `Box::new` instead - --> $DIR/issue-105946.rs:6:26 - | -LL | let [_y..] = [box 1, box 2]; - | ^^^^^ - | - = note: see issue #49733 <https://github.com/rust-lang/rust/issues/49733> for more information - = help: add `#![feature(box_syntax)]` to the crate attributes to enable - error[E0308]: mismatched types - --> $DIR/issue-105946.rs:2:10 + --> $DIR/issue-105946.rs:2:12 | -LL | return {}; - | ^^ expected `str`, found `()` +LL | return {}; + | ^^ expected `str`, found `()` error[E0527]: pattern requires 1 element but array has 2 --> $DIR/issue-105946.rs:6:9 | -LL | let [_y..] = [box 1, box 2]; +LL | let [_y..] = [Box::new(1), Box::new(2)]; | ^^^^^^ expected 2 elements -error: aborting due to 6 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0308, E0425, E0527, E0658. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/typeck/issue-107775.stderr b/tests/ui/typeck/issue-107775.stderr index 9ee9c022c..b97e74b7e 100644 --- a/tests/ui/typeck/issue-107775.stderr +++ b/tests/ui/typeck/issue-107775.stderr @@ -2,9 +2,9 @@ error[E0308]: mismatched types --> $DIR/issue-107775.rs:35:16 | LL | map.insert(1, Struct::do_something); - | - -------------------- this is of type `fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}`, which causes `map` to be inferred as `HashMap<{integer}, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>` - | | - | this is of type `{integer}`, which causes `map` to be inferred as `HashMap<{integer}, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>` + | --- -------------------- this argument has type `fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}`... + | | + | ... which causes `map` to have type `HashMap<{integer}, fn(u8) -> Pin<Box<dyn Future<Output = ()> + Send>> {<Struct as Trait>::do_something::<'_>}>` LL | Self { map } | ^^^ expected `HashMap<u16, fn(u8) -> Pin<...>>`, found `HashMap<{integer}, ...>` | diff --git a/tests/ui/typeck/issue-110052.rs b/tests/ui/typeck/issue-110052.rs new file mode 100644 index 000000000..f124b58b5 --- /dev/null +++ b/tests/ui/typeck/issue-110052.rs @@ -0,0 +1,12 @@ +// Makes sure we deal with escaping lifetimes *above* INNERMOST when +// suggesting trait for ambiguous associated type. + +impl<I, V> Validator<I> for () +where + for<'iter> dyn Validator<<&'iter I>::Item>:, + //~^ ERROR ambiguous associated type +{} + +pub trait Validator<T> {} + +fn main() {} diff --git a/tests/ui/typeck/issue-110052.stderr b/tests/ui/typeck/issue-110052.stderr new file mode 100644 index 000000000..0c15c03a7 --- /dev/null +++ b/tests/ui/typeck/issue-110052.stderr @@ -0,0 +1,9 @@ +error[E0223]: ambiguous associated type + --> $DIR/issue-110052.rs:6:30 + | +LL | for<'iter> dyn Validator<<&'iter I>::Item>:, + | ^^^^^^^^^^^^^^^^ help: use the fully-qualified path: `<&'iter I as IntoIterator>::Item` + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0223`. diff --git a/tests/ui/typeck/issue-43189.stderr b/tests/ui/typeck/issue-43189.stderr index caf7530b8..c072e6a08 100644 --- a/tests/ui/typeck/issue-43189.stderr +++ b/tests/ui/typeck/issue-43189.stderr @@ -12,7 +12,7 @@ LL | fn a(&self) {} = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use xcrate_issue_43189_b::xcrate_issue_43189_a::A; +LL + use xcrate_issue_43189_b::xcrate_issue_43189_a::A; | error: aborting due to previous error diff --git a/tests/ui/typeck/issue-87935-unsized-box-expr.rs b/tests/ui/typeck/issue-87935-unsized-box-expr.rs deleted file mode 100644 index cd2a82074..000000000 --- a/tests/ui/typeck/issue-87935-unsized-box-expr.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(box_syntax)] -// Box expression needs to be movable, and hence has to be of a Sized type. -fn main() { - let _x: Box<[u32]> = box { loop {} }; - //~^ ERROR: the size for values of type `[u32]` cannot be known at compilation time - - // Check that a deduced size does not cause issues. - let _y: Box<[u32]> = box []; - let _z: Box<[u32; 0]> = box { loop {} }; -} diff --git a/tests/ui/typeck/issue-87935-unsized-box-expr.stderr b/tests/ui/typeck/issue-87935-unsized-box-expr.stderr deleted file mode 100644 index 9ff822352..000000000 --- a/tests/ui/typeck/issue-87935-unsized-box-expr.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0277]: the size for values of type `[u32]` cannot be known at compilation time - --> $DIR/issue-87935-unsized-box-expr.rs:4:30 - | -LL | let _x: Box<[u32]> = box { loop {} }; - | ^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u32]` - = note: the type of a box expression must have a statically known size - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/typeck/issue-90164.stderr b/tests/ui/typeck/issue-90164.stderr index 1e2f1bae3..8586f5222 100644 --- a/tests/ui/typeck/issue-90164.stderr +++ b/tests/ui/typeck/issue-90164.stderr @@ -6,7 +6,8 @@ LL | copy(r, w); | | | required by a bound introduced by this call | - = note: consider using `Box::pin` + = note: consider using the `pin!` macro + consider using `Box::pin` if you need to access the pinned value outside of the current scope note: required by a bound in `copy` --> $DIR/issue-90164.rs:1:12 | diff --git a/tests/ui/typeck/lazy-norm/cast-checks-handling-projections.stderr b/tests/ui/typeck/lazy-norm/cast-checks-handling-projections.stderr deleted file mode 100644 index 6b09ccd52..000000000 --- a/tests/ui/typeck/lazy-norm/cast-checks-handling-projections.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0271]: type mismatch resolving `char == <u8 as Add>::Output` - --> $DIR/cast-checks-handling-projections.rs:5:5 - | -LL | (0u8 + 0u8) as char; - | ^^^^^^^^^^^ types differ - -error: aborting due to previous error - -For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/output-type-mismatch.rs b/tests/ui/typeck/output-type-mismatch.rs index 35097aa9e..35097aa9e 100644 --- a/tests/ui/output-type-mismatch.rs +++ b/tests/ui/typeck/output-type-mismatch.rs diff --git a/tests/ui/output-type-mismatch.stderr b/tests/ui/typeck/output-type-mismatch.stderr index 4507a4df6..4507a4df6 100644 --- a/tests/ui/output-type-mismatch.stderr +++ b/tests/ui/typeck/output-type-mismatch.stderr diff --git a/tests/ui/suppressed-error.rs b/tests/ui/typeck/suppressed-error.rs index 1e39be460..1e39be460 100644 --- a/tests/ui/suppressed-error.rs +++ b/tests/ui/typeck/suppressed-error.rs diff --git a/tests/ui/suppressed-error.stderr b/tests/ui/typeck/suppressed-error.stderr index 11d70f8a4..11d70f8a4 100644 --- a/tests/ui/suppressed-error.stderr +++ b/tests/ui/typeck/suppressed-error.stderr diff --git a/tests/ui/tag-that-dare-not-speak-its-name.rs b/tests/ui/typeck/tag-that-dare-not-speak-its-name.rs index 0e76ec246..0e76ec246 100644 --- a/tests/ui/tag-that-dare-not-speak-its-name.rs +++ b/tests/ui/typeck/tag-that-dare-not-speak-its-name.rs diff --git a/tests/ui/tag-that-dare-not-speak-its-name.stderr b/tests/ui/typeck/tag-that-dare-not-speak-its-name.stderr index f53abe53b..f53abe53b 100644 --- a/tests/ui/tag-that-dare-not-speak-its-name.stderr +++ b/tests/ui/typeck/tag-that-dare-not-speak-its-name.stderr diff --git a/tests/ui/terr-in-field.rs b/tests/ui/typeck/terr-in-field.rs index cfe350ef8..cfe350ef8 100644 --- a/tests/ui/terr-in-field.rs +++ b/tests/ui/typeck/terr-in-field.rs diff --git a/tests/ui/terr-in-field.stderr b/tests/ui/typeck/terr-in-field.stderr index 09df4b34b..09df4b34b 100644 --- a/tests/ui/terr-in-field.stderr +++ b/tests/ui/typeck/terr-in-field.stderr diff --git a/tests/ui/terr-sorts.rs b/tests/ui/typeck/terr-sorts.rs index c1e2f7dae..c1e2f7dae 100644 --- a/tests/ui/terr-sorts.rs +++ b/tests/ui/typeck/terr-sorts.rs diff --git a/tests/ui/terr-sorts.stderr b/tests/ui/typeck/terr-sorts.stderr index 8f1975374..8f1975374 100644 --- a/tests/ui/terr-sorts.stderr +++ b/tests/ui/typeck/terr-sorts.stderr diff --git a/tests/ui/while-type-error.rs b/tests/ui/typeck/while-type-error.rs index 8098bfcd8..8098bfcd8 100644 --- a/tests/ui/while-type-error.rs +++ b/tests/ui/typeck/while-type-error.rs diff --git a/tests/ui/while-type-error.stderr b/tests/ui/typeck/while-type-error.stderr index 529cbff05..529cbff05 100644 --- a/tests/ui/while-type-error.stderr +++ b/tests/ui/typeck/while-type-error.stderr diff --git a/tests/ui/wrong-ret-type.rs b/tests/ui/typeck/wrong-ret-type.rs index cbff8dbae..cbff8dbae 100644 --- a/tests/ui/wrong-ret-type.rs +++ b/tests/ui/typeck/wrong-ret-type.rs diff --git a/tests/ui/wrong-ret-type.stderr b/tests/ui/typeck/wrong-ret-type.stderr index c686a0b2f..c686a0b2f 100644 --- a/tests/ui/wrong-ret-type.stderr +++ b/tests/ui/typeck/wrong-ret-type.stderr diff --git a/tests/ui/ufcs/ufcs-partially-resolved.rs b/tests/ui/ufcs/ufcs-partially-resolved.rs index e6470aa6d..712668728 100644 --- a/tests/ui/ufcs/ufcs-partially-resolved.rs +++ b/tests/ui/ufcs/ufcs-partially-resolved.rs @@ -17,37 +17,37 @@ type A = u32; fn main() { let _: <u8 as Tr>::N; //~ ERROR cannot find associated type `N` in trait `Tr` - let _: <u8 as E>::N; //~ ERROR cannot find associated type `N` in enum `E` - let _: <u8 as A>::N; //~ ERROR cannot find associated type `N` in `A` + let _: <u8 as E>::N; //~ ERROR expected trait, found enum `E` + let _: <u8 as A>::N; //~ ERROR expected trait, found type alias `A` <u8 as Tr>::N; //~ ERROR cannot find method or associated constant `N` in trait `Tr` - <u8 as E>::N; //~ ERROR cannot find method or associated constant `N` in enum `E` - <u8 as A>::N; //~ ERROR cannot find method or associated constant `N` in `A` + <u8 as E>::N; //~ ERROR expected trait, found enum `E` + <u8 as A>::N; //~ ERROR expected trait, found type alias `A` let _: <u8 as Tr>::Y; // OK - let _: <u8 as E>::Y; //~ ERROR expected associated type, found variant `E::Y` + let _: <u8 as E>::Y; //~ ERROR expected trait, found enum `E` <u8 as Tr>::Y; // OK - <u8 as E>::Y; //~ ERROR expected method or associated constant, found unit variant `E::Y` + <u8 as E>::Y; //~ ERROR expected trait, found enum `E` let _: <u8 as Tr>::N::NN; //~ ERROR cannot find associated type `N` in trait `Tr` - let _: <u8 as E>::N::NN; //~ ERROR cannot find associated type `N` in enum `E` - let _: <u8 as A>::N::NN; //~ ERROR cannot find associated type `N` in `A` + let _: <u8 as E>::N::NN; //~ ERROR expected trait, found enum `E` + let _: <u8 as A>::N::NN; //~ ERROR expected trait, found type alias `A` <u8 as Tr>::N::NN; //~ ERROR cannot find associated type `N` in trait `Tr` - <u8 as E>::N::NN; //~ ERROR cannot find associated type `N` in enum `E` - <u8 as A>::N::NN; //~ ERROR cannot find associated type `N` in `A` + <u8 as E>::N::NN; //~ ERROR expected trait, found enum `E` + <u8 as A>::N::NN; //~ ERROR expected trait, found type alias `A` let _: <u8 as Tr>::Y::NN; //~ ERROR ambiguous associated type - let _: <u8 as E>::Y::NN; //~ ERROR expected associated type, found variant `E::Y` + let _: <u8 as E>::Y::NN; //~ ERROR expected trait, found enum `E` <u8 as Tr>::Y::NN; //~ ERROR no associated item named `NN` found for type `u16` - <u8 as E>::Y::NN; //~ ERROR expected associated type, found variant `E::Y` + <u8 as E>::Y::NN; //~ ERROR expected trait, found enum `E` - let _: <u8 as Tr::N>::NN; //~ ERROR cannot find associated type `NN` in `Tr::N` - let _: <u8 as E::N>::NN; //~ ERROR cannot find associated type `NN` in `E::N` - let _: <u8 as A::N>::NN; //~ ERROR cannot find associated type `NN` in `A::N` - <u8 as Tr::N>::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::N` - <u8 as E::N>::NN; //~ ERROR cannot find method or associated constant `NN` in `E::N` - <u8 as A::N>::NN; //~ ERROR cannot find method or associated constant `NN` in `A::N` - let _: <u8 as Tr::Y>::NN; //~ ERROR cannot find associated type `NN` in `Tr::Y` - let _: <u8 as E::Y>::NN; //~ ERROR failed to resolve: `Y` is a variant, not a module - <u8 as Tr::Y>::NN; //~ ERROR cannot find method or associated constant `NN` in `Tr::Y` - <u8 as E::Y>::NN; //~ ERROR failed to resolve: `Y` is a variant, not a module + let _: <u8 as Tr::N>::NN; //~ ERROR cannot find trait `N` in trait `Tr` + let _: <u8 as E::N>::NN; //~ ERROR cannot find trait `N` in enum `E` + let _: <u8 as A::N>::NN; //~ ERROR cannot find trait `N` in `A` + <u8 as Tr::N>::NN; //~ ERROR cannot find trait `N` in trait `Tr` + <u8 as E::N>::NN; //~ ERROR cannot find trait `N` in enum `E` + <u8 as A::N>::NN; //~ ERROR cannot find trait `N` in `A` + let _: <u8 as Tr::Y>::NN; //~ ERROR expected trait, found associated type `Tr::Y + let _: <u8 as E::Y>::NN; //~ ERROR expected trait, found variant `E::Y` + <u8 as Tr::Y>::NN; //~ ERROR expected trait, found associated type `Tr::Y` + <u8 as E::Y>::NN; //~ ERROR expected trait, found variant `E::Y` let _: <u8 as Dr>::Z; //~ ERROR expected associated type, found associated function `Dr::Z` <u8 as Dr>::X; //~ ERROR expected method or associated constant, found associated type `Dr::X` diff --git a/tests/ui/ufcs/ufcs-partially-resolved.stderr b/tests/ui/ufcs/ufcs-partially-resolved.stderr index 72fccea8a..eef55c8dc 100644 --- a/tests/ui/ufcs/ufcs-partially-resolved.stderr +++ b/tests/ui/ufcs/ufcs-partially-resolved.stderr @@ -1,15 +1,3 @@ -error[E0433]: failed to resolve: `Y` is a variant, not a module - --> $DIR/ufcs-partially-resolved.rs:48:22 - | -LL | let _: <u8 as E::Y>::NN; - | ^ `Y` is a variant, not a module - -error[E0433]: failed to resolve: `Y` is a variant, not a module - --> $DIR/ufcs-partially-resolved.rs:50:15 - | -LL | <u8 as E::Y>::NN; - | ^ `Y` is a variant, not a module - error[E0576]: cannot find associated type `N` in trait `Tr` --> $DIR/ufcs-partially-resolved.rs:19:24 | @@ -19,17 +7,25 @@ LL | type Y = u16; LL | let _: <u8 as Tr>::N; | ^ help: an associated type with a similar name exists: `Y` -error[E0576]: cannot find associated type `N` in enum `E` - --> $DIR/ufcs-partially-resolved.rs:20:23 +error[E0404]: expected trait, found enum `E` + --> $DIR/ufcs-partially-resolved.rs:20:19 | LL | let _: <u8 as E>::N; - | ^ not found in `E` + | ^ help: a trait with a similar name exists: `Eq` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | + = note: similarly named trait `Eq` defined here -error[E0576]: cannot find associated type `N` in `A` - --> $DIR/ufcs-partially-resolved.rs:21:23 +error[E0404]: expected trait, found type alias `A` + --> $DIR/ufcs-partially-resolved.rs:21:19 | LL | let _: <u8 as A>::N; - | ^ not found in `A` + | ^ type aliases cannot be used as traits + | +help: you might have meant to use `#![feature(trait_alias)]` instead of a `type` alias + | +LL | trait A = u32; + | error[E0576]: cannot find method or associated constant `N` in trait `Tr` --> $DIR/ufcs-partially-resolved.rs:22:17 @@ -40,29 +36,43 @@ LL | fn Y() {} LL | <u8 as Tr>::N; | ^ help: an associated function with a similar name exists: `Y` -error[E0576]: cannot find method or associated constant `N` in enum `E` - --> $DIR/ufcs-partially-resolved.rs:23:16 +error[E0404]: expected trait, found enum `E` + --> $DIR/ufcs-partially-resolved.rs:23:12 | LL | <u8 as E>::N; - | ^ not found in `E` + | ^ help: a trait with a similar name exists: `Eq` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | + = note: similarly named trait `Eq` defined here -error[E0576]: cannot find method or associated constant `N` in `A` - --> $DIR/ufcs-partially-resolved.rs:24:16 +error[E0404]: expected trait, found type alias `A` + --> $DIR/ufcs-partially-resolved.rs:24:12 | LL | <u8 as A>::N; - | ^ not found in `A` + | ^ type aliases cannot be used as traits + | +help: you might have meant to use `#![feature(trait_alias)]` instead of a `type` alias + | +LL | trait A = u32; + | -error[E0575]: expected associated type, found variant `E::Y` - --> $DIR/ufcs-partially-resolved.rs:26:12 +error[E0404]: expected trait, found enum `E` + --> $DIR/ufcs-partially-resolved.rs:26:19 | LL | let _: <u8 as E>::Y; - | ^^^^^^^^^^^^ not a associated type + | ^ help: a trait with a similar name exists: `Eq` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | + = note: similarly named trait `Eq` defined here -error[E0575]: expected method or associated constant, found unit variant `E::Y` - --> $DIR/ufcs-partially-resolved.rs:28:5 +error[E0404]: expected trait, found enum `E` + --> $DIR/ufcs-partially-resolved.rs:28:12 | LL | <u8 as E>::Y; - | ^^^^^^^^^^^^ not a method or associated constant + | ^ help: a trait with a similar name exists: `Eq` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | + = note: similarly named trait `Eq` defined here error[E0576]: cannot find associated type `N` in trait `Tr` --> $DIR/ufcs-partially-resolved.rs:30:24 @@ -73,17 +83,25 @@ LL | type Y = u16; LL | let _: <u8 as Tr>::N::NN; | ^ help: an associated type with a similar name exists: `Y` -error[E0576]: cannot find associated type `N` in enum `E` - --> $DIR/ufcs-partially-resolved.rs:31:23 +error[E0404]: expected trait, found enum `E` + --> $DIR/ufcs-partially-resolved.rs:31:19 | LL | let _: <u8 as E>::N::NN; - | ^ not found in `E` + | ^ help: a trait with a similar name exists: `Eq` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | + = note: similarly named trait `Eq` defined here -error[E0576]: cannot find associated type `N` in `A` - --> $DIR/ufcs-partially-resolved.rs:32:23 +error[E0404]: expected trait, found type alias `A` + --> $DIR/ufcs-partially-resolved.rs:32:19 | LL | let _: <u8 as A>::N::NN; - | ^ not found in `A` + | ^ type aliases cannot be used as traits + | +help: you might have meant to use `#![feature(trait_alias)]` instead of a `type` alias + | +LL | trait A = u32; + | error[E0576]: cannot find associated type `N` in trait `Tr` --> $DIR/ufcs-partially-resolved.rs:33:17 @@ -94,77 +112,103 @@ LL | type Y = u16; LL | <u8 as Tr>::N::NN; | ^ help: an associated type with a similar name exists: `Y` -error[E0576]: cannot find associated type `N` in enum `E` - --> $DIR/ufcs-partially-resolved.rs:34:16 +error[E0404]: expected trait, found enum `E` + --> $DIR/ufcs-partially-resolved.rs:34:12 | LL | <u8 as E>::N::NN; - | ^ not found in `E` + | ^ help: a trait with a similar name exists: `Eq` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | + = note: similarly named trait `Eq` defined here -error[E0576]: cannot find associated type `N` in `A` - --> $DIR/ufcs-partially-resolved.rs:35:16 +error[E0404]: expected trait, found type alias `A` + --> $DIR/ufcs-partially-resolved.rs:35:12 | LL | <u8 as A>::N::NN; - | ^ not found in `A` + | ^ type aliases cannot be used as traits + | +help: you might have meant to use `#![feature(trait_alias)]` instead of a `type` alias + | +LL | trait A = u32; + | -error[E0575]: expected associated type, found variant `E::Y` - --> $DIR/ufcs-partially-resolved.rs:37:12 +error[E0404]: expected trait, found enum `E` + --> $DIR/ufcs-partially-resolved.rs:37:19 | LL | let _: <u8 as E>::Y::NN; - | ^^^^^^^^^^^^^^^^ not a associated type + | ^ help: a trait with a similar name exists: `Eq` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | + = note: similarly named trait `Eq` defined here -error[E0575]: expected associated type, found variant `E::Y` - --> $DIR/ufcs-partially-resolved.rs:39:5 +error[E0404]: expected trait, found enum `E` + --> $DIR/ufcs-partially-resolved.rs:39:12 | LL | <u8 as E>::Y::NN; - | ^^^^^^^^^^^^^^^^ not a associated type + | ^ help: a trait with a similar name exists: `Eq` + --> $SRC_DIR/core/src/cmp.rs:LL:COL + | + = note: similarly named trait `Eq` defined here -error[E0576]: cannot find associated type `NN` in `Tr::N` - --> $DIR/ufcs-partially-resolved.rs:41:27 +error[E0405]: cannot find trait `N` in trait `Tr` + --> $DIR/ufcs-partially-resolved.rs:41:23 | LL | let _: <u8 as Tr::N>::NN; - | ^^ not found in `Tr::N` + | ^ not found in `Tr` -error[E0576]: cannot find associated type `NN` in `E::N` - --> $DIR/ufcs-partially-resolved.rs:42:26 +error[E0405]: cannot find trait `N` in enum `E` + --> $DIR/ufcs-partially-resolved.rs:42:22 | LL | let _: <u8 as E::N>::NN; - | ^^ not found in `E::N` + | ^ not found in `E` -error[E0576]: cannot find associated type `NN` in `A::N` - --> $DIR/ufcs-partially-resolved.rs:43:26 +error[E0405]: cannot find trait `N` in `A` + --> $DIR/ufcs-partially-resolved.rs:43:22 | LL | let _: <u8 as A::N>::NN; - | ^^ not found in `A::N` + | ^ not found in `A` -error[E0576]: cannot find method or associated constant `NN` in `Tr::N` - --> $DIR/ufcs-partially-resolved.rs:44:20 +error[E0405]: cannot find trait `N` in trait `Tr` + --> $DIR/ufcs-partially-resolved.rs:44:16 | LL | <u8 as Tr::N>::NN; - | ^^ not found in `Tr::N` + | ^ not found in `Tr` -error[E0576]: cannot find method or associated constant `NN` in `E::N` - --> $DIR/ufcs-partially-resolved.rs:45:19 +error[E0405]: cannot find trait `N` in enum `E` + --> $DIR/ufcs-partially-resolved.rs:45:15 | LL | <u8 as E::N>::NN; - | ^^ not found in `E::N` + | ^ not found in `E` -error[E0576]: cannot find method or associated constant `NN` in `A::N` - --> $DIR/ufcs-partially-resolved.rs:46:19 +error[E0405]: cannot find trait `N` in `A` + --> $DIR/ufcs-partially-resolved.rs:46:15 | LL | <u8 as A::N>::NN; - | ^^ not found in `A::N` + | ^ not found in `A` -error[E0576]: cannot find associated type `NN` in `Tr::Y` - --> $DIR/ufcs-partially-resolved.rs:47:27 +error[E0404]: expected trait, found associated type `Tr::Y` + --> $DIR/ufcs-partially-resolved.rs:47:19 | LL | let _: <u8 as Tr::Y>::NN; - | ^^ not found in `Tr::Y` + | ^^^^^ not a trait + +error[E0404]: expected trait, found variant `E::Y` + --> $DIR/ufcs-partially-resolved.rs:48:19 + | +LL | let _: <u8 as E::Y>::NN; + | ^^^^ not a trait -error[E0576]: cannot find method or associated constant `NN` in `Tr::Y` - --> $DIR/ufcs-partially-resolved.rs:49:20 +error[E0404]: expected trait, found associated type `Tr::Y` + --> $DIR/ufcs-partially-resolved.rs:49:12 | LL | <u8 as Tr::Y>::NN; - | ^^ not found in `Tr::Y` + | ^^^^^ not a trait + +error[E0404]: expected trait, found variant `E::Y` + --> $DIR/ufcs-partially-resolved.rs:50:12 + | +LL | <u8 as E::Y>::NN; + | ^^^^ not a trait error[E0575]: expected associated type, found associated function `Dr::Z` --> $DIR/ufcs-partially-resolved.rs:52:12 @@ -226,5 +270,5 @@ LL | <u8 as Dr>::X::N; error: aborting due to 32 previous errors -Some errors have detailed explanations: E0223, E0433, E0575, E0576, E0599. +Some errors have detailed explanations: E0223, E0404, E0405, E0575, E0576, E0599. For more information about an error, try `rustc --explain E0223`. diff --git a/tests/ui/ufcs-polymorphic-paths.rs b/tests/ui/ufcs/ufcs-polymorphic-paths.rs index a14ebd6a4..a14ebd6a4 100644 --- a/tests/ui/ufcs-polymorphic-paths.rs +++ b/tests/ui/ufcs/ufcs-polymorphic-paths.rs diff --git a/tests/ui/underscore-imports/shadow.stderr b/tests/ui/underscore-imports/shadow.stderr index 7faede4e6..f2c19405b 100644 --- a/tests/ui/underscore-imports/shadow.stderr +++ b/tests/ui/underscore-imports/shadow.stderr @@ -7,7 +7,7 @@ LL | x.deref(); = help: items from traits can only be used if the trait is in scope help: the following trait is implemented but not in scope; perhaps add a `use` for it: | -LL | use std::ops::Deref; +LL + use std::ops::Deref; | error: aborting due to previous error diff --git a/tests/ui/union/field_checks.rs b/tests/ui/union/field_checks.rs index d5d1e44ac..bb4eccb4c 100644 --- a/tests/ui/union/field_checks.rs +++ b/tests/ui/union/field_checks.rs @@ -21,15 +21,15 @@ union U24<T> { // OK } union U3 { - a: String, //~ ERROR unions cannot contain fields that may need dropping + a: String, //~ ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union } union U32 { // field that does not drop but is not `Copy`, either - a: std::cell::RefCell<i32>, //~ ERROR unions cannot contain fields that may need dropping + a: std::cell::RefCell<i32>, //~ ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union } union U4<T> { - a: T, //~ ERROR unions cannot contain fields that may need dropping + a: T, //~ ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union } union U5 { // Having a drop impl is OK @@ -41,11 +41,11 @@ impl Drop for U5 { } union U5Nested { // a nested union that drops is NOT OK - nest: U5, //~ ERROR unions cannot contain fields that may need dropping + nest: U5, //~ ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union } union U5Nested2 { // for now we don't special-case empty arrays - nest: [U5; 0], //~ ERROR unions cannot contain fields that may need dropping + nest: [U5; 0], //~ ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union } union U6 { // OK diff --git a/tests/ui/union/field_checks.stderr b/tests/ui/union/field_checks.stderr index 1f97e97ac..32407a749 100644 --- a/tests/ui/union/field_checks.stderr +++ b/tests/ui/union/field_checks.stderr @@ -1,59 +1,59 @@ -error[E0740]: unions cannot contain fields that may need dropping +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union --> $DIR/field_checks.rs:24:5 | LL | a: String, | ^^^^^^^^^ | - = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type -help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` | LL | a: std::mem::ManuallyDrop<String>, | +++++++++++++++++++++++ + -error[E0740]: unions cannot contain fields that may need dropping +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union --> $DIR/field_checks.rs:28:5 | LL | a: std::cell::RefCell<i32>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type -help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` | LL | a: std::mem::ManuallyDrop<std::cell::RefCell<i32>>, | +++++++++++++++++++++++ + -error[E0740]: unions cannot contain fields that may need dropping +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union --> $DIR/field_checks.rs:32:5 | LL | a: T, | ^^^^ | - = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type -help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` | LL | a: std::mem::ManuallyDrop<T>, | +++++++++++++++++++++++ + -error[E0740]: unions cannot contain fields that may need dropping +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union --> $DIR/field_checks.rs:44:5 | LL | nest: U5, | ^^^^^^^^ | - = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type -help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` | LL | nest: std::mem::ManuallyDrop<U5>, | +++++++++++++++++++++++ + -error[E0740]: unions cannot contain fields that may need dropping +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union --> $DIR/field_checks.rs:48:5 | LL | nest: [U5; 0], | ^^^^^^^^^^^^^ | - = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type -help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` | LL | nest: std::mem::ManuallyDrop<[U5; 0]>, | +++++++++++++++++++++++ + diff --git a/tests/ui/union/issue-41073.rs b/tests/ui/union/issue-41073.rs index 4dfdc606b..f7a82b4e7 100644 --- a/tests/ui/union/issue-41073.rs +++ b/tests/ui/union/issue-41073.rs @@ -1,5 +1,5 @@ union Test { - a: A, //~ ERROR unions cannot contain fields that may need dropping + a: A, //~ ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union b: B } diff --git a/tests/ui/union/issue-41073.stderr b/tests/ui/union/issue-41073.stderr index b3887fa0f..ae1c4dfed 100644 --- a/tests/ui/union/issue-41073.stderr +++ b/tests/ui/union/issue-41073.stderr @@ -1,11 +1,11 @@ -error[E0740]: unions cannot contain fields that may need dropping +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union --> $DIR/issue-41073.rs:2:5 | LL | a: A, | ^^^^ | - = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type -help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` | LL | a: std::mem::ManuallyDrop<A>, | +++++++++++++++++++++++ + diff --git a/tests/ui/union/union-copy.rs b/tests/ui/union/union-copy.rs index 5c3f8d908..7ad0a11c6 100644 --- a/tests/ui/union/union-copy.rs +++ b/tests/ui/union/union-copy.rs @@ -9,6 +9,6 @@ union W { } impl Copy for U {} // OK -impl Copy for W {} //~ ERROR the trait `Copy` may not be implemented for this type +impl Copy for W {} //~ ERROR the trait `Copy` cannot be implemented for this type fn main() {} diff --git a/tests/ui/union/union-copy.stderr b/tests/ui/union/union-copy.stderr index 53ee4dd2e..ff6fa48db 100644 --- a/tests/ui/union/union-copy.stderr +++ b/tests/ui/union/union-copy.stderr @@ -1,4 +1,4 @@ -error[E0204]: the trait `Copy` may not be implemented for this type +error[E0204]: the trait `Copy` cannot be implemented for this type --> $DIR/union-copy.rs:12:15 | LL | a: std::mem::ManuallyDrop<String> diff --git a/tests/ui/union/union-derive-clone.mirunsafeck.stderr b/tests/ui/union/union-derive-clone.mirunsafeck.stderr index b80e8b988..4d23d230f 100644 --- a/tests/ui/union/union-derive-clone.mirunsafeck.stderr +++ b/tests/ui/union/union-derive-clone.mirunsafeck.stderr @@ -9,7 +9,8 @@ note: required by a bound in `AssertParamIsCopy` = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `U1` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | union U1 { | error[E0599]: the method `clone` exists for union `U5<CloneNoCopy>`, but its trait bounds were not satisfied @@ -34,7 +35,8 @@ LL | #[derive(Clone, Copy)] | ^^^^^ unsatisfied trait bound introduced in this `derive` macro help: consider annotating `CloneNoCopy` with `#[derive(Clone, Copy)]` | -LL | #[derive(Clone, Copy)] +LL + #[derive(Clone, Copy)] +LL | struct CloneNoCopy; | error: aborting due to 2 previous errors diff --git a/tests/ui/union/union-derive-clone.thirunsafeck.stderr b/tests/ui/union/union-derive-clone.thirunsafeck.stderr index b80e8b988..4d23d230f 100644 --- a/tests/ui/union/union-derive-clone.thirunsafeck.stderr +++ b/tests/ui/union/union-derive-clone.thirunsafeck.stderr @@ -9,7 +9,8 @@ note: required by a bound in `AssertParamIsCopy` = note: this error originates in the derive macro `Clone` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `U1` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | union U1 { | error[E0599]: the method `clone` exists for union `U5<CloneNoCopy>`, but its trait bounds were not satisfied @@ -34,7 +35,8 @@ LL | #[derive(Clone, Copy)] | ^^^^^ unsatisfied trait bound introduced in this `derive` macro help: consider annotating `CloneNoCopy` with `#[derive(Clone, Copy)]` | -LL | #[derive(Clone, Copy)] +LL + #[derive(Clone, Copy)] +LL | struct CloneNoCopy; | error: aborting due to 2 previous errors diff --git a/tests/ui/union/union-derive-eq.mirunsafeck.stderr b/tests/ui/union/union-derive-eq.mirunsafeck.stderr index 9e55390b5..136cd883e 100644 --- a/tests/ui/union/union-derive-eq.mirunsafeck.stderr +++ b/tests/ui/union/union-derive-eq.mirunsafeck.stderr @@ -12,7 +12,8 @@ note: required by a bound in `AssertParamIsEq` = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `PartialEqNotEq` with `#[derive(Eq)]` | -LL | #[derive(Eq)] +LL + #[derive(Eq)] +LL | struct PartialEqNotEq; | error: aborting due to previous error diff --git a/tests/ui/union/union-derive-eq.thirunsafeck.stderr b/tests/ui/union/union-derive-eq.thirunsafeck.stderr index 9e55390b5..136cd883e 100644 --- a/tests/ui/union/union-derive-eq.thirunsafeck.stderr +++ b/tests/ui/union/union-derive-eq.thirunsafeck.stderr @@ -12,7 +12,8 @@ note: required by a bound in `AssertParamIsEq` = note: this error originates in the derive macro `Eq` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `PartialEqNotEq` with `#[derive(Eq)]` | -LL | #[derive(Eq)] +LL + #[derive(Eq)] +LL | struct PartialEqNotEq; | error: aborting due to previous error diff --git a/tests/ui/union/union-with-drop-fields.mirunsafeck.stderr b/tests/ui/union/union-with-drop-fields.mirunsafeck.stderr index 93fe996d2..9861a21cb 100644 --- a/tests/ui/union/union-with-drop-fields.mirunsafeck.stderr +++ b/tests/ui/union/union-with-drop-fields.mirunsafeck.stderr @@ -1,35 +1,35 @@ -error[E0740]: unions cannot contain fields that may need dropping +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union --> $DIR/union-with-drop-fields.rs:11:5 | LL | a: String, | ^^^^^^^^^ | - = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type -help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` | LL | a: std::mem::ManuallyDrop<String>, | +++++++++++++++++++++++ + -error[E0740]: unions cannot contain fields that may need dropping +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union --> $DIR/union-with-drop-fields.rs:19:5 | LL | a: S, | ^^^^ | - = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type -help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` | LL | a: std::mem::ManuallyDrop<S>, | +++++++++++++++++++++++ + -error[E0740]: unions cannot contain fields that may need dropping +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union --> $DIR/union-with-drop-fields.rs:24:5 | LL | a: T, | ^^^^ | - = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type -help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` | LL | a: std::mem::ManuallyDrop<T>, | +++++++++++++++++++++++ + diff --git a/tests/ui/union/union-with-drop-fields.rs b/tests/ui/union/union-with-drop-fields.rs index a7a8b69e7..9720830fb 100644 --- a/tests/ui/union/union-with-drop-fields.rs +++ b/tests/ui/union/union-with-drop-fields.rs @@ -8,7 +8,7 @@ union U { } union W { - a: String, //~ ERROR unions cannot contain fields that may need dropping + a: String, //~ ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union b: String, // OK, only one field is reported } @@ -16,12 +16,12 @@ struct S(String); // `S` doesn't implement `Drop` trait, but still has non-trivial destructor union Y { - a: S, //~ ERROR unions cannot contain fields that may need dropping + a: S, //~ ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union } // We don't know if `T` is trivially-destructable or not until trans union J<T> { - a: T, //~ ERROR unions cannot contain fields that may need dropping + a: T, //~ ERROR field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union } union H<T: Copy> { diff --git a/tests/ui/union/union-with-drop-fields.thirunsafeck.stderr b/tests/ui/union/union-with-drop-fields.thirunsafeck.stderr index 93fe996d2..9861a21cb 100644 --- a/tests/ui/union/union-with-drop-fields.thirunsafeck.stderr +++ b/tests/ui/union/union-with-drop-fields.thirunsafeck.stderr @@ -1,35 +1,35 @@ -error[E0740]: unions cannot contain fields that may need dropping +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union --> $DIR/union-with-drop-fields.rs:11:5 | LL | a: String, | ^^^^^^^^^ | - = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type -help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` | LL | a: std::mem::ManuallyDrop<String>, | +++++++++++++++++++++++ + -error[E0740]: unions cannot contain fields that may need dropping +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union --> $DIR/union-with-drop-fields.rs:19:5 | LL | a: S, | ^^^^ | - = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type -help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` | LL | a: std::mem::ManuallyDrop<S>, | +++++++++++++++++++++++ + -error[E0740]: unions cannot contain fields that may need dropping +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union --> $DIR/union-with-drop-fields.rs:24:5 | LL | a: T, | ^^^^ | - = note: a type is guaranteed not to need dropping when it implements `Copy`, or when it is the special `ManuallyDrop<_>` type -help: when the type does not implement `Copy`, wrap it inside a `ManuallyDrop<_>` and ensure it is manually dropped + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` | LL | a: std::mem::ManuallyDrop<T>, | +++++++++++++++++++++++ + diff --git a/tests/ui/union/unresolved-field-isnt-copy.rs b/tests/ui/union/unresolved-field-isnt-copy.rs new file mode 100644 index 000000000..7a6d79b2f --- /dev/null +++ b/tests/ui/union/unresolved-field-isnt-copy.rs @@ -0,0 +1,8 @@ +// Unresolved fields are not copy, but also shouldn't report an extra E0740. + +pub union Foo { + x: *const Missing, + //~^ ERROR cannot find type `Missing` in this scope +} + +fn main() {} diff --git a/tests/ui/union/unresolved-field-isnt-copy.stderr b/tests/ui/union/unresolved-field-isnt-copy.stderr new file mode 100644 index 000000000..22301582e --- /dev/null +++ b/tests/ui/union/unresolved-field-isnt-copy.stderr @@ -0,0 +1,9 @@ +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/unresolved-field-isnt-copy.rs:4:15 + | +LL | x: *const Missing, + | ^^^^^^^ not found in this scope + +error: aborting due to previous error + +For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/unpretty/box.rs b/tests/ui/unpretty/box.rs new file mode 100644 index 000000000..81f5c88d7 --- /dev/null +++ b/tests/ui/unpretty/box.rs @@ -0,0 +1,9 @@ +// compile-flags: -Zunpretty=hir +// check-pass + +#![feature(stmt_expr_attributes, rustc_attrs)] + +fn main() { + let _ = #[rustc_box] + Box::new(1); +} diff --git a/tests/ui/unpretty/box.stdout b/tests/ui/unpretty/box.stdout new file mode 100644 index 000000000..0c6e012e6 --- /dev/null +++ b/tests/ui/unpretty/box.stdout @@ -0,0 +1,14 @@ +// compile-flags: -Zunpretty=hir +// check-pass + +#![feature(stmt_expr_attributes, rustc_attrs)] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; + +fn main() { + let _ = + #[rustc_box] + Box::new(1); + } diff --git a/tests/ui/unpretty/flattened-format-args.rs b/tests/ui/unpretty/flattened-format-args.rs new file mode 100644 index 000000000..705dded16 --- /dev/null +++ b/tests/ui/unpretty/flattened-format-args.rs @@ -0,0 +1,8 @@ +// compile-flags: -Zunpretty=hir -Zflatten-format-args=yes +// check-pass + +fn main() { + let x = 1; + // Should flatten to println!("a 123 b {x} xyz\n"): + println!("a {} {}", format_args!("{} b {x}", 123), "xyz"); +} diff --git a/tests/ui/unpretty/flattened-format-args.stdout b/tests/ui/unpretty/flattened-format-args.stdout new file mode 100644 index 000000000..a8fe8da00 --- /dev/null +++ b/tests/ui/unpretty/flattened-format-args.stdout @@ -0,0 +1,16 @@ +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +// compile-flags: -Zunpretty=hir -Zflatten-format-args=yes +// check-pass + +fn main() { + let x = 1; + // Should flatten to println!("a 123 b {x} xyz\n"): + { + ::std::io::_print(<#[lang = "format_arguments"]>::new_v1(&["a 123 b ", + " xyz\n"], + &[<#[lang = "format_argument"]>::new_display(&x)])); + }; + } diff --git a/tests/ui/mir-unpretty.rs b/tests/ui/unpretty/mir-unpretty.rs index 30620c69f..30620c69f 100644 --- a/tests/ui/mir-unpretty.rs +++ b/tests/ui/unpretty/mir-unpretty.rs diff --git a/tests/ui/mir-unpretty.stderr b/tests/ui/unpretty/mir-unpretty.stderr index 3808f8583..3808f8583 100644 --- a/tests/ui/mir-unpretty.stderr +++ b/tests/ui/unpretty/mir-unpretty.stderr diff --git a/tests/ui/unpretty-expr-fn-arg.rs b/tests/ui/unpretty/unpretty-expr-fn-arg.rs index 6e1132a33..6e1132a33 100644 --- a/tests/ui/unpretty-expr-fn-arg.rs +++ b/tests/ui/unpretty/unpretty-expr-fn-arg.rs diff --git a/tests/ui/unpretty-expr-fn-arg.stdout b/tests/ui/unpretty/unpretty-expr-fn-arg.stdout index b745b9886..b745b9886 100644 --- a/tests/ui/unpretty-expr-fn-arg.stdout +++ b/tests/ui/unpretty/unpretty-expr-fn-arg.stdout diff --git a/tests/ui/unresolved/unresolved-candidates.stderr b/tests/ui/unresolved/unresolved-candidates.stderr index ea737c567..7ef2f6b1a 100644 --- a/tests/ui/unresolved/unresolved-candidates.stderr +++ b/tests/ui/unresolved/unresolved-candidates.stderr @@ -17,7 +17,7 @@ LL | impl Trait for () {} | help: consider importing this trait | -LL | use a::Trait; +LL + use a::Trait; | error: aborting due to 2 previous errors diff --git a/tests/ui/foreign-unsafe-fn-called.mir.stderr b/tests/ui/unsafe/foreign-unsafe-fn-called.mir.stderr index d3cf5d84f..d3cf5d84f 100644 --- a/tests/ui/foreign-unsafe-fn-called.mir.stderr +++ b/tests/ui/unsafe/foreign-unsafe-fn-called.mir.stderr diff --git a/tests/ui/foreign-unsafe-fn-called.rs b/tests/ui/unsafe/foreign-unsafe-fn-called.rs index 67302ea1b..67302ea1b 100644 --- a/tests/ui/foreign-unsafe-fn-called.rs +++ b/tests/ui/unsafe/foreign-unsafe-fn-called.rs diff --git a/tests/ui/foreign-unsafe-fn-called.thir.stderr b/tests/ui/unsafe/foreign-unsafe-fn-called.thir.stderr index 00ba0f7a6..00ba0f7a6 100644 --- a/tests/ui/foreign-unsafe-fn-called.thir.stderr +++ b/tests/ui/unsafe/foreign-unsafe-fn-called.thir.stderr diff --git a/tests/ui/new-unsafe-pointers.rs b/tests/ui/unsafe/new-unsafe-pointers.rs index d99eb4cbd..d99eb4cbd 100644 --- a/tests/ui/new-unsafe-pointers.rs +++ b/tests/ui/unsafe/new-unsafe-pointers.rs diff --git a/tests/ui/unsafe-fn-called-from-unsafe-blk.rs b/tests/ui/unsafe/unsafe-fn-called-from-unsafe-blk.rs index 3713a7065..3713a7065 100644 --- a/tests/ui/unsafe-fn-called-from-unsafe-blk.rs +++ b/tests/ui/unsafe/unsafe-fn-called-from-unsafe-blk.rs diff --git a/tests/ui/unsafe-fn-called-from-unsafe-fn.rs b/tests/ui/unsafe/unsafe-fn-called-from-unsafe-fn.rs index 5e9531076..5e9531076 100644 --- a/tests/ui/unsafe-fn-called-from-unsafe-fn.rs +++ b/tests/ui/unsafe/unsafe-fn-called-from-unsafe-fn.rs diff --git a/tests/ui/unsafe/unsafe-fn-deref-ptr.mir.stderr b/tests/ui/unsafe/unsafe-fn-deref-ptr.mir.stderr index a26149924..7f1e7c890 100644 --- a/tests/ui/unsafe/unsafe-fn-deref-ptr.mir.stderr +++ b/tests/ui/unsafe/unsafe-fn-deref-ptr.mir.stderr @@ -1,11 +1,35 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/unsafe-fn-deref-ptr.rs:5:12 + --> $DIR/unsafe-fn-deref-ptr.rs:5:13 + | +LL | let _ = *p; + | ^^ dereference of raw pointer + | + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + +error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block + --> $DIR/unsafe-fn-deref-ptr.rs:6:17 + | +LL | let _: u8 = *p; + | ^^ dereference of raw pointer + | + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + +error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block + --> $DIR/unsafe-fn-deref-ptr.rs:7:9 + | +LL | _ = *p; + | ^^ dereference of raw pointer + | + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + +error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block + --> $DIR/unsafe-fn-deref-ptr.rs:8:12 | LL | return *p; | ^^ dereference of raw pointer | = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior -error: aborting due to previous error +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0133`. diff --git a/tests/ui/unsafe/unsafe-fn-deref-ptr.rs b/tests/ui/unsafe/unsafe-fn-deref-ptr.rs index dc989535b..4b7c6bf69 100644 --- a/tests/ui/unsafe/unsafe-fn-deref-ptr.rs +++ b/tests/ui/unsafe/unsafe-fn-deref-ptr.rs @@ -2,6 +2,9 @@ // [thir]compile-flags: -Z thir-unsafeck fn f(p: *const u8) -> u8 { + let _ = *p; //~ ERROR dereference of raw pointer is unsafe + let _: u8 = *p; //~ ERROR dereference of raw pointer is unsafe + _ = *p; //~ ERROR dereference of raw pointer is unsafe return *p; //~ ERROR dereference of raw pointer is unsafe } diff --git a/tests/ui/unsafe/unsafe-fn-deref-ptr.thir.stderr b/tests/ui/unsafe/unsafe-fn-deref-ptr.thir.stderr index a26149924..7f1e7c890 100644 --- a/tests/ui/unsafe/unsafe-fn-deref-ptr.thir.stderr +++ b/tests/ui/unsafe/unsafe-fn-deref-ptr.thir.stderr @@ -1,11 +1,35 @@ error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block - --> $DIR/unsafe-fn-deref-ptr.rs:5:12 + --> $DIR/unsafe-fn-deref-ptr.rs:5:13 + | +LL | let _ = *p; + | ^^ dereference of raw pointer + | + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + +error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block + --> $DIR/unsafe-fn-deref-ptr.rs:6:17 + | +LL | let _: u8 = *p; + | ^^ dereference of raw pointer + | + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + +error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block + --> $DIR/unsafe-fn-deref-ptr.rs:7:9 + | +LL | _ = *p; + | ^^ dereference of raw pointer + | + = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior + +error[E0133]: dereference of raw pointer is unsafe and requires unsafe function or block + --> $DIR/unsafe-fn-deref-ptr.rs:8:12 | LL | return *p; | ^^ dereference of raw pointer | = note: raw pointers may be null, dangling or unaligned; they can violate aliasing rules and cause data races: all of these are undefined behavior -error: aborting due to previous error +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0133`. diff --git a/tests/ui/unsafe-pointer-assignability.rs b/tests/ui/unsafe/unsafe-pointer-assignability.rs index db822bb6a..db822bb6a 100644 --- a/tests/ui/unsafe-pointer-assignability.rs +++ b/tests/ui/unsafe/unsafe-pointer-assignability.rs diff --git a/tests/ui/use/use-mod.rs b/tests/ui/use/use-mod/use-mod.rs index 87064c6a4..87064c6a4 100644 --- a/tests/ui/use/use-mod.rs +++ b/tests/ui/use/use-mod/use-mod.rs diff --git a/tests/ui/use/use-mod.stderr b/tests/ui/use/use-mod/use-mod.stderr index 0cae5eb14..0cae5eb14 100644 --- a/tests/ui/use/use-mod.stderr +++ b/tests/ui/use/use-mod/use-mod.stderr diff --git a/tests/ui/use.rs b/tests/ui/use/use.rs index 1beee4a51..1beee4a51 100644 --- a/tests/ui/use.rs +++ b/tests/ui/use/use.rs diff --git a/tests/ui/variance-intersection-of-ref-and-opt-ref.rs b/tests/ui/variance/variance-intersection-of-ref-and-opt-ref.rs index 74707a98d..74707a98d 100644 --- a/tests/ui/variance-intersection-of-ref-and-opt-ref.rs +++ b/tests/ui/variance/variance-intersection-of-ref-and-opt-ref.rs diff --git a/tests/ui/variance-iterators-in-libcore.rs b/tests/ui/variance/variance-iterators-in-libcore.rs index a542e44d5..a542e44d5 100644 --- a/tests/ui/variance-iterators-in-libcore.rs +++ b/tests/ui/variance/variance-iterators-in-libcore.rs diff --git a/tests/ui/wasm-custom-section-relocations.rs b/tests/ui/wasm/wasm-custom-section-relocations.rs index c3cca3a35..c3cca3a35 100644 --- a/tests/ui/wasm-custom-section-relocations.rs +++ b/tests/ui/wasm/wasm-custom-section-relocations.rs diff --git a/tests/ui/wasm-custom-section-relocations.stderr b/tests/ui/wasm/wasm-custom-section-relocations.stderr index a37edc51d..a37edc51d 100644 --- a/tests/ui/wasm-custom-section-relocations.stderr +++ b/tests/ui/wasm/wasm-custom-section-relocations.stderr diff --git a/tests/ui/wf/hir-wf-check-erase-regions.rs b/tests/ui/wf/hir-wf-check-erase-regions.rs index 2b4b480df..3855f2c35 100644 --- a/tests/ui/wf/hir-wf-check-erase-regions.rs +++ b/tests/ui/wf/hir-wf-check-erase-regions.rs @@ -4,10 +4,10 @@ pub struct Table<T, const N: usize>([Option<T>; N]); impl<'a, T, const N: usize> IntoIterator for &'a Table<T, N> { - type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; //~ ERROR `&T` is not an iterator + type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; //~ ERROR `&'a T` is not an iterator type Item = &'a T; - fn into_iter(self) -> Self::IntoIter { //~ ERROR `&T` is not an iterator + fn into_iter(self) -> Self::IntoIter { //~ ERROR `&'a T` is not an iterator unimplemented!() } } diff --git a/tests/ui/wf/hir-wf-check-erase-regions.stderr b/tests/ui/wf/hir-wf-check-erase-regions.stderr index 7bc19dd2e..2843983c7 100644 --- a/tests/ui/wf/hir-wf-check-erase-regions.stderr +++ b/tests/ui/wf/hir-wf-check-erase-regions.stderr @@ -1,24 +1,24 @@ -error[E0277]: `&T` is not an iterator +error[E0277]: `&'a T` is not an iterator --> $DIR/hir-wf-check-erase-regions.rs:7:21 | LL | type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&T` is not an iterator + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&'a T` is not an iterator | - = help: the trait `Iterator` is not implemented for `&T` + = help: the trait `Iterator` is not implemented for `&'a T` = help: the trait `Iterator` is implemented for `&mut I` - = note: required for `&T` to implement `IntoIterator` + = note: required for `&'a T` to implement `IntoIterator` note: required by a bound in `Flatten` --> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL -error[E0277]: `&T` is not an iterator +error[E0277]: `&'a T` is not an iterator --> $DIR/hir-wf-check-erase-regions.rs:10:27 | LL | fn into_iter(self) -> Self::IntoIter { - | ^^^^^^^^^^^^^^ `&T` is not an iterator + | ^^^^^^^^^^^^^^ `&'a T` is not an iterator | - = help: the trait `Iterator` is not implemented for `&T` + = help: the trait `Iterator` is not implemented for `&'a T` = help: the trait `Iterator` is implemented for `&mut I` - = note: required for `&T` to implement `IntoIterator` + = note: required for `&'a T` to implement `IntoIterator` note: required by a bound in `Flatten` --> $SRC_DIR/core/src/iter/adapters/flatten.rs:LL:COL diff --git a/tests/ui/wf/issue-110157.rs b/tests/ui/wf/issue-110157.rs new file mode 100644 index 000000000..43a8ce72f --- /dev/null +++ b/tests/ui/wf/issue-110157.rs @@ -0,0 +1,12 @@ +struct NeedsDropTypes<'tcx, F>(std::marker::PhantomData<&'tcx F>); + +impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F> +//~^ ERROR type annotations needed +where + F: Fn(&Missing) -> Result<I, ()>, + //~^ ERROR cannot find type `Missing` in this scope + I: Iterator<Item = Missing>, + //~^ ERROR cannot find type `Missing` in this scope +{} + +fn main() {} diff --git a/tests/ui/wf/issue-110157.stderr b/tests/ui/wf/issue-110157.stderr new file mode 100644 index 000000000..91d801e94 --- /dev/null +++ b/tests/ui/wf/issue-110157.stderr @@ -0,0 +1,32 @@ +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/issue-110157.rs:6:12 + | +LL | F: Fn(&Missing) -> Result<I, ()>, + | ^^^^^^^ not found in this scope + +error[E0412]: cannot find type `Missing` in this scope + --> $DIR/issue-110157.rs:8:24 + | +LL | I: Iterator<Item = Missing>, + | ^^^^^^^ not found in this scope + +error[E0283]: type annotations needed + --> $DIR/issue-110157.rs:3:31 + | +LL | impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F> + | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for type parameter `I` + | + = note: cannot satisfy `_: Iterator` +note: required for `NeedsDropTypes<'tcx, F>` to implement `Iterator` + --> $DIR/issue-110157.rs:3:18 + | +LL | impl<'tcx, F, I> Iterator for NeedsDropTypes<'tcx, F> + | ^^^^^^^^ ^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | I: Iterator<Item = Missing>, + | ------------------------ unsatisfied trait bound introduced here + +error: aborting due to 3 previous errors + +Some errors have detailed explanations: E0283, E0412. +For more information about an error, try `rustc --explain E0283`. diff --git a/tests/ui/wf/wf-const-type.stderr b/tests/ui/wf/wf-const-type.stderr index 85938364e..617969720 100644 --- a/tests/ui/wf/wf-const-type.stderr +++ b/tests/ui/wf/wf-const-type.stderr @@ -12,7 +12,8 @@ LL | struct IsCopy<T:Copy> { t: T } | ^^^^ required by this bound in `IsCopy` help: consider annotating `NotCopy` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | struct NotCopy; | error: aborting due to previous error diff --git a/tests/ui/wf/wf-static-type.stderr b/tests/ui/wf/wf-static-type.stderr index 16c6124b6..bb5a57834 100644 --- a/tests/ui/wf/wf-static-type.stderr +++ b/tests/ui/wf/wf-static-type.stderr @@ -12,7 +12,8 @@ LL | struct IsCopy<T:Copy> { t: T } | ^^^^ required by this bound in `IsCopy` help: consider annotating `NotCopy` with `#[derive(Copy)]` | -LL | #[derive(Copy)] +LL + #[derive(Copy)] +LL | struct NotCopy; | error: aborting due to previous error diff --git a/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr b/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr index f4c7acd5c..ce409f627 100644 --- a/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr +++ b/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr @@ -1,8 +1,8 @@ -error[E0277]: the trait bound `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[1209]::called::'b), 'b))> fn(&ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[1209]::called::'b), 'b) }) ()): Foo` is not satisfied +error[E0277]: the trait bound `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b))> fn(&ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b) }) ()): Foo` is not satisfied --> $DIR/higher-ranked-fn-type.rs:20:5 | LL | called() - | ^^^^^^ the trait `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[1209]::called::'b), 'b))> Foo` is not implemented for `fn(&ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[1209]::called::'b), 'b) }) ())` + | ^^^^^^ the trait `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b))> Foo` is not implemented for `fn(&ReLateBound(DebruijnIndex(1), BoundRegion { var: 0, kind: BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b) }) ())` | note: required by a bound in `called` --> $DIR/higher-ranked-fn-type.rs:12:25 diff --git a/tests/ui/where-clauses/where-clauses-method-unsatisfied.stderr b/tests/ui/where-clauses/where-clauses-method-unsatisfied.stderr index e90502977..6cf717295 100644 --- a/tests/ui/where-clauses/where-clauses-method-unsatisfied.stderr +++ b/tests/ui/where-clauses/where-clauses-method-unsatisfied.stderr @@ -11,7 +11,8 @@ LL | fn equals(&self, u: &Foo<T>) -> bool where T : Eq { | ^^ required by this bound in `Foo::<T>::equals` help: consider annotating `Bar` with `#[derive(Eq)]` | -LL | #[derive(Eq)] +LL + #[derive(Eq)] +LL | struct Bar; // does not implement Eq | error: aborting due to previous error diff --git a/tests/ui/where-clauses/where-clauses-unsatisfied.stderr b/tests/ui/where-clauses/where-clauses-unsatisfied.stderr index b1805a452..4d239bf43 100644 --- a/tests/ui/where-clauses/where-clauses-unsatisfied.stderr +++ b/tests/ui/where-clauses/where-clauses-unsatisfied.stderr @@ -11,7 +11,8 @@ LL | fn equal<T>(a: &T, b: &T) -> bool where T : Eq { a == b } | ^^ required by this bound in `equal` help: consider annotating `Struct` with `#[derive(Eq)]` | -LL | #[derive(Eq)] +LL + #[derive(Eq)] +LL | struct Struct; | error: aborting due to previous error |