diff options
Diffstat (limited to 'tests')
64 files changed, 588 insertions, 528 deletions
diff --git a/tests/codegen/bool-select-unpredictable.rs b/tests/codegen/bool-select-unpredictable.rs new file mode 100644 index 00000000000..1562b177542 --- /dev/null +++ b/tests/codegen/bool-select-unpredictable.rs @@ -0,0 +1,35 @@ +//@ compile-flags: -O + +#![feature(select_unpredictable)] +#![crate_type = "lib"] + +#[no_mangle] +pub fn test_int(p: bool, a: u64, b: u64) -> u64 { + // CHECK-LABEL: define{{.*}} @test_int + // CHECK: select i1 %p, i64 %a, i64 %b, !unpredictable + p.select_unpredictable(a, b) +} + +#[no_mangle] +pub fn test_pair(p: bool, a: (u64, u64), b: (u64, u64)) -> (u64, u64) { + // CHECK-LABEL: define{{.*}} @test_pair + // CHECK: select i1 %p, {{.*}}, !unpredictable + p.select_unpredictable(a, b) +} + +struct Large { + e: [u64; 100], +} + +#[no_mangle] +pub fn test_struct(p: bool, a: Large, b: Large) -> Large { + // CHECK-LABEL: define{{.*}} @test_struct + // CHECK: select i1 %p, {{.*}}, !unpredictable + p.select_unpredictable(a, b) +} + +#[no_mangle] +pub fn test_zst(p: bool, a: (), b: ()) -> () { + // CHECK-LABEL: define{{.*}} @test_zst + p.select_unpredictable(a, b) +} diff --git a/tests/crashes/123141.rs b/tests/crashes/123141.rs deleted file mode 100644 index 07181387e04..00000000000 --- a/tests/crashes/123141.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ known-bug: #123141 - -trait Trait { - fn next(self) -> Self::Item; - type Item; -} - -struct Foo<T: ?Sized>(T); - -impl<T: ?Sized, U> Trait for Foo<U> { - type Item = Foo<T>; - fn next(self) -> Self::Item { - loop {} - } -} - -fn opaque() -> impl Trait { - Foo::<_>(10_u32) -} - -fn main() { - opaque().next(); -} diff --git a/tests/crashes/125874.rs b/tests/crashes/125874.rs deleted file mode 100644 index 6a2713cd7c8..00000000000 --- a/tests/crashes/125874.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ known-bug: rust-lang/rust#125874 -pub trait A {} - -pub trait Mirror { - type Assoc: ?Sized; -} -impl<T: ?Sized> Mirror for dyn A { - type Assoc = T; -} - -struct Bar { - foo: <dyn A + 'static as Mirror>::Assoc, -} - -pub fn main() { - let strct = Bar { foo: 3 }; - - match strct { - Bar { foo: 1, .. } => {} - _ => (), - }; -} diff --git a/tests/crashes/126942.rs b/tests/crashes/126942.rs deleted file mode 100644 index e4adc8fab28..00000000000 --- a/tests/crashes/126942.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: rust-lang/rust#126942 -struct Thing; - -pub trait Every { - type Assoc; -} -impl<T: ?Sized> Every for Thing { - type Assoc = T; -} - -static I: <Thing as Every>::Assoc = 3; diff --git a/tests/crashes/127804.rs b/tests/crashes/127804.rs deleted file mode 100644 index e583a7c1fc6..00000000000 --- a/tests/crashes/127804.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ known-bug: #127804 - -struct Thing; - -pub trait Every { - type Assoc; -} -impl<T: ?Sized> Every for Thing { - type Assoc = T; -} - -fn foo(_: <Thing as Every>::Assoc) {} diff --git a/tests/crashes/130967.rs b/tests/crashes/130967.rs deleted file mode 100644 index 8a3aae72c20..00000000000 --- a/tests/crashes/130967.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ known-bug: #130967 - -trait Producer { - type Produced; - fn make_one() -> Self::Produced; -} - -impl<E: ?Sized> Producer for () { - type Produced = Option<E>; - fn make_one() -> Self::Produced { - loop {} - } -} diff --git a/tests/run-make/strip/hello.rs b/tests/run-make/strip/hello.rs new file mode 100644 index 00000000000..2dc0376650b --- /dev/null +++ b/tests/run-make/strip/hello.rs @@ -0,0 +1,8 @@ +fn main() { + hey_i_get_compiled(); +} + +#[inline(never)] +fn hey_i_get_compiled() { + println!("Hi! Do or do not strip me, your choice."); +} diff --git a/tests/run-make/strip/rmake.rs b/tests/run-make/strip/rmake.rs new file mode 100644 index 00000000000..ef1acc26b45 --- /dev/null +++ b/tests/run-make/strip/rmake.rs @@ -0,0 +1,42 @@ +//@ ignore-windows Windows does not actually strip + +// Test that -Cstrip correctly strips/preserves debuginfo and symbols. + +use run_make_support::{bin_name, is_darwin, llvm_dwarfdump, llvm_nm, rustc}; + +fn main() { + // We use DW_ (the start of any DWARF name) to check that some debuginfo is present. + let dwarf_indicator = "DW_"; + + let test_symbol = "hey_i_get_compiled"; + let binary = &bin_name("hello"); + + // Avoid checking debuginfo on darwin, because it is not actually affected by strip. + // Darwin *never* puts debuginfo in the main binary (-Csplit-debuginfo=off just removes it), + // so we never actually have any debuginfo in there, so we can't check that it's present. + let do_debuginfo_check = !is_darwin(); + + // Additionally, use -Cdebuginfo=2 to make the test independent of the amount of debuginfo + // for std. + + // -Cstrip=none should preserve symbols and debuginfo. + rustc().arg("hello.rs").arg("-Cdebuginfo=2").arg("-Cstrip=none").run(); + llvm_nm().input(binary).run().assert_stdout_contains(test_symbol); + if do_debuginfo_check { + llvm_dwarfdump().input(binary).run().assert_stdout_contains(dwarf_indicator); + } + + // -Cstrip=debuginfo should preserve symbols and strip debuginfo. + rustc().arg("hello.rs").arg("-Cdebuginfo=2").arg("-Cstrip=debuginfo").run(); + llvm_nm().input(binary).run().assert_stdout_contains(test_symbol); + if do_debuginfo_check { + llvm_dwarfdump().input(binary).run().assert_stdout_not_contains(dwarf_indicator); + } + + // -Cstrip=symbols should strip symbols and strip debuginfo. + rustc().arg("hello.rs").arg("-Cdebuginfo=2").arg("-Cstrip=symbols").run(); + llvm_nm().input(binary).run().assert_stderr_not_contains(test_symbol); + if do_debuginfo_check { + llvm_dwarfdump().input(binary).run().assert_stdout_not_contains(dwarf_indicator); + } +} diff --git a/tests/rustdoc-js-std/core-transmute.js b/tests/rustdoc-js-std/core-transmute.js new file mode 100644 index 00000000000..8c9910a32d7 --- /dev/null +++ b/tests/rustdoc-js-std/core-transmute.js @@ -0,0 +1,11 @@ +const FILTER_CRATE = "core"; +const EXPECTED = [ + { + 'query': 'generic:T -> generic:U', + 'others': [ + { 'path': 'core::intrinsics::simd', 'name': 'simd_as' }, + { 'path': 'core::intrinsics::simd', 'name': 'simd_cast' }, + { 'path': 'core::mem', 'name': 'transmute' }, + ], + }, +]; diff --git a/tests/rustdoc-js-std/transmute-fail.js b/tests/rustdoc-js-std/transmute-fail.js index c4dddf3cf3c..ddfb2761948 100644 --- a/tests/rustdoc-js-std/transmute-fail.js +++ b/tests/rustdoc-js-std/transmute-fail.js @@ -1,4 +1,5 @@ // should-fail +const FILTER_CRATE = "std"; const EXPECTED = [ { // Keep this test case identical to `transmute`, except the @@ -7,7 +8,7 @@ const EXPECTED = [ 'others': [ { 'path': 'std::intrinsics::simd', 'name': 'simd_as' }, { 'path': 'std::intrinsics::simd', 'name': 'simd_cast' }, - { 'path': 'std::intrinsics', 'name': 'transmute' }, + { 'path': 'std::mem', 'name': 'transmute' }, ], }, ]; diff --git a/tests/rustdoc-js-std/transmute.js b/tests/rustdoc-js-std/transmute.js index 0e52e21e0de..f52e0ab1436 100644 --- a/tests/rustdoc-js-std/transmute.js +++ b/tests/rustdoc-js-std/transmute.js @@ -1,3 +1,4 @@ +const FILTER_CRATE = "std"; const EXPECTED = [ { // Keep this test case identical to `transmute-fail`, except the @@ -6,7 +7,7 @@ const EXPECTED = [ 'others': [ { 'path': 'std::intrinsics::simd', 'name': 'simd_as' }, { 'path': 'std::intrinsics::simd', 'name': 'simd_cast' }, - { 'path': 'std::intrinsics', 'name': 'transmute' }, + { 'path': 'std::mem', 'name': 'transmute' }, ], }, ]; diff --git a/tests/ui/array-slice-vec/suggest-array-length.fixed b/tests/ui/array-slice-vec/suggest-array-length.fixed index 29f85da56e5..2eacc2517d3 100644 --- a/tests/ui/array-slice-vec/suggest-array-length.fixed +++ b/tests/ui/array-slice-vec/suggest-array-length.fixed @@ -3,24 +3,21 @@ fn main() { const Foo: [i32; 3] = [1, 2, 3]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants const REF_FOO: &[u8; 1] = &[1]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + static Statik: [i32; 3] = [1, 2, 3]; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables + static REF_STATIK: &[u8; 1] = &[1]; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables let foo: [i32; 3] = [1, 2, 3]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR using `_` for array lengths is unstable let bar: [i32; 3] = [0; 3]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR using `_` for array lengths is unstable let ref_foo: &[i32; 3] = &[1, 2, 3]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR using `_` for array lengths is unstable let ref_bar: &[i32; 3] = &[0; 3]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR using `_` for array lengths is unstable let multiple_ref_foo: &&[i32; 3] = &&[1, 2, 3]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR using `_` for array lengths is unstable } diff --git a/tests/ui/array-slice-vec/suggest-array-length.rs b/tests/ui/array-slice-vec/suggest-array-length.rs index 82d871cf875..fb4424cfed9 100644 --- a/tests/ui/array-slice-vec/suggest-array-length.rs +++ b/tests/ui/array-slice-vec/suggest-array-length.rs @@ -3,24 +3,21 @@ fn main() { const Foo: [i32; _] = [1, 2, 3]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants const REF_FOO: &[u8; _] = &[1]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants + static Statik: [i32; _] = [1, 2, 3]; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables + static REF_STATIK: &[u8; _] = &[1]; + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for static variables let foo: [i32; _] = [1, 2, 3]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR using `_` for array lengths is unstable let bar: [i32; _] = [0; 3]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR using `_` for array lengths is unstable let ref_foo: &[i32; _] = &[1, 2, 3]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR using `_` for array lengths is unstable let ref_bar: &[i32; _] = &[0; 3]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR using `_` for array lengths is unstable let multiple_ref_foo: &&[i32; _] = &&[1, 2, 3]; - //~^ ERROR in expressions, `_` can only be used on the left-hand side of an assignment - //~| ERROR using `_` for array lengths is unstable + //~^ ERROR using `_` for array lengths is unstable } diff --git a/tests/ui/array-slice-vec/suggest-array-length.stderr b/tests/ui/array-slice-vec/suggest-array-length.stderr index fdab7ba7064..b71be306780 100644 --- a/tests/ui/array-slice-vec/suggest-array-length.stderr +++ b/tests/ui/array-slice-vec/suggest-array-length.stderr @@ -1,67 +1,49 @@ -error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/suggest-array-length.rs:11:20 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants + --> $DIR/suggest-array-length.rs:5:22 | -LL | let foo: [i32; _] = [1, 2, 3]; - | ^ `_` not allowed here - -error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/suggest-array-length.rs:14:20 +LL | const Foo: [i32; _] = [1, 2, 3]; + | ^ not allowed in type signatures | -LL | let bar: [i32; _] = [0; 3]; - | ^ `_` not allowed here - -error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/suggest-array-length.rs:17:25 +help: replace this with a fully-specified type | -LL | let ref_foo: &[i32; _] = &[1, 2, 3]; - | ^ `_` not allowed here +LL | const Foo: [i32; 3] = [1, 2, 3]; + | ~~~~~~~~ -error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/suggest-array-length.rs:20:25 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants + --> $DIR/suggest-array-length.rs:7:26 | -LL | let ref_bar: &[i32; _] = &[0; 3]; - | ^ `_` not allowed here - -error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/suggest-array-length.rs:23:35 +LL | const REF_FOO: &[u8; _] = &[1]; + | ^ not allowed in type signatures | -LL | let multiple_ref_foo: &&[i32; _] = &&[1, 2, 3]; - | ^ `_` not allowed here - -error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/suggest-array-length.rs:5:22 +help: replace this with a fully-specified type | -LL | const Foo: [i32; _] = [1, 2, 3]; - | ^ `_` not allowed here +LL | const REF_FOO: &[u8; 1] = &[1]; + | ~~~~~~~~ -error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/suggest-array-length.rs:8:26 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables + --> $DIR/suggest-array-length.rs:9:26 | -LL | const REF_FOO: &[u8; _] = &[1]; - | ^ `_` not allowed here - -error[E0658]: using `_` for array lengths is unstable - --> $DIR/suggest-array-length.rs:5:22 +LL | static Statik: [i32; _] = [1, 2, 3]; + | ^ not allowed in type signatures | -LL | const Foo: [i32; _] = [1, 2, 3]; - | ^ help: consider specifying the array length: `3` +help: replace this with a fully-specified type | - = note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information - = help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date +LL | static Statik: [i32; 3] = [1, 2, 3]; + | ~~~~~~~~ -error[E0658]: using `_` for array lengths is unstable - --> $DIR/suggest-array-length.rs:8:26 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables + --> $DIR/suggest-array-length.rs:11:30 | -LL | const REF_FOO: &[u8; _] = &[1]; - | ^ help: consider specifying the array length: `1` +LL | static REF_STATIK: &[u8; _] = &[1]; + | ^ not allowed in type signatures | - = note: see issue #85077 <https://github.com/rust-lang/rust/issues/85077> for more information - = help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date +help: replace this with a fully-specified type + | +LL | static REF_STATIK: &[u8; 1] = &[1]; + | ~~~~~~~~ error[E0658]: using `_` for array lengths is unstable - --> $DIR/suggest-array-length.rs:11:20 + --> $DIR/suggest-array-length.rs:13:20 | LL | let foo: [i32; _] = [1, 2, 3]; | ^ help: consider specifying the array length: `3` @@ -71,7 +53,7 @@ LL | let foo: [i32; _] = [1, 2, 3]; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: using `_` for array lengths is unstable - --> $DIR/suggest-array-length.rs:14:20 + --> $DIR/suggest-array-length.rs:15:20 | LL | let bar: [i32; _] = [0; 3]; | ^ help: consider specifying the array length: `3` @@ -91,7 +73,7 @@ LL | let ref_foo: &[i32; _] = &[1, 2, 3]; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: using `_` for array lengths is unstable - --> $DIR/suggest-array-length.rs:20:25 + --> $DIR/suggest-array-length.rs:19:25 | LL | let ref_bar: &[i32; _] = &[0; 3]; | ^ help: consider specifying the array length: `3` @@ -101,7 +83,7 @@ LL | let ref_bar: &[i32; _] = &[0; 3]; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: using `_` for array lengths is unstable - --> $DIR/suggest-array-length.rs:23:35 + --> $DIR/suggest-array-length.rs:21:35 | LL | let multiple_ref_foo: &&[i32; _] = &&[1, 2, 3]; | ^ help: consider specifying the array length: `3` @@ -110,6 +92,7 @@ LL | let multiple_ref_foo: &&[i32; _] = &&[1, 2, 3]; = help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 14 previous errors +error: aborting due to 9 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0121, E0658. +For more information about an error, try `rustc --explain E0121`. diff --git a/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.rs b/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.rs index b4df58b3c25..4dfeab9e8c3 100644 --- a/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.rs +++ b/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.rs @@ -11,9 +11,9 @@ struct Baz {} impl Foo for Baz { async fn bar<F>(&mut self, _func: F) -> () - //~^ ERROR `F` cannot be sent between threads safely where F: FnMut() + Send, + //~^ impl has stricter requirements than trait { () } diff --git a/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.stderr b/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.stderr index e6379954776..8d5cad4493e 100644 --- a/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.stderr +++ b/tests/ui/associated-types/remove-invalid-type-bound-suggest-issue-127555.stderr @@ -1,21 +1,14 @@ -error[E0277]: `F` cannot be sent between threads safely - --> $DIR/remove-invalid-type-bound-suggest-issue-127555.rs:13:5 +error[E0276]: impl has stricter requirements than trait + --> $DIR/remove-invalid-type-bound-suggest-issue-127555.rs:15:22 | -LL | / async fn bar<F>(&mut self, _func: F) -> () -LL | | +LL | / fn bar<F>(&mut self, func: F) -> impl std::future::Future<Output = ()> + Send LL | | where -LL | | F: FnMut() + Send, - | |__________________________^ `F` cannot be sent between threads safely - | -note: required by a bound in `<Baz as Foo>::bar` - --> $DIR/remove-invalid-type-bound-suggest-issue-127555.rs:16:22 - | -LL | async fn bar<F>(&mut self, _func: F) -> () - | --- required by a bound in this associated function +LL | | F: FnMut(); + | |___________________- definition of `bar` from trait ... -LL | F: FnMut() + Send, - | ^^^^ required by this bound in `<Baz as Foo>::bar` +LL | F: FnMut() + Send, + | ^^^^ impl has extra requirement `F: Send` error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0276`. diff --git a/tests/ui/async-await/issues/issue-95307.rs b/tests/ui/async-await/issues/issue-95307.rs index 40700c610f3..27903a667fb 100644 --- a/tests/ui/async-await/issues/issue-95307.rs +++ b/tests/ui/async-await/issues/issue-95307.rs @@ -5,8 +5,8 @@ pub trait C { async fn new() -> [u8; _]; - //~^ ERROR: using `_` for array lengths is unstable - //~| ERROR: in expressions, `_` can only be used on the left-hand side of an assignment + //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions + //~| ERROR using `_` for array lengths is unstable } fn main() {} diff --git a/tests/ui/async-await/issues/issue-95307.stderr b/tests/ui/async-await/issues/issue-95307.stderr index dd8fcd3690a..90100f39163 100644 --- a/tests/ui/async-await/issues/issue-95307.stderr +++ b/tests/ui/async-await/issues/issue-95307.stderr @@ -1,8 +1,8 @@ -error: in expressions, `_` can only be used on the left-hand side of an assignment +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/issue-95307.rs:7:28 | LL | async fn new() -> [u8; _]; - | ^ `_` not allowed here + | ^ not allowed in type signatures error[E0658]: using `_` for array lengths is unstable --> $DIR/issue-95307.rs:7:28 @@ -16,4 +16,5 @@ LL | async fn new() -> [u8; _]; error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0121, E0658. +For more information about an error, try `rustc --explain E0121`. diff --git a/tests/ui/const-generics/generic_arg_infer/in-signature.stderr b/tests/ui/const-generics/generic_arg_infer/in-signature.stderr index fcac95732d1..5999bc18204 100644 --- a/tests/ui/const-generics/generic_arg_infer/in-signature.stderr +++ b/tests/ui/const-generics/generic_arg_infer/in-signature.stderr @@ -27,52 +27,74 @@ LL | fn ty_fn_mixed() -> Bar<_, _> { | help: replace with the correct return type: `Bar<i32, 3>` error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/in-signature.rs:22:15 + --> $DIR/in-signature.rs:22:20 | LL | const ARR_CT: [u8; _] = [0; 3]; - | ^^^^^^^ not allowed in type signatures + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | const ARR_CT: [u8; 3] = [0; 3]; + | ~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables - --> $DIR/in-signature.rs:24:20 + --> $DIR/in-signature.rs:24:25 | LL | static ARR_STATIC: [u8; _] = [0; 3]; - | ^^^^^^^ not allowed in type signatures + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static ARR_STATIC: [u8; 3] = [0; 3]; + | ~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/in-signature.rs:26:14 + --> $DIR/in-signature.rs:26:23 | LL | const TY_CT: Bar<i32, _> = Bar::<i32, 3>(0); - | ^^^^^^^^^^^ - | | - | not allowed in type signatures - | help: replace with the correct type: `Bar<i32, 3>` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | const TY_CT: Bar<i32, 3> = Bar::<i32, 3>(0); + | ~~~~~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables - --> $DIR/in-signature.rs:28:19 + --> $DIR/in-signature.rs:28:28 | LL | static TY_STATIC: Bar<i32, _> = Bar::<i32, 3>(0); - | ^^^^^^^^^^^ - | | - | not allowed in type signatures - | help: replace with the correct type: `Bar<i32, 3>` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static TY_STATIC: Bar<i32, 3> = Bar::<i32, 3>(0); + | ~~~~~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/in-signature.rs:30:20 + --> $DIR/in-signature.rs:30:24 | LL | const TY_CT_MIXED: Bar<_, _> = Bar::<i32, 3>(0); - | ^^^^^^^^^ - | | - | not allowed in type signatures - | help: replace with the correct type: `Bar<i32, 3>` + | ^ ^ not allowed in type signatures + | | + | not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | const TY_CT_MIXED: Bar<i32, 3> = Bar::<i32, 3>(0); + | ~~~~~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables - --> $DIR/in-signature.rs:32:25 + --> $DIR/in-signature.rs:32:29 | LL | static TY_STATIC_MIXED: Bar<_, _> = Bar::<i32, 3>(0); - | ^^^^^^^^^ - | | - | not allowed in type signatures - | help: replace with the correct type: `Bar<i32, 3>` + | ^ ^ not allowed in type signatures + | | + | not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static TY_STATIC_MIXED: Bar<i32, 3> = Bar::<i32, 3>(0); + | ~~~~~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types --> $DIR/in-signature.rs:51:23 diff --git a/tests/ui/consts/issue-104768.rs b/tests/ui/consts/issue-104768.rs index 3192daafa0b..52a8070be4e 100644 --- a/tests/ui/consts/issue-104768.rs +++ b/tests/ui/consts/issue-104768.rs @@ -1,4 +1,5 @@ const A: &_ = 0_u32; //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for constants +//~| ERROR: mismatched types fn main() {} diff --git a/tests/ui/consts/issue-104768.stderr b/tests/ui/consts/issue-104768.stderr index 8a4a41e4d68..41a9bab0961 100644 --- a/tests/ui/consts/issue-104768.stderr +++ b/tests/ui/consts/issue-104768.stderr @@ -1,12 +1,28 @@ +error[E0308]: mismatched types + --> $DIR/issue-104768.rs:1:15 + | +LL | const A: &_ = 0_u32; + | ^^^^^ expected `&_`, found `u32` + | + = note: expected reference `&'static _` + found type `u32` +help: consider borrowing here + | +LL | const A: &_ = &0_u32; + | + + error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/issue-104768.rs:1:10 + --> $DIR/issue-104768.rs:1:11 | LL | const A: &_ = 0_u32; - | ^^ - | | - | not allowed in type signatures - | help: replace with the correct type: `u32` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | const A: u32 = 0_u32; + | ~~~ -error: aborting due to 1 previous error +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0121`. +Some errors have detailed explanations: E0121, E0308. +For more information about an error, try `rustc --explain E0121`. diff --git a/tests/ui/error-codes/E0121.stderr b/tests/ui/error-codes/E0121.stderr index 023d7e011bf..5f5df0fd0ae 100644 --- a/tests/ui/error-codes/E0121.stderr +++ b/tests/ui/error-codes/E0121.stderr @@ -11,10 +11,12 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/E0121.rs:3:13 | LL | static BAR: _ = "test"; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `&str` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static BAR: &str = "test"; + | ~~~~ error: aborting due to 2 previous errors diff --git a/tests/ui/feature-gates/feature-gate-generic_arg_infer.normal.stderr b/tests/ui/feature-gates/feature-gate-generic_arg_infer.normal.stderr index 97370f0489b..96fb4a53609 100644 --- a/tests/ui/feature-gates/feature-gate-generic_arg_infer.normal.stderr +++ b/tests/ui/feature-gates/feature-gate-generic_arg_infer.normal.stderr @@ -1,17 +1,5 @@ -error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/feature-gate-generic_arg_infer.rs:11:27 - | -LL | let _x: [u8; 3] = [0; _]; - | ^ `_` not allowed here - -error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/feature-gate-generic_arg_infer.rs:14:18 - | -LL | let _y: [u8; _] = [0; 3]; - | ^ `_` not allowed here - error[E0658]: using `_` for array lengths is unstable - --> $DIR/feature-gate-generic_arg_infer.rs:14:18 + --> $DIR/feature-gate-generic_arg_infer.rs:13:18 | LL | let _y: [u8; _] = [0; 3]; | ^ help: consider specifying the array length: `3` @@ -21,7 +9,7 @@ LL | let _y: [u8; _] = [0; 3]; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0747]: type provided when a constant was expected - --> $DIR/feature-gate-generic_arg_infer.rs:20:20 + --> $DIR/feature-gate-generic_arg_infer.rs:18:20 | LL | let _x = foo::<_>([1,2]); | ^ @@ -42,7 +30,7 @@ LL | let _x: [u8; 3] = [0; _]; = help: add `#![feature(generic_arg_infer)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 5 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0658, E0747. For more information about an error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs b/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs index 0473253004a..de4b7078ea6 100644 --- a/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs +++ b/tests/ui/feature-gates/feature-gate-generic_arg_infer.rs @@ -10,10 +10,8 @@ fn foo<const N: usize>(_: [u8; N]) -> [u8; N] { fn bar() { let _x: [u8; 3] = [0; _]; //[normal]~^ ERROR: using `_` for array lengths is unstable - //[normal]~| ERROR: in expressions, `_` can only be used on the left-hand side of an assignment let _y: [u8; _] = [0; 3]; //[normal]~^ ERROR: using `_` for array lengths is unstable - //[normal]~| ERROR: in expressions, `_` can only be used on the left-hand side of an assignment } fn main() { diff --git a/tests/ui/generic-associated-types/bugs/issue-87735.stderr b/tests/ui/generic-associated-types/bugs/issue-87735.stderr index d8005065238..1b955431363 100644 --- a/tests/ui/generic-associated-types/bugs/issue-87735.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-87735.stderr @@ -22,73 +22,7 @@ help: consider adding an explicit lifetime bound LL | type Output<'a> = FooRef<'a, U> where Self: 'a, U: 'a; | +++++++ -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/issue-87735.rs:31:15 - | -LL | impl<'b, T, U> AsRef2 for Foo<T> - | -- the parameter type `T` must be valid for the lifetime `'b` as defined here... -... -LL | T: AsRef2<Output<'b> = &'b [U]>, - | ^^^^^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/issue-87735.rs:7:31 - | -LL | type Output<'a> where Self: 'a; - | ^^ -help: consider adding an explicit lifetime bound - | -LL | T: AsRef2<Output<'b> = &'b [U]> + 'b, - | ++++ - -error[E0309]: the parameter type `T` may not live long enough - --> $DIR/issue-87735.rs:36:31 - | -LL | impl<'b, T, U> AsRef2 for Foo<T> - | -- the parameter type `T` must be valid for the lifetime `'b` as defined here... -... -LL | fn as_ref2<'a>(&'a self) -> Self::Output<'a> { - | ^^^^^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... - | -note: ...that is required by this bound - --> $DIR/issue-87735.rs:7:31 - | -LL | type Output<'a> where Self: 'a; - | ^^ -help: consider adding an explicit lifetime bound - | -LL | T: AsRef2<Output<'b> = &'b [U]> + 'b, - | ++++ - -error: lifetime may not live long enough - --> $DIR/issue-87735.rs:37:5 - | -LL | impl<'b, T, U> AsRef2 for Foo<T> - | -- lifetime `'b` defined here -... -LL | fn as_ref2<'a>(&'a self) -> Self::Output<'a> { - | -- lifetime `'a` defined here -LL | FooRef(self.0.as_ref2()) - | ^^^^^^^^^^^^^^^^^^^^^^^^ method was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` - | - = help: consider adding the following bound: `'b: 'a` - -error: lifetime may not live long enough - --> $DIR/issue-87735.rs:37:12 - | -LL | impl<'b, T, U> AsRef2 for Foo<T> - | -- lifetime `'b` defined here -... -LL | fn as_ref2<'a>(&'a self) -> Self::Output<'a> { - | -- lifetime `'a` defined here -LL | FooRef(self.0.as_ref2()) - | ^^^^^^^^^^^^^^^^ argument requires that `'a` must outlive `'b` - | - = help: consider adding the following bound: `'a: 'b` - -help: `'b` and `'a` must be the same: replace one with the other - -error: aborting due to 6 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0207, E0309. For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/generic-const-items/assoc-const-missing-type.rs b/tests/ui/generic-const-items/assoc-const-missing-type.rs index 93160f0b575..0c94a4262ef 100644 --- a/tests/ui/generic-const-items/assoc-const-missing-type.rs +++ b/tests/ui/generic-const-items/assoc-const-missing-type.rs @@ -12,7 +12,6 @@ impl Trait for () { const K<T> = (); //~^ ERROR missing type for `const` item //~| ERROR mismatched types - //~| ERROR mismatched types const Q = ""; //~^ ERROR missing type for `const` item //~| ERROR lifetime parameters or bounds on const `Q` do not match the trait declaration diff --git a/tests/ui/generic-const-items/assoc-const-missing-type.stderr b/tests/ui/generic-const-items/assoc-const-missing-type.stderr index 6f35c0958d4..5af119dffa7 100644 --- a/tests/ui/generic-const-items/assoc-const-missing-type.stderr +++ b/tests/ui/generic-const-items/assoc-const-missing-type.stderr @@ -16,7 +16,7 @@ LL | const K<T> = (); | ^ help: provide a type for the associated constant: `()` error[E0195]: lifetime parameters or bounds on const `Q` do not match the trait declaration - --> $DIR/assoc-const-missing-type.rs:16:12 + --> $DIR/assoc-const-missing-type.rs:15:12 | LL | const Q<'a>: &'a str; | ---- lifetimes in impl do not match this const in trait @@ -25,24 +25,12 @@ LL | const Q = ""; | ^ lifetimes do not match const in trait error: missing type for `const` item - --> $DIR/assoc-const-missing-type.rs:16:12 + --> $DIR/assoc-const-missing-type.rs:15:12 | LL | const Q = ""; | ^ help: provide a type for the associated constant: `: &str` -error[E0308]: mismatched types - --> $DIR/assoc-const-missing-type.rs:12:18 - | -LL | const K<T> = (); - | - ^^ expected type parameter `T`, found `()` - | | - | expected this type parameter - | - = note: expected type parameter `T` - found unit type `()` - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0195, E0308. For more information about an error, try `rustc --explain E0195`. diff --git a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr index e38e18857ef..b6e7e02f331 100644 --- a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr +++ b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr @@ -19,11 +19,11 @@ help: consider further restricting type parameter `F` with trait `MyFn` LL | F: Callback<Self::CallbackArg> + MyFn<i32>, | +++++++++++ -error[E0277]: the trait bound `F: MyFn<i32>` is not satisfied - --> $DIR/false-positive-predicate-entailment-error.rs:36:30 +error[E0277]: the trait bound `F: Callback<i32>` is not satisfied + --> $DIR/false-positive-predicate-entailment-error.rs:42:12 | -LL | fn autobatch<F>(self) -> impl Trait - | ^^^^^^^^^^ the trait `MyFn<i32>` is not implemented for `F` +LL | F: Callback<Self::CallbackArg>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyFn<i32>` is not implemented for `F` | note: required for `F` to implement `Callback<i32>` --> $DIR/false-positive-predicate-entailment-error.rs:14:21 @@ -32,14 +32,14 @@ LL | impl<A, F: MyFn<A>> Callback<A> for F { | ------- ^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here -note: required by a bound in `<Sender as ChannelSender>::autobatch` - --> $DIR/false-positive-predicate-entailment-error.rs:43:12 +note: the requirement `F: Callback<i32>` appears on the `impl`'s method `autobatch` but not on the corresponding trait's method + --> $DIR/false-positive-predicate-entailment-error.rs:25:8 | -LL | fn autobatch<F>(self) -> impl Trait - | --------- required by a bound in this associated function +LL | trait ChannelSender { + | ------------- in this trait ... -LL | F: Callback<Self::CallbackArg>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<Sender as ChannelSender>::autobatch` +LL | fn autobatch<F>(self) -> impl Trait + | ^^^^^^^^^ this trait's method doesn't have the requirement `F: Callback<i32>` help: consider further restricting type parameter `F` with trait `MyFn` | LL | F: Callback<Self::CallbackArg> + MyFn<i32>, @@ -118,7 +118,7 @@ LL | F: Callback<Self::CallbackArg> + MyFn<i32>, | +++++++++++ error[E0277]: the trait bound `F: MyFn<i32>` is not satisfied - --> $DIR/false-positive-predicate-entailment-error.rs:43:12 + --> $DIR/false-positive-predicate-entailment-error.rs:42:12 | LL | F: Callback<Self::CallbackArg>, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyFn<i32>` is not implemented for `F` diff --git a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs index 2987d183e04..cbe6c32b890 100644 --- a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs +++ b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.rs @@ -38,11 +38,11 @@ impl ChannelSender for Sender { //[current]~| ERROR the trait bound `F: MyFn<i32>` is not satisfied //[current]~| ERROR the trait bound `F: MyFn<i32>` is not satisfied //[current]~| ERROR the trait bound `F: MyFn<i32>` is not satisfied - //[current]~| ERROR the trait bound `F: MyFn<i32>` is not satisfied where F: Callback<Self::CallbackArg>, //[current]~^ ERROR the trait bound `F: MyFn<i32>` is not satisfied - { + //[current]~| ERROR the trait bound `F: Callback<i32>` is not satisfied + { Thing } } diff --git a/tests/ui/impl-trait/in-trait/mismatched-where-clauses.rs b/tests/ui/impl-trait/in-trait/mismatched-where-clauses.rs new file mode 100644 index 00000000000..a2c735cc126 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/mismatched-where-clauses.rs @@ -0,0 +1,12 @@ +trait Foo { + fn foo<S>(s: S) -> impl Sized; +} + +trait Bar {} + +impl Foo for () { + fn foo<S>(s: S) -> impl Sized where S: Bar {} + //~^ ERROR impl has stricter requirements than trait +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/mismatched-where-clauses.stderr b/tests/ui/impl-trait/in-trait/mismatched-where-clauses.stderr new file mode 100644 index 00000000000..cc6e027cad7 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/mismatched-where-clauses.stderr @@ -0,0 +1,12 @@ +error[E0276]: impl has stricter requirements than trait + --> $DIR/mismatched-where-clauses.rs:8:44 + | +LL | fn foo<S>(s: S) -> impl Sized; + | ------------------------------ definition of `foo` from trait +... +LL | fn foo<S>(s: S) -> impl Sized where S: Bar {} + | ^^^ impl has extra requirement `S: Bar` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0276`. diff --git a/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs b/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs index a9936c7bc3f..894f592d9e2 100644 --- a/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs +++ b/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs @@ -13,7 +13,6 @@ impl<T: ?Sized> Mirror for () { pub trait First { async fn first() -> <() as Mirror>::Assoc; - //~^ ERROR type annotations needed } impl First for () { diff --git a/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr b/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr index 0f5573dda04..10ebad2a7d5 100644 --- a/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr +++ b/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr @@ -4,13 +4,6 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T: ?Sized> Mirror for () { | ^ unconstrained type parameter -error[E0282]: type annotations needed - --> $DIR/refine-resolution-errors.rs:15:5 - | -LL | async fn first() -> <() as Mirror>::Assoc; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0207, E0282. -For more information about an error, try `rustc --explain E0207`. +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs index ee47de2c732..ff265e576b9 100644 --- a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.rs @@ -8,7 +8,7 @@ impl Foo<char> for Bar { fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> { //~^ ERROR: the trait bound `impl Foo<u8>: Foo<char>` is not satisfied [E0277] //~| ERROR: the trait bound `Bar: Foo<u8>` is not satisfied [E0277] - //~| ERROR: the trait bound `F2: Foo<u8>` is not satisfied + //~| ERROR: impl has stricter requirements than trait self } } diff --git a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr index 663c9a7f2ae..5cb80386b35 100644 --- a/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr +++ b/tests/ui/impl-trait/in-trait/return-dont-satisfy-bounds.stderr @@ -1,3 +1,12 @@ +error[E0276]: impl has stricter requirements than trait + --> $DIR/return-dont-satisfy-bounds.rs:8:16 + | +LL | fn foo<F2>(self) -> impl Foo<T>; + | -------------------------------- definition of `foo` from trait +... +LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> { + | ^^^^^^^ impl has extra requirement `F2: Foo<u8>` + error[E0277]: the trait bound `impl Foo<u8>: Foo<char>` is not satisfied --> $DIR/return-dont-satisfy-bounds.rs:8:34 | @@ -11,18 +20,6 @@ note: required by a bound in `Foo::{synthetic#0}` LL | fn foo<F2>(self) -> impl Foo<T>; | ^^^^^^ required by this bound in `Foo::{synthetic#0}` -error[E0277]: the trait bound `F2: Foo<u8>` is not satisfied - --> $DIR/return-dont-satisfy-bounds.rs:8:34 - | -LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> { - | ^^^^^^^^^^^^ the trait `Foo<u8>` is not implemented for `F2` - | -note: required by a bound in `<Bar as Foo<char>>::foo` - --> $DIR/return-dont-satisfy-bounds.rs:8:16 - | -LL | fn foo<F2: Foo<u8>>(self) -> impl Foo<u8> { - | ^^^^^^^ required by this bound in `<Bar as Foo<char>>::foo` - error[E0277]: the trait bound `Bar: Foo<u8>` is not satisfied --> $DIR/return-dont-satisfy-bounds.rs:8:34 | @@ -38,4 +35,5 @@ LL | self error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0276, E0277. +For more information about an error, try `rustc --explain E0276`. diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs index 37b0b229776..7a3a59d37c6 100644 --- a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs +++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.rs @@ -4,9 +4,9 @@ trait Extend { impl Extend for () { fn extend<'a: 'a>(s: &'a str) -> (Option<&'static &'a ()>, &'static str) - //~^ ERROR in type `&'static &'a ()`, reference has a longer lifetime than the data it references where 'a: 'static, + //~^ impl has stricter requirements than trait { (None, s) } diff --git a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr index 5ace64b6903..15bef5c78b0 100644 --- a/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr +++ b/tests/ui/impl-trait/in-trait/rpitit-hidden-types-self-implied-wf-via-param.stderr @@ -1,16 +1,17 @@ -error[E0491]: in type `&'static &'a ()`, reference has a longer lifetime than the data it references - --> $DIR/rpitit-hidden-types-self-implied-wf-via-param.rs:6:38 +error[E0276]: impl has stricter requirements than trait + --> $DIR/rpitit-hidden-types-self-implied-wf-via-param.rs:8:13 | -LL | fn extend<'a: 'a>(s: &'a str) -> (Option<&'static &'a ()>, &'static str) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn extend<'a: 'a>(_: &'a str) -> (impl Sized + 'a, &'static str); + | ----------------------------------------------------------------- definition of `extend` from trait +... +LL | 'a: 'static, + | ^^^^^^^ impl has extra requirement `'a: 'static` | - = note: the pointer is valid for the static lifetime -note: but the referenced data is only valid for the lifetime `'a` as defined here - --> $DIR/rpitit-hidden-types-self-implied-wf-via-param.rs:6:15 +help: copy the `where` clause predicates from the trait + | +LL | where 'a: 'a | -LL | fn extend<'a: 'a>(s: &'a str) -> (Option<&'static &'a ()>, &'static str) - | ^^ error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0491`. +For more information about this error, try `rustc --explain E0276`. diff --git a/tests/ui/impl-trait/issues/issue-87340.rs b/tests/ui/impl-trait/issues/issue-87340.rs index b1baaaa6ba5..705a4addcb7 100644 --- a/tests/ui/impl-trait/issues/issue-87340.rs +++ b/tests/ui/impl-trait/issues/issue-87340.rs @@ -9,8 +9,6 @@ impl<T> X for () { //~^ ERROR `T` is not constrained by the impl trait, self type, or predicates type I = impl Sized; fn f() -> Self::I {} - //~^ ERROR type annotations needed - //~| ERROR type annotations needed } fn main() {} diff --git a/tests/ui/impl-trait/issues/issue-87340.stderr b/tests/ui/impl-trait/issues/issue-87340.stderr index 1be4087be42..8513cb2881e 100644 --- a/tests/ui/impl-trait/issues/issue-87340.stderr +++ b/tests/ui/impl-trait/issues/issue-87340.stderr @@ -4,19 +4,6 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T> X for () { | ^ unconstrained type parameter -error[E0282]: type annotations needed - --> $DIR/issue-87340.rs:11:23 - | -LL | fn f() -> Self::I {} - | ^^ cannot infer type for type parameter `T` - -error[E0282]: type annotations needed - --> $DIR/issue-87340.rs:11:15 - | -LL | fn f() -> Self::I {} - | ^^^^^^^ cannot infer type for type parameter `T` - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0207, E0282. -For more information about an error, try `rustc --explain E0207`. +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/impl-unused-tps.stderr b/tests/ui/impl-unused-tps.stderr index da4589dee82..09c3fce641c 100644 --- a/tests/ui/impl-unused-tps.stderr +++ b/tests/ui/impl-unused-tps.stderr @@ -7,6 +7,12 @@ LL | impl<T> Foo<T> for [isize; 0] { LL | impl<T, U> Foo<T> for U { | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[isize; 0]` +error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates + --> $DIR/impl-unused-tps.rs:32:9 + | +LL | impl<T, U> Bar for T { + | ^ unconstrained type parameter + error[E0119]: conflicting implementations of trait `Bar` --> $DIR/impl-unused-tps.rs:40:1 | @@ -47,12 +53,6 @@ LL | impl<T, U> Foo<T> for [isize; 1] { | ^ unconstrained type parameter error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:32:9 - | -LL | impl<T, U> Bar for T { - | ^ unconstrained type parameter - -error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates --> $DIR/impl-unused-tps.rs:40:9 | LL | impl<T, U> Bar for T diff --git a/tests/ui/macros/issue-69396-const-no-type-in-macro.rs b/tests/ui/macros/issue-69396-const-no-type-in-macro.rs index 45a30857413..c200a1fd0b4 100644 --- a/tests/ui/macros/issue-69396-const-no-type-in-macro.rs +++ b/tests/ui/macros/issue-69396-const-no-type-in-macro.rs @@ -4,7 +4,7 @@ macro_rules! suite { const A = "A".$fn(); //~^ ERROR the name `A` is defined multiple times //~| ERROR missing type for `const` item - //~| ERROR the placeholder `_` is not allowed within types on item signatures for constants + //~| ERROR missing type for item )* } } diff --git a/tests/ui/macros/issue-69396-const-no-type-in-macro.stderr b/tests/ui/macros/issue-69396-const-no-type-in-macro.stderr index 89aeafebac4..4342d7d88f5 100644 --- a/tests/ui/macros/issue-69396-const-no-type-in-macro.stderr +++ b/tests/ui/macros/issue-69396-const-no-type-in-macro.stderr @@ -27,14 +27,11 @@ LL | | } | = note: this error originates in the macro `suite` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants +error[E0121]: missing type for item --> $DIR/issue-69396-const-no-type-in-macro.rs:4:20 | LL | const A = "A".$fn(); - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `bool` + | ^ not allowed in type signatures ... LL | / suite! { LL | | len; diff --git a/tests/ui/parser/issues/issue-89574.rs b/tests/ui/parser/issues/issue-89574.rs index bafb0ce5e66..276abfe7110 100644 --- a/tests/ui/parser/issues/issue-89574.rs +++ b/tests/ui/parser/issues/issue-89574.rs @@ -2,5 +2,4 @@ fn main() { const EMPTY_ARRAY = []; //~^ missing type for `const` item //~| ERROR type annotations needed - //~| ERROR type annotations needed } diff --git a/tests/ui/parser/issues/issue-89574.stderr b/tests/ui/parser/issues/issue-89574.stderr index aa5e66b18a9..f40f5aded8e 100644 --- a/tests/ui/parser/issues/issue-89574.stderr +++ b/tests/ui/parser/issues/issue-89574.stderr @@ -15,14 +15,6 @@ help: provide a type for the item LL | const EMPTY_ARRAY: <type> = []; | ++++++++ -error[E0282]: type annotations needed - --> $DIR/issue-89574.rs:2:25 - | -LL | const EMPTY_ARRAY = []; - | ^^ cannot infer type - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/suggestions/unnamable-types.rs b/tests/ui/suggestions/unnamable-types.rs index dd2c3536eb9..094584ff850 100644 --- a/tests/ui/suggestions/unnamable-types.rs +++ b/tests/ui/suggestions/unnamable-types.rs @@ -10,7 +10,7 @@ const A = 5; static B: _ = "abc"; //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static variables //~| NOTE: not allowed in type signatures -//~| HELP: replace with the correct type +//~| HELP: replace this with a fully-specified type // FIXME: this should also suggest a function pointer, as the closure is non-capturing diff --git a/tests/ui/suggestions/unnamable-types.stderr b/tests/ui/suggestions/unnamable-types.stderr index 6623678fd0c..dc236af91f8 100644 --- a/tests/ui/suggestions/unnamable-types.stderr +++ b/tests/ui/suggestions/unnamable-types.stderr @@ -8,10 +8,12 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/unnamable-types.rs:10:11 | LL | static B: _ = "abc"; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `&str` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static B: &str = "abc"; + | ~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/unnamable-types.rs:17:10 diff --git a/tests/ui/traits/const-traits/pattern-custom-partial-eq.rs b/tests/ui/traits/const-traits/pattern-custom-partial-eq.rs new file mode 100644 index 00000000000..1003775be2f --- /dev/null +++ b/tests/ui/traits/const-traits/pattern-custom-partial-eq.rs @@ -0,0 +1,54 @@ +//! Ensure that a `const fn` can match on constants of a type that is `PartialEq` +//! but not `const PartialEq`. This is accepted for backwards compatibility reasons. +//@ check-pass +#![feature(const_trait_impl)] + +#[derive(Eq, PartialEq)] +pub struct Y(u8); +pub const GREEN: Y = Y(4); +pub const fn is_green(x: Y) -> bool { + match x { GREEN => true, _ => false } +} + +struct CustomEq; + +impl Eq for CustomEq {} +impl PartialEq for CustomEq { + fn eq(&self, _: &Self) -> bool { + false + } +} + +#[derive(PartialEq, Eq)] +#[allow(unused)] +enum Foo { + Bar, + Baz, + Qux(CustomEq), +} + +const BAR_BAZ: Foo = if 42 == 42 { + Foo::Bar +} else { + Foo::Qux(CustomEq) // dead arm +}; + +const EMPTY: &[CustomEq] = &[]; + +const fn test() { + // BAR_BAZ itself is fine but the enum has other variants + // that are non-structural. Still, this should be accepted. + match Foo::Qux(CustomEq) { + BAR_BAZ => panic!(), + _ => {} + } + + // Similarly, an empty slice of a type that is non-structural + // is accepted. + match &[CustomEq] as &[CustomEq] { + EMPTY => panic!(), + _ => {}, + } +} + +fn main() {} diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr b/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr new file mode 100644 index 00000000000..2bb389c6ec1 --- /dev/null +++ b/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr @@ -0,0 +1,9 @@ +error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates + --> $DIR/unconstrained-projection-normalization-2.rs:14:6 + | +LL | impl<T: ?Sized> Every for Thing { + | ^ unconstrained type parameter + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr b/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr new file mode 100644 index 00000000000..2bb389c6ec1 --- /dev/null +++ b/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr @@ -0,0 +1,9 @@ +error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates + --> $DIR/unconstrained-projection-normalization-2.rs:14:6 + | +LL | impl<T: ?Sized> Every for Thing { + | ^ unconstrained type parameter + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.rs b/tests/ui/traits/unconstrained-projection-normalization-2.rs new file mode 100644 index 00000000000..6b584c436c6 --- /dev/null +++ b/tests/ui/traits/unconstrained-projection-normalization-2.rs @@ -0,0 +1,21 @@ +// Make sure we don't ICE in `normalize_erasing_regions` when normalizing +// an associated type in an impl with unconstrained non-lifetime params. +// (This time in a function signature) + +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +struct Thing; + +pub trait Every { + type Assoc; +} +impl<T: ?Sized> Every for Thing { +//~^ ERROR the type parameter `T` is not constrained + type Assoc = T; +} + +fn foo(_: <Thing as Every>::Assoc) {} + +fn main() {} diff --git a/tests/ui/traits/unconstrained-projection-normalization.current.stderr b/tests/ui/traits/unconstrained-projection-normalization.current.stderr new file mode 100644 index 00000000000..991f0e8ba66 --- /dev/null +++ b/tests/ui/traits/unconstrained-projection-normalization.current.stderr @@ -0,0 +1,9 @@ +error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates + --> $DIR/unconstrained-projection-normalization.rs:13:6 + | +LL | impl<T: ?Sized> Every for Thing { + | ^ unconstrained type parameter + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization.next.stderr b/tests/ui/traits/unconstrained-projection-normalization.next.stderr new file mode 100644 index 00000000000..991f0e8ba66 --- /dev/null +++ b/tests/ui/traits/unconstrained-projection-normalization.next.stderr @@ -0,0 +1,9 @@ +error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates + --> $DIR/unconstrained-projection-normalization.rs:13:6 + | +LL | impl<T: ?Sized> Every for Thing { + | ^ unconstrained type parameter + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization.rs b/tests/ui/traits/unconstrained-projection-normalization.rs new file mode 100644 index 00000000000..fa4ab7fec4c --- /dev/null +++ b/tests/ui/traits/unconstrained-projection-normalization.rs @@ -0,0 +1,20 @@ +// Make sure we don't ICE in `normalize_erasing_regions` when normalizing +// an associated type in an impl with unconstrained non-lifetime params. + +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +struct Thing; + +pub trait Every { + type Assoc; +} +impl<T: ?Sized> Every for Thing { +//~^ ERROR the type parameter `T` is not constrained + type Assoc = T; +} + +static I: <Thing as Every>::Assoc = 3; + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs index 0ee188d825f..2bcb8f06f4f 100644 --- a/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs +++ b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.rs @@ -42,7 +42,6 @@ impl<T: MyFrom<Phantom2<DummyT<U>>>, U> MyIndex<DummyT<T>> for Scope<U> { //~^ ERROR the type parameter `T` is not constrained by the impl type O = T; fn my_index(self) -> Self::O { - //~^ ERROR item does not constrain MyFrom::my_from(self.0).ok().unwrap() } } diff --git a/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr index eace96317dc..0ab4c34381a 100644 --- a/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr +++ b/tests/ui/type-alias-impl-trait/ice-failed-to-resolve-instance-for-110696.stderr @@ -17,19 +17,6 @@ note: this opaque type is in the signature LL | type DummyT<T> = impl F; | ^^^^^^ -error: item does not constrain `DummyT::{opaque#0}`, but has it in its signature - --> $DIR/ice-failed-to-resolve-instance-for-110696.rs:44:8 - | -LL | fn my_index(self) -> Self::O { - | ^^^^^^^^ - | - = note: consider moving the opaque type's declaration and defining uses into a separate module -note: this opaque type is in the signature - --> $DIR/ice-failed-to-resolve-instance-for-110696.rs:20:18 - | -LL | type DummyT<T> = impl F; - | ^^^^^^ - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0207`. 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 fcac83500ec..1824ff5e2fb 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 @@ -12,8 +12,6 @@ impl<T> X for () { //~^ ERROR the type parameter `T` is not constrained type I = impl Sized; fn f() -> Self::I {} - //~^ ERROR type annotations needed - //~| ERROR type annotations needed } fn main() {} diff --git a/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr b/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr index bb0e11d314c..137a4db81b5 100644 --- a/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr +++ b/tests/ui/type-alias-impl-trait/impl-with-unconstrained-param.stderr @@ -4,19 +4,6 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T> X for () { | ^ unconstrained type parameter -error[E0282]: type annotations needed - --> $DIR/impl-with-unconstrained-param.rs:14:23 - | -LL | fn f() -> Self::I {} - | ^^ cannot infer type for type parameter `T` - -error[E0282]: type annotations needed - --> $DIR/impl-with-unconstrained-param.rs:14:15 - | -LL | fn f() -> Self::I {} - | ^^^^^^^ cannot infer type for type parameter `T` - -error: aborting due to 3 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0207, E0282. -For more information about an error, try `rustc --explain E0207`. +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/type-alias-impl-trait/issue-74244.rs b/tests/ui/type-alias-impl-trait/issue-74244.rs index ce8a38a3361..bb4104b3d25 100644 --- a/tests/ui/type-alias-impl-trait/issue-74244.rs +++ b/tests/ui/type-alias-impl-trait/issue-74244.rs @@ -14,7 +14,6 @@ impl<T> Allocator for DefaultAllocator { type A = impl Fn(<DefaultAllocator as Allocator>::Buffer); fn foo() -> A { - //~^ ERROR: type annotations needed |_| () } diff --git a/tests/ui/type-alias-impl-trait/issue-74244.stderr b/tests/ui/type-alias-impl-trait/issue-74244.stderr index d2b50ffd86b..f5ca56baccc 100644 --- a/tests/ui/type-alias-impl-trait/issue-74244.stderr +++ b/tests/ui/type-alias-impl-trait/issue-74244.stderr @@ -4,13 +4,6 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T> Allocator for DefaultAllocator { | ^ unconstrained type parameter -error[E0282]: type annotations needed - --> $DIR/issue-74244.rs:16:13 - | -LL | fn foo() -> A { - | ^ cannot infer type for type parameter `T` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0207, E0282. -For more information about an error, try `rustc --explain E0207`. +For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/typeck/issue-79040.rs b/tests/ui/typeck/issue-79040.rs index 03e00820756..f8e38e7867d 100644 --- a/tests/ui/typeck/issue-79040.rs +++ b/tests/ui/typeck/issue-79040.rs @@ -1,6 +1,6 @@ fn main() { - const FOO = "hello" + 1; //~ ERROR cannot add `{integer}` to `&str` - //~^ missing type for `const` item - //~| ERROR cannot add `{integer}` to `&str` + const FOO = "hello" + 1; + //~^ ERROR cannot add `{integer}` to `&str` + //~| missing type for `const` item println!("{}", FOO); } diff --git a/tests/ui/typeck/issue-79040.stderr b/tests/ui/typeck/issue-79040.stderr index 39636db85a7..4ab8df8f6c9 100644 --- a/tests/ui/typeck/issue-79040.stderr +++ b/tests/ui/typeck/issue-79040.stderr @@ -17,16 +17,6 @@ help: provide a type for the item LL | const FOO: <type> = "hello" + 1; | ++++++++ -error[E0369]: cannot add `{integer}` to `&str` - --> $DIR/issue-79040.rs:2:25 - | -LL | const FOO = "hello" + 1; - | ------- ^ - {integer} - | | - | &str - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0369`. diff --git a/tests/ui/typeck/typeck_type_placeholder_item.rs b/tests/ui/typeck/typeck_type_placeholder_item.rs index 437a1aed403..9f1bfd7909e 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.rs +++ b/tests/ui/typeck/typeck_type_placeholder_item.rs @@ -221,6 +221,7 @@ fn value() -> Option<&'static _> { const _: Option<_> = map(value); //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants +//~| ERROR cannot call non-const function `map::<u8>` in constants fn evens_squared(n: usize) -> _ { //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index e62ebae5fd2..c97b9312076 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -67,25 +67,36 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:13:15 | LL | static TEST3: _ = "test"; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `&str` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static TEST3: &str = "test"; + | ~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/typeck_type_placeholder_item.rs:16:15 | LL | static TEST4: _ = 145; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `i32` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static TEST4: i32 = 145; + | ~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables - --> $DIR/typeck_type_placeholder_item.rs:19:15 + --> $DIR/typeck_type_placeholder_item.rs:19:16 | LL | static TEST5: (_, _) = (1, 2); - | ^^^^^^ not allowed in type signatures + | ^ ^ not allowed in type signatures + | | + | not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static TEST5: (i32, i32) = (1, 2); + | ~~~~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:22:13 @@ -220,16 +231,23 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:75:15 | LL | static B: _ = 42; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `i32` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static B: i32 = 42; + | ~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables - --> $DIR/typeck_type_placeholder_item.rs:77:15 + --> $DIR/typeck_type_placeholder_item.rs:77:22 | LL | static C: Option<_> = Some(42); - | ^^^^^^^^^ not allowed in type signatures + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static C: Option<i32> = Some(42); + | ~~~~~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:79:21 @@ -254,25 +272,36 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:85:22 | LL | static FN_TEST3: _ = "test"; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `&str` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static FN_TEST3: &str = "test"; + | ~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables --> $DIR/typeck_type_placeholder_item.rs:88:22 | LL | static FN_TEST4: _ = 145; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `i32` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static FN_TEST4: i32 = 145; + | ~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables - --> $DIR/typeck_type_placeholder_item.rs:91:22 + --> $DIR/typeck_type_placeholder_item.rs:91:23 | LL | static FN_TEST5: (_, _) = (1, 2); - | ^^^^^^ not allowed in type signatures + | ^ ^ not allowed in type signatures + | | + | not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | static FN_TEST5: (i32, i32) = (1, 2); + | ~~~~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:94:20 @@ -539,10 +568,12 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item.rs:194:14 | LL | const D: _ = 42; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `i32` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | const D: i32 = 42; + | ~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/typeck_type_placeholder_item.rs:209:14 @@ -569,16 +600,18 @@ LL | fn value() -> Option<&'static _> { | help: replace with the correct return type: `Option<&'static u8>` error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/typeck_type_placeholder_item.rs:222:10 + --> $DIR/typeck_type_placeholder_item.rs:222:17 | LL | const _: Option<_> = map(value); - | ^^^^^^^^^ - | | - | not allowed in type signatures - | help: replace with the correct type: `Option<u8>` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | const _: Option<u8> = map(value); + | ~~~~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:225:31 + --> $DIR/typeck_type_placeholder_item.rs:226:31 | LL | fn evens_squared(n: usize) -> _ { | ^ @@ -587,13 +620,13 @@ LL | fn evens_squared(n: usize) -> _ { | help: replace with an appropriate return type: `impl Iterator<Item = usize>` error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/typeck_type_placeholder_item.rs:230:10 + --> $DIR/typeck_type_placeholder_item.rs:231:10 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^ not allowed in type signatures | -note: however, the inferred type `Map<Filter<Range<i32>, {closure@typeck_type_placeholder_item.rs:230:29}>, {closure@typeck_type_placeholder_item.rs:230:49}>` cannot be named - --> $DIR/typeck_type_placeholder_item.rs:230:14 +note: however, the inferred type `Map<Filter<Range<i32>, {closure@typeck_type_placeholder_item.rs:231:29}>, {closure@typeck_type_placeholder_item.rs:231:49}>` cannot be named + --> $DIR/typeck_type_placeholder_item.rs:231:14 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -668,23 +701,31 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | type F: std::ops::Fn(_); | ^ not allowed in type signatures -error[E0015]: cannot call non-const method `<std::ops::Range<i32> as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:230:29: 230:32}>` in constants - --> $DIR/typeck_type_placeholder_item.rs:230:22 +error[E0015]: cannot call non-const function `map::<u8>` in constants + --> $DIR/typeck_type_placeholder_item.rs:222:22 + | +LL | const _: Option<_> = map(value); + | ^^^^^^^^^^ + | + = note: calls in constants are limited to constant functions, tuple structs and tuple variants + +error[E0015]: cannot call non-const method `<std::ops::Range<i32> as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:231:29: 231:32}>` in constants + --> $DIR/typeck_type_placeholder_item.rs:231:22 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^^^^^^^^^ | = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const method `<Filter<std::ops::Range<i32>, {closure@$DIR/typeck_type_placeholder_item.rs:230:29: 230:32}> as Iterator>::map::<i32, {closure@$DIR/typeck_type_placeholder_item.rs:230:49: 230:52}>` in constants - --> $DIR/typeck_type_placeholder_item.rs:230:45 +error[E0015]: cannot call non-const method `<Filter<std::ops::Range<i32>, {closure@$DIR/typeck_type_placeholder_item.rs:231:29: 231:32}> as Iterator>::map::<i32, {closure@$DIR/typeck_type_placeholder_item.rs:231:49: 231:52}>` in constants + --> $DIR/typeck_type_placeholder_item.rs:231:45 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^ | = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error: aborting due to 74 previous errors +error: aborting due to 75 previous errors Some errors have detailed explanations: E0015, E0046, E0121, E0282, E0403. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/typeck/typeck_type_placeholder_item_help.stderr b/tests/ui/typeck/typeck_type_placeholder_item_help.stderr index 32585e2937b..a05e27cebfc 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item_help.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item_help.stderr @@ -11,19 +11,23 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item_help.rs:7:14 | LL | const TEST2: _ = 42u32; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `u32` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | const TEST2: u32 = 42u32; + | ~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/typeck_type_placeholder_item_help.rs:10:14 | LL | const TEST3: _ = Some(42); - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `Option<i32>` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | const TEST3: Option<i32> = Some(42); + | ~~~~~~~~~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item_help.rs:13:22 @@ -41,19 +45,23 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/typeck_type_placeholder_item_help.rs:25:18 | LL | const TEST6: _ = 13; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `i32` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | const TEST6: i32 = 13; + | ~~~ error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/typeck_type_placeholder_item_help.rs:18:18 | LL | const TEST5: _ = 42; - | ^ - | | - | not allowed in type signatures - | help: replace with the correct type: `i32` + | ^ not allowed in type signatures + | +help: replace this with a fully-specified type + | +LL | const TEST5: i32 = 42; + | ~~~ error[E0308]: mismatched types --> $DIR/typeck_type_placeholder_item_help.rs:30:28 |
