diff options
Diffstat (limited to 'tests')
131 files changed, 1019 insertions, 1301 deletions
diff --git a/tests/assembly/dwarf-mixed-versions-lto.rs b/tests/assembly/dwarf-mixed-versions-lto.rs index 5b8e5ff4f4a..f1fc0814c9d 100644 --- a/tests/assembly/dwarf-mixed-versions-lto.rs +++ b/tests/assembly/dwarf-mixed-versions-lto.rs @@ -1,5 +1,6 @@ // This test ensures that if LTO occurs between crates with different DWARF versions, we // will choose the highest DWARF version for the final binary. This matches Clang's behavior. +// Note: `.2byte` directive is used on MIPS. //@ only-linux //@ aux-build:dwarf-mixed-versions-lto-aux.rs @@ -14,6 +15,6 @@ fn main() { } // CHECK: .section .debug_info -// CHECK-NOT: {{\.(short|hword)}} 2 -// CHECK-NOT: {{\.(short|hword)}} 4 -// CHECK: {{\.(short|hword)}} 5 +// CHECK-NOT: {{\.(short|hword|2byte)}} 2 +// CHECK-NOT: {{\.(short|hword|2byte)}} 4 +// CHECK: {{\.(short|hword|2byte)}} 5 diff --git a/tests/assembly/rust-abi-arg-attr.rs b/tests/assembly/rust-abi-arg-attr.rs index e55a53fbdeb..5b5eeb29f0f 100644 --- a/tests/assembly/rust-abi-arg-attr.rs +++ b/tests/assembly/rust-abi-arg-attr.rs @@ -51,10 +51,7 @@ enum Ordering { } #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -fn three_way_compare<T: Copy>(lhs: T, rhs: T) -> Ordering { - loop {} -} +fn three_way_compare<T: Copy>(lhs: T, rhs: T) -> Ordering; // ^^^^^ core diff --git a/tests/pretty/hir-pretty-attr.pp b/tests/pretty/hir-pretty-attr.pp new file mode 100644 index 00000000000..586810b0046 --- /dev/null +++ b/tests/pretty/hir-pretty-attr.pp @@ -0,0 +1,11 @@ +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; +//@ pretty-compare-only +//@ pretty-mode:hir +//@ pp-exact:hir-pretty-attr.pp + +#[attr="Repr([ReprC, ReprPacked(Align(4 bytes)), ReprTransparent])")] +struct Example { +} diff --git a/tests/pretty/hir-pretty-attr.rs b/tests/pretty/hir-pretty-attr.rs new file mode 100644 index 00000000000..eb5a677024a --- /dev/null +++ b/tests/pretty/hir-pretty-attr.rs @@ -0,0 +1,7 @@ +//@ pretty-compare-only +//@ pretty-mode:hir +//@ pp-exact:hir-pretty-attr.pp + +#[repr(C, packed(4))] +#[repr(transparent)] +struct Example {} diff --git a/tests/rustdoc-json/enums/discriminant/struct.rs b/tests/rustdoc-json/enums/discriminant/struct.rs index 0ac40cda733..24d5f5b08c2 100644 --- a/tests/rustdoc-json/enums/discriminant/struct.rs +++ b/tests/rustdoc-json/enums/discriminant/struct.rs @@ -1,7 +1,7 @@ // ignore-tidy-linelength #[repr(i32)] -//@ is "$.index[*][?(@.name=='Foo')].attrs" '["#[repr(i32)]"]' +//@ is "$.index[*][?(@.name=='Foo')].attrs" '["#[attr=\"Repr([ReprInt(SignedInt(I32))])\")]\n"]' pub enum Foo { //@ is "$.index[*][?(@.name=='Struct')].inner.variant.discriminant" null //@ count "$.index[*][?(@.name=='Struct')].inner.variant.kind.struct.fields[*]" 0 diff --git a/tests/rustdoc-json/enums/discriminant/tuple.rs b/tests/rustdoc-json/enums/discriminant/tuple.rs index fbff5aacd67..a50ae8b9189 100644 --- a/tests/rustdoc-json/enums/discriminant/tuple.rs +++ b/tests/rustdoc-json/enums/discriminant/tuple.rs @@ -1,7 +1,7 @@ // ignore-tidy-linelength #[repr(u32)] -//@ is "$.index[*][?(@.name=='Foo')].attrs" '["#[repr(u32)]"]' +//@ is "$.index[*][?(@.name=='Foo')].attrs" '["#[attr=\"Repr([ReprInt(UnsignedInt(U32))])\")]\n"]' pub enum Foo { //@ is "$.index[*][?(@.name=='Tuple')].inner.variant.discriminant" null //@ count "$.index[*][?(@.name=='Tuple')].inner.variant.kind.tuple[*]" 0 diff --git a/tests/rustdoc/const-intrinsic.rs b/tests/rustdoc/const-intrinsic.rs index 8444d4a3aa7..7dedb083b7d 100644 --- a/tests/rustdoc/const-intrinsic.rs +++ b/tests/rustdoc/const-intrinsic.rs @@ -9,19 +9,13 @@ #[stable(since="1.0.0", feature="rust1")] #[rustc_const_stable(feature = "const_transmute", since = "1.56.0")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub const unsafe fn transmute<T, U>(_: T) -> U { - loop {} -} +pub const unsafe fn transmute<T, U>(_: T) -> U; //@ has 'foo/fn.unreachable.html' //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe fn unreachable() -> !' #[stable(since="1.0.0", feature="rust1")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub unsafe fn unreachable() -> ! { - loop {} -} +pub unsafe fn unreachable() -> !; extern "C" { //@ has 'foo/fn.needs_drop.html' diff --git a/tests/rustdoc/safe-intrinsic.rs b/tests/rustdoc/safe-intrinsic.rs index 1edc1d9f79b..0d2ee89415d 100644 --- a/tests/rustdoc/safe-intrinsic.rs +++ b/tests/rustdoc/safe-intrinsic.rs @@ -11,14 +11,8 @@ trait Sized {} //@ has 'foo/fn.abort.html' //@ has - '//pre[@class="rust item-decl"]' 'pub fn abort() -> !' #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub fn abort() -> ! { - loop {} -} +pub fn abort() -> !; //@ has 'foo/fn.unreachable.html' //@ has - '//pre[@class="rust item-decl"]' 'pub unsafe fn unreachable() -> !' #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -pub unsafe fn unreachable() -> ! { - loop {} -} +pub unsafe fn unreachable() -> !; diff --git a/tests/ui-fulldeps/stable-mir/check_attribute.rs b/tests/ui-fulldeps/stable-mir/check_attribute.rs index 11cb63f3f8a..de5ba15f6ea 100644 --- a/tests/ui-fulldeps/stable-mir/check_attribute.rs +++ b/tests/ui-fulldeps/stable-mir/check_attribute.rs @@ -27,63 +27,23 @@ fn test_stable_mir() -> ControlFlow<()> { // Find items in the local crate. let items = stable_mir::all_local_items(); - test_builtins(&items); - test_derive(&items); test_tool(&items); - test_all_attrs(&items); ControlFlow::Continue(()) } -// Test built-in attributes. -fn test_builtins(items: &CrateItems) { - let target_fn = *get_item(&items, "builtins_fn").unwrap(); - let allow_attrs = target_fn.attrs_by_path(&["allow".to_string()]); - assert_eq!(allow_attrs[0].as_str(), "#![allow(unused_variables)]"); - - let inline_attrs = target_fn.attrs_by_path(&["inline".to_string()]); - assert_eq!(inline_attrs[0].as_str(), "#[inline]"); - - let deprecated_attrs = target_fn.attrs_by_path(&["deprecated".to_string()]); - assert_eq!(deprecated_attrs[0].as_str(), "#[deprecated(since = \"5.2.0\")]"); -} - -// Test derive attribute. -fn test_derive(items: &CrateItems) { - let target_struct = *get_item(&items, "Foo").unwrap(); - let attrs = target_struct.attrs_by_path(&["derive".to_string()]); - // No `derive` attribute since it's expanded before MIR. - assert_eq!(attrs.len(), 0); - - // Check derived trait method's attributes. - let derived_fmt = *get_item(&items, "<Foo as std::fmt::Debug>::fmt").unwrap(); - // The Rust reference lies about this attribute. It doesn't show up in `clone` or `fmt` impl. - let _fmt_attrs = derived_fmt.attrs_by_path(&["automatically_derived".to_string()]); -} - // Test tool attributes. fn test_tool(items: &CrateItems) { let rustfmt_fn = *get_item(&items, "do_not_format").unwrap(); - let rustfmt_attrs = rustfmt_fn.attrs_by_path(&["rustfmt".to_string(), "skip".to_string()]); + let rustfmt_attrs = rustfmt_fn.tool_attrs(&["rustfmt".to_string(), "skip".to_string()]); assert_eq!(rustfmt_attrs[0].as_str(), "#[rustfmt::skip]"); let clippy_fn = *get_item(&items, "complex_fn").unwrap(); - let clippy_attrs = clippy_fn.attrs_by_path(&["clippy".to_string(), + let clippy_attrs = clippy_fn.tool_attrs(&["clippy".to_string(), "cyclomatic_complexity".to_string()]); assert_eq!(clippy_attrs[0].as_str(), "#[clippy::cyclomatic_complexity = \"100\"]"); } -fn test_all_attrs(items: &CrateItems) { - let target_fn = *get_item(&items, "many_attrs").unwrap(); - let all_attrs = target_fn.all_attrs(); - assert_eq!(all_attrs[0].as_str(), "#[inline]"); - assert_eq!(all_attrs[1].as_str(), "#[allow(unused_variables)]"); - assert_eq!(all_attrs[2].as_str(), "#[allow(dead_code)]"); - assert_eq!(all_attrs[3].as_str(), "#[allow(unused_imports)]"); - assert_eq!(all_attrs[4].as_str(), "#![allow(clippy::filter_map)]"); -} - - fn get_item<'a>( items: &'a CrateItems, name: &str, diff --git a/tests/ui-fulldeps/stable-mir/check_intrinsics.rs b/tests/ui-fulldeps/stable-mir/check_intrinsics.rs index 2f772b97886..07a2a62e066 100644 --- a/tests/ui-fulldeps/stable-mir/check_intrinsics.rs +++ b/tests/ui-fulldeps/stable-mir/check_intrinsics.rs @@ -51,13 +51,11 @@ fn test_intrinsics() -> ControlFlow<()> { /// This check is unfortunately tight to the implementation of intrinsics. /// -/// We want to ensure that StableMIR can handle intrinsics with and without fallback body. +/// We want to ensure that StableMIR can handle intrinsics with and without fallback body: +/// for intrinsics without a body, obviously we cannot expose anything. /// /// If by any chance this test breaks because you changed how an intrinsic is implemented, please /// update the test to invoke a different intrinsic. -/// -/// In StableMIR, we only expose intrinsic body if they are not marked with -/// `rustc_intrinsic_must_be_overridden`. fn check_instance(instance: &Instance) { assert_eq!(instance.kind, InstanceKind::Intrinsic); let name = instance.intrinsic_name().unwrap(); diff --git a/tests/ui/asm/conditionally-sized-ptr-fail.rs b/tests/ui/asm/conditionally-sized-ptr-fail.rs new file mode 100644 index 00000000000..b0a93495ffa --- /dev/null +++ b/tests/ui/asm/conditionally-sized-ptr-fail.rs @@ -0,0 +1,19 @@ +//@ needs-asm-support + +use std::arch::asm; + +fn _f<T: ?Sized>(p: *mut T) { + unsafe { + asm!("/* {} */", in(reg) p); + //~^ ERROR cannot use value of unsized pointer type `*mut T` for inline assembly + } +} + +fn _g(p: *mut [u8]) { + unsafe { + asm!("/* {} */", in(reg) p); + //~^ ERROR cannot use value of unsized pointer type `*mut [u8]` for inline assembly + } +} + +fn main() {} diff --git a/tests/ui/asm/conditionally-sized-ptr-fail.stderr b/tests/ui/asm/conditionally-sized-ptr-fail.stderr new file mode 100644 index 00000000000..b88f59f569c --- /dev/null +++ b/tests/ui/asm/conditionally-sized-ptr-fail.stderr @@ -0,0 +1,18 @@ +error: cannot use value of unsized pointer type `*mut T` for inline assembly + --> $DIR/conditionally-sized-ptr-fail.rs:7:34 + | +LL | asm!("/* {} */", in(reg) p); + | ^ + | + = note: only sized pointers can be used in inline assembly + +error: cannot use value of unsized pointer type `*mut [u8]` for inline assembly + --> $DIR/conditionally-sized-ptr-fail.rs:14:34 + | +LL | asm!("/* {} */", in(reg) p); + | ^ + | + = note: only sized pointers can be used in inline assembly + +error: aborting due to 2 previous errors + diff --git a/tests/ui/asm/conditionally-sized-ptr.rs b/tests/ui/asm/conditionally-sized-ptr.rs new file mode 100644 index 00000000000..8ff18fd1da1 --- /dev/null +++ b/tests/ui/asm/conditionally-sized-ptr.rs @@ -0,0 +1,12 @@ +//@ check-pass +//@ needs-asm-support + +use std::arch::asm; + +fn _f<T>(p: *mut T) { + unsafe { + asm!("/* {} */", in(reg) p); + } +} + +fn main() {} diff --git a/tests/ui/attributes/arg-error-issue-121425.stderr b/tests/ui/attributes/arg-error-issue-121425.stderr index 1beb99b1703..6e71f15fdc8 100644 --- a/tests/ui/attributes/arg-error-issue-121425.stderr +++ b/tests/ui/attributes/arg-error-issue-121425.stderr @@ -1,3 +1,9 @@ +error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses + --> $DIR/arg-error-issue-121425.rs:16:8 + | +LL | #[repr(align())] + | ^^^^^^^ + error[E0693]: incorrect `repr(align)` attribute format: `align` expects a literal integer as argument --> $DIR/arg-error-issue-121425.rs:4:14 | @@ -16,12 +22,6 @@ error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer LL | #[repr(align("str"))] | ^^^^^ -error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses - --> $DIR/arg-error-issue-121425.rs:16:8 - | -LL | #[repr(align())] - | ^^^^^^^ - error[E0552]: incorrect `repr(packed)` attribute format: `packed` expects a literal integer as argument --> $DIR/arg-error-issue-121425.rs:21:15 | diff --git a/tests/ui/attributes/issue-100631.stderr b/tests/ui/attributes/issue-100631.stderr index 6e8e4f3b418..b2bd0a96325 100644 --- a/tests/ui/attributes/issue-100631.stderr +++ b/tests/ui/attributes/issue-100631.stderr @@ -1,8 +1,8 @@ error[E0084]: unsupported representation for zero-variant enum - --> $DIR/issue-100631.rs:4:1 + --> $DIR/issue-100631.rs:4:8 | LL | #[repr(C)] - | ^^^^^^^^^^ + | ^ LL | #[repr(C)] LL | enum Foo {} | -------- zero-variant enum diff --git a/tests/ui/attributes/malformed-fn-align.rs b/tests/ui/attributes/malformed-fn-align.rs new file mode 100644 index 00000000000..4aaad01b723 --- /dev/null +++ b/tests/ui/attributes/malformed-fn-align.rs @@ -0,0 +1,7 @@ +#![feature(fn_align)] +#![crate_type = "lib"] + +trait MyTrait { + #[repr(align)] //~ ERROR invalid `repr(align)` attribute: `align` needs an argument + fn myfun(); +} diff --git a/tests/ui/attributes/malformed-fn-align.stderr b/tests/ui/attributes/malformed-fn-align.stderr new file mode 100644 index 00000000000..57913c48ef7 --- /dev/null +++ b/tests/ui/attributes/malformed-fn-align.stderr @@ -0,0 +1,9 @@ +error[E0589]: invalid `repr(align)` attribute: `align` needs an argument + --> $DIR/malformed-fn-align.rs:5:12 + | +LL | #[repr(align)] + | ^^^^^ help: supply an argument here: `align(...)` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0589`. diff --git a/tests/ui/attributes/mixed_export_name_and_no_mangle.fixed b/tests/ui/attributes/mixed_export_name_and_no_mangle.fixed index 7224d4289e3..d8b5235c52f 100644 --- a/tests/ui/attributes/mixed_export_name_and_no_mangle.fixed +++ b/tests/ui/attributes/mixed_export_name_and_no_mangle.fixed @@ -3,7 +3,7 @@ //@ check-pass #![warn(unused_attributes)] -//~^ WARN `#[no_mangle]` attribute may not be used in combination with `#[export_name]` [unused_attributes] +//~^ WARN `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[export_name]` [unused_attributes] #[export_name = "foo"] pub fn bar() {} diff --git a/tests/ui/attributes/mixed_export_name_and_no_mangle.rs b/tests/ui/attributes/mixed_export_name_and_no_mangle.rs index 149a7904e1e..83a673a7d13 100644 --- a/tests/ui/attributes/mixed_export_name_and_no_mangle.rs +++ b/tests/ui/attributes/mixed_export_name_and_no_mangle.rs @@ -4,7 +4,7 @@ #![warn(unused_attributes)] #[no_mangle] -//~^ WARN `#[no_mangle]` attribute may not be used in combination with `#[export_name]` [unused_attributes] +//~^ WARN `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[export_name]` [unused_attributes] #[export_name = "foo"] pub fn bar() {} diff --git a/tests/ui/attributes/mixed_export_name_and_no_mangle.stderr b/tests/ui/attributes/mixed_export_name_and_no_mangle.stderr index ba63127ba2d..c760d27db25 100644 --- a/tests/ui/attributes/mixed_export_name_and_no_mangle.stderr +++ b/tests/ui/attributes/mixed_export_name_and_no_mangle.stderr @@ -1,8 +1,8 @@ -warning: `#[no_mangle]` attribute may not be used in combination with `#[export_name]` +warning: `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[export_name]` --> $DIR/mixed_export_name_and_no_mangle.rs:6:1 | LL | #[no_mangle] - | ^^^^^^^^^^^^ `#[no_mangle]` is ignored + | ^^^^^^^^^^^^ `#[unsafe(no_mangle)]` is ignored | note: `#[export_name]` takes precedence --> $DIR/mixed_export_name_and_no_mangle.rs:8:1 @@ -14,7 +14,7 @@ note: the lint level is defined here | LL | #![warn(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -help: remove the `#[no_mangle]` attribute +help: remove the `#[unsafe(no_mangle)]` attribute | LL - #[no_mangle] | diff --git a/tests/ui/attributes/nonterminal-expansion.rs b/tests/ui/attributes/nonterminal-expansion.rs index 1b2e92a3170..5ea30bb8627 100644 --- a/tests/ui/attributes/nonterminal-expansion.rs +++ b/tests/ui/attributes/nonterminal-expansion.rs @@ -6,6 +6,7 @@ macro_rules! pass_nonterminal { ($n:expr) => { #[repr(align($n))] //~^ ERROR expected unsuffixed literal, found `n!()` + //~^^ ERROR incorrect `repr(align)` attribute format: `align` expects a literal integer as argument [E0693] struct S; }; } @@ -15,6 +16,5 @@ macro_rules! n { } pass_nonterminal!(n!()); -//~^ ERROR incorrect `repr(align)` attribute format: `align` expects a literal integer as argument [E0693] fn main() {} diff --git a/tests/ui/attributes/nonterminal-expansion.stderr b/tests/ui/attributes/nonterminal-expansion.stderr index b640575d17d..cce5c453d52 100644 --- a/tests/ui/attributes/nonterminal-expansion.stderr +++ b/tests/ui/attributes/nonterminal-expansion.stderr @@ -10,10 +10,15 @@ LL | pass_nonterminal!(n!()); = note: this error originates in the macro `pass_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0693]: incorrect `repr(align)` attribute format: `align` expects a literal integer as argument - --> $DIR/nonterminal-expansion.rs:17:19 + --> $DIR/nonterminal-expansion.rs:7:22 | +LL | #[repr(align($n))] + | ^^ +... LL | pass_nonterminal!(n!()); - | ^ + | ----------------------- in this macro invocation + | + = note: this error originates in the macro `pass_nonterminal` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/attributes/repr-align-in-trait-issue-132391.rs b/tests/ui/attributes/repr-align-in-trait-issue-132391.rs new file mode 100644 index 00000000000..b3b79e93e9b --- /dev/null +++ b/tests/ui/attributes/repr-align-in-trait-issue-132391.rs @@ -0,0 +1,6 @@ +trait MyTrait { + #[repr(align)] //~ ERROR invalid `repr(align)` attribute: `align` needs an argument + fn myfun(); +} + +pub fn main() {} diff --git a/tests/ui/attributes/repr-align-in-trait-issue-132391.stderr b/tests/ui/attributes/repr-align-in-trait-issue-132391.stderr new file mode 100644 index 00000000000..4208b018f52 --- /dev/null +++ b/tests/ui/attributes/repr-align-in-trait-issue-132391.stderr @@ -0,0 +1,9 @@ +error[E0589]: invalid `repr(align)` attribute: `align` needs an argument + --> $DIR/repr-align-in-trait-issue-132391.rs:2:12 + | +LL | #[repr(align)] + | ^^^^^ help: supply an argument here: `align(...)` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0589`. diff --git a/tests/ui/attributes/rustc_confusables.stderr b/tests/ui/attributes/rustc_confusables.stderr index dc71d974daf..55c9219a08a 100644 --- a/tests/ui/attributes/rustc_confusables.stderr +++ b/tests/ui/attributes/rustc_confusables.stderr @@ -4,12 +4,6 @@ error: malformed `rustc_confusables` attribute input LL | #[rustc_confusables] | ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]` -error: attribute should be applied to an inherent method - --> $DIR/rustc_confusables.rs:45:1 - | -LL | #[rustc_confusables("blah")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: expected at least one confusable name --> $DIR/rustc_confusables.rs:30:5 | @@ -27,6 +21,12 @@ help: consider surrounding this with quotes LL | #[rustc_confusables("invalid_meta_item")] | + + +error: attribute should be applied to an inherent method + --> $DIR/rustc_confusables.rs:45:1 + | +LL | #[rustc_confusables("blah")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0599]: no method named `inser` found for struct `rustc_confusables_across_crate::BTreeSet` in the current scope --> $DIR/rustc_confusables.rs:12:7 | diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index 51808c5c7bc..8675f7a61c7 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -290,9 +290,14 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `xsavec` `xsaveopt` `xsaves` +`za128rs` +`za64rs` `zaamo` `zabha` +`zacas` `zalrsc` +`zama16b` +`zawrs` `zba` `zbb` `zbc` diff --git a/tests/ui/coercion/issue-26905.stderr b/tests/ui/coercion/issue-26905.stderr index 86f6a14cd10..17387ae992b 100644 --- a/tests/ui/coercion/issue-26905.stderr +++ b/tests/ui/coercion/issue-26905.stderr @@ -1,11 +1,16 @@ -error[E0375]: implementing the trait `CoerceUnsized` requires multiple coercions +error[E0375]: implementing `CoerceUnsized` does not allow multiple fields to be coerced --> $DIR/issue-26905.rs:16:40 | LL | impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<MyRc<U>> for MyRc<T>{ } - | ^^^^^^^^^^^^^^^^^^^^^^ requires multiple coercions + | ^^^^^^^^^^^^^^^^^^^^^^ | - = note: `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced - = note: currently, 2 fields need coercions: `_ptr` (`*const T` to `*const U`), `_boo` (`NotPhantomData<T>` to `NotPhantomData<U>`) +note: the trait `CoerceUnsized` may only be implemented when a single field is being coerced + --> $DIR/issue-26905.rs:12:5 + | +LL | _ptr: *const T, + | ^^^^^^^^^^^^^^ +LL | _boo: NotPhantomData<T>, + | ^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/coherence/coherence-unsafe-trait-object-impl.rs b/tests/ui/coherence/coherence-unsafe-trait-object-impl.rs deleted file mode 100644 index 16baf0958a6..00000000000 --- a/tests/ui/coherence/coherence-unsafe-trait-object-impl.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Check that unsafe trait object do not implement themselves -// automatically - -#![feature(dyn_compatible_for_dispatch)] - -trait Trait: Sized { - fn call(&self); -} - -fn takes_t<S: Trait>(s: S) { - s.call(); -} - -fn takes_t_obj(t: &dyn Trait) { - takes_t(t); //~ ERROR E0277 -} - -fn main() {} diff --git a/tests/ui/coherence/coherence-unsafe-trait-object-impl.stderr b/tests/ui/coherence/coherence-unsafe-trait-object-impl.stderr deleted file mode 100644 index 4f898ec127b..00000000000 --- a/tests/ui/coherence/coherence-unsafe-trait-object-impl.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0277]: the trait bound `&dyn Trait: Trait` is not satisfied - --> $DIR/coherence-unsafe-trait-object-impl.rs:15:13 - | -LL | takes_t(t); - | ------- ^ the trait `Trait` is not implemented for `&dyn Trait` - | | - | required by a bound introduced by this call - | -help: this trait has no implementations, consider adding one - --> $DIR/coherence-unsafe-trait-object-impl.rs:6:1 - | -LL | trait Trait: Sized { - | ^^^^^^^^^^^^^^^^^^ -note: required by a bound in `takes_t` - --> $DIR/coherence-unsafe-trait-object-impl.rs:10:15 - | -LL | fn takes_t<S: Trait>(s: S) { - | ^^^^^ required by this bound in `takes_t` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.rs b/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.rs index 5a67d34d6e5..dac5429f678 100644 --- a/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.rs +++ b/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.rs @@ -1,10 +1,7 @@ -//@ check-pass - // Regression test for #128176. Previously we would call `type_of` on the `1` anon const // before the anon const had been lowered and had the `type_of` fed with a result. #![feature(generic_const_exprs)] -#![feature(dyn_compatible_for_dispatch)] #![allow(incomplete_features)] trait X { @@ -13,6 +10,7 @@ trait X { const _: () = { fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {} + //~^ ERROR the trait `X` is not dyn compatible }; fn main() {} diff --git a/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.stderr b/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.stderr new file mode 100644 index 00000000000..7d563e3b605 --- /dev/null +++ b/tests/ui/const-generics/issues/cg-in-dyn-issue-128176.stderr @@ -0,0 +1,19 @@ +error[E0038]: the trait `X` is not dyn compatible + --> $DIR/cg-in-dyn-issue-128176.rs:12:24 + | +LL | fn f2<'a>(arg: Box<dyn X<Y<1> = &'a ()>>) {} + | ^^^^^^^^^^^^^^^^^^^^ `X` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/cg-in-dyn-issue-128176.rs:8:10 + | +LL | trait X { + | - this trait is not dyn compatible... +LL | type Y<const N: i16>; + | ^ ...because it contains the generic associated type `Y` + = help: consider moving `Y` to another trait + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/deprecation/deprecation-sanity.rs b/tests/ui/deprecation/deprecation-sanity.rs index 9ea75b68f81..d5b149b18ed 100644 --- a/tests/ui/deprecation/deprecation-sanity.rs +++ b/tests/ui/deprecation/deprecation-sanity.rs @@ -4,16 +4,16 @@ mod bogus_attribute_types_1 { #[deprecated(since = "a", note = "a", reason)] //~ ERROR unknown meta item 'reason' fn f1() { } - #[deprecated(since = "a", note)] //~ ERROR incorrect meta item + #[deprecated(since = "a", note)] //~ ERROR expected a quoted string literal fn f2() { } - #[deprecated(since, note = "a")] //~ ERROR incorrect meta item + #[deprecated(since, note = "a")] //~ ERROR expected a quoted string literal fn f3() { } - #[deprecated(since = "a", note(b))] //~ ERROR incorrect meta item + #[deprecated(since = "a", note(b))] //~ ERROR expected a quoted string literal fn f5() { } - #[deprecated(since(b), note = "a")] //~ ERROR incorrect meta item + #[deprecated(since(b), note = "a")] //~ ERROR expected a quoted string literal fn f6() { } #[deprecated(note = b"test")] //~ ERROR literal in `deprecated` value must be a string diff --git a/tests/ui/deprecation/deprecation-sanity.stderr b/tests/ui/deprecation/deprecation-sanity.stderr index 383212ad9b4..53047d40cb2 100644 --- a/tests/ui/deprecation/deprecation-sanity.stderr +++ b/tests/ui/deprecation/deprecation-sanity.stderr @@ -1,40 +1,28 @@ -error: multiple `deprecated` attributes - --> $DIR/deprecation-sanity.rs:27:1 - | -LL | #[deprecated(since = "a", note = "b")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/deprecation-sanity.rs:26:1 - | -LL | #[deprecated(since = "a", note = "b")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0541]: unknown meta item 'reason' --> $DIR/deprecation-sanity.rs:4:43 | LL | #[deprecated(since = "a", note = "a", reason)] | ^^^^^^ expected one of `since`, `note` -error[E0539]: incorrect meta item +error[E0539]: expected a quoted string literal --> $DIR/deprecation-sanity.rs:7:31 | LL | #[deprecated(since = "a", note)] | ^^^^ -error[E0539]: incorrect meta item +error[E0539]: expected a quoted string literal --> $DIR/deprecation-sanity.rs:10:18 | LL | #[deprecated(since, note = "a")] | ^^^^^ -error[E0539]: incorrect meta item +error[E0539]: expected a quoted string literal --> $DIR/deprecation-sanity.rs:13:31 | LL | #[deprecated(since = "a", note(b))] | ^^^^^^^ -error[E0539]: incorrect meta item +error[E0539]: expected a quoted string literal --> $DIR/deprecation-sanity.rs:16:18 | LL | #[deprecated(since(b), note = "a")] @@ -54,6 +42,18 @@ error[E0565]: item in `deprecated` must be a key/value pair LL | #[deprecated("test")] | ^^^^^^ +error: multiple `deprecated` attributes + --> $DIR/deprecation-sanity.rs:27:1 + | +LL | #[deprecated(since = "a", note = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/deprecation-sanity.rs:26:1 + | +LL | #[deprecated(since = "a", note = "b")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0538]: multiple 'since' items --> $DIR/deprecation-sanity.rs:30:27 | diff --git a/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs b/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs index 6653bd15ddd..c5433151a8f 100644 --- a/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs +++ b/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.rs @@ -3,7 +3,7 @@ // was a well-formed `MetaItem`. fn main() { - foo() + foo() //~ WARNING use of deprecated function `foo` } #[deprecated(note = test)] diff --git a/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr b/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr index a030da5068c..2ff8534b276 100644 --- a/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr +++ b/tests/ui/deprecation/issue-66340-deprecated-attr-non-meta-grammar.stderr @@ -9,5 +9,13 @@ help: surround the identifier with quotation marks to make it into a string lite LL | #[deprecated(note = "test")] | + + -error: aborting due to 1 previous error +warning: use of deprecated function `foo` + --> $DIR/issue-66340-deprecated-attr-non-meta-grammar.rs:6:5 + | +LL | foo() + | ^^^ + | + = note: `#[warn(deprecated)]` on by default + +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/deriving/deriving-coerce-pointee-neg.rs b/tests/ui/deriving/deriving-coerce-pointee-neg.rs index 6577500d8eb..2713366945e 100644 --- a/tests/ui/deriving/deriving-coerce-pointee-neg.rs +++ b/tests/ui/deriving/deriving-coerce-pointee-neg.rs @@ -142,4 +142,27 @@ struct TryToWipeRepr<'a, #[pointee] T: ?Sized> { ptr: &'a T, } +#[repr(transparent)] +#[derive(CoercePointee)] +//~^ ERROR for `RcWithId<T>` to have a valid implementation of `CoerceUnsized`, it must be possible to coerce the field of type `Rc<(i32, Box<T>)>` +struct RcWithId<T: ?Sized> { + inner: std::rc::Rc<(i32, Box<T>)>, +} + +#[repr(transparent)] +#[derive(CoercePointee)] +//~^ ERROR implementing `CoerceUnsized` does not allow multiple fields to be coerced +struct MoreThanOneField<T: ?Sized> { + //~^ ERROR transparent struct needs at most one field with non-trivial size or alignment, but has 2 + inner1: Box<T>, + inner2: Box<T>, +} + +struct NotCoercePointeeData<T: ?Sized>(T); + +#[repr(transparent)] +#[derive(CoercePointee)] +//~^ ERROR for `UsingNonCoercePointeeData<T>` to have a valid implementation of `CoerceUnsized`, it must be possible to coerce the field of type `NotCoercePointeeData<T>` +struct UsingNonCoercePointeeData<T: ?Sized>(NotCoercePointeeData<T>); + fn main() {} diff --git a/tests/ui/deriving/deriving-coerce-pointee-neg.stderr b/tests/ui/deriving/deriving-coerce-pointee-neg.stderr index 999214bfa9f..d3d73132078 100644 --- a/tests/ui/deriving/deriving-coerce-pointee-neg.stderr +++ b/tests/ui/deriving/deriving-coerce-pointee-neg.stderr @@ -118,7 +118,55 @@ error[E0802]: `derive(CoercePointee)` is only applicable to `struct` with `repr( LL | struct TryToWipeRepr<'a, #[pointee] T: ?Sized> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 17 previous errors +error: for `RcWithId<T>` to have a valid implementation of `CoerceUnsized`, it must be possible to coerce the field of type `Rc<(i32, Box<T>)>` + --> $DIR/deriving-coerce-pointee-neg.rs:146:10 + | +LL | #[derive(CoercePointee)] + | ^^^^^^^^^^^^^ +... +LL | inner: std::rc::Rc<(i32, Box<T>)>, + | --------------------------------- `Rc<(i32, Box<T>)>` must be a pointer, reference, or smart pointer that is allowed to be unsized + | + = note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0375]: implementing `CoerceUnsized` does not allow multiple fields to be coerced + --> $DIR/deriving-coerce-pointee-neg.rs:153:10 + | +LL | #[derive(CoercePointee)] + | ^^^^^^^^^^^^^ + | +note: the trait `CoerceUnsized` may only be implemented when a single field is being coerced + --> $DIR/deriving-coerce-pointee-neg.rs:157:5 + | +LL | inner1: Box<T>, + | ^^^^^^^^^^^^^^ +LL | inner2: Box<T>, + | ^^^^^^^^^^^^^^ + = note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: for `UsingNonCoercePointeeData<T>` to have a valid implementation of `CoerceUnsized`, it must be possible to coerce the field of type `NotCoercePointeeData<T>` + --> $DIR/deriving-coerce-pointee-neg.rs:164:10 + | +LL | #[derive(CoercePointee)] + | ^^^^^^^^^^^^^ +LL | +LL | struct UsingNonCoercePointeeData<T: ?Sized>(NotCoercePointeeData<T>); + | ----------------------- `NotCoercePointeeData<T>` must be a pointer, reference, or smart pointer that is allowed to be unsized + | + = note: this error originates in the derive macro `CoercePointee` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0690]: transparent struct needs at most one field with non-trivial size or alignment, but has 2 + --> $DIR/deriving-coerce-pointee-neg.rs:155:1 + | +LL | struct MoreThanOneField<T: ?Sized> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ needs at most one field with non-trivial size or alignment, but has 2 +LL | +LL | inner1: Box<T>, + | -------------- this field has non-zero size or requires alignment +LL | inner2: Box<T>, + | -------------- this field has non-zero size or requires alignment + +error: aborting due to 21 previous errors -Some errors have detailed explanations: E0392, E0802. -For more information about an error, try `rustc --explain E0392`. +Some errors have detailed explanations: E0375, E0392, E0690, E0802. +For more information about an error, try `rustc --explain E0375`. diff --git a/tests/ui/dropck/dropck-after-failed-type-lowering.rs b/tests/ui/dropck/dropck-after-failed-type-lowering.rs new file mode 100644 index 00000000000..2441e26fec9 --- /dev/null +++ b/tests/ui/dropck/dropck-after-failed-type-lowering.rs @@ -0,0 +1,14 @@ +// Regression test for #137329 + +trait B { + type C<'a>; + fn d<E>() -> F<E> { + todo!() + } +} +struct F<G> { + h: Option<<G as B>::C>, + //~^ ERROR missing generics for associated type `B::C` +} + +fn main() {} diff --git a/tests/ui/dropck/dropck-after-failed-type-lowering.stderr b/tests/ui/dropck/dropck-after-failed-type-lowering.stderr new file mode 100644 index 00000000000..56ea72de0c5 --- /dev/null +++ b/tests/ui/dropck/dropck-after-failed-type-lowering.stderr @@ -0,0 +1,19 @@ +error[E0107]: missing generics for associated type `B::C` + --> $DIR/dropck-after-failed-type-lowering.rs:10:25 + | +LL | h: Option<<G as B>::C>, + | ^ expected 1 lifetime argument + | +note: associated type defined here, with 1 lifetime parameter: `'a` + --> $DIR/dropck-after-failed-type-lowering.rs:4:10 + | +LL | type C<'a>; + | ^ -- +help: add missing lifetime argument + | +LL | h: Option<<G as B>::C<'a>>, + | ++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0107`. diff --git a/tests/ui/dyn-compatibility/associated-consts.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/associated-consts.dyn_compatible_for_dispatch.stderr deleted file mode 100644 index 704d833f00b..00000000000 --- a/tests/ui/dyn-compatibility/associated-consts.dyn_compatible_for_dispatch.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/associated-consts.rs:14:5 - | -LL | t - | ^ `Bar` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/associated-consts.rs:9:11 - | -LL | trait Bar { - | --- this trait is not dyn compatible... -LL | const X: usize; - | ^ ...because it contains this associated `const` - = help: consider moving `X` to another trait - = note: required for the cast from `&T` to `&dyn Bar` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/associated-consts.rs b/tests/ui/dyn-compatibility/associated-consts.rs index fc7b372b782..10d151d9a8b 100644 --- a/tests/ui/dyn-compatibility/associated-consts.rs +++ b/tests/ui/dyn-compatibility/associated-consts.rs @@ -1,16 +1,12 @@ // Check that we correctly prevent users from making trait objects // from traits with associated consts. -// -//@ revisions: curr dyn_compatible_for_dispatch - -#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))] trait Bar { const X: usize; } fn make_bar<T:Bar>(t: &T) -> &dyn Bar { - //[curr]~^ ERROR E0038 + //~^ ERROR E0038 t //~^ ERROR E0038 } diff --git a/tests/ui/dyn-compatibility/generics.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/associated-consts.stderr index b3565a766fe..beaf263af07 100644 --- a/tests/ui/dyn-compatibility/generics.dyn_compatible_for_dispatch.stderr +++ b/tests/ui/dyn-compatibility/associated-consts.stderr @@ -1,35 +1,34 @@ error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/generics.rs:20:5 + --> $DIR/associated-consts.rs:8:31 | -LL | t - | ^ `Bar` is not dyn compatible +LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar { + | ^^^^^^^ `Bar` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/generics.rs:10:8 + --> $DIR/associated-consts.rs:5:11 | LL | trait Bar { | --- this trait is not dyn compatible... -LL | fn bar<T>(&self, t: T); - | ^^^ ...because method `bar` has generic type parameters - = help: consider moving `bar` to another trait - = note: required for the cast from `&T` to `&dyn Bar` +LL | const X: usize; + | ^ ...because it contains this associated `const` + = help: consider moving `X` to another trait error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/generics.rs:27:5 + --> $DIR/associated-consts.rs:10:5 | -LL | t as &dyn Bar +LL | t | ^ `Bar` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/generics.rs:10:8 + --> $DIR/associated-consts.rs:5:11 | LL | trait Bar { | --- this trait is not dyn compatible... -LL | fn bar<T>(&self, t: T); - | ^^^ ...because method `bar` has generic type parameters - = help: consider moving `bar` to another trait +LL | const X: usize; + | ^ ...because it contains this associated `const` + = help: consider moving `X` to another trait = note: required for the cast from `&T` to `&dyn Bar` error: aborting due to 2 previous errors diff --git a/tests/ui/dyn-compatibility/generics.rs b/tests/ui/dyn-compatibility/generics.rs index b51555aa500..dcce17f925b 100644 --- a/tests/ui/dyn-compatibility/generics.rs +++ b/tests/ui/dyn-compatibility/generics.rs @@ -1,9 +1,6 @@ // Check that we correctly prevent users from making trait objects // from traits with generic methods, unless `where Self : Sized` is // present. -//@ revisions: curr dyn_compatible_for_dispatch - -#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))] trait Bar { @@ -16,18 +13,16 @@ trait Quux { } fn make_bar<T:Bar>(t: &T) -> &dyn Bar { - //[curr]~^ ERROR E0038 + //~^ ERROR E0038 t - //[dyn_compatible_for_dispatch]~^ ERROR E0038 - //[curr]~^^ ERROR E0038 + //~^ ERROR E0038 } fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar { - //[curr]~^ ERROR E0038 + //~^ ERROR E0038 t as &dyn Bar - //[dyn_compatible_for_dispatch]~^ ERROR E0038 - //[curr]~^^ ERROR E0038 - //[curr]~| ERROR E0038 + //~^ ERROR E0038 + //~| ERROR E0038 } fn make_quux<T:Quux>(t: &T) -> &dyn Quux { diff --git a/tests/ui/dyn-compatibility/generics.stderr b/tests/ui/dyn-compatibility/generics.stderr new file mode 100644 index 00000000000..c0193010541 --- /dev/null +++ b/tests/ui/dyn-compatibility/generics.stderr @@ -0,0 +1,85 @@ +error[E0038]: the trait `Bar` is not dyn compatible + --> $DIR/generics.rs:15:31 + | +LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar { + | ^^^^^^^ `Bar` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/generics.rs:7:8 + | +LL | trait Bar { + | --- this trait is not dyn compatible... +LL | fn bar<T>(&self, t: T); + | ^^^ ...because method `bar` has generic type parameters + = help: consider moving `bar` to another trait + +error[E0038]: the trait `Bar` is not dyn compatible + --> $DIR/generics.rs:21:40 + | +LL | fn make_bar_explicit<T:Bar>(t: &T) -> &dyn Bar { + | ^^^^^^^ `Bar` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/generics.rs:7:8 + | +LL | trait Bar { + | --- this trait is not dyn compatible... +LL | fn bar<T>(&self, t: T); + | ^^^ ...because method `bar` has generic type parameters + = help: consider moving `bar` to another trait + +error[E0038]: the trait `Bar` is not dyn compatible + --> $DIR/generics.rs:17:5 + | +LL | t + | ^ `Bar` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/generics.rs:7:8 + | +LL | trait Bar { + | --- this trait is not dyn compatible... +LL | fn bar<T>(&self, t: T); + | ^^^ ...because method `bar` has generic type parameters + = help: consider moving `bar` to another trait + = note: required for the cast from `&T` to `&dyn Bar` + +error[E0038]: the trait `Bar` is not dyn compatible + --> $DIR/generics.rs:23:10 + | +LL | t as &dyn Bar + | ^^^^^^^^ `Bar` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/generics.rs:7:8 + | +LL | trait Bar { + | --- this trait is not dyn compatible... +LL | fn bar<T>(&self, t: T); + | ^^^ ...because method `bar` has generic type parameters + = help: consider moving `bar` to another trait + +error[E0038]: the trait `Bar` is not dyn compatible + --> $DIR/generics.rs:23:5 + | +LL | t as &dyn Bar + | ^ `Bar` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/generics.rs:7:8 + | +LL | trait Bar { + | --- this trait is not dyn compatible... +LL | fn bar<T>(&self, t: T); + | ^^^ ...because method `bar` has generic type parameters + = help: consider moving `bar` to another trait + = note: required for the cast from `&T` to `&dyn Bar` + +error: aborting due to 5 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/mentions-Self.curr.stderr b/tests/ui/dyn-compatibility/mentions-Self.curr.stderr index 2d3fe5ce636..6d1ae90152e 100644 --- a/tests/ui/dyn-compatibility/mentions-Self.curr.stderr +++ b/tests/ui/dyn-compatibility/mentions-Self.curr.stderr @@ -1,12 +1,12 @@ error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/mentions-Self.rs:22:31 + --> $DIR/mentions-Self.rs:18:31 | LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar { | ^^^^^^^ `Bar` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/mentions-Self.rs:11:22 + --> $DIR/mentions-Self.rs:7:22 | LL | trait Bar { | --- this trait is not dyn compatible... @@ -15,14 +15,14 @@ LL | fn bar(&self, x: &Self); = help: consider moving `bar` to another trait error[E0038]: the trait `Baz` is not dyn compatible - --> $DIR/mentions-Self.rs:28:31 + --> $DIR/mentions-Self.rs:24:31 | LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz { | ^^^^^^^ `Baz` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/mentions-Self.rs:15:22 + --> $DIR/mentions-Self.rs:11:22 | LL | trait Baz { | --- this trait is not dyn compatible... @@ -31,14 +31,14 @@ LL | fn baz(&self) -> Self; = help: consider moving `baz` to another trait error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/mentions-Self.rs:24:5 + --> $DIR/mentions-Self.rs:20:5 | LL | t | ^ `Bar` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/mentions-Self.rs:11:22 + --> $DIR/mentions-Self.rs:7:22 | LL | trait Bar { | --- this trait is not dyn compatible... @@ -48,14 +48,14 @@ LL | fn bar(&self, x: &Self); = note: required for the cast from `&T` to `&dyn Bar` error[E0038]: the trait `Baz` is not dyn compatible - --> $DIR/mentions-Self.rs:30:5 + --> $DIR/mentions-Self.rs:26:5 | LL | t | ^ `Baz` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/mentions-Self.rs:15:22 + --> $DIR/mentions-Self.rs:11:22 | LL | trait Baz { | --- this trait is not dyn compatible... diff --git a/tests/ui/dyn-compatibility/mentions-Self.rs b/tests/ui/dyn-compatibility/mentions-Self.rs index 84c229e252d..ce210f4776f 100644 --- a/tests/ui/dyn-compatibility/mentions-Self.rs +++ b/tests/ui/dyn-compatibility/mentions-Self.rs @@ -1,10 +1,6 @@ // Check that we correctly prevent users from making trait objects // form traits that make use of `Self` in an argument or return // position, unless `where Self : Sized` is present.. -// -//@ revisions: curr dyn_compatible_for_dispatch - -#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))] trait Bar { @@ -20,13 +16,13 @@ trait Quux { } fn make_bar<T:Bar>(t: &T) -> &dyn Bar { - //[curr]~^ ERROR E0038 + //~^ ERROR E0038 t //~^ ERROR E0038 } fn make_baz<T:Baz>(t: &T) -> &dyn Baz { - //[curr]~^ ERROR E0038 + //~^ ERROR E0038 t //~^ ERROR E0038 } diff --git a/tests/ui/dyn-compatibility/mentions-Self.stderr b/tests/ui/dyn-compatibility/mentions-Self.stderr new file mode 100644 index 00000000000..6d1ae90152e --- /dev/null +++ b/tests/ui/dyn-compatibility/mentions-Self.stderr @@ -0,0 +1,69 @@ +error[E0038]: the trait `Bar` is not dyn compatible + --> $DIR/mentions-Self.rs:18:31 + | +LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar { + | ^^^^^^^ `Bar` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/mentions-Self.rs:7:22 + | +LL | trait Bar { + | --- this trait is not dyn compatible... +LL | fn bar(&self, x: &Self); + | ^^^^^ ...because method `bar` references the `Self` type in this parameter + = help: consider moving `bar` to another trait + +error[E0038]: the trait `Baz` is not dyn compatible + --> $DIR/mentions-Self.rs:24:31 + | +LL | fn make_baz<T:Baz>(t: &T) -> &dyn Baz { + | ^^^^^^^ `Baz` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/mentions-Self.rs:11:22 + | +LL | trait Baz { + | --- this trait is not dyn compatible... +LL | fn baz(&self) -> Self; + | ^^^^ ...because method `baz` references the `Self` type in its return type + = help: consider moving `baz` to another trait + +error[E0038]: the trait `Bar` is not dyn compatible + --> $DIR/mentions-Self.rs:20:5 + | +LL | t + | ^ `Bar` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/mentions-Self.rs:7:22 + | +LL | trait Bar { + | --- this trait is not dyn compatible... +LL | fn bar(&self, x: &Self); + | ^^^^^ ...because method `bar` references the `Self` type in this parameter + = help: consider moving `bar` to another trait + = note: required for the cast from `&T` to `&dyn Bar` + +error[E0038]: the trait `Baz` is not dyn compatible + --> $DIR/mentions-Self.rs:26:5 + | +LL | t + | ^ `Baz` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/mentions-Self.rs:11:22 + | +LL | trait Baz { + | --- this trait is not dyn compatible... +LL | fn baz(&self) -> Self; + | ^^^^ ...because method `baz` references the `Self` type in its return type + = help: consider moving `baz` to another trait + = note: required for the cast from `&T` to `&dyn Baz` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/no-static.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/no-static.dyn_compatible_for_dispatch.stderr deleted file mode 100644 index d5ad4510334..00000000000 --- a/tests/ui/dyn-compatibility/no-static.dyn_compatible_for_dispatch.stderr +++ /dev/null @@ -1,28 +0,0 @@ -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/no-static.rs:22:27 - | -LL | let b: Box<dyn Foo> = Box::new(Bar); - | ^^^^^^^^^^^^^ `Foo` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/no-static.rs:9:8 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn foo() {} - | ^^^ ...because associated function `foo` has no `self` parameter - = help: only type `Bar` implements `Foo`; consider using it directly instead. - = note: required for the cast from `Box<Bar>` to `Box<dyn Foo>` -help: consider turning `foo` into a method by giving it a `&self` argument - | -LL | fn foo(&self) {} - | +++++ -help: alternatively, consider constraining `foo` so it does not apply to trait objects - | -LL | fn foo() where Self: Sized {} - | +++++++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/no-static.rs b/tests/ui/dyn-compatibility/no-static.rs index 54af16fe18e..9bd87161972 100644 --- a/tests/ui/dyn-compatibility/no-static.rs +++ b/tests/ui/dyn-compatibility/no-static.rs @@ -1,16 +1,12 @@ // Check that we correctly prevent users from making trait objects // from traits with static methods. -// -//@ revisions: curr dyn_compatible_for_dispatch - -#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))] trait Foo { fn foo() {} } fn diverges() -> Box<dyn Foo> { - //[curr]~^ ERROR E0038 + //~^ ERROR E0038 loop { } } @@ -21,5 +17,5 @@ impl Foo for Bar {} fn main() { let b: Box<dyn Foo> = Box::new(Bar); //~^ ERROR E0038 - //[curr]~| ERROR E0038 + //~| ERROR E0038 } diff --git a/tests/ui/dyn-compatibility/no-static.stderr b/tests/ui/dyn-compatibility/no-static.stderr new file mode 100644 index 00000000000..814ab0d53c3 --- /dev/null +++ b/tests/ui/dyn-compatibility/no-static.stderr @@ -0,0 +1,76 @@ +error[E0038]: the trait `Foo` is not dyn compatible + --> $DIR/no-static.rs:8:22 + | +LL | fn diverges() -> Box<dyn Foo> { + | ^^^^^^^ `Foo` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/no-static.rs:5:8 + | +LL | trait Foo { + | --- this trait is not dyn compatible... +LL | fn foo() {} + | ^^^ ...because associated function `foo` has no `self` parameter + = help: only type `Bar` implements `Foo`; consider using it directly instead. +help: consider turning `foo` into a method by giving it a `&self` argument + | +LL | fn foo(&self) {} + | +++++ +help: alternatively, consider constraining `foo` so it does not apply to trait objects + | +LL | fn foo() where Self: Sized {} + | +++++++++++++++++ + +error[E0038]: the trait `Foo` is not dyn compatible + --> $DIR/no-static.rs:18:12 + | +LL | let b: Box<dyn Foo> = Box::new(Bar); + | ^^^^^^^^^^^^ `Foo` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/no-static.rs:5:8 + | +LL | trait Foo { + | --- this trait is not dyn compatible... +LL | fn foo() {} + | ^^^ ...because associated function `foo` has no `self` parameter + = help: only type `Bar` implements `Foo`; consider using it directly instead. +help: consider turning `foo` into a method by giving it a `&self` argument + | +LL | fn foo(&self) {} + | +++++ +help: alternatively, consider constraining `foo` so it does not apply to trait objects + | +LL | fn foo() where Self: Sized {} + | +++++++++++++++++ + +error[E0038]: the trait `Foo` is not dyn compatible + --> $DIR/no-static.rs:18:27 + | +LL | let b: Box<dyn Foo> = Box::new(Bar); + | ^^^^^^^^^^^^^ `Foo` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/no-static.rs:5:8 + | +LL | trait Foo { + | --- this trait is not dyn compatible... +LL | fn foo() {} + | ^^^ ...because associated function `foo` has no `self` parameter + = help: only type `Bar` implements `Foo`; consider using it directly instead. + = note: required for the cast from `Box<Bar>` to `Box<dyn Foo>` +help: consider turning `foo` into a method by giving it a `&self` argument + | +LL | fn foo(&self) {} + | +++++ +help: alternatively, consider constraining `foo` so it does not apply to trait objects + | +LL | fn foo() where Self: Sized {} + | +++++++++++++++++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/sized-2.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/sized-2.dyn_compatible_for_dispatch.stderr deleted file mode 100644 index 1fbc10c0c3f..00000000000 --- a/tests/ui/dyn-compatibility/sized-2.dyn_compatible_for_dispatch.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/sized-2.rs:16:5 - | -LL | t - | ^ `Bar` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/sized-2.rs:9:18 - | -LL | trait Bar - | --- this trait is not dyn compatible... -LL | where Self : Sized - | ^^^^^ ...because it requires `Self: Sized` - = note: required for the cast from `&T` to `&dyn Bar` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/sized-2.rs b/tests/ui/dyn-compatibility/sized-2.rs index f5edd287f24..f61d49ee8df 100644 --- a/tests/ui/dyn-compatibility/sized-2.rs +++ b/tests/ui/dyn-compatibility/sized-2.rs @@ -1,9 +1,5 @@ // Check that we correctly prevent users from making trait objects // from traits where `Self : Sized`. -// -//@ revisions: curr dyn_compatible_for_dispatch - -#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))] trait Bar where Self : Sized @@ -12,7 +8,7 @@ trait Bar } fn make_bar<T:Bar>(t: &T) -> &dyn Bar { - //[curr]~^ ERROR E0038 + //~^ ERROR E0038 t //~^ ERROR E0038 } diff --git a/tests/ui/dyn-compatibility/mentions-Self.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/sized-2.stderr index 91c26a86025..1834d906bb8 100644 --- a/tests/ui/dyn-compatibility/mentions-Self.dyn_compatible_for_dispatch.stderr +++ b/tests/ui/dyn-compatibility/sized-2.stderr @@ -1,36 +1,33 @@ error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/mentions-Self.rs:24:5 + --> $DIR/sized-2.rs:10:31 | -LL | t - | ^ `Bar` is not dyn compatible +LL | fn make_bar<T:Bar>(t: &T) -> &dyn Bar { + | ^^^^^^^ `Bar` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/mentions-Self.rs:11:22 + --> $DIR/sized-2.rs:5:18 | -LL | trait Bar { +LL | trait Bar | --- this trait is not dyn compatible... -LL | fn bar(&self, x: &Self); - | ^^^^^ ...because method `bar` references the `Self` type in this parameter - = help: consider moving `bar` to another trait - = note: required for the cast from `&T` to `&dyn Bar` +LL | where Self : Sized + | ^^^^^ ...because it requires `Self: Sized` -error[E0038]: the trait `Baz` is not dyn compatible - --> $DIR/mentions-Self.rs:30:5 +error[E0038]: the trait `Bar` is not dyn compatible + --> $DIR/sized-2.rs:12:5 | LL | t - | ^ `Baz` is not dyn compatible + | ^ `Bar` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/mentions-Self.rs:15:22 + --> $DIR/sized-2.rs:5:18 | -LL | trait Baz { +LL | trait Bar | --- this trait is not dyn compatible... -LL | fn baz(&self) -> Self; - | ^^^^ ...because method `baz` references the `Self` type in its return type - = help: consider moving `baz` to another trait - = note: required for the cast from `&T` to `&dyn Baz` +LL | where Self : Sized + | ^^^^^ ...because it requires `Self: Sized` + = note: required for the cast from `&T` to `&dyn Bar` error: aborting due to 2 previous errors diff --git a/tests/ui/dyn-compatibility/sized.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/sized.dyn_compatible_for_dispatch.stderr deleted file mode 100644 index 350c8992c6f..00000000000 --- a/tests/ui/dyn-compatibility/sized.dyn_compatible_for_dispatch.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0038]: the trait `Bar` is not dyn compatible - --> $DIR/sized.rs:14:5 - | -LL | t - | ^ `Bar` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/sized.rs:8:12 - | -LL | trait Bar: Sized { - | --- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - = note: required for the cast from `&T` to `&dyn Bar` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/sized.rs b/tests/ui/dyn-compatibility/sized.rs index 4c4fe3f8f25..eb5279c17e6 100644 --- a/tests/ui/dyn-compatibility/sized.rs +++ b/tests/ui/dyn-compatibility/sized.rs @@ -1,16 +1,12 @@ // Check that we correctly prevent users from making trait objects // from traits where `Self : Sized`. -// -//@ revisions: curr dyn_compatible_for_dispatch - -#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))] trait Bar: Sized { fn bar<T>(&self, t: T); } fn make_bar<T: Bar>(t: &T) -> &dyn Bar { - //[curr]~^ ERROR E0038 + //~^ ERROR E0038 t //~^ ERROR E0038 } diff --git a/tests/ui/dyn-compatibility/sized.stderr b/tests/ui/dyn-compatibility/sized.stderr new file mode 100644 index 00000000000..c66e299cf6f --- /dev/null +++ b/tests/ui/dyn-compatibility/sized.stderr @@ -0,0 +1,34 @@ +error[E0038]: the trait `Bar` is not dyn compatible + --> $DIR/sized.rs:8:32 + | +LL | fn make_bar<T: Bar>(t: &T) -> &dyn Bar { + | ^^^^^^^ `Bar` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/sized.rs:4:12 + | +LL | trait Bar: Sized { + | --- ^^^^^ ...because it requires `Self: Sized` + | | + | this trait is not dyn compatible... + +error[E0038]: the trait `Bar` is not dyn compatible + --> $DIR/sized.rs:10:5 + | +LL | t + | ^ `Bar` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/sized.rs:4:12 + | +LL | trait Bar: Sized { + | --- ^^^^^ ...because it requires `Self: Sized` + | | + | this trait is not dyn compatible... + = note: required for the cast from `&T` to `&dyn Bar` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/taint-const-eval.dyn_compatible_for_dispatch.stderr b/tests/ui/dyn-compatibility/taint-const-eval.dyn_compatible_for_dispatch.stderr deleted file mode 100644 index 0bc7d0b14d3..00000000000 --- a/tests/ui/dyn-compatibility/taint-const-eval.dyn_compatible_for_dispatch.stderr +++ /dev/null @@ -1,27 +0,0 @@ -error[E0038]: the trait `Qux` is not dyn compatible - --> $DIR/taint-const-eval.rs:11:33 - | -LL | static FOO: &(dyn Qux + Sync) = "desc"; - | ^^^^^^ `Qux` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/taint-const-eval.rs:8:8 - | -LL | trait Qux { - | --- this trait is not dyn compatible... -LL | fn bar(); - | ^^^ ...because associated function `bar` has no `self` parameter - = note: required for the cast from `&'static str` to `&'static (dyn Qux + Sync + 'static)` -help: consider turning `bar` into a method by giving it a `&self` argument - | -LL | fn bar(&self); - | +++++ -help: alternatively, consider constraining `bar` so it does not apply to trait objects - | -LL | fn bar() where Self: Sized; - | +++++++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-compatibility/taint-const-eval.rs b/tests/ui/dyn-compatibility/taint-const-eval.rs index 2feae58080b..7ea763e1846 100644 --- a/tests/ui/dyn-compatibility/taint-const-eval.rs +++ b/tests/ui/dyn-compatibility/taint-const-eval.rs @@ -1,16 +1,12 @@ // Test that we do not attempt to create dyn-incompatible trait objects in const eval. -//@ revisions: curr dyn_compatible_for_dispatch - -#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))] - trait Qux { fn bar(); } static FOO: &(dyn Qux + Sync) = "desc"; //~^ the trait `Qux` is not dyn compatible -//[curr]~| the trait `Qux` is not dyn compatible -//[curr]~| the trait `Qux` is not dyn compatible +//~| the trait `Qux` is not dyn compatible +//~| the trait `Qux` is not dyn compatible fn main() {} diff --git a/tests/ui/dyn-compatibility/taint-const-eval.stderr b/tests/ui/dyn-compatibility/taint-const-eval.stderr new file mode 100644 index 00000000000..942c20db6ce --- /dev/null +++ b/tests/ui/dyn-compatibility/taint-const-eval.stderr @@ -0,0 +1,74 @@ +error[E0038]: the trait `Qux` is not dyn compatible + --> $DIR/taint-const-eval.rs:7:15 + | +LL | static FOO: &(dyn Qux + Sync) = "desc"; + | ^^^^^^^^^^^^^^ `Qux` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/taint-const-eval.rs:4:8 + | +LL | trait Qux { + | --- this trait is not dyn compatible... +LL | fn bar(); + | ^^^ ...because associated function `bar` has no `self` parameter +help: consider turning `bar` into a method by giving it a `&self` argument + | +LL | fn bar(&self); + | +++++ +help: alternatively, consider constraining `bar` so it does not apply to trait objects + | +LL | fn bar() where Self: Sized; + | +++++++++++++++++ + +error[E0038]: the trait `Qux` is not dyn compatible + --> $DIR/taint-const-eval.rs:7:33 + | +LL | static FOO: &(dyn Qux + Sync) = "desc"; + | ^^^^^^ `Qux` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/taint-const-eval.rs:4:8 + | +LL | trait Qux { + | --- this trait is not dyn compatible... +LL | fn bar(); + | ^^^ ...because associated function `bar` has no `self` parameter + = note: required for the cast from `&'static str` to `&'static (dyn Qux + Sync + 'static)` +help: consider turning `bar` into a method by giving it a `&self` argument + | +LL | fn bar(&self); + | +++++ +help: alternatively, consider constraining `bar` so it does not apply to trait objects + | +LL | fn bar() where Self: Sized; + | +++++++++++++++++ + +error[E0038]: the trait `Qux` is not dyn compatible + --> $DIR/taint-const-eval.rs:7:15 + | +LL | static FOO: &(dyn Qux + Sync) = "desc"; + | ^^^^^^^^^^^^^^ `Qux` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/taint-const-eval.rs:4:8 + | +LL | trait Qux { + | --- this trait is not dyn compatible... +LL | fn bar(); + | ^^^ ...because associated function `bar` has no `self` parameter + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider turning `bar` into a method by giving it a `&self` argument + | +LL | fn bar(&self); + | +++++ +help: alternatively, consider constraining `bar` so it does not apply to trait objects + | +LL | fn bar() where Self: Sized; + | +++++++++++++++++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/error-codes/E0084.stderr b/tests/ui/error-codes/E0084.stderr index f1fbe6c2532..3df2e4a322b 100644 --- a/tests/ui/error-codes/E0084.stderr +++ b/tests/ui/error-codes/E0084.stderr @@ -1,8 +1,8 @@ error[E0084]: unsupported representation for zero-variant enum - --> $DIR/E0084.rs:1:1 + --> $DIR/E0084.rs:1:8 | LL | #[repr(i32)] - | ^^^^^^^^^^^^ + | ^^^ LL | enum Foo {} | -------- zero-variant enum diff --git a/tests/ui/error-codes/E0094.rs b/tests/ui/error-codes/E0094.rs index da59d3decac..2067179b26a 100644 --- a/tests/ui/error-codes/E0094.rs +++ b/tests/ui/error-codes/E0094.rs @@ -1,10 +1,7 @@ #![feature(intrinsics)] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -fn size_of<T, U>() -> usize { - //~^ ERROR E0094 - loop {} -} +fn size_of<T, U>() -> usize; +//~^ ERROR E0094 fn main() {} diff --git a/tests/ui/error-codes/E0094.stderr b/tests/ui/error-codes/E0094.stderr index e45cc0ea063..da29987f8b1 100644 --- a/tests/ui/error-codes/E0094.stderr +++ b/tests/ui/error-codes/E0094.stderr @@ -1,7 +1,7 @@ error[E0094]: intrinsic has wrong number of type parameters: found 2, expected 1 - --> $DIR/E0094.rs:5:11 + --> $DIR/E0094.rs:4:11 | -LL | fn size_of<T, U>() -> usize { +LL | fn size_of<T, U>() -> usize; | ^^^^^^ expected 1 type parameter error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0308.rs b/tests/ui/error-codes/E0308.rs index f8f93d49a8e..c27d4245471 100644 --- a/tests/ui/error-codes/E0308.rs +++ b/tests/ui/error-codes/E0308.rs @@ -2,10 +2,7 @@ #![feature(rustc_attrs)] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -fn size_of<T>() { - //~^ ERROR E0308 - loop {} -} +fn size_of<T>(); +//~^ ERROR E0308 fn main() {} diff --git a/tests/ui/error-codes/E0308.stderr b/tests/ui/error-codes/E0308.stderr index 77e5c06e06a..a1077481a81 100644 --- a/tests/ui/error-codes/E0308.stderr +++ b/tests/ui/error-codes/E0308.stderr @@ -1,7 +1,7 @@ error[E0308]: intrinsic has wrong type - --> $DIR/E0308.rs:6:16 + --> $DIR/E0308.rs:5:16 | -LL | fn size_of<T>() { +LL | fn size_of<T>(); | ^ expected `usize`, found `()` | = note: expected signature `fn() -> usize` diff --git a/tests/ui/error-codes/E0374.stderr b/tests/ui/error-codes/E0374.stderr index 71eec4c16fd..95e6b95e0d5 100644 --- a/tests/ui/error-codes/E0374.stderr +++ b/tests/ui/error-codes/E0374.stderr @@ -6,7 +6,7 @@ LL | struct Foo<T: ?Sized> { | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` -error[E0374]: the trait `CoerceUnsized` may only be implemented for a coercion between structures +error[E0374]: implementing `CoerceUnsized` requires a field to be coerced --> $DIR/E0374.rs:8:1 | LL | / impl<T, U> CoerceUnsized<Foo<U>> for Foo<T> diff --git a/tests/ui/error-codes/E0375.stderr b/tests/ui/error-codes/E0375.stderr index af720bd40e7..a797ba9d461 100644 --- a/tests/ui/error-codes/E0375.stderr +++ b/tests/ui/error-codes/E0375.stderr @@ -23,14 +23,19 @@ help: the `Box` type always has a statically known size and allocates its conten LL | b: Box<T>, | ++++ + -error[E0375]: implementing the trait `CoerceUnsized` requires multiple coercions +error[E0375]: implementing `CoerceUnsized` does not allow multiple fields to be coerced --> $DIR/E0375.rs:10:12 | LL | impl<T, U> CoerceUnsized<Foo<U, T>> for Foo<T, U> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ requires multiple coercions + | ^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: `CoerceUnsized` may only be implemented for a coercion between structures with one field being coerced - = note: currently, 2 fields need coercions: `b` (`T` to `U`), `c` (`U` to `T`) +note: the trait `CoerceUnsized` may only be implemented when a single field is being coerced + --> $DIR/E0375.rs:6:5 + | +LL | b: T, + | ^^^^ +LL | c: U, + | ^^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/error-codes/E0376.rs b/tests/ui/error-codes/E0376.rs deleted file mode 100644 index f092eb02c2b..00000000000 --- a/tests/ui/error-codes/E0376.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(coerce_unsized)] -use std::ops::CoerceUnsized; - -struct Foo<T: ?Sized> { - a: T, -} - -impl<T, U> CoerceUnsized<U> for Foo<T> {} //~ ERROR E0376 - -fn main() {} diff --git a/tests/ui/error-codes/E0376.stderr b/tests/ui/error-codes/E0376.stderr deleted file mode 100644 index 46668e05a42..00000000000 --- a/tests/ui/error-codes/E0376.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0376]: the trait `CoerceUnsized` may only be implemented for a coercion between structures - --> $DIR/E0376.rs:8:1 - | -LL | impl<T, U> CoerceUnsized<U> for Foo<T> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0376`. diff --git a/tests/ui/error-codes/E0565.stderr b/tests/ui/error-codes/E0565.stderr index 68f4a37dcff..6e56600133d 100644 --- a/tests/ui/error-codes/E0565.stderr +++ b/tests/ui/error-codes/E0565.stderr @@ -1,8 +1,8 @@ error[E0565]: meta item in `repr` must be an identifier - --> $DIR/E0565.rs:2:8 + --> $DIR/E0565.rs:2:1 | LL | #[repr("C")] - | ^^^ + | ^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/error-codes/E0789.rs b/tests/ui/error-codes/E0789.rs index 08471e1b3f3..4a55e174315 100644 --- a/tests/ui/error-codes/E0789.rs +++ b/tests/ui/error-codes/E0789.rs @@ -8,5 +8,3 @@ // #[stable(feature = "foo", since = "1.0")] struct Foo; //~^ ERROR `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute -//~^^ ERROR `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute -// FIXME: we shouldn't have two errors here, only occurs when using `-Zdeduplicate-diagnostics=no` diff --git a/tests/ui/error-codes/E0789.stderr b/tests/ui/error-codes/E0789.stderr index 6df9daafec7..23631ee1b03 100644 --- a/tests/ui/error-codes/E0789.stderr +++ b/tests/ui/error-codes/E0789.stderr @@ -4,14 +4,6 @@ error[E0789]: `rustc_allowed_through_unstable_modules` attribute must be paired LL | struct Foo; | ^^^^^^^^^^^ -error[E0789]: `rustc_allowed_through_unstable_modules` attribute must be paired with a `stable` attribute - --> $DIR/E0789.rs:9:1 - | -LL | struct Foo; - | ^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0789`. diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs index 8b13f1bf278..81b7fe3db2b 100644 --- a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs +++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.rs @@ -1,7 +1,9 @@ // checks that this attribute is caught on non-macro items. // this needs a different test since this is done after expansion -#[allow_internal_unstable()] //~ ERROR allow_internal_unstable side-steps +// FIXME(jdonszelmann): empty attributes are currently ignored, since when its empty no actual +// change is applied. This should be fixed when later moving this check to attribute parsing. +#[allow_internal_unstable(something)] //~ ERROR allow_internal_unstable side-steps //~| ERROR attribute should struct S; diff --git a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr index 28f1a0d6ed5..076f2df28e3 100644 --- a/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr +++ b/tests/ui/feature-gates/feature-gate-allow-internal-unstable-struct.stderr @@ -1,17 +1,17 @@ error[E0658]: allow_internal_unstable side-steps feature gating and stability checks - --> $DIR/feature-gate-allow-internal-unstable-struct.rs:4:1 + --> $DIR/feature-gate-allow-internal-unstable-struct.rs:6:1 | -LL | #[allow_internal_unstable()] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[allow_internal_unstable(something)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: add `#![feature(allow_internal_unstable)]` 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: attribute should be applied to a macro - --> $DIR/feature-gate-allow-internal-unstable-struct.rs:4:1 + --> $DIR/feature-gate-allow-internal-unstable-struct.rs:6:1 | -LL | #[allow_internal_unstable()] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | #[allow_internal_unstable(something)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | struct S; | --------- not a macro diff --git a/tests/ui/feature-gates/feature-gate-dyn_compatible_for_dispatch.rs b/tests/ui/feature-gates/feature-gate-dyn_compatible_for_dispatch.rs deleted file mode 100644 index e38ab66dbe5..00000000000 --- a/tests/ui/feature-gates/feature-gate-dyn_compatible_for_dispatch.rs +++ /dev/null @@ -1,41 +0,0 @@ -// Test that the use of the dyn-incompatible trait objects -// are gated by the `dyn_compatible_for_dispatch` feature gate. - -trait DynIncompatible1: Sized {} - -trait DynIncompatible2 { - fn static_fn() {} -} - -trait DynIncompatible3 { - fn foo<T>(&self); -} - -trait DynIncompatible4 { - fn foo(&self, s: &Self); -} - -fn takes_dyn_incompatible_ref<T>(obj: &dyn DynIncompatible1) { - //~^ ERROR E0038 -} - -fn return_dyn_incompatible_ref() -> &'static dyn DynIncompatible2 { - //~^ ERROR E0038 - loop {} -} - -fn takes_dyn_incompatible_box(obj: Box<dyn DynIncompatible3>) { - //~^ ERROR E0038 -} - -fn return_dyn_incompatible_rc() -> std::rc::Rc<dyn DynIncompatible4> { - //~^ ERROR E0038 - loop {} -} - -trait Trait {} - -impl Trait for dyn DynIncompatible1 {} -//~^ ERROR E0038 - -fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-dyn_compatible_for_dispatch.stderr b/tests/ui/feature-gates/feature-gate-dyn_compatible_for_dispatch.stderr deleted file mode 100644 index 2c3edd6e6a5..00000000000 --- a/tests/ui/feature-gates/feature-gate-dyn_compatible_for_dispatch.stderr +++ /dev/null @@ -1,88 +0,0 @@ -error[E0038]: the trait `DynIncompatible1` is not dyn compatible - --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:18:40 - | -LL | fn takes_dyn_incompatible_ref<T>(obj: &dyn DynIncompatible1) { - | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible1` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:4:25 - | -LL | trait DynIncompatible1: Sized {} - | ---------------- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - -error[E0038]: the trait `DynIncompatible2` is not dyn compatible - --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:22:46 - | -LL | fn return_dyn_incompatible_ref() -> &'static dyn DynIncompatible2 { - | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible2` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:7:8 - | -LL | trait DynIncompatible2 { - | ---------------- this trait is not dyn compatible... -LL | fn static_fn() {} - | ^^^^^^^^^ ...because associated function `static_fn` has no `self` parameter -help: consider turning `static_fn` into a method by giving it a `&self` argument - | -LL | fn static_fn(&self) {} - | +++++ -help: alternatively, consider constraining `static_fn` so it does not apply to trait objects - | -LL | fn static_fn() where Self: Sized {} - | +++++++++++++++++ - -error[E0038]: the trait `DynIncompatible3` is not dyn compatible - --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:27:40 - | -LL | fn takes_dyn_incompatible_box(obj: Box<dyn DynIncompatible3>) { - | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible3` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:11:8 - | -LL | trait DynIncompatible3 { - | ---------------- this trait is not dyn compatible... -LL | fn foo<T>(&self); - | ^^^ ...because method `foo` has generic type parameters - = help: consider moving `foo` to another trait - -error[E0038]: the trait `DynIncompatible4` is not dyn compatible - --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:31:48 - | -LL | fn return_dyn_incompatible_rc() -> std::rc::Rc<dyn DynIncompatible4> { - | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible4` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:15:22 - | -LL | trait DynIncompatible4 { - | ---------------- this trait is not dyn compatible... -LL | fn foo(&self, s: &Self); - | ^^^^^ ...because method `foo` references the `Self` type in this parameter - = help: consider moving `foo` to another trait - -error[E0038]: the trait `DynIncompatible1` is not dyn compatible - --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:38:16 - | -LL | impl Trait for dyn DynIncompatible1 {} - | ^^^^^^^^^^^^^^^^^^^^ `DynIncompatible1` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/feature-gate-dyn_compatible_for_dispatch.rs:4:25 - | -LL | trait DynIncompatible1: Sized {} - | ---------------- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/feature-gates/feature-gate-fn_align.rs b/tests/ui/feature-gates/feature-gate-fn_align.rs index 06784a45d76..744877704dd 100644 --- a/tests/ui/feature-gates/feature-gate-fn_align.rs +++ b/tests/ui/feature-gates/feature-gate-fn_align.rs @@ -4,6 +4,6 @@ fn requires_alignment() {} trait MyTrait { - #[repr(align)] //~ ERROR `repr(align)` attributes on functions are unstable + #[repr(align)] //~ ERROR invalid `repr(align)` attribute: `align` needs an argument fn myfun(); } diff --git a/tests/ui/feature-gates/feature-gate-fn_align.stderr b/tests/ui/feature-gates/feature-gate-fn_align.stderr index cd9900c6051..ff17c29fe02 100644 --- a/tests/ui/feature-gates/feature-gate-fn_align.stderr +++ b/tests/ui/feature-gates/feature-gate-fn_align.stderr @@ -1,3 +1,9 @@ +error[E0589]: invalid `repr(align)` attribute: `align` needs an argument + --> $DIR/feature-gate-fn_align.rs:7:12 + | +LL | #[repr(align)] + | ^^^^^ help: supply an argument here: `align(...)` + error[E0658]: `repr(align)` attributes on functions are unstable --> $DIR/feature-gate-fn_align.rs:3:8 | @@ -8,16 +14,7 @@ LL | #[repr(align(16))] = help: add `#![feature(fn_align)]` 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[E0658]: `repr(align)` attributes on functions are unstable - --> $DIR/feature-gate-fn_align.rs:7:12 - | -LL | #[repr(align)] - | ^^^^^ - | - = note: see issue #82232 <https://github.com/rust-lang/rust/issues/82232> for more information - = help: add `#![feature(fn_align)]` 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 2 previous errors -For more information about this error, try `rustc --explain E0658`. +Some errors have detailed explanations: E0589, E0658. +For more information about an error, try `rustc --explain E0589`. diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr index 648bafe6460..5c2a3ae699c 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs-error.stderr @@ -130,21 +130,6 @@ LL - #![rustc_main] LL + #[rustc_main] | -error: `repr` attribute cannot be used at crate level - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:17:1 - | -LL | #![repr()] - | ^^^^^^^^^^ -... -LL | mod inline { - | ------ the inner attribute doesn't annotate this module - | -help: perhaps you meant to use an outer attribute - | -LL - #![repr()] -LL + #[repr()] - | - error: `path` attribute cannot be used at crate level --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:19:1 | @@ -175,6 +160,21 @@ LL - #![automatically_derived] LL + #[automatically_derived] | +error: `repr` attribute cannot be used at crate level + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:17:1 + | +LL | #![repr()] + | ^^^^^^^^^^ +... +LL | mod inline { + | ------ the inner attribute doesn't annotate this module + | +help: perhaps you meant to use an outer attribute + | +LL - #![repr()] +LL + #[repr()] + | + error[E0518]: attribute should be applied to function or closure --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:40:17 | diff --git a/tests/ui/internal/internal-unstable.rs b/tests/ui/internal/internal-unstable.rs index 35a2941633a..381c1337148 100644 --- a/tests/ui/internal/internal-unstable.rs +++ b/tests/ui/internal/internal-unstable.rs @@ -7,7 +7,7 @@ extern crate internal_unstable; struct Baz { - #[allow_internal_unstable] + #[allow_internal_unstable] //~ ERROR `allow_internal_unstable` expects a list of feature names baz: u8, } @@ -56,7 +56,7 @@ fn main() { bar!(internal_unstable::unstable()); //~ ERROR use of unstable match true { - #[allow_internal_unstable] + #[allow_internal_unstable] //~ ERROR `allow_internal_unstable` expects a list of feature names _ => {} } diff --git a/tests/ui/internal/internal-unstable.stderr b/tests/ui/internal/internal-unstable.stderr index ea74175f09b..bbf589d3f92 100644 --- a/tests/ui/internal/internal-unstable.stderr +++ b/tests/ui/internal/internal-unstable.stderr @@ -1,3 +1,15 @@ +error: `allow_internal_unstable` expects a list of feature names + --> $DIR/internal-unstable.rs:10:5 + | +LL | #[allow_internal_unstable] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `allow_internal_unstable` expects a list of feature names + --> $DIR/internal-unstable.rs:59:9 + | +LL | #[allow_internal_unstable] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0658]: use of unstable library feature `function` --> $DIR/internal-unstable.rs:48:25 | @@ -47,6 +59,6 @@ LL | bar!(internal_unstable::unstable()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date = note: this error originates in the macro `foo` which comes from the expansion of the macro `bar` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 5 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/intrinsics/always-gets-overridden.rs b/tests/ui/intrinsics/always-gets-overridden.rs index 2fb64f96d83..aaac5415c21 100644 --- a/tests/ui/intrinsics/always-gets-overridden.rs +++ b/tests/ui/intrinsics/always-gets-overridden.rs @@ -1,5 +1,5 @@ -//! Check that `vtable_size` gets overridden by llvm backend even if there is no -//! `rustc_intrinsic_must_be_overridden` attribute on this usage. +//! Check that `vtable_size` gets overridden by llvm backend even if there is a +//! fallback body. #![feature(intrinsics)] //@run-pass diff --git a/tests/ui/invalid_dispatch_from_dyn_impls.rs b/tests/ui/invalid_dispatch_from_dyn_impls.rs index b7bc766fbe0..972465d7197 100644 --- a/tests/ui/invalid_dispatch_from_dyn_impls.rs +++ b/tests/ui/invalid_dispatch_from_dyn_impls.rs @@ -8,9 +8,10 @@ use std::{ struct WrapperWithExtraField<T>(T, i32); impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T> +//~^ ERROR [E0378] where T: DispatchFromDyn<U>, -{} //~^^^ ERROR [E0378] +{} struct MultiplePointers<T: ?Sized>{ @@ -19,9 +20,10 @@ struct MultiplePointers<T: ?Sized>{ } impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for MultiplePointers<T> +//~^ implementing `DispatchFromDyn` does not allow multiple fields to be coerced where T: Unsize<U>, -{} //~^^^ ERROR [E0378] +{} struct NothingToCoerce<T: ?Sized> { @@ -29,23 +31,25 @@ struct NothingToCoerce<T: ?Sized> { } impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {} -//~^ ERROR [E0378] +//~^ ERROR implementing `DispatchFromDyn` requires a field to be coerced #[repr(C)] struct HasReprC<T: ?Sized>(Box<T>); impl<T: ?Sized, U: ?Sized> DispatchFromDyn<HasReprC<U>> for HasReprC<T> +//~^ ERROR [E0378] where T: Unsize<U>, -{} //~^^^ ERROR [E0378] +{} #[repr(align(64))] struct OverAlignedZst; struct OverAligned<T: ?Sized>(Box<T>, OverAlignedZst); impl<T: ?Sized, U: ?Sized> DispatchFromDyn<OverAligned<U>> for OverAligned<T> +//~^ ERROR [E0378] where T: Unsize<U>, -{} //~^^^ ERROR [E0378] +{} fn main() {} diff --git a/tests/ui/invalid_dispatch_from_dyn_impls.stderr b/tests/ui/invalid_dispatch_from_dyn_impls.stderr index 02718334c73..93ec6bbe089 100644 --- a/tests/ui/invalid_dispatch_from_dyn_impls.stderr +++ b/tests/ui/invalid_dispatch_from_dyn_impls.stderr @@ -2,25 +2,32 @@ error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs co --> $DIR/invalid_dispatch_from_dyn_impls.rs:10:1 | LL | / impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T> +LL | | LL | | where LL | | T: DispatchFromDyn<U>, | |__________________________^ | = note: extra field `1` of type `i32` is not allowed -error[E0378]: implementing the `DispatchFromDyn` trait requires multiple coercions - --> $DIR/invalid_dispatch_from_dyn_impls.rs:21:1 +error[E0375]: implementing `DispatchFromDyn` does not allow multiple fields to be coerced + --> $DIR/invalid_dispatch_from_dyn_impls.rs:22:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for MultiplePointers<T> +LL | | LL | | where LL | | T: Unsize<U>, | |_________________^ | - = note: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced - = note: currently, 2 fields need coercions: `ptr1` (`*const T` to `*const U`), `ptr2` (`*const T` to `*const U`) +note: the trait `DispatchFromDyn` may only be implemented when a single field is being coerced + --> $DIR/invalid_dispatch_from_dyn_impls.rs:18:5 + | +LL | ptr1: *const T, + | ^^^^^^^^^^^^^^ +LL | ptr2: *const T, + | ^^^^^^^^^^^^^^ -error[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures - --> $DIR/invalid_dispatch_from_dyn_impls.rs:31:1 +error[E0374]: implementing `DispatchFromDyn` requires a field to be coerced + --> $DIR/invalid_dispatch_from_dyn_impls.rs:33:1 | LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -28,17 +35,19 @@ LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingT = note: expected a single field to be coerced, none found error[E0378]: structs implementing `DispatchFromDyn` may not have `#[repr(packed)]` or `#[repr(C)]` - --> $DIR/invalid_dispatch_from_dyn_impls.rs:37:1 + --> $DIR/invalid_dispatch_from_dyn_impls.rs:39:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<HasReprC<U>> for HasReprC<T> +LL | | LL | | where LL | | T: Unsize<U>, | |_________________^ error[E0378]: the trait `DispatchFromDyn` may only be implemented for structs containing the field being coerced, ZST fields with 1 byte alignment that don't mention type/const generics, and nothing else - --> $DIR/invalid_dispatch_from_dyn_impls.rs:46:1 + --> $DIR/invalid_dispatch_from_dyn_impls.rs:49:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<OverAligned<U>> for OverAligned<T> +LL | | LL | | where LL | | T: Unsize<U>, | |_____________________^ @@ -47,4 +56,5 @@ LL | | T: Unsize<U>, error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0378`. +Some errors have detailed explanations: E0374, E0375, E0378. +For more information about an error, try `rustc --explain E0374`. diff --git a/tests/ui/issues/issue-43988.stderr b/tests/ui/issues/issue-43988.stderr index 7bbb8ed2ca9..d629f199b22 100644 --- a/tests/ui/issues/issue-43988.stderr +++ b/tests/ui/issues/issue-43988.stderr @@ -10,22 +10,6 @@ error: malformed `repr` attribute input LL | let _z = #[repr] 1; | ^^^^^^^ help: must be of the form: `#[repr(C)]` -error[E0518]: attribute should be applied to function or closure - --> $DIR/issue-43988.rs:5:5 - | -LL | #[inline] - | ^^^^^^^^^ -LL | let _a = 4; - | ----------- not a function or closure - -error[E0518]: attribute should be applied to function or closure - --> $DIR/issue-43988.rs:10:5 - | -LL | #[inline(XYZ)] - | ^^^^^^^^^^^^^^ -LL | let _b = 4; - | ----------- not a function or closure - error[E0552]: unrecognized representation hint --> $DIR/issue-43988.rs:14:12 | @@ -43,6 +27,22 @@ LL | #[repr(something_not_real)] = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` error[E0518]: attribute should be applied to function or closure + --> $DIR/issue-43988.rs:5:5 + | +LL | #[inline] + | ^^^^^^^^^ +LL | let _a = 4; + | ----------- not a function or closure + +error[E0518]: attribute should be applied to function or closure + --> $DIR/issue-43988.rs:10:5 + | +LL | #[inline(XYZ)] + | ^^^^^^^^^^^^^^ +LL | let _b = 4; + | ----------- not a function or closure + +error[E0518]: attribute should be applied to function or closure --> $DIR/issue-43988.rs:30:5 | LL | #[inline(ABC)] diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.rs b/tests/ui/kindck/kindck-inherited-copy-bound.rs index dda95229ddf..20d54a3fb10 100644 --- a/tests/ui/kindck/kindck-inherited-copy-bound.rs +++ b/tests/ui/kindck/kindck-inherited-copy-bound.rs @@ -1,8 +1,4 @@ // Test that Copy bounds inherited by trait are checked. -// -//@ revisions: curr dyn_compatible_for_dispatch - -#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))] use std::any::Any; @@ -18,17 +14,15 @@ fn take_param<T:Foo>(foo: &T) { } fn a() { let x: Box<_> = Box::new(3); - take_param(&x); //[curr]~ ERROR E0277 - //[dyn_compatible_for_dispatch]~^ ERROR E0277 + take_param(&x); //~ ERROR E0277 } fn b() { let x: Box<_> = Box::new(3); let y = &x; let z = &x as &dyn Foo; - //[curr]~^ ERROR E0038 - //[curr]~| ERROR E0038 - //[dyn_compatible_for_dispatch]~^^^ ERROR E0038 + //~^ ERROR E0038 + //~| ERROR E0038 } fn main() { } diff --git a/tests/ui/kindck/kindck-inherited-copy-bound.dyn_compatible_for_dispatch.stderr b/tests/ui/kindck/kindck-inherited-copy-bound.stderr index 296f011193e..edfa7ae7769 100644 --- a/tests/ui/kindck/kindck-inherited-copy-bound.dyn_compatible_for_dispatch.stderr +++ b/tests/ui/kindck/kindck-inherited-copy-bound.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `Box<{integer}>: Foo` is not satisfied - --> $DIR/kindck-inherited-copy-bound.rs:21:16 + --> $DIR/kindck-inherited-copy-bound.rs:17:16 | LL | take_param(&x); | ---------- ^^ the trait `Copy` is not implemented for `Box<{integer}>` @@ -7,35 +7,50 @@ LL | take_param(&x); | required by a bound introduced by this call | note: required for `Box<{integer}>` to implement `Foo` - --> $DIR/kindck-inherited-copy-bound.rs:14:14 + --> $DIR/kindck-inherited-copy-bound.rs:10:14 | LL | impl<T:Copy> Foo for T { | ---- ^^^ ^ | | | unsatisfied trait bound introduced here note: required by a bound in `take_param` - --> $DIR/kindck-inherited-copy-bound.rs:17:17 + --> $DIR/kindck-inherited-copy-bound.rs:13:17 | LL | fn take_param<T:Foo>(foo: &T) { } | ^^^ required by this bound in `take_param` error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/kindck-inherited-copy-bound.rs:28:13 + --> $DIR/kindck-inherited-copy-bound.rs:23:19 + | +LL | let z = &x as &dyn Foo; + | ^^^^^^^^ `Foo` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/kindck-inherited-copy-bound.rs:6:13 + | +LL | trait Foo : Copy { + | --- ^^^^ ...because it requires `Self: Sized` + | | + | this trait is not dyn compatible... + +error[E0038]: the trait `Foo` is not dyn compatible + --> $DIR/kindck-inherited-copy-bound.rs:23:13 | LL | let z = &x as &dyn Foo; | ^^ `Foo` is not dyn compatible | note: for a trait to be dyn compatible it needs to allow building a vtable for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/kindck-inherited-copy-bound.rs:10:13 + --> $DIR/kindck-inherited-copy-bound.rs:6:13 | LL | trait Foo : Copy { | --- ^^^^ ...because it requires `Self: Sized` | | | this trait is not dyn compatible... - = note: required for the cast from `&Box<i32>` to `&dyn Foo` + = note: required for the cast from `&Box<{integer}>` to `&dyn Foo` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0038, E0277. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/repr/16-bit-repr-c-enum.rs b/tests/ui/repr/16-bit-repr-c-enum.rs index 011076882d2..8c2d2fafce0 100644 --- a/tests/ui/repr/16-bit-repr-c-enum.rs +++ b/tests/ui/repr/16-bit-repr-c-enum.rs @@ -24,10 +24,7 @@ enum Foo { #[stable(feature = "intrinsics_for_test", since = "3.3.3")] #[rustc_const_stable(feature = "intrinsics_for_test", since = "3.3.3")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -const fn size_of<T>() -> usize { - loop {} -} +const fn size_of<T>() -> usize; #[lang="sized"] trait Sized {} diff --git a/tests/ui/repr/invalid_repr_list_help.stderr b/tests/ui/repr/invalid_repr_list_help.stderr index e87cbd37a99..763ad9c2795 100644 --- a/tests/ui/repr/invalid_repr_list_help.stderr +++ b/tests/ui/repr/invalid_repr_list_help.stderr @@ -30,14 +30,6 @@ LL | #[repr(uwu, u8)] | = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` -error: unknown `doc` attribute `owo` - --> $DIR/invalid_repr_list_help.rs:20:7 - | -LL | #[doc(owo)] - | ^^^ - | - = note: `#[deny(invalid_doc_attributes)]` on by default - error[E0552]: unrecognized representation hint --> $DIR/invalid_repr_list_help.rs:19:8 | @@ -46,6 +38,14 @@ LL | #[repr(uwu)] | = help: valid reprs are `Rust` (default), `C`, `align`, `packed`, `transparent`, `simd`, `i8`, `u8`, `i16`, `u16`, `i32`, `u32`, `i64`, `u64`, `i128`, `u128`, `isize`, `usize` +error: unknown `doc` attribute `owo` + --> $DIR/invalid_repr_list_help.rs:20:7 + | +LL | #[doc(owo)] + | ^^^ + | + = note: `#[deny(invalid_doc_attributes)]` on by default + error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0552`. diff --git a/tests/ui/repr/issue-83505-repr-simd.stderr b/tests/ui/repr/issue-83505-repr-simd.stderr index 44e154b4bb6..57cfbeb95de 100644 --- a/tests/ui/repr/issue-83505-repr-simd.stderr +++ b/tests/ui/repr/issue-83505-repr-simd.stderr @@ -26,10 +26,10 @@ LL | enum Es {} | ---------- not a struct error[E0084]: unsupported representation for zero-variant enum - --> $DIR/issue-83505-repr-simd.rs:5:1 + --> $DIR/issue-83505-repr-simd.rs:5:8 | LL | #[repr(simd)] - | ^^^^^^^^^^^^^ + | ^^^^ ... LL | enum Es {} | ------- zero-variant enum diff --git a/tests/ui/repr/malformed-repr-hints.stderr b/tests/ui/repr/malformed-repr-hints.stderr index 6fb92755761..7a6e9ccc73e 100644 --- a/tests/ui/repr/malformed-repr-hints.stderr +++ b/tests/ui/repr/malformed-repr-hints.stderr @@ -1,15 +1,3 @@ -error[E0552]: incorrect `repr(packed)` attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all - --> $DIR/malformed-repr-hints.rs:6:8 - | -LL | #[repr(packed())] - | ^^^^^^^^ - -error[E0589]: invalid `repr(align)` attribute: `align` needs an argument - --> $DIR/malformed-repr-hints.rs:10:8 - | -LL | #[repr(align)] - | ^^^^^ help: supply an argument here: `align(...)` - error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly one argument in parentheses --> $DIR/malformed-repr-hints.rs:14:8 | @@ -22,6 +10,18 @@ error[E0693]: incorrect `repr(align)` attribute format: `align` takes exactly on LL | #[repr(align())] | ^^^^^^^ +error[E0552]: incorrect `repr(packed)` attribute format: `packed` takes exactly one parenthesized argument, or no parentheses at all + --> $DIR/malformed-repr-hints.rs:6:8 + | +LL | #[repr(packed())] + | ^^^^^^^^ + +error[E0589]: invalid `repr(align)` attribute: `align` needs an argument + --> $DIR/malformed-repr-hints.rs:10:8 + | +LL | #[repr(align)] + | ^^^^^ help: supply an argument here: `align(...)` + error[E0552]: invalid representation hint: `Rust` does not take a parenthesized argument list --> $DIR/malformed-repr-hints.rs:23:8 | diff --git a/tests/ui/repr/repr-align-assign.fixed b/tests/ui/repr/repr-align-assign.fixed index d40fcadf57b..96f9866611b 100644 --- a/tests/ui/repr/repr-align-assign.fixed +++ b/tests/ui/repr/repr-align-assign.fixed @@ -3,11 +3,9 @@ #![allow(dead_code)] #[repr(align(8))] //~ ERROR incorrect `repr(align)` attribute format - //~| ERROR incorrect `repr(align)` attribute format struct A(u64); #[repr(align(8))] //~ ERROR incorrect `repr(align)` attribute format - //~| ERROR incorrect `repr(align)` attribute format struct B(u64); fn main() {} diff --git a/tests/ui/repr/repr-align-assign.rs b/tests/ui/repr/repr-align-assign.rs index 3aff84a91f7..0b30ee65664 100644 --- a/tests/ui/repr/repr-align-assign.rs +++ b/tests/ui/repr/repr-align-assign.rs @@ -3,11 +3,9 @@ #![allow(dead_code)] #[repr(align=8)] //~ ERROR incorrect `repr(align)` attribute format - //~| ERROR incorrect `repr(align)` attribute format struct A(u64); #[repr(align="8")] //~ ERROR incorrect `repr(align)` attribute format - //~| ERROR incorrect `repr(align)` attribute format struct B(u64); fn main() {} diff --git a/tests/ui/repr/repr-align-assign.stderr b/tests/ui/repr/repr-align-assign.stderr index 3606d02210b..cc046e04de5 100644 --- a/tests/ui/repr/repr-align-assign.stderr +++ b/tests/ui/repr/repr-align-assign.stderr @@ -5,27 +5,11 @@ LL | #[repr(align=8)] | ^^^^^^^ help: use parentheses instead: `align(8)` error[E0693]: incorrect `repr(align)` attribute format - --> $DIR/repr-align-assign.rs:9:8 + --> $DIR/repr-align-assign.rs:8:8 | LL | #[repr(align="8")] | ^^^^^^^^^ help: use parentheses instead: `align(8)` -error[E0693]: incorrect `repr(align)` attribute format - --> $DIR/repr-align-assign.rs:5:8 - | -LL | #[repr(align=8)] - | ^^^^^^^ help: use parentheses instead: `align(8)` - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0693]: incorrect `repr(align)` attribute format - --> $DIR/repr-align-assign.rs:9:8 - | -LL | #[repr(align="8")] - | ^^^^^^^^^ help: use parentheses instead: `align(8)` - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0693`. diff --git a/tests/ui/repr/repr-align.rs b/tests/ui/repr/repr-align.rs index 33aa727d4bd..6b60a765461 100644 --- a/tests/ui/repr/repr-align.rs +++ b/tests/ui/repr/repr-align.rs @@ -1,41 +1,33 @@ #![allow(dead_code)] #[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer - //~| ERROR: invalid `repr(align)` attribute: not an unsuffixed integer struct S0(i32); #[repr(align(15))] //~ ERROR: invalid `repr(align)` attribute: not a power of two - //~| ERROR: invalid `repr(align)` attribute: not a power of two struct S1(i32); #[repr(align(4294967296))] //~ ERROR: invalid `repr(align)` attribute: larger than 2^29 - //~| ERROR: invalid `repr(align)` attribute: larger than 2^29 struct S2(i32); #[repr(align(536870912))] // ok: this is the largest accepted alignment struct S3(i32); #[repr(align(0))] //~ ERROR: invalid `repr(align)` attribute: not a power of two - //~| ERROR: invalid `repr(align)` attribute: not a power of two struct S4(i32); #[repr(align(16.0))] //~ ERROR: invalid `repr(align)` attribute: not an unsuffixed integer - //~| ERROR: invalid `repr(align)` attribute: not an unsuffixed integer enum E0 { A, B } #[repr(align(15))] //~ ERROR: invalid `repr(align)` attribute: not a power of two - //~| ERROR: invalid `repr(align)` attribute: not a power of two enum E1 { A, B } #[repr(align(4294967296))] //~ ERROR: invalid `repr(align)` attribute: larger than 2^29 - //~| ERROR: invalid `repr(align)` attribute: larger than 2^29 enum E2 { A, B } #[repr(align(536870912))] // ok: this is the largest accepted alignment enum E3 { A, B } #[repr(align(0))] //~ ERROR: invalid `repr(align)` attribute: not a power of two - //~| ERROR: invalid `repr(align)` attribute: not a power of two enum E4 { A, B } fn main() {} diff --git a/tests/ui/repr/repr-align.stderr b/tests/ui/repr/repr-align.stderr index 660247840c4..fe919e30b15 100644 --- a/tests/ui/repr/repr-align.stderr +++ b/tests/ui/repr/repr-align.stderr @@ -5,111 +5,47 @@ LL | #[repr(align(16.0))] | ^^^^ error[E0589]: invalid `repr(align)` attribute: not a power of two - --> $DIR/repr-align.rs:7:14 + --> $DIR/repr-align.rs:6:14 | LL | #[repr(align(15))] | ^^ error[E0589]: invalid `repr(align)` attribute: larger than 2^29 - --> $DIR/repr-align.rs:11:14 + --> $DIR/repr-align.rs:9:14 | LL | #[repr(align(4294967296))] | ^^^^^^^^^^ error[E0589]: invalid `repr(align)` attribute: not a power of two - --> $DIR/repr-align.rs:18:14 + --> $DIR/repr-align.rs:15:14 | LL | #[repr(align(0))] | ^ error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer - --> $DIR/repr-align.rs:22:14 - | -LL | #[repr(align(16.0))] - | ^^^^ - -error[E0589]: invalid `repr(align)` attribute: not a power of two - --> $DIR/repr-align.rs:26:14 - | -LL | #[repr(align(15))] - | ^^ - -error[E0589]: invalid `repr(align)` attribute: larger than 2^29 - --> $DIR/repr-align.rs:30:14 - | -LL | #[repr(align(4294967296))] - | ^^^^^^^^^^ - -error[E0589]: invalid `repr(align)` attribute: not a power of two - --> $DIR/repr-align.rs:37:14 - | -LL | #[repr(align(0))] - | ^ - -error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer - --> $DIR/repr-align.rs:3:14 - | -LL | #[repr(align(16.0))] - | ^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0589]: invalid `repr(align)` attribute: not a power of two - --> $DIR/repr-align.rs:7:14 - | -LL | #[repr(align(15))] - | ^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0589]: invalid `repr(align)` attribute: larger than 2^29 - --> $DIR/repr-align.rs:11:14 - | -LL | #[repr(align(4294967296))] - | ^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0589]: invalid `repr(align)` attribute: not a power of two --> $DIR/repr-align.rs:18:14 | -LL | #[repr(align(0))] - | ^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0589]: invalid `repr(align)` attribute: not an unsuffixed integer - --> $DIR/repr-align.rs:22:14 - | LL | #[repr(align(16.0))] | ^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0589]: invalid `repr(align)` attribute: not a power of two - --> $DIR/repr-align.rs:26:14 + --> $DIR/repr-align.rs:21:14 | LL | #[repr(align(15))] | ^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0589]: invalid `repr(align)` attribute: larger than 2^29 - --> $DIR/repr-align.rs:30:14 + --> $DIR/repr-align.rs:24:14 | LL | #[repr(align(4294967296))] | ^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0589]: invalid `repr(align)` attribute: not a power of two - --> $DIR/repr-align.rs:37:14 + --> $DIR/repr-align.rs:30:14 | LL | #[repr(align(0))] | ^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 16 previous errors +error: aborting due to 8 previous errors For more information about this error, try `rustc --explain E0589`. diff --git a/tests/ui/repr/repr-transparent.stderr b/tests/ui/repr/repr-transparent.stderr index d0c78a8418a..2cafb989bce 100644 --- a/tests/ui/repr/repr-transparent.stderr +++ b/tests/ui/repr/repr-transparent.stderr @@ -35,10 +35,10 @@ LL | struct GenericAlign<T>(ZstAlign32<T>, u32); | needs at most one field with non-trivial size or alignment, but has 2 error[E0084]: unsupported representation for zero-variant enum - --> $DIR/repr-transparent.rs:47:1 + --> $DIR/repr-transparent.rs:47:8 | LL | #[repr(transparent)] - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^ LL | enum Void {} | --------- zero-variant enum diff --git a/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/downcast-unsafe-trait-objects.rs b/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/downcast-unsafe-trait-objects.rs deleted file mode 100644 index b1b2dcf3eb9..00000000000 --- a/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/downcast-unsafe-trait-objects.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Check that we if we get ahold of a dyn-incompatible trait -// object with auto traits and lifetimes, we can downcast it -// -//@ check-pass - -#![feature(dyn_compatible_for_dispatch)] - -trait Trait: Sized {} - -fn downcast_auto(t: &(dyn Trait + Send)) -> &dyn Trait { - t -} - -fn downcast_lifetime<'a, 'b, 't>(t: &'a (dyn Trait + 't)) - -> &'b (dyn Trait + 't) -where - 'a: 'b, - 't: 'a + 'b, -{ - t -} - -fn main() {} diff --git a/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/manual-self-impl-for-unsafe-obj.current.stderr b/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/manual-self-impl-for-unsafe-obj.current.stderr deleted file mode 100644 index 1489791b20d..00000000000 --- a/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/manual-self-impl-for-unsafe-obj.current.stderr +++ /dev/null @@ -1,15 +0,0 @@ -warning: methods `good_virt` and `good_indirect` are never used - --> $DIR/manual-self-impl-for-unsafe-obj.rs:23:8 - | -LL | trait Good { - | ---- methods in this trait -LL | fn good_virt(&self) -> char { - | ^^^^^^^^^ -... -LL | fn good_indirect(&self) -> char { - | ^^^^^^^^^^^^^ - | - = note: `#[warn(dead_code)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/manual-self-impl-for-unsafe-obj.next.stderr b/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/manual-self-impl-for-unsafe-obj.next.stderr deleted file mode 100644 index 1489791b20d..00000000000 --- a/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/manual-self-impl-for-unsafe-obj.next.stderr +++ /dev/null @@ -1,15 +0,0 @@ -warning: methods `good_virt` and `good_indirect` are never used - --> $DIR/manual-self-impl-for-unsafe-obj.rs:23:8 - | -LL | trait Good { - | ---- methods in this trait -LL | fn good_virt(&self) -> char { - | ^^^^^^^^^ -... -LL | fn good_indirect(&self) -> char { - | ^^^^^^^^^^^^^ - | - = note: `#[warn(dead_code)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/manual-self-impl-for-unsafe-obj.rs b/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/manual-self-impl-for-unsafe-obj.rs deleted file mode 100644 index 425dc130d45..00000000000 --- a/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/manual-self-impl-for-unsafe-obj.rs +++ /dev/null @@ -1,69 +0,0 @@ -// Check that we can manually implement a dyn-incompatible trait for its trait object. - -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[next] compile-flags: -Znext-solver -//@ run-pass - -#![feature(dyn_compatible_for_dispatch)] - -trait Bad { - fn stat() -> char { - 'A' - } - fn virt(&self) -> char { - 'B' - } - fn indirect(&self) -> char { - Self::stat() - } -} - -trait Good { - fn good_virt(&self) -> char { //~ WARN methods `good_virt` and `good_indirect` are never used - panic!() - } - fn good_indirect(&self) -> char { - panic!() - } -} - -impl<'a> Bad for dyn Bad + 'a { - fn stat() -> char { - 'C' - } - fn virt(&self) -> char { - 'D' - } -} - -struct Struct {} - -impl Bad for Struct {} - -impl Good for Struct {} - -fn main() { - let s = Struct {}; - - let mut res = String::new(); - - // Directly call static. - res.push(Struct::stat()); // "A" - res.push(<dyn Bad>::stat()); // "AC" - - let good: &dyn Good = &s; - - // These look similar enough... - let bad = unsafe { std::mem::transmute::<&dyn Good, &dyn Bad>(good) }; - - // Call virtual. - res.push(s.virt()); // "ACB" - res.push(bad.virt()); // "ACBD" - - // Indirectly call static. - res.push(s.indirect()); // "ACBDA" - res.push(bad.indirect()); // "ACBDAC" - - assert_eq!(&res, "ACBDAC"); -} diff --git a/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/static-dispatch-unsafe-object.rs b/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/static-dispatch-unsafe-object.rs deleted file mode 100644 index c38928a9f44..00000000000 --- a/tests/ui/rfcs/rfc-2027-dyn-compatible-for-dispatch/static-dispatch-unsafe-object.rs +++ /dev/null @@ -1,37 +0,0 @@ -// Check that we can statically dispatch methods for object -// unsafe trait objects, directly and indirectly -// -//@ check-pass - -#![feature(dyn_compatible_for_dispatch)] - -trait Statics { - fn plain() {} - fn generic<T>() {} -} - -trait Trait: Sized {} - -impl<'a> Statics for dyn Trait + 'a {} - -fn static_poly<T: Statics + ?Sized>() { - T::plain(); - T::generic::<usize>(); -} - -fn inferred_poly<T: Statics + ?Sized>(t: &T) { - static_poly::<T>(); - T::plain(); - T::generic::<usize>(); -} - -fn call(t: &dyn Trait) { - static_poly::<dyn Trait>(); - inferred_poly(t); -} - -fn main() { - static_poly::<dyn Trait>(); - <dyn Trait>::plain(); - <dyn Trait>::generic::<usize>() -} diff --git a/tests/ui/rust-2021/ice-return-unsized-can-impl-2.rs b/tests/ui/rust-2021/ice-return-unsized-can-impl-2.rs index e57e9ce4844..567d37e1b82 100644 --- a/tests/ui/rust-2021/ice-return-unsized-can-impl-2.rs +++ b/tests/ui/rust-2021/ice-return-unsized-can-impl-2.rs @@ -1,15 +1,17 @@ // Doesn't trigger ICE when returning unsized trait that can be impl // issue https://github.com/rust-lang/rust/issues/125512 //@ edition:2021 -#![feature(dyn_compatible_for_dispatch)] + trait B { fn f(a: A) -> A; //~^ ERROR: expected a type, found a trait //~| ERROR: expected a type, found a trait } + trait A { fn concrete(b: B) -> B; //~^ ERROR: expected a type, found a trait //~| ERROR: expected a type, found a trait } + fn main() {} diff --git a/tests/ui/rust-2021/ice-return-unsized-can-impl-2.stderr b/tests/ui/rust-2021/ice-return-unsized-can-impl-2.stderr index ac19f91881d..f2942820e28 100644 --- a/tests/ui/rust-2021/ice-return-unsized-can-impl-2.stderr +++ b/tests/ui/rust-2021/ice-return-unsized-can-impl-2.stderr @@ -1,5 +1,5 @@ error[E0782]: expected a type, found a trait - --> $DIR/ice-return-unsized-can-impl-2.rs:11:20 + --> $DIR/ice-return-unsized-can-impl-2.rs:12:20 | LL | fn concrete(b: B) -> B; | ^ @@ -16,7 +16,7 @@ LL | fn concrete(b: impl B) -> B; | ++++ error[E0782]: expected a type, found a trait - --> $DIR/ice-return-unsized-can-impl-2.rs:11:26 + --> $DIR/ice-return-unsized-can-impl-2.rs:12:26 | LL | fn concrete(b: B) -> B; | ^ diff --git a/tests/ui/rust-2021/ice-return-unsized-can-impl.rs b/tests/ui/rust-2021/ice-return-unsized-can-impl.rs index 055b11b4424..8b83b7b537a 100644 --- a/tests/ui/rust-2021/ice-return-unsized-can-impl.rs +++ b/tests/ui/rust-2021/ice-return-unsized-can-impl.rs @@ -1,7 +1,6 @@ // Doesn't trigger ICE when returning unsized trait that can be impl // issue https://github.com/rust-lang/rust/issues/120482 //@ edition:2021 -#![feature(dyn_compatible_for_dispatch)] trait B { fn bar(&self, x: &Self); diff --git a/tests/ui/rust-2021/ice-return-unsized-can-impl.stderr b/tests/ui/rust-2021/ice-return-unsized-can-impl.stderr index 463c6892ca2..cfee506e29b 100644 --- a/tests/ui/rust-2021/ice-return-unsized-can-impl.stderr +++ b/tests/ui/rust-2021/ice-return-unsized-can-impl.stderr @@ -1,5 +1,5 @@ error[E0782]: expected a type, found a trait - --> $DIR/ice-return-unsized-can-impl.rs:11:15 + --> $DIR/ice-return-unsized-can-impl.rs:10:15 | LL | fn g(new: B) -> B; | ^ @@ -16,7 +16,7 @@ LL | fn g(new: impl B) -> B; | ++++ error[E0782]: expected a type, found a trait - --> $DIR/ice-return-unsized-can-impl.rs:11:21 + --> $DIR/ice-return-unsized-can-impl.rs:10:21 | LL | fn g(new: B) -> B; | ^ diff --git a/tests/ui/rust-2021/ice-unsized-fn-params-2.rs b/tests/ui/rust-2021/ice-unsized-fn-params-2.rs index 2b4f7bd088f..8af56ffe80d 100644 --- a/tests/ui/rust-2021/ice-unsized-fn-params-2.rs +++ b/tests/ui/rust-2021/ice-unsized-fn-params-2.rs @@ -1,7 +1,7 @@ //@ edition:2021 // Test that it doesn't trigger an ICE when using an unsized fn params. // https://github.com/rust-lang/rust/issues/120241 -#![feature(dyn_compatible_for_dispatch)] + #![feature(unsized_fn_params)] fn guard(_s: Copy) -> bool { diff --git a/tests/ui/rust-2021/ice-unsized-fn-params.rs b/tests/ui/rust-2021/ice-unsized-fn-params.rs index 6d8c1c3f152..6ed67698e96 100644 --- a/tests/ui/rust-2021/ice-unsized-fn-params.rs +++ b/tests/ui/rust-2021/ice-unsized-fn-params.rs @@ -1,7 +1,6 @@ //@ edition:2021 // Test that it doesn't trigger an ICE when using an unsized fn params. // https://github.com/rust-lang/rust/issues/120241 -#![feature(dyn_compatible_for_dispatch)] trait B { fn f(a: A) -> A; diff --git a/tests/ui/rust-2021/ice-unsized-fn-params.stderr b/tests/ui/rust-2021/ice-unsized-fn-params.stderr index c31500ba800..4d900711ed6 100644 --- a/tests/ui/rust-2021/ice-unsized-fn-params.stderr +++ b/tests/ui/rust-2021/ice-unsized-fn-params.stderr @@ -1,5 +1,5 @@ error[E0782]: expected a type, found a trait - --> $DIR/ice-unsized-fn-params.rs:13:13 + --> $DIR/ice-unsized-fn-params.rs:12:13 | LL | fn g(b: B) -> B; | ^ @@ -16,7 +16,7 @@ LL | fn g(b: impl B) -> B; | ++++ error[E0782]: expected a type, found a trait - --> $DIR/ice-unsized-fn-params.rs:13:19 + --> $DIR/ice-unsized-fn-params.rs:12:19 | LL | fn g(b: B) -> B; | ^ @@ -27,7 +27,7 @@ LL | fn g(b: B) -> impl B; | ++++ error[E0782]: expected a type, found a trait - --> $DIR/ice-unsized-fn-params.rs:7:13 + --> $DIR/ice-unsized-fn-params.rs:6:13 | LL | fn f(a: A) -> A; | ^ @@ -44,7 +44,7 @@ LL | fn f(a: impl A) -> A; | ++++ error[E0782]: expected a type, found a trait - --> $DIR/ice-unsized-fn-params.rs:7:19 + --> $DIR/ice-unsized-fn-params.rs:6:19 | LL | fn f(a: A) -> A; | ^ diff --git a/tests/ui/self/arbitrary-self-types-dyn-incompatible.dyn_compatible_for_dispatch.stderr b/tests/ui/self/arbitrary-self-types-dyn-incompatible.dyn_compatible_for_dispatch.stderr deleted file mode 100644 index d324f4641cf..00000000000 --- a/tests/ui/self/arbitrary-self-types-dyn-incompatible.dyn_compatible_for_dispatch.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0038]: the trait `Foo` is not dyn compatible - --> $DIR/arbitrary-self-types-dyn-incompatible.rs:33:13 - | -LL | fn foo(self: &Rc<Self>) -> usize; - | --------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self` -... -LL | let x = Rc::new(5usize) as Rc<dyn Foo>; - | ^^^^^^^^^^^^^^^ `Foo` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/arbitrary-self-types-dyn-incompatible.rs:8:18 - | -LL | trait Foo { - | --- this trait is not dyn compatible... -LL | fn foo(self: &Rc<Self>) -> usize; - | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on - = help: only type `usize` implements `Foo`; consider using it directly instead. - = note: required for the cast from `Rc<usize>` to `Rc<dyn Foo>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/self/arbitrary-self-types-dyn-incompatible.rs b/tests/ui/self/arbitrary-self-types-dyn-incompatible.rs index 940b2f1e8e2..0477d9d79c7 100644 --- a/tests/ui/self/arbitrary-self-types-dyn-incompatible.rs +++ b/tests/ui/self/arbitrary-self-types-dyn-incompatible.rs @@ -1,7 +1,3 @@ -//@ revisions: curr dyn_compatible_for_dispatch - -#![cfg_attr(dyn_compatible_for_dispatch, feature(dyn_compatible_for_dispatch))] - use std::rc::Rc; trait Foo { @@ -31,9 +27,8 @@ impl Bar for usize { fn make_foo() { let x = Rc::new(5usize) as Rc<dyn Foo>; - //[curr]~^ ERROR E0038 - //[curr]~| ERROR E0038 - //[dyn_compatible_for_dispatch]~^^^ ERROR E0038 + //~^ ERROR E0038 + //~| ERROR E0038 } fn make_bar() { diff --git a/tests/ui/self/arbitrary-self-types-dyn-incompatible.stderr b/tests/ui/self/arbitrary-self-types-dyn-incompatible.stderr new file mode 100644 index 00000000000..9fb4c80329d --- /dev/null +++ b/tests/ui/self/arbitrary-self-types-dyn-incompatible.stderr @@ -0,0 +1,42 @@ +error[E0038]: the trait `Foo` is not dyn compatible + --> $DIR/arbitrary-self-types-dyn-incompatible.rs:29:32 + | +LL | fn foo(self: &Rc<Self>) -> usize; + | --------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self` +... +LL | let x = Rc::new(5usize) as Rc<dyn Foo>; + | ^^^^^^^^^^^ `Foo` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/arbitrary-self-types-dyn-incompatible.rs:4:18 + | +LL | trait Foo { + | --- this trait is not dyn compatible... +LL | fn foo(self: &Rc<Self>) -> usize; + | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on + = help: only type `usize` implements `Foo`; consider using it directly instead. + +error[E0038]: the trait `Foo` is not dyn compatible + --> $DIR/arbitrary-self-types-dyn-incompatible.rs:29:13 + | +LL | fn foo(self: &Rc<Self>) -> usize; + | --------- help: consider changing method `foo`'s `self` parameter to be `&self`: `&Self` +... +LL | let x = Rc::new(5usize) as Rc<dyn Foo>; + | ^^^^^^^^^^^^^^^ `Foo` is not dyn compatible + | +note: for a trait to be dyn compatible it needs to allow building a vtable + for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> + --> $DIR/arbitrary-self-types-dyn-incompatible.rs:4:18 + | +LL | trait Foo { + | --- this trait is not dyn compatible... +LL | fn foo(self: &Rc<Self>) -> usize; + | ^^^^^^^^^ ...because method `foo`'s `self` parameter cannot be dispatched on + = help: only type `usize` implements `Foo`; consider using it directly instead. + = note: required for the cast from `Rc<usize>` to `Rc<dyn Foo>` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.rs b/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.rs index 71f198f7dc7..94b76fe9685 100644 --- a/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.rs +++ b/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.rs @@ -15,7 +15,7 @@ struct Dispatchable<T: ?Sized, Z> { } impl<T, U> DispatchFromDyn<Dispatchable<U, i32>> for Dispatchable<T, ()> -//~^ ERROR implementing the `DispatchFromDyn` trait requires multiple coercions +//~^ ERROR implementing `DispatchFromDyn` does not allow multiple fields to be coerced where T: Unsize<U> + ?Sized, U: ?Sized, diff --git a/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.stderr b/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.stderr index 1f13c51f679..91760b9e2ea 100644 --- a/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.stderr +++ b/tests/ui/self/dispatch-from-dyn-zst-transmute-zst-nonzst.stderr @@ -1,4 +1,4 @@ -error[E0378]: implementing the `DispatchFromDyn` trait requires multiple coercions +error[E0375]: implementing `DispatchFromDyn` does not allow multiple fields to be coerced --> $DIR/dispatch-from-dyn-zst-transmute-zst-nonzst.rs:17:1 | LL | / impl<T, U> DispatchFromDyn<Dispatchable<U, i32>> for Dispatchable<T, ()> @@ -8,9 +8,14 @@ LL | | T: Unsize<U> + ?Sized, LL | | U: ?Sized, | |______________^ | - = note: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced - = note: currently, 2 fields need coercions: `_ptr` (`Box<T>` to `Box<U>`), `z` (`()` to `i32`) +note: the trait `DispatchFromDyn` may only be implemented when a single field is being coerced + --> $DIR/dispatch-from-dyn-zst-transmute-zst-nonzst.rs:13:5 + | +LL | _ptr: Box<T>, + | ^^^^^^^^^^^^ +LL | z: Z, + | ^^^^ error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0378`. +For more information about this error, try `rustc --explain E0375`. diff --git a/tests/ui/self/dispatch-from-dyn-zst-transmute.rs b/tests/ui/self/dispatch-from-dyn-zst-transmute.rs index 57c255b4d7b..967958ab486 100644 --- a/tests/ui/self/dispatch-from-dyn-zst-transmute.rs +++ b/tests/ui/self/dispatch-from-dyn-zst-transmute.rs @@ -15,7 +15,7 @@ struct Foo<'a, U: ?Sized> { } impl<'a, T, U> DispatchFromDyn<Foo<'a, U>> for Foo<'a, T> -//~^ ERROR implementing the `DispatchFromDyn` trait requires multiple coercions +//~^ ERROR implementing `DispatchFromDyn` does not allow multiple fields to be coerced where T: Unsize<U> + ?Sized, U: ?Sized {} diff --git a/tests/ui/self/dispatch-from-dyn-zst-transmute.stderr b/tests/ui/self/dispatch-from-dyn-zst-transmute.stderr index 5a8ae88b5f1..cc8be45e99d 100644 --- a/tests/ui/self/dispatch-from-dyn-zst-transmute.stderr +++ b/tests/ui/self/dispatch-from-dyn-zst-transmute.stderr @@ -1,4 +1,4 @@ -error[E0378]: implementing the `DispatchFromDyn` trait requires multiple coercions +error[E0375]: implementing `DispatchFromDyn` does not allow multiple fields to be coerced --> $DIR/dispatch-from-dyn-zst-transmute.rs:17:1 | LL | / impl<'a, T, U> DispatchFromDyn<Foo<'a, U>> for Foo<'a, T> @@ -8,9 +8,14 @@ LL | | T: Unsize<U> + ?Sized, LL | | U: ?Sized {} | |_____________^ | - = note: the trait `DispatchFromDyn` may only be implemented for a coercion between structures with a single field being coerced - = note: currently, 2 fields need coercions: `token` (`IsSendToken<T>` to `IsSendToken<U>`), `ptr` (`&'a T` to `&'a U`) +note: the trait `DispatchFromDyn` may only be implemented when a single field is being coerced + --> $DIR/dispatch-from-dyn-zst-transmute.rs:13:5 + | +LL | token: IsSendToken<U>, + | ^^^^^^^^^^^^^^^^^^^^^ +LL | ptr: &'a U, + | ^^^^^^^^^^ error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0378`. +For more information about this error, try `rustc --explain E0375`. diff --git a/tests/ui/simd/intrinsic/generic-elements.rs b/tests/ui/simd/intrinsic/generic-elements.rs index 4be6645f029..54cf35df8c7 100644 --- a/tests/ui/simd/intrinsic/generic-elements.rs +++ b/tests/ui/simd/intrinsic/generic-elements.rs @@ -41,7 +41,7 @@ unsafe fn simd_extract<T, E>(x: T, idx: u32) -> E; unsafe fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; #[rustc_intrinsic] -unsafe fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U; +unsafe fn simd_shuffle_const_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U; #[repr(simd)] @@ -83,27 +83,27 @@ fn main() { //~^ ERROR expected return type of length 8, found `i32x2` with length 2 const I2: &[u32] = &[0; 2]; - simd_shuffle_generic::<i32, i32, I2>(0, 0); + simd_shuffle_const_generic::<i32, i32, I2>(0, 0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` const I4: &[u32] = &[0; 4]; - simd_shuffle_generic::<i32, i32, I4>(0, 0); + simd_shuffle_const_generic::<i32, i32, I4>(0, 0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` const I8: &[u32] = &[0; 8]; - simd_shuffle_generic::<i32, i32, I8>(0, 0); + simd_shuffle_const_generic::<i32, i32, I8>(0, 0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` - simd_shuffle_generic::<_, f32x2, I2>(x, x); + simd_shuffle_const_generic::<_, f32x2, I2>(x, x); //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` - simd_shuffle_generic::<_, f32x4, I4>(x, x); + simd_shuffle_const_generic::<_, f32x4, I4>(x, x); //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` - simd_shuffle_generic::<_, f32x8, I8>(x, x); + simd_shuffle_const_generic::<_, f32x8, I8>(x, x); //~^ ERROR element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` - simd_shuffle_generic::<_, i32x8, I2>(x, x); + simd_shuffle_const_generic::<_, i32x8, I2>(x, x); //~^ ERROR expected return type of length 2, found `i32x8` with length 8 - simd_shuffle_generic::<_, i32x8, I4>(x, x); + simd_shuffle_const_generic::<_, i32x8, I4>(x, x); //~^ ERROR expected return type of length 4, found `i32x8` with length 8 - simd_shuffle_generic::<_, i32x2, I8>(x, x); + simd_shuffle_const_generic::<_, i32x2, I8>(x, x); //~^ ERROR expected return type of length 8, found `i32x2` with length 2 } } diff --git a/tests/ui/simd/intrinsic/generic-elements.stderr b/tests/ui/simd/intrinsic/generic-elements.stderr index 8104c3ba5a2..1b3e8d59213 100644 --- a/tests/ui/simd/intrinsic/generic-elements.stderr +++ b/tests/ui/simd/intrinsic/generic-elements.stderr @@ -70,59 +70,59 @@ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected ret LL | simd_shuffle::<_, _, i32x2>(x, x, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` +error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` --> $DIR/generic-elements.rs:86:9 | -LL | simd_shuffle_generic::<i32, i32, I2>(0, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle_const_generic::<i32, i32, I2>(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` +error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` --> $DIR/generic-elements.rs:89:9 | -LL | simd_shuffle_generic::<i32, i32, I4>(0, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle_const_generic::<i32, i32, I4>(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` +error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` --> $DIR/generic-elements.rs:92:9 | -LL | simd_shuffle_generic::<i32, i32, I8>(0, 0); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle_const_generic::<i32, i32, I8>(0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` +error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` --> $DIR/generic-elements.rs:95:9 | -LL | simd_shuffle_generic::<_, f32x2, I2>(x, x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle_const_generic::<_, f32x2, I2>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` +error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` --> $DIR/generic-elements.rs:97:9 | -LL | simd_shuffle_generic::<_, f32x4, I4>(x, x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle_const_generic::<_, f32x4, I4>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` +error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` --> $DIR/generic-elements.rs:99:9 | -LL | simd_shuffle_generic::<_, f32x8, I8>(x, x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle_const_generic::<_, f32x8, I8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 2, found `i32x8` with length 8 +error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return type of length 2, found `i32x8` with length 8 --> $DIR/generic-elements.rs:102:9 | -LL | simd_shuffle_generic::<_, i32x8, I2>(x, x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle_const_generic::<_, i32x8, I2>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 4, found `i32x8` with length 8 +error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return type of length 4, found `i32x8` with length 8 --> $DIR/generic-elements.rs:104:9 | -LL | simd_shuffle_generic::<_, i32x8, I4>(x, x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle_const_generic::<_, i32x8, I4>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 8, found `i32x2` with length 2 +error[E0511]: invalid monomorphization of `simd_shuffle_const_generic` intrinsic: expected return type of length 8, found `i32x2` with length 2 --> $DIR/generic-elements.rs:106:9 | -LL | simd_shuffle_generic::<_, i32x2, I8>(x, x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | simd_shuffle_const_generic::<_, i32x2, I8>(x, x); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 21 previous errors diff --git a/tests/ui/simd/monomorphize-shuffle-index.generic.stderr b/tests/ui/simd/monomorphize-shuffle-index.generic.stderr index b0a8da59fac..8d4bf1e0533 100644 --- a/tests/ui/simd/monomorphize-shuffle-index.generic.stderr +++ b/tests/ui/simd/monomorphize-shuffle-index.generic.stderr @@ -1,10 +1,10 @@ error: overly complex generic constant - --> $DIR/monomorphize-shuffle-index.rs:32:45 + --> $DIR/monomorphize-shuffle-index.rs:32:51 | -LL | return simd_shuffle_generic::<_, _, { &Self::I.0 }>(a, b); - | ^^----------^^ - | | - | pointer casts are not allowed in generic constants +LL | return simd_shuffle_const_generic::<_, _, { &Self::I.0 }>(a, b); + | ^^----------^^ + | | + | pointer casts are not allowed in generic constants | = help: consider moving this anonymous constant into a `const` function diff --git a/tests/ui/simd/monomorphize-shuffle-index.rs b/tests/ui/simd/monomorphize-shuffle-index.rs index 01926408a2c..026193e6af6 100644 --- a/tests/ui/simd/monomorphize-shuffle-index.rs +++ b/tests/ui/simd/monomorphize-shuffle-index.rs @@ -11,7 +11,7 @@ unsafe fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; #[rustc_intrinsic] #[cfg(any(generic, generic_with_fn))] -unsafe fn simd_shuffle_generic<T, U, const I: &'static [u32]>(a: T, b: T) -> U; +unsafe fn simd_shuffle_const_generic<T, U, const I: &'static [u32]>(a: T, b: T) -> U; #[derive(Copy, Clone)] @@ -29,10 +29,10 @@ trait Shuffle<const N: usize> { #[cfg(old)] return simd_shuffle(a, b, Self::I); #[cfg(generic)] - return simd_shuffle_generic::<_, _, { &Self::I.0 }>(a, b); + return simd_shuffle_const_generic::<_, _, { &Self::I.0 }>(a, b); //[generic]~^ overly complex generic constant #[cfg(generic_with_fn)] - return simd_shuffle_generic::<_, _, { Self::J }>(a, b); + return simd_shuffle_const_generic::<_, _, { Self::J }>(a, b); } } diff --git a/tests/ui/stability-attribute/stability-attribute-sanity.rs b/tests/ui/stability-attribute/stability-attribute-sanity.rs index 7857a0603bd..f46e35e1a72 100644 --- a/tests/ui/stability-attribute/stability-attribute-sanity.rs +++ b/tests/ui/stability-attribute/stability-attribute-sanity.rs @@ -8,16 +8,16 @@ mod bogus_attribute_types_1 { #[stable(feature = "a", since = "4.4.4", reason)] //~ ERROR unknown meta item 'reason' [E0541] fn f1() { } - #[stable(feature = "a", since)] //~ ERROR incorrect meta item [E0539] + #[stable(feature = "a", since)] //~ ERROR expected a quoted string literal [E0539] fn f2() { } - #[stable(feature, since = "3.3.3")] //~ ERROR incorrect meta item [E0539] + #[stable(feature, since = "3.3.3")] //~ ERROR expected a quoted string literal [E0539] fn f3() { } - #[stable(feature = "a", since(b))] //~ ERROR incorrect meta item [E0539] + #[stable(feature = "a", since(b))] //~ ERROR expected a quoted string literal [E0539] fn f5() { } - #[stable(feature(b), since = "3.3.3")] //~ ERROR incorrect meta item [E0539] + #[stable(feature(b), since = "3.3.3")] //~ ERROR expected a quoted string literal [E0539] fn f6() { } } diff --git a/tests/ui/stability-attribute/stability-attribute-sanity.stderr b/tests/ui/stability-attribute/stability-attribute-sanity.stderr index c614fc2b9f7..2e2b5b509c8 100644 --- a/tests/ui/stability-attribute/stability-attribute-sanity.stderr +++ b/tests/ui/stability-attribute/stability-attribute-sanity.stderr @@ -1,40 +1,28 @@ -error: multiple `deprecated` attributes - --> $DIR/stability-attribute-sanity.rs:62:1 - | -LL | #[deprecated(since = "5.5.5", note = "text")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/stability-attribute-sanity.rs:61:1 - | -LL | #[deprecated(since = "5.5.5", note = "text")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error[E0541]: unknown meta item 'reason' --> $DIR/stability-attribute-sanity.rs:8:46 | LL | #[stable(feature = "a", since = "4.4.4", reason)] | ^^^^^^ expected one of `feature`, `since` -error[E0539]: incorrect meta item +error[E0539]: expected a quoted string literal --> $DIR/stability-attribute-sanity.rs:11:29 | LL | #[stable(feature = "a", since)] | ^^^^^ -error[E0539]: incorrect meta item +error[E0539]: expected a quoted string literal --> $DIR/stability-attribute-sanity.rs:14:14 | LL | #[stable(feature, since = "3.3.3")] | ^^^^^^^ -error[E0539]: incorrect meta item +error[E0539]: expected a quoted string literal --> $DIR/stability-attribute-sanity.rs:17:29 | LL | #[stable(feature = "a", since(b))] | ^^^^^^^^ -error[E0539]: incorrect meta item +error[E0539]: expected a quoted string literal --> $DIR/stability-attribute-sanity.rs:20:14 | LL | #[stable(feature(b), since = "3.3.3")] @@ -100,6 +88,18 @@ error: 'since' must be a Rust version number, such as "1.31.0" LL | #[stable(feature = "e", since = "b")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: multiple `deprecated` attributes + --> $DIR/stability-attribute-sanity.rs:62:1 + | +LL | #[deprecated(since = "5.5.5", note = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/stability-attribute-sanity.rs:61:1 + | +LL | #[deprecated(since = "5.5.5", note = "text")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0544]: multiple stability levels --> $DIR/stability-attribute-sanity.rs:64:1 | diff --git a/tests/ui/suggestions/issue-104328.rs b/tests/ui/suggestions/issue-104328.rs deleted file mode 100644 index 2b0fbdb8d35..00000000000 --- a/tests/ui/suggestions/issue-104328.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(dyn_compatible_for_dispatch)] - -trait Foo { - fn f() {} -} - -impl Foo for dyn Sized {} - -fn main() { - Foo::f(); - //~^ ERROR cannot call associated function on trait without specifying the corresponding `impl` type -} diff --git a/tests/ui/suggestions/issue-104328.stderr b/tests/ui/suggestions/issue-104328.stderr deleted file mode 100644 index 3c5e6f16289..00000000000 --- a/tests/ui/suggestions/issue-104328.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0790]: cannot call associated function on trait without specifying the corresponding `impl` type - --> $DIR/issue-104328.rs:10:5 - | -LL | fn f() {} - | --------- `Foo::f` defined here -... -LL | Foo::f(); - | ^^^^^^^^ cannot call associated function of trait - | -help: use the fully-qualified path to the only available implementation - | -LL | <(dyn Sized + 'static) as Foo>::f(); - | +++++++++++++++++++++++++ + - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0790`. diff --git a/tests/ui/target-feature/feature-hierarchy.rs b/tests/ui/target-feature/feature-hierarchy.rs index d62b86693c2..315ec983a19 100644 --- a/tests/ui/target-feature/feature-hierarchy.rs +++ b/tests/ui/target-feature/feature-hierarchy.rs @@ -21,10 +21,7 @@ impl Copy for bool {} #[stable(feature = "test", since = "1.0.0")] #[rustc_const_stable(feature = "test", since = "1.0.0")] #[rustc_intrinsic] -#[rustc_intrinsic_must_be_overridden] -const unsafe fn unreachable() -> ! { - loop {} -} +const unsafe fn unreachable() -> !; #[rustc_builtin_macro] macro_rules! cfg { diff --git a/tests/ui/traits/issue-78372.stderr b/tests/ui/traits/issue-78372.stderr index d4dfba4f039..fbc60ce5d83 100644 --- a/tests/ui/traits/issue-78372.stderr +++ b/tests/ui/traits/issue-78372.stderr @@ -65,7 +65,7 @@ LL | fn foo(self: Smaht<Self, T>); = note: type of `self` must be `Self` or a type that dereferences to it = help: consider changing to `self`, `&self`, `&mut self`, `self: Box<Self>`, `self: Rc<Self>`, `self: Arc<Self>`, or `self: Pin<P>` (where P is one of the previous types except `Self`) -error[E0378]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures +error[E0377]: the trait `DispatchFromDyn` may only be implemented for a coercion between structures --> $DIR/issue-78372.rs:3:1 | LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {} @@ -73,5 +73,5 @@ LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {} error: aborting due to 7 previous errors -Some errors have detailed explanations: E0307, E0378, E0412, E0658. +Some errors have detailed explanations: E0307, E0377, E0412, E0658. For more information about an error, try `rustc --explain E0307`. diff --git a/tests/ui/wf/wf-convert-dyn-incompat-trait-obj-box.rs b/tests/ui/wf/wf-convert-dyn-incompat-trait-obj-box.rs deleted file mode 100644 index 26292a1d218..00000000000 --- a/tests/ui/wf/wf-convert-dyn-incompat-trait-obj-box.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Check that we do not allow casts or coercions -// to dyn-incompatible trait objects inside a Box - -#![feature(dyn_compatible_for_dispatch)] - -trait Trait: Sized {} - -struct S; - -impl Trait for S {} - -fn takes_box(t: Box<dyn Trait>) {} - -fn main() { - Box::new(S) as Box<dyn Trait>; //~ ERROR E0038 - let t_box: Box<dyn Trait> = Box::new(S); //~ ERROR E0038 - takes_box(Box::new(S)); //~ ERROR E0038 -} diff --git a/tests/ui/wf/wf-convert-dyn-incompat-trait-obj-box.stderr b/tests/ui/wf/wf-convert-dyn-incompat-trait-obj-box.stderr deleted file mode 100644 index f3e4f2a63e9..00000000000 --- a/tests/ui/wf/wf-convert-dyn-incompat-trait-obj-box.stderr +++ /dev/null @@ -1,54 +0,0 @@ -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/wf-convert-dyn-incompat-trait-obj-box.rs:16:33 - | -LL | let t_box: Box<dyn Trait> = Box::new(S); - | ^^^^^^^^^^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/wf-convert-dyn-incompat-trait-obj-box.rs:6:14 - | -LL | trait Trait: Sized {} - | ----- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - = help: only type `S` implements `Trait`; consider using it directly instead. - = note: required for the cast from `Box<S>` to `Box<dyn Trait>` - -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/wf-convert-dyn-incompat-trait-obj-box.rs:17:15 - | -LL | takes_box(Box::new(S)); - | ^^^^^^^^^^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/wf-convert-dyn-incompat-trait-obj-box.rs:6:14 - | -LL | trait Trait: Sized {} - | ----- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - = help: only type `S` implements `Trait`; consider using it directly instead. - = note: required for the cast from `Box<S>` to `Box<(dyn Trait + 'static)>` - -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/wf-convert-dyn-incompat-trait-obj-box.rs:15:5 - | -LL | Box::new(S) as Box<dyn Trait>; - | ^^^^^^^^^^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/wf-convert-dyn-incompat-trait-obj-box.rs:6:14 - | -LL | trait Trait: Sized {} - | ----- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - = help: only type `S` implements `Trait`; consider using it directly instead. - = note: required for the cast from `Box<S>` to `Box<dyn Trait>` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/wf/wf-convert-dyn-incompat-trait-obj.rs b/tests/ui/wf/wf-convert-dyn-incompat-trait-obj.rs deleted file mode 100644 index ec4bb2897f9..00000000000 --- a/tests/ui/wf/wf-convert-dyn-incompat-trait-obj.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Check that we do not allow casts or coercions -// to dyn-incompatible trait objects by ref - -#![feature(dyn_compatible_for_dispatch)] - -trait Trait: Sized {} - -struct S; - -impl Trait for S {} - -fn takes_trait(t: &dyn Trait) {} - -fn main() { - &S as &dyn Trait; //~ ERROR E0038 - let t: &dyn Trait = &S; //~ ERROR E0038 - takes_trait(&S); //~ ERROR E0038 -} diff --git a/tests/ui/wf/wf-convert-dyn-incompat-trait-obj.stderr b/tests/ui/wf/wf-convert-dyn-incompat-trait-obj.stderr deleted file mode 100644 index 716d0e78ff1..00000000000 --- a/tests/ui/wf/wf-convert-dyn-incompat-trait-obj.stderr +++ /dev/null @@ -1,54 +0,0 @@ -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/wf-convert-dyn-incompat-trait-obj.rs:16:25 - | -LL | let t: &dyn Trait = &S; - | ^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/wf-convert-dyn-incompat-trait-obj.rs:6:14 - | -LL | trait Trait: Sized {} - | ----- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - = help: only type `S` implements `Trait`; consider using it directly instead. - = note: required for the cast from `&S` to `&dyn Trait` - -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/wf-convert-dyn-incompat-trait-obj.rs:17:17 - | -LL | takes_trait(&S); - | ^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/wf-convert-dyn-incompat-trait-obj.rs:6:14 - | -LL | trait Trait: Sized {} - | ----- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - = help: only type `S` implements `Trait`; consider using it directly instead. - = note: required for the cast from `&S` to `&dyn Trait` - -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/wf-convert-dyn-incompat-trait-obj.rs:15:5 - | -LL | &S as &dyn Trait; - | ^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/wf-convert-dyn-incompat-trait-obj.rs:6:14 - | -LL | trait Trait: Sized {} - | ----- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - = help: only type `S` implements `Trait`; consider using it directly instead. - = note: required for the cast from `&S` to `&dyn Trait` - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/wf/wf-dyn-incompat-trait-obj-match.rs b/tests/ui/wf/wf-dyn-incompat-trait-obj-match.rs deleted file mode 100644 index 6eba6b7abec..00000000000 --- a/tests/ui/wf/wf-dyn-incompat-trait-obj-match.rs +++ /dev/null @@ -1,29 +0,0 @@ -// Check that we do not allow coercions to object -// unsafe trait objects in match arms - -#![feature(dyn_compatible_for_dispatch)] - -trait Trait: Sized {} - -struct S; - -impl Trait for S {} - -struct R; - -impl Trait for R {} - -fn opt() -> Option<()> { - Some(()) -} - -fn main() { - match opt() { - Some(()) => &S, - None => &R, //~ ERROR E0308 - } - let t: &dyn Trait = match opt() { - Some(()) => &S, //~ ERROR E0038 - None => &R, //~ ERROR E0038 - }; -} diff --git a/tests/ui/wf/wf-dyn-incompat-trait-obj-match.stderr b/tests/ui/wf/wf-dyn-incompat-trait-obj-match.stderr deleted file mode 100644 index a7405ce4caa..00000000000 --- a/tests/ui/wf/wf-dyn-incompat-trait-obj-match.stderr +++ /dev/null @@ -1,60 +0,0 @@ -error[E0308]: `match` arms have incompatible types - --> $DIR/wf-dyn-incompat-trait-obj-match.rs:23:17 - | -LL | / match opt() { -LL | | Some(()) => &S, - | | -- this is found to be of type `&S` -LL | | None => &R, - | | ^^ expected `&S`, found `&R` -LL | | } - | |_____- `match` arms have incompatible types - | - = note: expected reference `&S` - found reference `&R` - -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/wf-dyn-incompat-trait-obj-match.rs:26:21 - | -LL | Some(()) => &S, - | ^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/wf-dyn-incompat-trait-obj-match.rs:6:14 - | -LL | trait Trait: Sized {} - | ----- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - = help: the following types implement `Trait`: - S - R - consider defining an enum where each variant holds one of these types, - implementing `Trait` for this new enum and using it instead - = note: required for the cast from `&S` to `&dyn Trait` - -error[E0038]: the trait `Trait` is not dyn compatible - --> $DIR/wf-dyn-incompat-trait-obj-match.rs:27:17 - | -LL | None => &R, - | ^^ `Trait` is not dyn compatible - | -note: for a trait to be dyn compatible it needs to allow building a vtable - for more information, visit <https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility> - --> $DIR/wf-dyn-incompat-trait-obj-match.rs:6:14 - | -LL | trait Trait: Sized {} - | ----- ^^^^^ ...because it requires `Self: Sized` - | | - | this trait is not dyn compatible... - = help: the following types implement `Trait`: - S - R - consider defining an enum where each variant holds one of these types, - implementing `Trait` for this new enum and using it instead - = note: required for the cast from `&R` to `&dyn Trait` - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0038, E0308. -For more information about an error, try `rustc --explain E0038`. |
