diff options
Diffstat (limited to 'tests')
1575 files changed, 23188 insertions, 14044 deletions
diff --git a/tests/assembly/cmse.rs b/tests/assembly/cmse.rs index 2984df92225..a68ee99eac6 100644 --- a/tests/assembly/cmse.rs +++ b/tests/assembly/cmse.rs @@ -6,7 +6,7 @@ //@ [hard] needs-llvm-components: arm //@ [soft] needs-llvm-components: arm #![crate_type = "lib"] -#![feature(abi_c_cmse_nonsecure_call, cmse_nonsecure_entry, no_core, lang_items)] +#![feature(abi_cmse_nonsecure_call, cmse_nonsecure_entry, no_core, lang_items)] #![no_core] extern crate minicore; @@ -53,7 +53,7 @@ use minicore::*; // Branch back to non-secure side // CHECK: bxns lr #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn entry_point() -> i64 { +pub extern "cmse-nonsecure-entry" fn entry_point() -> i64 { 0 } @@ -95,8 +95,6 @@ pub extern "C-cmse-nonsecure-entry" fn entry_point() -> i64 { // Call to non-secure // CHECK: blxns r12 #[no_mangle] -pub fn call_nonsecure( - f: unsafe extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32) -> u64, -) -> u64 { +pub fn call_nonsecure(f: unsafe extern "cmse-nonsecure-call" fn(u32, u32, u32, u32) -> u64) -> u64 { unsafe { f(0, 1, 2, 3) } } diff --git a/tests/assembly/naked-functions/wasm32.rs b/tests/assembly/naked-functions/wasm32.rs index 5f114246ad5..77547e82041 100644 --- a/tests/assembly/naked-functions/wasm32.rs +++ b/tests/assembly/naked-functions/wasm32.rs @@ -27,18 +27,16 @@ extern "C" fn nop() { naked_asm!("nop") } -// CHECK: .section .text.weak_aligned_nop,"",@ -// CHECK: .weak weak_aligned_nop +// CHECK: .section .text.weak_nop,"",@ +// CHECK: .weak weak_nop // CHECK-LABEL: nop: -// CHECK: .functype weak_aligned_nop () -> () +// CHECK: .functype weak_nop () -> () // CHECK-NOT: .size // CHECK: end_function #[no_mangle] #[unsafe(naked)] #[linkage = "weak"] -// wasm functions cannot be aligned, so this has no effect -#[align(32)] -extern "C" fn weak_aligned_nop() { +extern "C" fn weak_nop() { naked_asm!("nop") } diff --git a/tests/auxiliary/minicore.rs b/tests/auxiliary/minicore.rs index db11549382f..392ad1cee14 100644 --- a/tests/auxiliary/minicore.rs +++ b/tests/auxiliary/minicore.rs @@ -5,7 +5,8 @@ //! # Important notes //! //! - `minicore` is **only** intended for `core` items, and the stubs should match the actual `core` -//! items. +//! items. For identical error output, any `diagnostic` attributes (e.g. `on_unimplemented`) +//! should also be replicated here. //! - Be careful of adding new features and things that are only available for a subset of targets. //! //! # References @@ -16,6 +17,7 @@ #![feature( no_core, + intrinsics, lang_items, auto_traits, freeze_impls, @@ -40,12 +42,24 @@ macro_rules! impl_marker_trait { } #[lang = "pointee_sized"] +#[diagnostic::on_unimplemented( + message = "values of type `{Self}` may or may not have a size", + label = "may or may not have a known size" +)] pub trait PointeeSized {} #[lang = "meta_sized"] +#[diagnostic::on_unimplemented( + message = "the size for values of type `{Self}` cannot be known", + label = "doesn't have a known size" +)] pub trait MetaSized: PointeeSized {} #[lang = "sized"] +#[diagnostic::on_unimplemented( + message = "the size for values of type `{Self}` cannot be known at compilation time", + label = "doesn't have a size known at compile-time" +)] pub trait Sized: MetaSized {} #[lang = "legacy_receiver"] @@ -63,6 +77,10 @@ pub trait BikeshedGuaranteedNoDrop {} pub unsafe auto trait Freeze {} #[lang = "unpin"] +#[diagnostic::on_unimplemented( + note = "consider using the `pin!` macro\nconsider using `Box::pin` if you need to access the pinned value outside of the current scope", + message = "`{Self}` cannot be unpinned" +)] pub auto trait Unpin {} impl_marker_trait!( @@ -109,6 +127,7 @@ pub struct UnsafeCell<T: PointeeSized> { impl<T: PointeeSized> !Freeze for UnsafeCell<T> {} #[lang = "tuple_trait"] +#[diagnostic::on_unimplemented(message = "`{Self}` is not a tuple")] pub trait Tuple {} #[rustc_builtin_macro] @@ -196,3 +215,9 @@ impl<'a, 'b: 'a, T: PointeeSized + Unsize<U>, U: PointeeSized> CoerceUnsized<&'a trait Drop { fn drop(&mut self); } + +pub mod mem { + #[rustc_nounwind] + #[rustc_intrinsic] + pub unsafe fn transmute<Src, Dst>(src: Src) -> Dst; +} diff --git a/tests/codegen-units/item-collection/drop-glue-noop.rs b/tests/codegen-units/item-collection/drop-glue-noop.rs new file mode 100644 index 00000000000..604ba883bb2 --- /dev/null +++ b/tests/codegen-units/item-collection/drop-glue-noop.rs @@ -0,0 +1,23 @@ +//@ compile-flags:-Clink-dead-code -Zmir-opt-level=0 + +#![deny(dead_code)] +#![crate_type = "lib"] + +//~ MONO_ITEM fn start +#[no_mangle] +pub fn start(_: isize, _: *const *const u8) -> isize { + // No item produced for this, it's a no-op drop and so is removed. + unsafe { + std::ptr::drop_in_place::<u32>(&mut 0); + } + + // No choice but to codegen for indirect drop as a function pointer, since we have to produce a + // function with the right signature. In vtables we can avoid that (tested in + // instantiation-through-vtable.rs) because we special case null pointer for drop glue since + // #122662. + // + //~ MONO_ITEM fn std::ptr::drop_in_place::<u64> - shim(None) @@ drop_glue_noop-cgu.0[External] + std::ptr::drop_in_place::<u64> as unsafe fn(*mut u64); + + 0 +} diff --git a/tests/codegen-units/item-collection/instantiation-through-vtable.rs b/tests/codegen-units/item-collection/instantiation-through-vtable.rs index 8f13fd55808..7882a526b68 100644 --- a/tests/codegen-units/item-collection/instantiation-through-vtable.rs +++ b/tests/codegen-units/item-collection/instantiation-through-vtable.rs @@ -24,7 +24,6 @@ impl<T> Trait for Struct<T> { pub fn start(_: isize, _: *const *const u8) -> isize { let s1 = Struct { _a: 0u32 }; - //~ MONO_ITEM fn std::ptr::drop_in_place::<Struct<u32>> - shim(None) @@ instantiation_through_vtable-cgu.0[External] //~ MONO_ITEM fn <Struct<u32> as Trait>::foo //~ MONO_ITEM fn <Struct<u32> as Trait>::bar let r1 = &s1 as &Trait; @@ -32,7 +31,6 @@ pub fn start(_: isize, _: *const *const u8) -> isize { r1.bar(); let s1 = Struct { _a: 0u64 }; - //~ MONO_ITEM fn std::ptr::drop_in_place::<Struct<u64>> - shim(None) @@ instantiation_through_vtable-cgu.0[External] //~ MONO_ITEM fn <Struct<u64> as Trait>::foo //~ MONO_ITEM fn <Struct<u64> as Trait>::bar let _ = &s1 as &Trait; diff --git a/tests/codegen-units/item-collection/non-generic-closures.rs b/tests/codegen-units/item-collection/non-generic-closures.rs index 124fe7e3b69..2d9c461e6fd 100644 --- a/tests/codegen-units/item-collection/non-generic-closures.rs +++ b/tests/codegen-units/item-collection/non-generic-closures.rs @@ -1,4 +1,4 @@ -//@ compile-flags:-Clink-dead-code -Zinline-mir=no +//@ compile-flags:-Clink-dead-code -Zinline-mir=no -O #![deny(dead_code)] #![crate_type = "lib"] @@ -22,9 +22,8 @@ fn assigned_to_variable_but_not_executed() { //~ MONO_ITEM fn assigned_to_variable_executed_indirectly @@ non_generic_closures-cgu.0[External] fn assigned_to_variable_executed_indirectly() { //~ MONO_ITEM fn assigned_to_variable_executed_indirectly::{closure#0} @@ non_generic_closures-cgu.0[External] - //~ MONO_ITEM fn <{closure@TEST_PATH:28:13: 28:21} as std::ops::FnOnce<(i32,)>>::call_once - shim @@ non_generic_closures-cgu.0[External] - //~ MONO_ITEM fn <{closure@TEST_PATH:28:13: 28:21} as std::ops::FnOnce<(i32,)>>::call_once - shim(vtable) @@ non_generic_closures-cgu.0[External] - //~ MONO_ITEM fn std::ptr::drop_in_place::<{closure@TEST_PATH:28:13: 28:21}> - shim(None) @@ non_generic_closures-cgu.0[External] + //~ MONO_ITEM fn <{closure@TEST_PATH:27:13: 27:21} as std::ops::FnOnce<(i32,)>>::call_once - shim @@ non_generic_closures-cgu.0[External] + //~ MONO_ITEM fn <{closure@TEST_PATH:27:13: 27:21} as std::ops::FnOnce<(i32,)>>::call_once - shim(vtable) @@ non_generic_closures-cgu.0[External] let f = |a: i32| { let _ = a + 2; }; @@ -40,6 +39,20 @@ fn assigned_to_variable_executed_directly() { f(4); } +// Make sure we generate mono items for stateful closures that need dropping +//~ MONO_ITEM fn with_drop @@ non_generic_closures-cgu.0[External] +fn with_drop(v: PresentDrop) { + //~ MONO_ITEM fn with_drop::{closure#0} @@ non_generic_closures-cgu.0[External] + //~ MONO_ITEM fn std::ptr::drop_in_place::<PresentDrop> - shim(Some(PresentDrop)) @@ non_generic_closures-cgu.0[Internal] + //~ MONO_ITEM fn std::ptr::drop_in_place::<{closure@TEST_PATH:49:14: 49:24}> - shim(Some({closure@TEST_PATH:49:14: 49:24})) @@ non_generic_closures-cgu.0[Internal] + + let _f = |a: usize| { + let _ = a + 2; + //~ MONO_ITEM fn std::mem::drop::<PresentDrop> @@ non_generic_closures-cgu.0[External] + drop(v); + }; +} + //~ MONO_ITEM fn start @@ non_generic_closures-cgu.0[External] #[no_mangle] pub fn start(_: isize, _: *const *const u8) -> isize { @@ -47,6 +60,7 @@ pub fn start(_: isize, _: *const *const u8) -> isize { assigned_to_variable_but_not_executed(); assigned_to_variable_executed_directly(); assigned_to_variable_executed_indirectly(); + with_drop(PresentDrop); 0 } @@ -55,3 +69,10 @@ pub fn start(_: isize, _: *const *const u8) -> isize { fn run_closure(f: &Fn(i32)) { f(3); } + +struct PresentDrop; + +impl Drop for PresentDrop { + //~ MONO_ITEM fn <PresentDrop as std::ops::Drop>::drop @@ non_generic_closures-cgu.0[External] + fn drop(&mut self) {} +} diff --git a/tests/codegen-units/item-collection/unsizing.rs b/tests/codegen-units/item-collection/unsizing.rs index 15e42bce249..b751d2153a9 100644 --- a/tests/codegen-units/item-collection/unsizing.rs +++ b/tests/codegen-units/item-collection/unsizing.rs @@ -1,4 +1,4 @@ -//@ compile-flags:-Zmir-opt-level=0 +//@ compile-flags:-Zmir-opt-level=0 -O #![deny(dead_code)] #![feature(coerce_unsized)] @@ -42,33 +42,47 @@ struct Wrapper<T: ?Sized>(#[allow(dead_code)] *const T); impl<T: ?Sized + Unsize<U>, U: ?Sized> CoerceUnsized<Wrapper<U>> for Wrapper<T> {} +struct PresentDrop; + +impl Drop for PresentDrop { + fn drop(&mut self) {} +} + +// Custom Coercion Case +impl Trait for PresentDrop { + fn foo(&self) {} +} + //~ MONO_ITEM fn start #[no_mangle] pub fn start(_: isize, _: *const *const u8) -> isize { // simple case let bool_sized = &true; - //~ MONO_ITEM fn std::ptr::drop_in_place::<bool> - shim(None) @@ unsizing-cgu.0[Internal] //~ MONO_ITEM fn <bool as Trait>::foo let _bool_unsized = bool_sized as &Trait; let char_sized = &'a'; - //~ MONO_ITEM fn std::ptr::drop_in_place::<char> - shim(None) @@ unsizing-cgu.0[Internal] //~ MONO_ITEM fn <char as Trait>::foo let _char_unsized = char_sized as &Trait; // struct field let struct_sized = &Struct { _a: 1, _b: 2, _c: 3.0f64 }; - //~ MONO_ITEM fn std::ptr::drop_in_place::<f64> - shim(None) @@ unsizing-cgu.0[Internal] //~ MONO_ITEM fn <f64 as Trait>::foo let _struct_unsized = struct_sized as &Struct<Trait>; // custom coercion let wrapper_sized = Wrapper(&0u32); - //~ MONO_ITEM fn std::ptr::drop_in_place::<u32> - shim(None) @@ unsizing-cgu.0[Internal] //~ MONO_ITEM fn <u32 as Trait>::foo let _wrapper_sized = wrapper_sized as Wrapper<Trait>; + // with drop + let droppable = &PresentDrop; + //~ MONO_ITEM fn <PresentDrop as std::ops::Drop>::drop @@ unsizing-cgu.0[Internal] + //~ MONO_ITEM fn std::ptr::drop_in_place::<PresentDrop> - shim(Some(PresentDrop)) @@ unsizing-cgu.0[Internal] + //~ MONO_ITEM fn <PresentDrop as Trait>::foo + let droppable = droppable as &dyn Trait; + false.foo(); 0 diff --git a/tests/codegen-units/partitioning/vtable-through-const.rs b/tests/codegen-units/partitioning/vtable-through-const.rs index aad9ccb634b..7a070728843 100644 --- a/tests/codegen-units/partitioning/vtable-through-const.rs +++ b/tests/codegen-units/partitioning/vtable-through-const.rs @@ -35,7 +35,6 @@ mod mod1 { } } - //~ MONO_ITEM fn mod1::id::<i64> @@ vtable_through_const-mod1.volatile[Internal] fn id<T>(x: T) -> T { x } @@ -50,8 +49,6 @@ mod mod1 { fn do_something_else(&self) {} } - //~ MONO_ITEM fn <mod1::NeedsDrop as mod1::Trait2>::do_something @@ vtable_through_const-mod1.volatile[External] - //~ MONO_ITEM fn <mod1::NeedsDrop as mod1::Trait2>::do_something_else @@ vtable_through_const-mod1.volatile[External] impl Trait2 for NeedsDrop {} pub trait Trait2Gen<T> { @@ -93,8 +90,6 @@ pub fn main() { // Same as above //~ MONO_ITEM fn <mod1::NeedsDrop as mod1::Trait1Gen<u8>>::do_something @@ vtable_through_const-mod1.volatile[External] //~ MONO_ITEM fn <mod1::NeedsDrop as mod1::Trait1Gen<u8>>::do_something_else @@ vtable_through_const-mod1.volatile[External] - //~ MONO_ITEM fn <mod1::NeedsDrop as mod1::Trait2Gen<u8>>::do_something @@ vtable_through_const-mod1.volatile[External] - //~ MONO_ITEM fn <mod1::NeedsDrop as mod1::Trait2Gen<u8>>::do_something_else @@ vtable_through_const-mod1.volatile[External] mod1::TRAIT1_GEN_REF.do_something(0u8); //~ MONO_ITEM fn mod1::id::<char> @@ vtable_through_const-mod1.volatile[External] diff --git a/tests/codegen/abi-x86-interrupt.rs b/tests/codegen/abi-x86-interrupt.rs index 255ccba2c11..9a1ded2c9e3 100644 --- a/tests/codegen/abi-x86-interrupt.rs +++ b/tests/codegen/abi-x86-interrupt.rs @@ -13,8 +13,6 @@ extern crate minicore; use minicore::*; -// CHECK: define x86_intrcc i64 @has_x86_interrupt_abi +// CHECK: define x86_intrcc void @has_x86_interrupt_abi #[no_mangle] -pub extern "x86-interrupt" fn has_x86_interrupt_abi(a: i64) -> i64 { - a -} +pub extern "x86-interrupt" fn has_x86_interrupt_abi() {} diff --git a/tests/codegen/align-fn.rs b/tests/codegen/align-fn.rs index 267da060240..fd572910c28 100644 --- a/tests/codegen/align-fn.rs +++ b/tests/codegen/align-fn.rs @@ -1,10 +1,12 @@ -//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 +//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 -Clink-dead-code +//@ edition: 2024 +//@ ignore-wasm32 aligning functions is not currently supported on wasm (#143368) #![crate_type = "lib"] #![feature(fn_align)] // CHECK: align 16 -#[no_mangle] +#[unsafe(no_mangle)] #[align(16)] pub fn fn_align() {} @@ -12,12 +14,12 @@ pub struct A; impl A { // CHECK: align 16 - #[no_mangle] + #[unsafe(no_mangle)] #[align(16)] pub fn method_align(self) {} // CHECK: align 16 - #[no_mangle] + #[unsafe(no_mangle)] #[align(16)] pub fn associated_fn() {} } @@ -25,46 +27,115 @@ impl A { trait T: Sized { fn trait_fn() {} - // CHECK: align 32 - #[align(32)] fn trait_method(self) {} + + #[align(8)] + fn trait_method_inherit_low(self); + + #[align(32)] + fn trait_method_inherit_high(self); + + #[align(32)] + fn trait_method_inherit_default(self) {} + + #[align(4)] + #[align(128)] + #[align(8)] + fn inherit_highest(self) {} } impl T for A { - // CHECK: align 16 - #[no_mangle] + // CHECK-LABEL: trait_fn + // CHECK-SAME: align 16 + #[unsafe(no_mangle)] #[align(16)] fn trait_fn() {} - // CHECK: align 16 - #[no_mangle] + // CHECK-LABEL: trait_method + // CHECK-SAME: align 16 + #[unsafe(no_mangle)] #[align(16)] fn trait_method(self) {} -} -impl T for () {} + // The prototype's align is ignored because the align here is higher. + // CHECK-LABEL: trait_method_inherit_low + // CHECK-SAME: align 16 + #[unsafe(no_mangle)] + #[align(16)] + fn trait_method_inherit_low(self) {} + + // The prototype's align is used because it is higher. + // CHECK-LABEL: trait_method_inherit_high + // CHECK-SAME: align 32 + #[unsafe(no_mangle)] + #[align(16)] + fn trait_method_inherit_high(self) {} + + // The prototype's align inherited. + // CHECK-LABEL: trait_method_inherit_default + // CHECK-SAME: align 32 + #[unsafe(no_mangle)] + fn trait_method_inherit_default(self) {} -pub fn foo() { - ().trait_method(); + // The prototype's highest align inherited. + // CHECK-LABEL: inherit_highest + // CHECK-SAME: align 128 + #[unsafe(no_mangle)] + #[align(32)] + #[align(64)] + fn inherit_highest(self) {} +} + +trait HasDefaultImpl: Sized { + // CHECK-LABEL: inherit_from_default_method + // CHECK-LABEL: inherit_from_default_method + // CHECK-SAME: align 32 + #[align(32)] + fn inherit_from_default_method(self) {} } +pub struct InstantiateDefaultMethods; + +impl HasDefaultImpl for InstantiateDefaultMethods {} + // CHECK-LABEL: align_specified_twice_1 // CHECK-SAME: align 64 -#[no_mangle] +#[unsafe(no_mangle)] #[align(32)] #[align(64)] pub fn align_specified_twice_1() {} // CHECK-LABEL: align_specified_twice_2 // CHECK-SAME: align 128 -#[no_mangle] +#[unsafe(no_mangle)] #[align(128)] #[align(32)] pub fn align_specified_twice_2() {} // CHECK-LABEL: align_specified_twice_3 // CHECK-SAME: align 256 -#[no_mangle] +#[unsafe(no_mangle)] #[align(32)] #[align(256)] pub fn align_specified_twice_3() {} + +const _: () = { + // CHECK-LABEL: align_unmangled + // CHECK-SAME: align 256 + #[unsafe(no_mangle)] + #[align(32)] + #[align(256)] + extern "C" fn align_unmangled() {} +}; + +unsafe extern "C" { + #[align(256)] + fn align_unmangled(); +} + +// FIXME also check `gen` et al +// CHECK-LABEL: async_align +// CHECK-SAME: align 64 +#[unsafe(no_mangle)] +#[align(64)] +pub async fn async_align() {} diff --git a/tests/codegen/align-struct.rs b/tests/codegen/align-struct.rs index 402a184d4c0..d4cc65e9158 100644 --- a/tests/codegen/align-struct.rs +++ b/tests/codegen/align-struct.rs @@ -15,9 +15,11 @@ pub struct Nested64 { d: i8, } +// This has the extra field in B to ensure it's not ScalarPair, +// and thus that the test actually emits it via memory, not `insertvalue`. pub enum Enum4 { A(i32), - B(i32), + B(i32, i32), } pub enum Enum64 { @@ -54,7 +56,7 @@ pub fn nested64(a: Align64, b: i32, c: i32, d: i8) -> Nested64 { // CHECK-LABEL: @enum4 #[no_mangle] pub fn enum4(a: i32) -> Enum4 { - // CHECK: %e4 = alloca [8 x i8], align 4 + // CHECK: %e4 = alloca [12 x i8], align 4 let e4 = Enum4::A(a); e4 } diff --git a/tests/codegen/asm/critical.rs b/tests/codegen/asm/critical.rs index 8c039900cab..0f29d7c69b4 100644 --- a/tests/codegen/asm/critical.rs +++ b/tests/codegen/asm/critical.rs @@ -1,6 +1,5 @@ //@ only-x86_64 //@ compile-flags: -C no-prepopulate-passes -#![feature(asm_goto)] #![feature(asm_goto_with_outputs)] #![crate_type = "lib"] use std::arch::asm; diff --git a/tests/codegen/common_prim_int_ptr.rs b/tests/codegen/common_prim_int_ptr.rs index a1d7a125f32..53716adccbf 100644 --- a/tests/codegen/common_prim_int_ptr.rs +++ b/tests/codegen/common_prim_int_ptr.rs @@ -11,9 +11,9 @@ #[no_mangle] pub fn insert_int(x: usize) -> Result<usize, Box<()>> { // CHECK: start: - // CHECK-NEXT: inttoptr i{{[0-9]+}} %x to ptr - // CHECK-NEXT: insertvalue - // CHECK-NEXT: ret { i{{[0-9]+}}, ptr } + // CHECK-NEXT: %[[WO_PROV:.+]] = getelementptr i8, ptr null, [[USIZE:i[0-9]+]] %x + // CHECK-NEXT: %[[R:.+]] = insertvalue { [[USIZE]], ptr } { [[USIZE]] 0, ptr poison }, ptr %[[WO_PROV]], 1 + // CHECK-NEXT: ret { [[USIZE]], ptr } %[[R]] Ok(x) } diff --git a/tests/codegen/enum/enum-aggregate.rs b/tests/codegen/enum/enum-aggregate.rs new file mode 100644 index 00000000000..b6a9b8dd814 --- /dev/null +++ b/tests/codegen/enum/enum-aggregate.rs @@ -0,0 +1,129 @@ +//@ compile-flags: -Copt-level=0 -Cno-prepopulate-passes +//@ min-llvm-version: 19 +//@ only-64bit + +#![crate_type = "lib"] + +use std::cmp::Ordering; +use std::num::NonZero; +use std::ptr::NonNull; + +#[no_mangle] +fn make_some_bool(x: bool) -> Option<bool> { + // CHECK-LABEL: i8 @make_some_bool(i1 zeroext %x) + // CHECK-NEXT: start: + // CHECK-NEXT: %[[WIDER:.+]] = zext i1 %x to i8 + // CHECK-NEXT: ret i8 %[[WIDER]] + Some(x) +} + +#[no_mangle] +fn make_none_bool() -> Option<bool> { + // CHECK-LABEL: i8 @make_none_bool() + // CHECK-NEXT: start: + // CHECK-NEXT: ret i8 2 + None +} + +#[no_mangle] +fn make_some_ordering(x: Ordering) -> Option<Ordering> { + // CHECK-LABEL: i8 @make_some_ordering(i8 %x) + // CHECK-NEXT: start: + // CHECK-NEXT: ret i8 %x + Some(x) +} + +#[no_mangle] +fn make_some_u16(x: u16) -> Option<u16> { + // CHECK-LABEL: { i16, i16 } @make_some_u16(i16 %x) + // CHECK-NEXT: start: + // CHECK-NEXT: %0 = insertvalue { i16, i16 } { i16 1, i16 poison }, i16 %x, 1 + // CHECK-NEXT: ret { i16, i16 } %0 + Some(x) +} + +#[no_mangle] +fn make_none_u16() -> Option<u16> { + // CHECK-LABEL: { i16, i16 } @make_none_u16() + // CHECK-NEXT: start: + // CHECK-NEXT: ret { i16, i16 } { i16 0, i16 undef } + None +} + +#[no_mangle] +fn make_some_nzu32(x: NonZero<u32>) -> Option<NonZero<u32>> { + // CHECK-LABEL: i32 @make_some_nzu32(i32 %x) + // CHECK-NEXT: start: + // CHECK-NEXT: ret i32 %x + Some(x) +} + +#[no_mangle] +fn make_ok_ptr(x: NonNull<u16>) -> Result<NonNull<u16>, usize> { + // CHECK-LABEL: { i64, ptr } @make_ok_ptr(ptr %x) + // CHECK-NEXT: start: + // CHECK-NEXT: %0 = insertvalue { i64, ptr } { i64 0, ptr poison }, ptr %x, 1 + // CHECK-NEXT: ret { i64, ptr } %0 + Ok(x) +} + +#[no_mangle] +fn make_ok_int(x: usize) -> Result<usize, NonNull<u16>> { + // CHECK-LABEL: { i64, ptr } @make_ok_int(i64 %x) + // CHECK-NEXT: start: + // CHECK-NEXT: %[[NOPROV:.+]] = getelementptr i8, ptr null, i64 %x + // CHECK-NEXT: %[[R:.+]] = insertvalue { i64, ptr } { i64 0, ptr poison }, ptr %[[NOPROV]], 1 + // CHECK-NEXT: ret { i64, ptr } %[[R]] + Ok(x) +} + +#[no_mangle] +fn make_some_ref(x: &u16) -> Option<&u16> { + // CHECK-LABEL: ptr @make_some_ref(ptr align 2 %x) + // CHECK-NEXT: start: + // CHECK-NEXT: ret ptr %x + Some(x) +} + +#[no_mangle] +fn make_none_ref<'a>() -> Option<&'a u16> { + // CHECK-LABEL: ptr @make_none_ref() + // CHECK-NEXT: start: + // CHECK-NEXT: ret ptr null + None +} + +#[inline(never)] +fn make_err_generic<E>(e: E) -> Result<u32, E> { + // CHECK-LABEL: define{{.+}}make_err_generic + // CHECK-NEXT: start: + // CHECK-NEXT: call void @llvm.trap() + // CHECK-NEXT: ret i32 poison + Err(e) +} + +#[no_mangle] +fn make_uninhabited_err_indirectly(n: Never) -> Result<u32, Never> { + // CHECK-LABEL: i32 @make_uninhabited_err_indirectly() + // CHECK-NEXT: start: + // CHECK-NEXT: call{{.+}}make_err_generic + make_err_generic(n) +} + +#[no_mangle] +fn make_fully_uninhabited_result(v: u32, n: Never) -> Result<(u32, Never), (Never, u32)> { + // We don't try to do this in SSA form since the whole type is uninhabited. + + // CHECK-LABEL: { i32, i32 } @make_fully_uninhabited_result(i32 %v) + // CHECK: %[[ALLOC_V:.+]] = alloca [4 x i8] + // CHECK: %[[RET:.+]] = alloca [8 x i8] + // CHECK: store i32 %v, ptr %[[ALLOC_V]] + // CHECK: %[[TEMP_V:.+]] = load i32, ptr %[[ALLOC_V]] + // CHECK: %[[INNER:.+]] = getelementptr inbounds i8, ptr %[[RET]] + // CHECK: store i32 %[[TEMP_V]], ptr %[[INNER]] + // CHECK: call void @llvm.trap() + // CHECK: unreachable + Ok((v, n)) +} + +enum Never {} diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index f0708a7a109..c8cd8526ae5 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -1,7 +1,6 @@ //@ compile-flags: -Copt-level=3 -C no-prepopulate-passes #![crate_type = "lib"] #![feature(rustc_attrs)] -#![feature(dyn_star)] #![feature(allocator_api)] use std::marker::PhantomPinned; @@ -277,11 +276,3 @@ pub fn enum_id_1(x: Option<Result<u16, u16>>) -> Option<Result<u16, u16>> { pub fn enum_id_2(x: Option<u8>) -> Option<u8> { x } - -// CHECK: { ptr, {{.+}} } @dyn_star(ptr noundef %x.0, {{.+}} noalias noundef readonly align {{.*}} dereferenceable({{.*}}) %x.1) -// Expect an ABI something like `{ {}*, [3 x i64]* }`, but that's hard to match on generically, -// so do like the `trait_box` test and just match on `{{.+}}` for the vtable. -#[no_mangle] -pub fn dyn_star(x: dyn* Drop) -> dyn* Drop { - x -} diff --git a/tests/codegen/intrinsics/transmute-x64.rs b/tests/codegen/intrinsics/transmute-x64.rs index be45e4db90f..8c9480ab091 100644 --- a/tests/codegen/intrinsics/transmute-x64.rs +++ b/tests/codegen/intrinsics/transmute-x64.rs @@ -9,17 +9,20 @@ use std::mem::transmute; // CHECK-LABEL: @check_sse_pair_to_avx( #[no_mangle] pub unsafe fn check_sse_pair_to_avx(x: (__m128i, __m128i)) -> __m256i { + // CHECK: start: // CHECK-NOT: alloca - // CHECK: %0 = load <4 x i64>, ptr %x, align 16 - // CHECK: store <4 x i64> %0, ptr %_0, align 32 + // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 32 %_0, ptr align 16 %x, i64 32, i1 false) + // CHECK-NEXT: ret void transmute(x) } // CHECK-LABEL: @check_sse_pair_from_avx( #[no_mangle] pub unsafe fn check_sse_pair_from_avx(x: __m256i) -> (__m128i, __m128i) { + // CHECK: start: // CHECK-NOT: alloca - // CHECK: %0 = load <4 x i64>, ptr %x, align 32 - // CHECK: store <4 x i64> %0, ptr %_0, align 16 + // CHECK-NEXT: %[[TEMP:.+]] = load <4 x i64>, ptr %x, align 32 + // CHECK-NEXT: store <4 x i64> %[[TEMP]], ptr %_0, align 16 + // CHECK-NEXT: ret void transmute(x) } diff --git a/tests/codegen/intrinsics/transmute.rs b/tests/codegen/intrinsics/transmute.rs index 560ebcccdd0..e375724bc1b 100644 --- a/tests/codegen/intrinsics/transmute.rs +++ b/tests/codegen/intrinsics/transmute.rs @@ -29,28 +29,28 @@ pub struct Aggregate8(u8); // CHECK-LABEL: @check_bigger_size( #[no_mangle] pub unsafe fn check_bigger_size(x: u16) -> u32 { - // CHECK: call void @llvm.trap + // CHECK: call void @llvm.assume(i1 false) transmute_unchecked(x) } // CHECK-LABEL: @check_smaller_size( #[no_mangle] pub unsafe fn check_smaller_size(x: u32) -> u16 { - // CHECK: call void @llvm.trap + // CHECK: call void @llvm.assume(i1 false) transmute_unchecked(x) } // CHECK-LABEL: @check_smaller_array( #[no_mangle] pub unsafe fn check_smaller_array(x: [u32; 7]) -> [u32; 3] { - // CHECK: call void @llvm.trap + // CHECK: call void @llvm.assume(i1 false) transmute_unchecked(x) } // CHECK-LABEL: @check_bigger_array( #[no_mangle] pub unsafe fn check_bigger_array(x: [u32; 3]) -> [u32; 7] { - // CHECK: call void @llvm.trap + // CHECK: call void @llvm.assume(i1 false) transmute_unchecked(x) } @@ -73,9 +73,9 @@ pub unsafe fn check_to_empty_array(x: [u32; 5]) -> [u32; 0] { #[no_mangle] #[custom_mir(dialect = "runtime", phase = "optimized")] pub unsafe fn check_from_empty_array(x: [u32; 0]) -> [u32; 5] { - // CHECK-NOT: trap - // CHECK: call void @llvm.trap - // CHECK-NOT: trap + // CHECK-NOT: call + // CHECK: call void @llvm.assume(i1 false) + // CHECK-NOT: call mir! { { RET = CastTransmute(x); diff --git a/tests/codegen/min-function-alignment.rs b/tests/codegen/min-function-alignment.rs index 75f845572a4..6a3843b0f4f 100644 --- a/tests/codegen/min-function-alignment.rs +++ b/tests/codegen/min-function-alignment.rs @@ -1,17 +1,20 @@ //@ revisions: align16 align1024 -//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 +//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 -Clink-dead-code //@ [align16] compile-flags: -Zmin-function-alignment=16 //@ [align1024] compile-flags: -Zmin-function-alignment=1024 +//@ ignore-wasm32 aligning functions is not currently supported on wasm (#143368) #![crate_type = "lib"] #![feature(fn_align)] -// functions without explicit alignment use the global minimum +// Functions without explicit alignment use the global minimum. // -// CHECK-LABEL: @no_explicit_align +// NOTE: this function deliberately has zero (0) attributes! That is to make sure that +// `-Zmin-function-alignment` is applied regardless of whether attributes are used. +// +// CHECK-LABEL: no_explicit_align // align16: align 16 // align1024: align 1024 -#[no_mangle] pub fn no_explicit_align() {} // CHECK-LABEL: @lower_align diff --git a/tests/codegen/naked-fn/aligned.rs b/tests/codegen/naked-fn/aligned.rs index f9fce8e5a5d..2648b0213ca 100644 --- a/tests/codegen/naked-fn/aligned.rs +++ b/tests/codegen/naked-fn/aligned.rs @@ -1,6 +1,7 @@ //@ compile-flags: -C no-prepopulate-passes -Copt-level=0 //@ needs-asm-support //@ ignore-arm no "ret" mnemonic +//@ ignore-wasm32 aligning functions is not currently supported on wasm (#143368) #![crate_type = "lib"] #![feature(fn_align)] diff --git a/tests/codegen/naked-fn/min-function-alignment.rs b/tests/codegen/naked-fn/min-function-alignment.rs index 59554c1cae5..4ebaacd3eff 100644 --- a/tests/codegen/naked-fn/min-function-alignment.rs +++ b/tests/codegen/naked-fn/min-function-alignment.rs @@ -1,6 +1,7 @@ //@ compile-flags: -C no-prepopulate-passes -Copt-level=0 -Zmin-function-alignment=16 //@ needs-asm-support //@ ignore-arm no "ret" mnemonic +//@ ignore-wasm32 aligning functions is not currently supported on wasm (#143368) #![feature(fn_align)] #![crate_type = "lib"] diff --git a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs index 2a7eca6fc19..8fec275fd06 100644 --- a/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs +++ b/tests/codegen/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs @@ -1,5 +1,9 @@ // Verifies that type metadata identifiers for drop functions are emitted correctly. // +// Non needs_drop drop glue isn't codegen'd at all, so we don't try to check the IDs there. But we +// do check it's not emitted which should help catch bugs if we do start generating it again in the +// future. +// //@ needs-sanitizer-cfi //@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static @@ -10,18 +14,18 @@ // CHECK: call i1 @llvm.type.test(ptr {{%.+}}, metadata !"_ZTSFvPu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops4drop4Dropu6regionEE") struct EmptyDrop; -// CHECK: define{{.*}}4core3ptr{{[0-9]+}}drop_in_place$LT${{.*}}EmptyDrop$GT${{.*}}!type ![[TYPE1]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} +// CHECK-NOT: define{{.*}}4core3ptr{{[0-9]+}}drop_in_place$LT${{.*}}EmptyDrop$GT${{.*}}!type ![[TYPE1]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} -struct NonEmptyDrop; +struct PresentDrop; -impl Drop for NonEmptyDrop { +impl Drop for PresentDrop { fn drop(&mut self) {} - // CHECK: define{{.*}}4core3ptr{{[0-9]+}}drop_in_place$LT${{.*}}NonEmptyDrop$GT${{.*}}!type ![[TYPE1]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} + // CHECK: define{{.*}}4core3ptr{{[0-9]+}}drop_in_place$LT${{.*}}PresentDrop$GT${{.*}}!type ![[TYPE1]] !type !{{[0-9]+}} !type !{{[0-9]+}} !type !{{[0-9]+}} } pub fn foo() { let _ = Box::new(EmptyDrop) as Box<dyn Send>; - let _ = Box::new(NonEmptyDrop) as Box<dyn Send>; + let _ = Box::new(PresentDrop) as Box<dyn Send>; } // CHECK: ![[TYPE1]] = !{i64 0, !"_ZTSFvPu3dynIu{{[0-9]+}}NtNtNtC{{[[:print:]]+}}_4core3ops4drop4Dropu6regionEE"} diff --git a/tests/codegen/set-discriminant-invalid.rs b/tests/codegen/set-discriminant-invalid.rs index 0b7cb14880c..dd584ef1c14 100644 --- a/tests/codegen/set-discriminant-invalid.rs +++ b/tests/codegen/set-discriminant-invalid.rs @@ -16,10 +16,9 @@ impl IntoError<Error> for Api { type Source = ApiError; // CHECK-LABEL: @into_error // CHECK: llvm.trap() - // Also check the next two instructions to make sure we do not match against `trap` + // Also check the next instruction to make sure we do not match against `trap` // elsewhere in the code. - // CHECK-NEXT: load - // CHECK-NEXT: ret + // CHECK-NEXT: ret i8 poison #[no_mangle] fn into_error(self, error: Self::Source) -> Error { Error::Api { source: error } diff --git a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs index 977bf3379b7..301f06c2d74 100644 --- a/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs +++ b/tests/codegen/simd-intrinsic/simd-intrinsic-transmute-array.rs @@ -40,8 +40,7 @@ pub fn build_array_s(x: [f32; 4]) -> S<4> { // CHECK-LABEL: @build_array_transmute_s #[no_mangle] pub fn build_array_transmute_s(x: [f32; 4]) -> S<4> { - // CHECK: %[[VAL:.+]] = load <4 x float>, ptr %x, align [[ARRAY_ALIGN]] - // CHECK: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] + // CHECK: call void @llvm.memcpy.{{.+}}({{.*}} align [[VECTOR_ALIGN]] {{.*}} align [[ARRAY_ALIGN]] {{.*}}, [[USIZE]] 16, i1 false) unsafe { std::mem::transmute(x) } } @@ -55,7 +54,6 @@ pub fn build_array_t(x: [f32; 4]) -> T { // CHECK-LABEL: @build_array_transmute_t #[no_mangle] pub fn build_array_transmute_t(x: [f32; 4]) -> T { - // CHECK: %[[VAL:.+]] = load <4 x float>, ptr %x, align [[ARRAY_ALIGN]] - // CHECK: store <4 x float> %[[VAL:.+]], ptr %_0, align [[VECTOR_ALIGN]] + // CHECK: call void @llvm.memcpy.{{.+}}({{.*}} align [[VECTOR_ALIGN]] {{.*}} align [[ARRAY_ALIGN]] {{.*}}, [[USIZE]] 16, i1 false) unsafe { std::mem::transmute(x) } } diff --git a/tests/codegen/transmute-scalar.rs b/tests/codegen/transmute-scalar.rs index c080259a917..ce1b0558b2e 100644 --- a/tests/codegen/transmute-scalar.rs +++ b/tests/codegen/transmute-scalar.rs @@ -1,6 +1,12 @@ +//@ add-core-stubs //@ compile-flags: -C opt-level=0 -C no-prepopulate-passes #![crate_type = "lib"] +#![feature(no_core, repr_simd, arm_target_feature, mips_target_feature, s390x_target_feature)] +#![no_core] +extern crate minicore; + +use minicore::*; // With opaque ptrs in LLVM, `transmute` can load/store any `alloca` as any type, // without needing to pointercast, and SRoA will turn that into a `bitcast`. @@ -14,7 +20,7 @@ // CHECK-NEXT: ret i32 %_0 #[no_mangle] pub fn f32_to_bits(x: f32) -> u32 { - unsafe { std::mem::transmute(x) } + unsafe { mem::transmute(x) } } // CHECK-LABEL: define{{.*}}i8 @bool_to_byte(i1 zeroext %b) @@ -22,7 +28,7 @@ pub fn f32_to_bits(x: f32) -> u32 { // CHECK-NEXT: ret i8 %_0 #[no_mangle] pub fn bool_to_byte(b: bool) -> u8 { - unsafe { std::mem::transmute(b) } + unsafe { mem::transmute(b) } } // CHECK-LABEL: define{{.*}}zeroext i1 @byte_to_bool(i8{{.*}} %byte) @@ -30,14 +36,14 @@ pub fn bool_to_byte(b: bool) -> u8 { // CHECK-NEXT: ret i1 %_0 #[no_mangle] pub unsafe fn byte_to_bool(byte: u8) -> bool { - std::mem::transmute(byte) + mem::transmute(byte) } // CHECK-LABEL: define{{.*}}ptr @ptr_to_ptr(ptr %p) // CHECK: ret ptr %p #[no_mangle] pub fn ptr_to_ptr(p: *mut u16) -> *mut u8 { - unsafe { std::mem::transmute(p) } + unsafe { mem::transmute(p) } } // CHECK: define{{.*}}[[USIZE:i[0-9]+]] @ptr_to_int(ptr %p) @@ -45,7 +51,7 @@ pub fn ptr_to_ptr(p: *mut u16) -> *mut u8 { // CHECK-NEXT: ret [[USIZE]] %_0 #[no_mangle] pub fn ptr_to_int(p: *mut u16) -> usize { - unsafe { std::mem::transmute(p) } + unsafe { mem::transmute(p) } } // CHECK: define{{.*}}ptr @int_to_ptr([[USIZE]] %i) @@ -53,5 +59,85 @@ pub fn ptr_to_int(p: *mut u16) -> usize { // CHECK-NEXT: ret ptr %_0 #[no_mangle] pub fn int_to_ptr(i: usize) -> *mut u16 { - unsafe { std::mem::transmute(i) } + unsafe { mem::transmute(i) } +} + +// This is the one case where signedness matters to transmuting: +// the LLVM type is `i8` here because of `repr(i8)`, +// whereas below with the `repr(u8)` it's `i1` in LLVM instead. +#[repr(i8)] +pub enum FakeBoolSigned { + False = 0, + True = 1, +} + +// CHECK-LABEL: define{{.*}}i8 @bool_to_fake_bool_signed(i1 zeroext %b) +// CHECK: %_0 = zext i1 %b to i8 +// CHECK-NEXT: ret i8 %_0 +#[no_mangle] +pub fn bool_to_fake_bool_signed(b: bool) -> FakeBoolSigned { + unsafe { mem::transmute(b) } +} + +// CHECK-LABEL: define{{.*}}i1 @fake_bool_signed_to_bool(i8 %b) +// CHECK: %_0 = trunc nuw i8 %b to i1 +// CHECK-NEXT: ret i1 %_0 +#[no_mangle] +pub fn fake_bool_signed_to_bool(b: FakeBoolSigned) -> bool { + unsafe { mem::transmute(b) } +} + +#[repr(u8)] +pub enum FakeBoolUnsigned { + False = 0, + True = 1, +} + +// CHECK-LABEL: define{{.*}}i1 @bool_to_fake_bool_unsigned(i1 zeroext %b) +// CHECK: ret i1 %b +#[no_mangle] +pub fn bool_to_fake_bool_unsigned(b: bool) -> FakeBoolUnsigned { + unsafe { mem::transmute(b) } +} + +// CHECK-LABEL: define{{.*}}i1 @fake_bool_unsigned_to_bool(i1 zeroext %b) +// CHECK: ret i1 %b +#[no_mangle] +pub fn fake_bool_unsigned_to_bool(b: FakeBoolUnsigned) -> bool { + unsafe { mem::transmute(b) } +} + +#[repr(simd)] +struct S([i64; 1]); + +// CHECK-LABEL: define{{.*}}i64 @single_element_simd_to_scalar(<1 x i64> %b) +// CHECK-NEXT: start: +// CHECK-NEXT: %[[RET:.+]] = alloca [8 x i8] +// CHECK-NEXT: store <1 x i64> %b, ptr %[[RET]] +// CHECK-NEXT: %[[TEMP:.+]] = load i64, ptr %[[RET]] +// CHECK-NEXT: ret i64 %[[TEMP]] +#[no_mangle] +#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))] +#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))] +#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))] +#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))] +#[cfg_attr(target_arch = "s390x", target_feature(enable = "vector"))] +pub extern "C" fn single_element_simd_to_scalar(b: S) -> i64 { + unsafe { mem::transmute(b) } +} + +// CHECK-LABEL: define{{.*}}<1 x i64> @scalar_to_single_element_simd(i64 %b) +// CHECK-NEXT: start: +// CHECK-NEXT: %[[RET:.+]] = alloca [8 x i8] +// CHECK-NEXT: store i64 %b, ptr %[[RET]] +// CHECK-NEXT: %[[TEMP:.+]] = load <1 x i64>, ptr %[[RET]] +// CHECK-NEXT: ret <1 x i64> %[[TEMP]] +#[no_mangle] +#[cfg_attr(target_family = "wasm", target_feature(enable = "simd128"))] +#[cfg_attr(target_arch = "arm", target_feature(enable = "neon"))] +#[cfg_attr(target_arch = "x86", target_feature(enable = "sse"))] +#[cfg_attr(target_arch = "mips", target_feature(enable = "msa"))] +#[cfg_attr(target_arch = "s390x", target_feature(enable = "vector"))] +pub extern "C" fn scalar_to_single_element_simd(b: i64) -> S { + unsafe { mem::transmute(b) } } diff --git a/tests/codegen/union-aggregate.rs b/tests/codegen/union-aggregate.rs new file mode 100644 index 00000000000..3c6053379fa --- /dev/null +++ b/tests/codegen/union-aggregate.rs @@ -0,0 +1,85 @@ +//@ compile-flags: -Copt-level=0 -Cno-prepopulate-passes +//@ min-llvm-version: 19 +//@ only-64bit + +#![crate_type = "lib"] +#![feature(transparent_unions)] + +#[repr(transparent)] +union MU<T: Copy> { + uninit: (), + value: T, +} + +use std::cmp::Ordering; +use std::num::NonZero; +use std::ptr::NonNull; + +#[no_mangle] +fn make_mu_bool(x: bool) -> MU<bool> { + // CHECK-LABEL: i8 @make_mu_bool(i1 zeroext %x) + // CHECK-NEXT: start: + // CHECK-NEXT: %[[WIDER:.+]] = zext i1 %x to i8 + // CHECK-NEXT: ret i8 %[[WIDER]] + MU { value: x } +} + +#[no_mangle] +fn make_mu_bool_uninit() -> MU<bool> { + // CHECK-LABEL: i8 @make_mu_bool_uninit() + // CHECK-NEXT: start: + // CHECK-NEXT: ret i8 undef + MU { uninit: () } +} + +#[no_mangle] +fn make_mu_ref(x: &u16) -> MU<&u16> { + // CHECK-LABEL: ptr @make_mu_ref(ptr align 2 %x) + // CHECK-NEXT: start: + // CHECK-NEXT: ret ptr %x + MU { value: x } +} + +#[no_mangle] +fn make_mu_ref_uninit<'a>() -> MU<&'a u16> { + // CHECK-LABEL: ptr @make_mu_ref_uninit() + // CHECK-NEXT: start: + // CHECK-NEXT: ret ptr undef + MU { uninit: () } +} + +#[no_mangle] +fn make_mu_str(x: &str) -> MU<&str> { + // CHECK-LABEL: { ptr, i64 } @make_mu_str(ptr align 1 %x.0, i64 %x.1) + // CHECK-NEXT: start: + // CHECK-NEXT: %0 = insertvalue { ptr, i64 } poison, ptr %x.0, 0 + // CHECK-NEXT: %1 = insertvalue { ptr, i64 } %0, i64 %x.1, 1 + // CHECK-NEXT: ret { ptr, i64 } %1 + MU { value: x } +} + +#[no_mangle] +fn make_mu_str_uninit<'a>() -> MU<&'a str> { + // CHECK-LABEL: { ptr, i64 } @make_mu_str_uninit() + // CHECK-NEXT: start: + // CHECK-NEXT: ret { ptr, i64 } undef + MU { uninit: () } +} + +#[no_mangle] +fn make_mu_pair(x: (u8, u32)) -> MU<(u8, u32)> { + // CHECK-LABEL: { i8, i32 } @make_mu_pair(i8 %x.0, i32 %x.1) + // CHECK-NEXT: start: + // CHECK-NEXT: %0 = insertvalue { i8, i32 } poison, i8 %x.0, 0 + // CHECK-NEXT: %1 = insertvalue { i8, i32 } %0, i32 %x.1, 1 + // CHECK-NEXT: ret { i8, i32 } %1 + MU { value: x } +} + +#[no_mangle] +fn make_mu_pair_uninit() -> MU<(u8, u32)> { + // CHECK-LABEL: { i8, i32 } @make_mu_pair_uninit() + // CHECK-NEXT: start: + // CHECK-NEXT: ret { i8, i32 } undef + MU { uninit: () } +} diff --git a/tests/codegen/vec-in-place.rs b/tests/codegen/vec-in-place.rs index 1f6836f6dfa..a5ef8653b99 100644 --- a/tests/codegen/vec-in-place.rs +++ b/tests/codegen/vec-in-place.rs @@ -41,9 +41,6 @@ pub fn vec_iterator_cast_primitive(vec: Vec<i8>) -> Vec<u8> { // CHECK: call{{.+}}void @llvm.assume(i1 %{{.+}}) // CHECK-NOT: loop // CHECK-NOT: call - // CHECK: call{{.+}}void @llvm.assume(i1 %{{.+}}) - // CHECK-NOT: loop - // CHECK-NOT: call vec.into_iter().map(|e| e as u8).collect() } @@ -55,9 +52,6 @@ pub fn vec_iterator_cast_wrapper(vec: Vec<u8>) -> Vec<Wrapper<u8>> { // CHECK: call{{.+}}void @llvm.assume(i1 %{{.+}}) // CHECK-NOT: loop // CHECK-NOT: call - // CHECK: call{{.+}}void @llvm.assume(i1 %{{.+}}) - // CHECK-NOT: loop - // CHECK-NOT: call vec.into_iter().map(|e| Wrapper(e)).collect() } @@ -86,9 +80,6 @@ pub fn vec_iterator_cast_unwrap(vec: Vec<Wrapper<u8>>) -> Vec<u8> { // CHECK: call{{.+}}void @llvm.assume(i1 %{{.+}}) // CHECK-NOT: loop // CHECK-NOT: call - // CHECK: call{{.+}}void @llvm.assume(i1 %{{.+}}) - // CHECK-NOT: loop - // CHECK-NOT: call vec.into_iter().map(|e| e.0).collect() } @@ -100,9 +91,6 @@ pub fn vec_iterator_cast_aggregate(vec: Vec<[u64; 4]>) -> Vec<Foo> { // CHECK: call{{.+}}void @llvm.assume(i1 %{{.+}}) // CHECK-NOT: loop // CHECK-NOT: call - // CHECK: call{{.+}}void @llvm.assume(i1 %{{.+}}) - // CHECK-NOT: loop - // CHECK-NOT: call vec.into_iter().map(|e| unsafe { std::mem::transmute(e) }).collect() } @@ -114,9 +102,6 @@ pub fn vec_iterator_cast_deaggregate_tra(vec: Vec<Bar>) -> Vec<[u64; 4]> { // CHECK: call{{.+}}void @llvm.assume(i1 %{{.+}}) // CHECK-NOT: loop // CHECK-NOT: call - // CHECK: call{{.+}}void @llvm.assume(i1 %{{.+}}) - // CHECK-NOT: loop - // CHECK-NOT: call // Safety: For the purpose of this test we assume that Bar layout matches [u64; 4]. // This currently is not guaranteed for repr(Rust) types, but it happens to work here and @@ -133,9 +118,6 @@ pub fn vec_iterator_cast_deaggregate_fold(vec: Vec<Baz>) -> Vec<[u64; 4]> { // CHECK: call{{.+}}void @llvm.assume(i1 %{{.+}}) // CHECK-NOT: loop // CHECK-NOT: call - // CHECK: call{{.+}}void @llvm.assume(i1 %{{.+}}) - // CHECK-NOT: loop - // CHECK-NOT: call // Safety: For the purpose of this test we assume that Bar layout matches [u64; 4]. // This currently is not guaranteed for repr(Rust) types, but it happens to work here and @@ -156,12 +138,7 @@ pub fn vec_iterator_cast_unwrap_drop(vec: Vec<Wrapper<String>>) -> Vec<String> { // CHECK-NOT: call // CHECK-NOT: %{{.*}} = mul // CHECK-NOT: %{{.*}} = udiv - // CHECK: call - // CHECK-SAME: void @llvm.assume(i1 %{{.+}}) - // CHECK-NOT: br i1 %{{.*}}, label %{{.*}}, label %{{.*}} - // CHECK-NOT: call - // CHECK-NOT: %{{.*}} = mul - // CHECK-NOT: %{{.*}} = udiv + // CHECK: ret void vec.into_iter().map(|Wrapper(e)| e).collect() } @@ -178,12 +155,6 @@ pub fn vec_iterator_cast_wrap_drop(vec: Vec<String>) -> Vec<Wrapper<String>> { // CHECK-NOT: call // CHECK-NOT: %{{.*}} = mul // CHECK-NOT: %{{.*}} = udiv - // CHECK: call - // CHECK-SAME: void @llvm.assume(i1 %{{.+}}) - // CHECK-NOT: br i1 %{{.*}}, label %{{.*}}, label %{{.*}} - // CHECK-NOT: call - // CHECK-NOT: %{{.*}} = mul - // CHECK-NOT: %{{.*}} = udiv // CHECK: ret void vec.into_iter().map(Wrapper).collect() diff --git a/tests/coverage/branch/if-let.coverage b/tests/coverage/branch/if-let.coverage index 9a3f0113f75..e55da7fb726 100644 --- a/tests/coverage/branch/if-let.coverage +++ b/tests/coverage/branch/if-let.coverage @@ -1,5 +1,5 @@ - LL| |#![feature(coverage_attribute, let_chains)] - LL| |//@ edition: 2021 + LL| |#![feature(coverage_attribute)] + LL| |//@ edition: 2024 LL| |//@ compile-flags: -Zcoverage-options=branch LL| |//@ llvm-cov-flags: --show-branches=count LL| | diff --git a/tests/coverage/branch/if-let.rs b/tests/coverage/branch/if-let.rs index 13db00a82b1..6f88de54cda 100644 --- a/tests/coverage/branch/if-let.rs +++ b/tests/coverage/branch/if-let.rs @@ -1,5 +1,5 @@ -#![feature(coverage_attribute, let_chains)] -//@ edition: 2021 +#![feature(coverage_attribute)] +//@ edition: 2024 //@ compile-flags: -Zcoverage-options=branch //@ llvm-cov-flags: --show-branches=count diff --git a/tests/crashes/116979.rs b/tests/crashes/116979.rs deleted file mode 100644 index 28bbc972ea3..00000000000 --- a/tests/crashes/116979.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ known-bug: #116979 -//@ compile-flags: -Csymbol-mangling-version=v0 -//@ needs-rustc-debug-assertions - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Display; - -pub fn require_dyn_star_display(_: dyn* Display) {} - -fn main() { - require_dyn_star_display(1usize); -} diff --git a/tests/crashes/119694.rs b/tests/crashes/119694.rs deleted file mode 100644 index f655ea1cd34..00000000000 --- a/tests/crashes/119694.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ known-bug: #119694 -#![feature(dyn_star)] - -trait Trait { - fn foo(self); -} - -impl Trait for usize { - fn foo(self) {} -} - -fn bar(x: dyn* Trait) { - x.foo(); -} - -fn main() { - bar(0usize); -} diff --git a/tests/crashes/126269.rs b/tests/crashes/126269.rs deleted file mode 100644 index ca4b76eb930..00000000000 --- a/tests/crashes/126269.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ known-bug: rust-lang/rust#126269 -#![feature(coerce_unsized)] - -pub enum Foo<T> { - Bar([T; usize::MAX]), -} - -use std::ops::CoerceUnsized; - -impl<T, U> CoerceUnsized<U> for T {} - -fn main() {} diff --git a/tests/crashes/126982.rs b/tests/crashes/126982.rs deleted file mode 100644 index 8522d9415eb..00000000000 --- a/tests/crashes/126982.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ known-bug: rust-lang/rust#126982 - -#![feature(coerce_unsized)] -use std::ops::CoerceUnsized; - -struct Foo<T: ?Sized> { - a: T, -} - -impl<T, U> CoerceUnsized<U> for Foo<T> {} - -union U { - a: usize, -} - -const C: U = Foo { a: 10 }; - -fn main() {} diff --git a/tests/crashes/130104.rs b/tests/crashes/130104.rs index 0ffc21ad360..b961108c923 100644 --- a/tests/crashes/130104.rs +++ b/tests/crashes/130104.rs @@ -2,5 +2,5 @@ fn main() { let non_secure_function = - core::mem::transmute::<fn() -> _, extern "C-cmse-nonsecure-call" fn() -> _>; + core::mem::transmute::<fn() -> _, extern "cmse-nonsecure-call" fn() -> _>; } diff --git a/tests/crashes/131048.rs b/tests/crashes/131048.rs deleted file mode 100644 index d57e9921a8a..00000000000 --- a/tests/crashes/131048.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ known-bug: #131048 - -impl<A> std::ops::CoerceUnsized<A> for A {} - -fn main() { - format_args!("Hello, world!"); -} diff --git a/tests/crashes/132142.rs b/tests/crashes/132142.rs index 9a026f3bca7..813bf0bf0a8 100644 --- a/tests/crashes/132142.rs +++ b/tests/crashes/132142.rs @@ -1,3 +1,3 @@ //@ known-bug: #132142 -async extern "C-cmse-nonsecure-entry" fn fun(...) {} +async extern "cmse-nonsecure-entry" fn fun(...) {} diff --git a/tests/crashes/132430.rs b/tests/crashes/132430.rs deleted file mode 100644 index 81c8c6d6f7d..00000000000 --- a/tests/crashes/132430.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ known-bug: #132430 - -//@ compile-flags: --crate-type=lib -//@ edition: 2018 -#![feature(cmse_nonsecure_entry)] -struct Test; - -impl Test { - pub async unsafe extern "C-cmse-nonsecure-entry" fn test(val: &str) {} -} diff --git a/tests/crashes/132882.rs b/tests/crashes/132882.rs deleted file mode 100644 index 6b5e4dba803..00000000000 --- a/tests/crashes/132882.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ known-bug: #132882 - -use std::ops::Add; - -pub trait Numoid -where - for<N: Numoid> &'a Self: Add<Self>, -{ -} - -pub fn compute<N: Numoid>(a: N) -> N { - &a + a -} diff --git a/tests/crashes/133808.rs b/tests/crashes/133808.rs deleted file mode 100644 index 9c6a23d1e35..00000000000 --- a/tests/crashes/133808.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ known-bug: #133808 - -#![feature(generic_const_exprs, transmutability)] - -mod assert { - use std::mem::TransmuteFrom; - - pub fn is_transmutable<Src, Dst>() - where - Dst: TransmuteFrom<Src>, - { - } -} - -pub fn main() {} diff --git a/tests/crashes/134217.rs b/tests/crashes/134217.rs deleted file mode 100644 index 1b14c660e8b..00000000000 --- a/tests/crashes/134217.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ known-bug: #134217 - -impl<A> std::ops::CoerceUnsized<A> for A {} - -fn main() { - if let _ = true - && true - {} -} diff --git a/tests/crashes/138265.rs b/tests/crashes/138265.rs deleted file mode 100644 index f6c8ea74889..00000000000 --- a/tests/crashes/138265.rs +++ /dev/null @@ -1,12 +0,0 @@ -//@ known-bug: #138265 - -#![feature(coerce_unsized)] -#![crate_type = "lib"] -impl<A> std::ops::CoerceUnsized<A> for A {} -pub fn f() { - [0; { - let mut c = &0; - c = &0; - 0 - }] -} diff --git a/tests/crashes/138738.rs b/tests/crashes/138738.rs deleted file mode 100644 index 74e5effa56f..00000000000 --- a/tests/crashes/138738.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ known-bug: #138738 -//@ only-x86_64 - -#![feature(abi_ptx)] -fn main() { - let a = unsafe { core::mem::transmute::<usize, extern "ptx-kernel" fn(i32)>(4) }(2); -} diff --git a/tests/crashes/139905.rs b/tests/crashes/139905.rs deleted file mode 100644 index 7da622aaaba..00000000000 --- a/tests/crashes/139905.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ known-bug: #139905 -trait a<const b: bool> {} -impl a<{}> for () {} -trait c {} -impl<const d: u8> c for () where (): a<d> {} -impl c for () {} diff --git a/tests/crashes/140333.rs b/tests/crashes/140333.rs deleted file mode 100644 index cec1100e6ad..00000000000 --- a/tests/crashes/140333.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ known-bug: #140333 -fn a() -> impl b< - [c; { - struct d { - #[a] - bar: e, - } - }], ->; diff --git a/tests/incremental/issue-54242.rs b/tests/incremental/issue-54242.rs index 9fa5363e004..17bbd619a8f 100644 --- a/tests/incremental/issue-54242.rs +++ b/tests/incremental/issue-54242.rs @@ -14,7 +14,7 @@ impl Tr for str { type Arr = [u8; 8]; #[cfg(cfail)] type Arr = [u8; Self::C]; - //[cfail]~^ ERROR cycle detected when evaluating type-level constant + //[cfail]~^ ERROR cycle detected when caching mir } fn main() {} diff --git a/tests/incremental/issue-61323.rs b/tests/incremental/issue-61323.rs index b7423c81fc1..4845648d49c 100644 --- a/tests/incremental/issue-61323.rs +++ b/tests/incremental/issue-61323.rs @@ -1,7 +1,7 @@ //@ revisions: rpass cfail enum A { - //[cfail]~^ ERROR 3:1: 3:7: recursive types `A` and `C` have infinite size [E0072] + //[cfail]~^ ERROR recursive types `A` and `C` have infinite size [E0072] B(C), } diff --git a/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-abort.diff new file mode 100644 index 00000000000..8c5e6a9e827 --- /dev/null +++ b/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-abort.diff @@ -0,0 +1,101 @@ +- // MIR for `borrow_in_loop` before CopyProp ++ // MIR for `borrow_in_loop` after CopyProp + + fn borrow_in_loop() -> () { + let mut _0: (); + let mut _1: bool; + let _3: bool; + let mut _4: !; + let mut _5: (); + let mut _7: bool; + let mut _9: bool; + let mut _10: bool; + let mut _11: &bool; + let _12: &bool; + let mut _13: bool; + let mut _14: bool; + let mut _15: bool; + let mut _16: !; + scope 1 { + debug c => _1; + let mut _2: &bool; + let mut _17: &bool; + scope 2 { + debug p => _2; + let _6: bool; + scope 3 { + debug a => _6; + let _8: bool; + scope 4 { + debug b => _8; + } + } + } + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _17 = const borrow_in_loop::promoted[0]; + _2 = &(*_17); +- StorageLive(_4); + goto -> bb1; + } + + bb1: { +- StorageLive(_6); + StorageLive(_7); + _7 = copy (*_2); + _6 = Not(move _7); + StorageDead(_7); +- StorageLive(_8); + StorageLive(_9); + _9 = copy (*_2); + _8 = Not(move _9); + StorageDead(_9); +- StorageLive(_10); +- _10 = copy _6; +- _1 = move _10; +- StorageDead(_10); ++ _1 = copy _6; + StorageLive(_11); + StorageLive(_12); + _12 = &_1; + _11 = &(*_12); + _2 = move _11; + StorageDead(_11); + StorageDead(_12); + StorageLive(_13); +- StorageLive(_14); +- _14 = copy _6; +- StorageLive(_15); +- _15 = copy _8; +- _13 = Ne(move _14, move _15); ++ _13 = Ne(copy _6, copy _8); + switchInt(move _13) -> [0: bb3, otherwise: bb2]; + } + + bb2: { +- StorageDead(_15); +- StorageDead(_14); + _0 = const (); + StorageDead(_13); +- StorageDead(_8); +- StorageDead(_6); +- StorageDead(_4); + StorageDead(_2); + StorageDead(_1); + return; + } + + bb3: { +- StorageDead(_15); +- StorageDead(_14); +- _5 = const (); + StorageDead(_13); +- StorageDead(_8); +- StorageDead(_6); + goto -> bb1; + } + } + diff --git a/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-unwind.diff new file mode 100644 index 00000000000..8c5e6a9e827 --- /dev/null +++ b/tests/mir-opt/copy-prop/borrowed_local.borrow_in_loop.CopyProp.panic-unwind.diff @@ -0,0 +1,101 @@ +- // MIR for `borrow_in_loop` before CopyProp ++ // MIR for `borrow_in_loop` after CopyProp + + fn borrow_in_loop() -> () { + let mut _0: (); + let mut _1: bool; + let _3: bool; + let mut _4: !; + let mut _5: (); + let mut _7: bool; + let mut _9: bool; + let mut _10: bool; + let mut _11: &bool; + let _12: &bool; + let mut _13: bool; + let mut _14: bool; + let mut _15: bool; + let mut _16: !; + scope 1 { + debug c => _1; + let mut _2: &bool; + let mut _17: &bool; + scope 2 { + debug p => _2; + let _6: bool; + scope 3 { + debug a => _6; + let _8: bool; + scope 4 { + debug b => _8; + } + } + } + } + + bb0: { + StorageLive(_1); + StorageLive(_2); + _17 = const borrow_in_loop::promoted[0]; + _2 = &(*_17); +- StorageLive(_4); + goto -> bb1; + } + + bb1: { +- StorageLive(_6); + StorageLive(_7); + _7 = copy (*_2); + _6 = Not(move _7); + StorageDead(_7); +- StorageLive(_8); + StorageLive(_9); + _9 = copy (*_2); + _8 = Not(move _9); + StorageDead(_9); +- StorageLive(_10); +- _10 = copy _6; +- _1 = move _10; +- StorageDead(_10); ++ _1 = copy _6; + StorageLive(_11); + StorageLive(_12); + _12 = &_1; + _11 = &(*_12); + _2 = move _11; + StorageDead(_11); + StorageDead(_12); + StorageLive(_13); +- StorageLive(_14); +- _14 = copy _6; +- StorageLive(_15); +- _15 = copy _8; +- _13 = Ne(move _14, move _15); ++ _13 = Ne(copy _6, copy _8); + switchInt(move _13) -> [0: bb3, otherwise: bb2]; + } + + bb2: { +- StorageDead(_15); +- StorageDead(_14); + _0 = const (); + StorageDead(_13); +- StorageDead(_8); +- StorageDead(_6); +- StorageDead(_4); + StorageDead(_2); + StorageDead(_1); + return; + } + + bb3: { +- StorageDead(_15); +- StorageDead(_14); +- _5 = const (); + StorageDead(_13); +- StorageDead(_8); +- StorageDead(_6); + goto -> bb1; + } + } + diff --git a/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-abort.diff b/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-abort.diff index 40e8c06f357..285cd0f6527 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-abort.diff +++ b/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-abort.diff @@ -7,14 +7,13 @@ let mut _3: &T; bb0: { -- _2 = copy _1; + _2 = copy _1; _3 = &_1; _0 = opaque::<&T>(copy _3) -> [return: bb1, unwind unreachable]; } bb1: { -- _0 = opaque::<T>(copy _2) -> [return: bb2, unwind unreachable]; -+ _0 = opaque::<T>(copy _1) -> [return: bb2, unwind unreachable]; + _0 = opaque::<T>(copy _2) -> [return: bb2, unwind unreachable]; } bb2: { diff --git a/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-unwind.diff b/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-unwind.diff index d09c96c0f2b..f189615ea95 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-unwind.diff +++ b/tests/mir-opt/copy-prop/borrowed_local.borrowed.CopyProp.panic-unwind.diff @@ -7,14 +7,13 @@ let mut _3: &T; bb0: { -- _2 = copy _1; + _2 = copy _1; _3 = &_1; _0 = opaque::<&T>(copy _3) -> [return: bb1, unwind continue]; } bb1: { -- _0 = opaque::<T>(copy _2) -> [return: bb2, unwind continue]; -+ _0 = opaque::<T>(copy _1) -> [return: bb2, unwind continue]; + _0 = opaque::<T>(copy _2) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/copy-prop/borrowed_local.rs b/tests/mir-opt/copy-prop/borrowed_local.rs index 8db19fbd377..68cdc57483a 100644 --- a/tests/mir-opt/copy-prop/borrowed_local.rs +++ b/tests/mir-opt/copy-prop/borrowed_local.rs @@ -50,10 +50,11 @@ fn compare_address() -> bool { fn borrowed<T: Copy + Freeze>(x: T) -> bool { // CHECK-LABEL: fn borrowed( // CHECK: bb0: { + // CHECK-NEXT: _2 = copy _1; // CHECK-NEXT: _3 = &_1; // CHECK-NEXT: _0 = opaque::<&T>(copy _3) // CHECK: bb1: { - // CHECK-NEXT: _0 = opaque::<T>(copy _1) + // CHECK-NEXT: _0 = opaque::<T>(copy _2) mir! { { let a = x; @@ -94,11 +95,45 @@ fn non_freeze<T: Copy>(x: T) -> bool { } } +/// We must not unify a borrowed local with another that may be written-to before the borrow is +/// read again. As we have no aliasing model yet, this means forbidding unifying borrowed locals. +fn borrow_in_loop() { + // CHECK-LABEL: fn borrow_in_loop( + // CHECK: debug c => [[c:_.*]]; + // CHECK: debug p => [[p:_.*]]; + // CHECK: debug a => [[a:_.*]]; + // CHECK: debug b => [[b:_.*]]; + // CHECK-NOT: &[[a]] + // CHECK-NOT: &[[b]] + // CHECK: [[a]] = Not({{.*}}); + // CHECK-NOT: &[[a]] + // CHECK-NOT: &[[b]] + // CHECK: [[b]] = Not({{.*}}); + // CHECK-NOT: &[[a]] + // CHECK-NOT: &[[b]] + // CHECK: &[[c]] + // CHECK-NOT: &[[a]] + // CHECK-NOT: &[[b]] + let mut c; + let mut p = &false; + loop { + let a = !*p; + let b = !*p; + c = a; + p = &c; + if a != b { + return; + } + } +} + fn main() { assert!(!compare_address()); non_freeze(5); + borrow_in_loop(); } // EMIT_MIR borrowed_local.compare_address.CopyProp.diff // EMIT_MIR borrowed_local.borrowed.CopyProp.diff // EMIT_MIR borrowed_local.non_freeze.CopyProp.diff +// EMIT_MIR borrowed_local.borrow_in_loop.CopyProp.diff diff --git a/tests/mir-opt/copy-prop/write_to_borrowed.main.CopyProp.diff b/tests/mir-opt/copy-prop/write_to_borrowed.main.CopyProp.diff index eab06b1ba1e..baa71501047 100644 --- a/tests/mir-opt/copy-prop/write_to_borrowed.main.CopyProp.diff +++ b/tests/mir-opt/copy-prop/write_to_borrowed.main.CopyProp.diff @@ -16,11 +16,10 @@ _3 = const 'b'; _5 = copy _3; _6 = &_3; -- _4 = copy _5; + _4 = copy _5; (*_1) = copy (*_6); _6 = &_5; -- _7 = dump_var::<char>(copy _4) -> [return: bb1, unwind unreachable]; -+ _7 = dump_var::<char>(copy _5) -> [return: bb1, unwind unreachable]; + _7 = dump_var::<char>(copy _4) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/copy-prop/write_to_borrowed.rs b/tests/mir-opt/copy-prop/write_to_borrowed.rs index 58809749103..05aa2fba18d 100644 --- a/tests/mir-opt/copy-prop/write_to_borrowed.rs +++ b/tests/mir-opt/copy-prop/write_to_borrowed.rs @@ -27,13 +27,13 @@ fn main() { _5 = _3; // CHECK-NEXT: _6 = &_3; _6 = &_3; - // CHECK-NOT: {{_.*}} = {{_.*}}; + // CHECK-NEXT: _4 = copy _5; _4 = _5; // CHECK-NEXT: (*_1) = copy (*_6); *_1 = *_6; // CHECK-NEXT: _6 = &_5; _6 = &_5; - // CHECK-NEXT: _7 = dump_var::<char>(copy _5) + // CHECK-NEXT: _7 = dump_var::<char>(copy _4) Call(_7 = dump_var(_4), ReturnTo(bb1), UnwindUnreachable()) } bb1 = { Return() } diff --git a/tests/mir-opt/gvn_const_eval_polymorphic.no_optimize.GVN.diff b/tests/mir-opt/gvn_const_eval_polymorphic.no_optimize.GVN.diff new file mode 100644 index 00000000000..a91561ba304 --- /dev/null +++ b/tests/mir-opt/gvn_const_eval_polymorphic.no_optimize.GVN.diff @@ -0,0 +1,12 @@ +- // MIR for `no_optimize` before GVN ++ // MIR for `no_optimize` after GVN + + fn no_optimize() -> bool { + let mut _0: bool; + + bb0: { + _0 = Eq(const no_optimize::<T>::{constant#0}, const no_optimize::<T>::{constant#1}); + return; + } + } + diff --git a/tests/mir-opt/gvn_const_eval_polymorphic.optimize_false.GVN.diff b/tests/mir-opt/gvn_const_eval_polymorphic.optimize_false.GVN.diff new file mode 100644 index 00000000000..bdfa2987b23 --- /dev/null +++ b/tests/mir-opt/gvn_const_eval_polymorphic.optimize_false.GVN.diff @@ -0,0 +1,13 @@ +- // MIR for `optimize_false` before GVN ++ // MIR for `optimize_false` after GVN + + fn optimize_false() -> bool { + let mut _0: bool; + + bb0: { +- _0 = Eq(const optimize_false::<T>::{constant#0}, const optimize_false::<T>::{constant#1}); ++ _0 = const false; + return; + } + } + diff --git a/tests/mir-opt/gvn_const_eval_polymorphic.optimize_true.GVN.diff b/tests/mir-opt/gvn_const_eval_polymorphic.optimize_true.GVN.diff new file mode 100644 index 00000000000..dc337d43fb0 --- /dev/null +++ b/tests/mir-opt/gvn_const_eval_polymorphic.optimize_true.GVN.diff @@ -0,0 +1,13 @@ +- // MIR for `optimize_true` before GVN ++ // MIR for `optimize_true` after GVN + + fn optimize_true() -> bool { + let mut _0: bool; + + bb0: { +- _0 = Eq(const optimize_true::<T>::{constant#0}, const optimize_true::<T>::{constant#1}); ++ _0 = const true; + return; + } + } + diff --git a/tests/mir-opt/gvn_const_eval_polymorphic.rs b/tests/mir-opt/gvn_const_eval_polymorphic.rs new file mode 100644 index 00000000000..7320ad947ff --- /dev/null +++ b/tests/mir-opt/gvn_const_eval_polymorphic.rs @@ -0,0 +1,57 @@ +//@ test-mir-pass: GVN +//@ compile-flags: --crate-type lib + +//! Regressions test for a mis-optimization where some functions +//! (`type_id` / `type_name` / `needs_drop`) could be evaluated in +//! a generic context, even though their value depends on some type +//! parameter `T`. +//! +//! In particular, `type_name_of_val(&generic::<T>)` was incorrectly +//! evaluated to the string "crate_name::generic::<T>", and +//! `no_optimize` was incorrectly optimized to `false`. + +#![feature(const_type_name)] + +fn generic<T>() {} + +const fn type_name_contains_i32<T>(_: &T) -> bool { + let pattern = b"i32"; + let name = std::any::type_name::<T>().as_bytes(); + let mut i = 0; + 'outer: while i < name.len() - pattern.len() + 1 { + let mut j = 0; + while j < pattern.len() { + if name[i + j] != pattern[j] { + i += 1; + continue 'outer; + } + j += 1; + } + return true; + } + false +} + +// EMIT_MIR gvn_const_eval_polymorphic.optimize_true.GVN.diff +fn optimize_true<T>() -> bool { + // CHECK-LABEL: fn optimize_true( + // CHECK: _0 = const true; + // CHECK-NEXT: return; + (const { type_name_contains_i32(&generic::<i32>) }) == const { true } +} + +// EMIT_MIR gvn_const_eval_polymorphic.optimize_false.GVN.diff +fn optimize_false<T>() -> bool { + // CHECK-LABEL: fn optimize_false( + // CHECK: _0 = const false; + // CHECK-NEXT: return; + (const { type_name_contains_i32(&generic::<i64>) }) == const { true } +} + +// EMIT_MIR gvn_const_eval_polymorphic.no_optimize.GVN.diff +fn no_optimize<T>() -> bool { + // CHECK-LABEL: fn no_optimize( + // CHECK: _0 = Eq(const no_optimize::<T>::{constant#0}, const no_optimize::<T>::{constant#1}); + // CHECK-NEXT: return; + (const { type_name_contains_i32(&generic::<T>) }) == const { true } +} diff --git a/tests/mir-opt/gvn_type_id_polymorphic.cursed_is_i32.GVN.diff b/tests/mir-opt/gvn_type_id_polymorphic.cursed_is_i32.GVN.diff deleted file mode 100644 index 2f83f54d2af..00000000000 --- a/tests/mir-opt/gvn_type_id_polymorphic.cursed_is_i32.GVN.diff +++ /dev/null @@ -1,12 +0,0 @@ -- // MIR for `cursed_is_i32` before GVN -+ // MIR for `cursed_is_i32` after GVN - - fn cursed_is_i32() -> bool { - let mut _0: bool; - - bb0: { - _0 = Eq(const cursed_is_i32::<T>::{constant#0}, const cursed_is_i32::<T>::{constant#1}); - return; - } - } - diff --git a/tests/mir-opt/gvn_type_id_polymorphic.rs b/tests/mir-opt/gvn_type_id_polymorphic.rs deleted file mode 100644 index 39bc5c24ecc..00000000000 --- a/tests/mir-opt/gvn_type_id_polymorphic.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ test-mir-pass: GVN -//@ compile-flags: -C opt-level=2 - -#![feature(core_intrinsics)] - -fn generic<T>() {} - -const fn type_id_of_val<T: 'static>(_: &T) -> u128 { - std::intrinsics::type_id::<T>() -} - -// EMIT_MIR gvn_type_id_polymorphic.cursed_is_i32.GVN.diff -fn cursed_is_i32<T: 'static>() -> bool { - // CHECK-LABEL: fn cursed_is_i32( - // CHECK: _0 = Eq(const cursed_is_i32::<T>::{constant#0}, const cursed_is_i32::<T>::{constant#1}); - // CHECK-NEXT: return; - (const { type_id_of_val(&generic::<T>) } == const { type_id_of_val(&generic::<i32>) }) -} - -fn main() { - dbg!(cursed_is_i32::<i32>()); -} diff --git a/tests/mir-opt/inline_default_trait_body.Trait-a.Inline.panic-abort.diff b/tests/mir-opt/inline_default_trait_body.Trait-a.Inline.panic-abort.diff new file mode 100644 index 00000000000..db72e84f24b --- /dev/null +++ b/tests/mir-opt/inline_default_trait_body.Trait-a.Inline.panic-abort.diff @@ -0,0 +1,27 @@ +- // MIR for `Trait::a` before Inline ++ // MIR for `Trait::a` after Inline + + fn Trait::a(_1: &Self) -> () { + debug self => _1; + let mut _0: (); + let _2: (); + let mut _3: &(); + let _4: (); + let mut _5: &(); + + bb0: { + StorageLive(_2); + StorageLive(_3); + _5 = const <Self as Trait>::a::promoted[0]; + _3 = &(*_5); + _2 = <() as Trait>::b(move _3) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline_default_trait_body.Trait-a.Inline.panic-unwind.diff b/tests/mir-opt/inline_default_trait_body.Trait-a.Inline.panic-unwind.diff new file mode 100644 index 00000000000..aad5a62f82d --- /dev/null +++ b/tests/mir-opt/inline_default_trait_body.Trait-a.Inline.panic-unwind.diff @@ -0,0 +1,27 @@ +- // MIR for `Trait::a` before Inline ++ // MIR for `Trait::a` after Inline + + fn Trait::a(_1: &Self) -> () { + debug self => _1; + let mut _0: (); + let _2: (); + let mut _3: &(); + let _4: (); + let mut _5: &(); + + bb0: { + StorageLive(_2); + StorageLive(_3); + _5 = const <Self as Trait>::a::promoted[0]; + _3 = &(*_5); + _2 = <() as Trait>::b(move _3) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline_default_trait_body.Trait-b.Inline.panic-abort.diff b/tests/mir-opt/inline_default_trait_body.Trait-b.Inline.panic-abort.diff new file mode 100644 index 00000000000..b5ca892077e --- /dev/null +++ b/tests/mir-opt/inline_default_trait_body.Trait-b.Inline.panic-abort.diff @@ -0,0 +1,27 @@ +- // MIR for `Trait::b` before Inline ++ // MIR for `Trait::b` after Inline + + fn Trait::b(_1: &Self) -> () { + debug self => _1; + let mut _0: (); + let _2: (); + let mut _3: &(); + let _4: (); + let mut _5: &(); + + bb0: { + StorageLive(_2); + StorageLive(_3); + _5 = const <Self as Trait>::b::promoted[0]; + _3 = &(*_5); + _2 = <() as Trait>::a(move _3) -> [return: bb1, unwind unreachable]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline_default_trait_body.Trait-b.Inline.panic-unwind.diff b/tests/mir-opt/inline_default_trait_body.Trait-b.Inline.panic-unwind.diff new file mode 100644 index 00000000000..1f51d2e4b5e --- /dev/null +++ b/tests/mir-opt/inline_default_trait_body.Trait-b.Inline.panic-unwind.diff @@ -0,0 +1,27 @@ +- // MIR for `Trait::b` before Inline ++ // MIR for `Trait::b` after Inline + + fn Trait::b(_1: &Self) -> () { + debug self => _1; + let mut _0: (); + let _2: (); + let mut _3: &(); + let _4: (); + let mut _5: &(); + + bb0: { + StorageLive(_2); + StorageLive(_3); + _5 = const <Self as Trait>::b::promoted[0]; + _3 = &(*_5); + _2 = <() as Trait>::a(move _3) -> [return: bb1, unwind continue]; + } + + bb1: { + StorageDead(_3); + StorageDead(_2); + _0 = const (); + return; + } + } + diff --git a/tests/mir-opt/inline_default_trait_body.rs b/tests/mir-opt/inline_default_trait_body.rs new file mode 100644 index 00000000000..aeb8031b418 --- /dev/null +++ b/tests/mir-opt/inline_default_trait_body.rs @@ -0,0 +1,19 @@ +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// skip-filecheck +//@ test-mir-pass: Inline +//@ edition: 2021 +//@ compile-flags: -Zinline-mir --crate-type=lib + +// EMIT_MIR inline_default_trait_body.Trait-a.Inline.diff +// EMIT_MIR inline_default_trait_body.Trait-b.Inline.diff +pub trait Trait { + fn a(&self) { + ().b(); + } + + fn b(&self) { + ().a(); + } +} + +impl Trait for () {} diff --git a/tests/mir-opt/inline_var_debug_info_kept.rs b/tests/mir-opt/inline_var_debug_info_kept.rs new file mode 100644 index 00000000000..e2f00fc6ee9 --- /dev/null +++ b/tests/mir-opt/inline_var_debug_info_kept.rs @@ -0,0 +1,50 @@ +//@ test-mir-pass: Inline +//@ revisions: PRESERVE FULL NONE LIMITED +//@ [PRESERVE]compile-flags: -O -C debuginfo=0 -Zinline-mir-preserve-debug +//@ [FULL]compile-flags: -O -C debuginfo=2 +//@ [NONE]compile-flags: -O -C debuginfo=0 +//@ [LIMITED]compile-flags: -O -C debuginfo=1 + +#[inline(always)] +fn inline_fn1(arg1: i32) -> i32 { + let local1 = arg1 + 1; + let _local2 = 10; + arg1 + local1 +} + +#[inline(always)] +fn inline_fn2(binding: i32) -> i32 { + { + let binding = inline_fn1(binding); + binding + } +} + +#[inline(never)] +fn test() -> i32 { + // CHECK-LABEL: fn test + inline_fn2(1) + // CHECK-LABEL: (inlined inline_fn2) + + // PRESERVE: debug binding => + // FULL: debug binding => + // NONE-NOT: debug binding => + // LIMITED-NOT: debug binding => + + // CHECK-LABEL: (inlined inline_fn1) + + // PRESERVE: debug arg1 => + // FULL: debug arg1 => + // NONE-NOT: debug arg1 => + // LIMITED-NOT: debug arg1 => + + // PRESERVE: debug local1 => + // FULL: debug local1 => + // NONE-NOT: debug local1 => + // LIMITED-NOT: debug local1 => + + // PRESERVE: debug _local2 => + // FULL: debug _local2 => + // NONE-NOT: debug _local2 => + // LIMITED-NOT: debug _local2 => +} diff --git a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir index cbdd194afd3..97036745009 100644 --- a/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/slice_filter.variant_a-{closure#0}.PreCodegen.after.mir @@ -10,18 +10,18 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 let mut _8: &&usize; let _9: &usize; let mut _10: &&usize; - let mut _13: bool; - let mut _14: &&usize; - let _15: &usize; + let mut _15: bool; let mut _16: &&usize; - let mut _19: bool; - let mut _20: &&usize; - let _21: &usize; - let mut _22: &&usize; + let _17: &usize; + let mut _18: &&usize; let mut _23: bool; let mut _24: &&usize; let _25: &usize; let mut _26: &&usize; + let mut _29: bool; + let mut _30: &&usize; + let _31: &usize; + let mut _32: &&usize; scope 1 { debug a => _4; debug b => _5; @@ -30,39 +30,47 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 scope 2 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) { debug self => _8; debug other => _10; + let mut _11: &usize; + let mut _12: &usize; scope 3 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) { - debug self => _4; - debug other => _6; - let mut _11: usize; - let mut _12: usize; + debug self => _11; + debug other => _12; + let mut _13: usize; + let mut _14: usize; } } scope 4 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) { - debug self => _14; - debug other => _16; + debug self => _16; + debug other => _18; + let mut _19: &usize; + let mut _20: &usize; scope 5 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) { - debug self => _7; - debug other => _5; - let mut _17: usize; - let mut _18: usize; + debug self => _19; + debug other => _20; + let mut _21: usize; + let mut _22: usize; } } scope 6 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) { - debug self => _20; - debug other => _22; + debug self => _24; + debug other => _26; + let mut _27: &usize; + let mut _28: &usize; scope 7 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) { - debug self => _6; - debug other => _4; + debug self => _27; + debug other => _28; } } scope 8 (inlined std::cmp::impls::<impl PartialOrd for &usize>::le) { - debug self => _24; - debug other => _26; + debug self => _30; + debug other => _32; + let mut _33: &usize; + let mut _34: &usize; scope 9 (inlined std::cmp::impls::<impl PartialOrd for usize>::le) { - debug self => _5; - debug other => _7; - let mut _27: usize; - let mut _28: usize; + debug self => _33; + debug other => _34; + let mut _35: usize; + let mut _36: usize; } } } @@ -73,17 +81,23 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 _5 = &((*_3).1: usize); _6 = &((*_3).2: usize); _7 = &((*_3).3: usize); - StorageLive(_13); + StorageLive(_15); StorageLive(_8); _8 = &_4; StorageLive(_10); StorageLive(_9); _9 = copy _6; _10 = &_9; - _11 = copy ((*_3).0: usize); - _12 = copy ((*_3).2: usize); - _13 = Le(copy _11, copy _12); - switchInt(move _13) -> [0: bb1, otherwise: bb2]; + StorageLive(_11); + StorageLive(_12); + _11 = copy _4; + _12 = copy _6; + _13 = copy ((*_3).0: usize); + _14 = copy ((*_3).2: usize); + _15 = Le(copy _13, copy _14); + StorageDead(_12); + StorageDead(_11); + switchInt(move _15) -> [0: bb1, otherwise: bb2]; } bb1: { @@ -97,89 +111,107 @@ fn variant_a::{closure#0}(_1: &mut {closure@$DIR/slice_filter.rs:7:25: 7:39}, _2 StorageDead(_9); StorageDead(_10); StorageDead(_8); - StorageLive(_19); - StorageLive(_14); - _14 = &_7; + StorageLive(_23); StorageLive(_16); - StorageLive(_15); - _15 = copy _5; - _16 = &_15; - StorageLive(_17); - _17 = copy ((*_3).3: usize); + _16 = &_7; StorageLive(_18); - _18 = copy ((*_3).1: usize); - _19 = Le(move _17, move _18); - StorageDead(_18); - StorageDead(_17); - switchInt(move _19) -> [0: bb3, otherwise: bb8]; + StorageLive(_17); + _17 = copy _5; + _18 = &_17; + StorageLive(_19); + StorageLive(_20); + _19 = copy _7; + _20 = copy _5; + StorageLive(_21); + _21 = copy ((*_3).3: usize); + StorageLive(_22); + _22 = copy ((*_3).1: usize); + _23 = Le(move _21, move _22); + StorageDead(_22); + StorageDead(_21); + StorageDead(_20); + StorageDead(_19); + switchInt(move _23) -> [0: bb3, otherwise: bb8]; } bb3: { - StorageDead(_15); + StorageDead(_17); + StorageDead(_18); StorageDead(_16); - StorageDead(_14); goto -> bb4; } bb4: { - StorageLive(_23); - StorageLive(_20); - _20 = &_6; - StorageLive(_22); - StorageLive(_21); - _21 = copy _4; - _22 = &_21; - _23 = Le(copy _12, copy _11); - switchInt(move _23) -> [0: bb5, otherwise: bb6]; - } - - bb5: { - StorageDead(_21); - StorageDead(_22); - StorageDead(_20); - _0 = const false; - goto -> bb7; - } - - bb6: { - StorageDead(_21); - StorageDead(_22); - StorageDead(_20); + StorageLive(_29); StorageLive(_24); - _24 = &_5; + _24 = &_6; StorageLive(_26); StorageLive(_25); - _25 = copy _7; + _25 = copy _4; _26 = &_25; StorageLive(_27); - _27 = copy ((*_3).1: usize); StorageLive(_28); - _28 = copy ((*_3).3: usize); - _0 = Le(move _27, move _28); + _27 = copy _6; + _28 = copy _4; + _29 = Le(copy _14, copy _13); StorageDead(_28); StorageDead(_27); + switchInt(move _29) -> [0: bb5, otherwise: bb6]; + } + + bb5: { StorageDead(_25); StorageDead(_26); StorageDead(_24); + _0 = const false; + goto -> bb7; + } + + bb6: { + StorageDead(_25); + StorageDead(_26); + StorageDead(_24); + StorageLive(_30); + _30 = &_5; + StorageLive(_32); + StorageLive(_31); + _31 = copy _7; + _32 = &_31; + StorageLive(_33); + StorageLive(_34); + _33 = copy _5; + _34 = copy _7; + StorageLive(_35); + _35 = copy ((*_3).1: usize); + StorageLive(_36); + _36 = copy ((*_3).3: usize); + _0 = Le(move _35, move _36); + StorageDead(_36); + StorageDead(_35); + StorageDead(_34); + StorageDead(_33); + StorageDead(_31); + StorageDead(_32); + StorageDead(_30); goto -> bb7; } bb7: { - StorageDead(_23); + StorageDead(_29); goto -> bb9; } bb8: { - StorageDead(_15); + StorageDead(_17); + StorageDead(_18); StorageDead(_16); - StorageDead(_14); _0 = const true; goto -> bb9; } bb9: { - StorageDead(_19); - StorageDead(_13); + StorageDead(_23); + StorageDead(_15); return; } } diff --git a/tests/pretty/hir-lifetimes.pp b/tests/pretty/hir-lifetimes.pp index 4d1ab9d383b..58de6d81915 100644 --- a/tests/pretty/hir-lifetimes.pp +++ b/tests/pretty/hir-lifetimes.pp @@ -69,7 +69,7 @@ type Q<'a> = dyn MyTrait<'a, 'a> + 'a; fn h<'b, F>(f: F, y: Foo<'b>) where F: for<'d> MyTrait<'d, 'b> { } // FIXME(?): attr printing is weird -#[attr = Repr([ReprC])] +#[attr = Repr {reprs: [ReprC]}] struct S<'a>(&'a u32); extern "C" { diff --git a/tests/pretty/hir-pretty-attr.pp b/tests/pretty/hir-pretty-attr.pp index d8cc8c424ca..db7489c1264 100644 --- a/tests/pretty/hir-pretty-attr.pp +++ b/tests/pretty/hir-pretty-attr.pp @@ -6,6 +6,6 @@ extern crate std; //@ pretty-mode:hir //@ pp-exact:hir-pretty-attr.pp -#[attr = Repr([ReprC, ReprPacked(Align(4 bytes)), ReprTransparent])] +#[attr = Repr {reprs: [ReprC, ReprPacked(Align(4 bytes)), ReprTransparent]}] struct Example { } diff --git a/tests/pretty/pin-ergonomics-hir.pp b/tests/pretty/pin-ergonomics-hir.pp new file mode 100644 index 00000000000..212e0e174da --- /dev/null +++ b/tests/pretty/pin-ergonomics-hir.pp @@ -0,0 +1,44 @@ +//@ pretty-compare-only +//@ pretty-mode:hir +//@ pp-exact:pin-ergonomics-hir.pp + +#![feature(pin_ergonomics)] +#![allow(dead_code, incomplete_features)] +#[prelude_import] +use ::std::prelude::rust_2015::*; +#[macro_use] +extern crate std; + +use std::pin::Pin; + +struct Foo; + +impl Foo { + fn baz(&mut self) { } + + fn baz_const(&self) { } + + fn baz_lt<'a>(&mut self) { } + + fn baz_const_lt(&self) { } +} + +fn foo(_: Pin<&'_ mut Foo>) { } +fn foo_lt<'a>(_: Pin<&'a mut Foo>) { } + +fn foo_const(_: Pin<&'_ Foo>) { } +fn foo_const_lt(_: Pin<&'_ Foo>) { } + +fn bar() { + let mut x: Pin<&mut _> = &pin mut Foo; + foo(x.as_mut()); + foo(x.as_mut()); + foo_const(x); + + let x: Pin<&_> = &pin const Foo; + + foo_const(x); + foo_const(x); +} + +fn main() { } diff --git a/tests/pretty/pin-ergonomics-hir.rs b/tests/pretty/pin-ergonomics-hir.rs new file mode 100644 index 00000000000..5f2158258f0 --- /dev/null +++ b/tests/pretty/pin-ergonomics-hir.rs @@ -0,0 +1,40 @@ +//@ pretty-compare-only +//@ pretty-mode:hir +//@ pp-exact:pin-ergonomics-hir.pp + +#![feature(pin_ergonomics)] +#![allow(dead_code, incomplete_features)] + +use std::pin::Pin; + +struct Foo; + +impl Foo { + fn baz(&mut self) { } + + fn baz_const(&self) { } + + fn baz_lt<'a>(&mut self) { } + + fn baz_const_lt(&self) { } +} + +fn foo(_: Pin<&'_ mut Foo>) { } +fn foo_lt<'a>(_: Pin<&'a mut Foo>) { } + +fn foo_const(_: Pin<&'_ Foo>) { } +fn foo_const_lt(_: Pin<&'_ Foo>) { } + +fn bar() { + let mut x: Pin<&mut _> = &pin mut Foo; + foo(x.as_mut()); + foo(x.as_mut()); + foo_const(x); + + let x: Pin<&_> = &pin const Foo; + + foo_const(x); + foo_const(x); +} + +fn main() { } diff --git a/tests/pretty/pin-ergonomics.rs b/tests/pretty/pin-ergonomics.rs index 47ffc97b118..8e8ced791b1 100644 --- a/tests/pretty/pin-ergonomics.rs +++ b/tests/pretty/pin-ergonomics.rs @@ -3,6 +3,8 @@ #![feature(pin_ergonomics)] #![allow(dead_code, incomplete_features)] +use std::pin::Pin; + struct Foo; impl Foo { @@ -21,4 +23,15 @@ fn foo_lt<'a>(_: &'a pin mut Foo) {} fn foo_const(_: &pin const Foo) {} fn foo_const_lt(_: &'_ pin const Foo) {} +fn bar() { + let mut x: Pin<&mut _> = &pin mut Foo; + foo(x.as_mut()); + foo(x.as_mut()); + foo_const(x); + + let x: Pin<&_> = &pin const Foo; + foo_const(x); + foo_const(x); +} + fn main() {} diff --git a/tests/run-make/arm64ec-import-export-static/export.rs b/tests/run-make/arm64ec-import-export-static/export.rs new file mode 100644 index 00000000000..ca6ccf00ca1 --- /dev/null +++ b/tests/run-make/arm64ec-import-export-static/export.rs @@ -0,0 +1,27 @@ +#![crate_type = "dylib"] +#![allow(internal_features)] +#![feature(no_core, lang_items)] +#![no_core] +#![no_std] + +// This is needed because of #![no_core]: +#[lang = "pointee_sized"] +pub trait PointeeSized {} +#[lang = "meta_sized"] +pub trait MetaSized: PointeeSized {} +#[lang = "sized"] +pub trait Sized: MetaSized {} +#[lang = "sync"] +trait Sync {} +impl Sync for i32 {} +#[lang = "copy"] +pub trait Copy {} +impl Copy for i32 {} +#[lang = "drop_in_place"] +pub unsafe fn drop_in_place<T: ?Sized>(_: *mut T) {} +#[no_mangle] +extern "system" fn _DllMainCRTStartup(_: *const u8, _: u32, _: *const u8) -> u32 { + 1 +} + +pub static VALUE: i32 = 42; diff --git a/tests/run-make/arm64ec-import-export-static/import.rs b/tests/run-make/arm64ec-import-export-static/import.rs new file mode 100644 index 00000000000..9d52db25125 --- /dev/null +++ b/tests/run-make/arm64ec-import-export-static/import.rs @@ -0,0 +1,12 @@ +#![crate_type = "cdylib"] +#![allow(internal_features)] +#![feature(no_core)] +#![no_std] +#![no_core] + +extern crate export; + +#[no_mangle] +pub extern "C" fn func() -> i32 { + export::VALUE +} diff --git a/tests/run-make/arm64ec-import-export-static/rmake.rs b/tests/run-make/arm64ec-import-export-static/rmake.rs new file mode 100644 index 00000000000..7fa31144810 --- /dev/null +++ b/tests/run-make/arm64ec-import-export-static/rmake.rs @@ -0,0 +1,15 @@ +// Test that a static can be exported from one crate and imported into another. +// +// This was broken for Arm64EC as only functions, not variables, should be +// decorated with `#`. +// See https://github.com/rust-lang/rust/issues/138541 + +//@ needs-llvm-components: aarch64 +//@ only-windows + +use run_make_support::rustc; + +fn main() { + rustc().input("export.rs").target("aarch64-pc-windows-msvc").panic("abort").run(); + rustc().input("import.rs").target("aarch64-pc-windows-msvc").panic("abort").run(); +} diff --git a/tests/run-make/bin-emit-no-symbols/app.rs b/tests/run-make/bin-emit-no-symbols/app.rs index e9dc1e9744f..ad74fcc43dc 100644 --- a/tests/run-make/bin-emit-no-symbols/app.rs +++ b/tests/run-make/bin-emit-no-symbols/app.rs @@ -12,7 +12,15 @@ fn panic(_: &PanicInfo) -> ! { } #[lang = "eh_personality"] -fn eh() {} +fn eh( + _version: i32, + _actions: i32, + _exception_class: u64, + _exception_object: *mut (), + _context: *mut (), +) -> i32 { + loop {} +} #[alloc_error_handler] fn oom(_: Layout) -> ! { diff --git a/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs b/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs index 36c9db106ec..63d8d713d62 100644 --- a/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs +++ b/tests/run-make/c-link-to-rust-va-list-fn/checkrust.rs @@ -1,7 +1,8 @@ #![crate_type = "staticlib"] #![feature(c_variadic)] +#![feature(cfg_select)] -use std::ffi::{CStr, CString, VaList, c_char, c_double, c_int, c_long, c_longlong}; +use std::ffi::{CStr, CString, VaList, VaListImpl, c_char, c_double, c_int, c_long, c_longlong}; macro_rules! continue_if { ($cond:expr) => { @@ -19,7 +20,7 @@ unsafe fn compare_c_str(ptr: *const c_char, val: &str) -> bool { } } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn check_list_0(mut ap: VaList) -> usize { continue_if!(ap.arg::<c_longlong>() == 1); continue_if!(ap.arg::<c_int>() == 2); @@ -27,7 +28,7 @@ pub unsafe extern "C" fn check_list_0(mut ap: VaList) -> usize { 0 } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn check_list_1(mut ap: VaList) -> usize { continue_if!(ap.arg::<c_int>() == -1); continue_if!(ap.arg::<c_int>() == 'A' as c_int); @@ -39,7 +40,7 @@ pub unsafe extern "C" fn check_list_1(mut ap: VaList) -> usize { 0 } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn check_list_2(mut ap: VaList) -> usize { continue_if!(ap.arg::<c_double>().floor() == 3.14f64.floor()); continue_if!(ap.arg::<c_long>() == 12); @@ -51,7 +52,7 @@ pub unsafe extern "C" fn check_list_2(mut ap: VaList) -> usize { 0 } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn check_list_copy_0(mut ap: VaList) -> usize { continue_if!(ap.arg::<c_double>().floor() == 6.28f64.floor()); continue_if!(ap.arg::<c_int>() == 16); @@ -64,14 +65,14 @@ pub unsafe extern "C" fn check_list_copy_0(mut ap: VaList) -> usize { ) } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn check_varargs_0(_: c_int, mut ap: ...) -> usize { continue_if!(ap.arg::<c_int>() == 42); continue_if!(compare_c_str(ap.arg::<*const c_char>(), "Hello, World!")); 0 } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn check_varargs_1(_: c_int, mut ap: ...) -> usize { continue_if!(ap.arg::<c_double>().floor() == 3.14f64.floor()); continue_if!(ap.arg::<c_long>() == 12); @@ -80,12 +81,12 @@ pub unsafe extern "C" fn check_varargs_1(_: c_int, mut ap: ...) -> usize { 0 } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn check_varargs_2(_: c_int, _ap: ...) -> usize { 0 } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn check_varargs_3(_: c_int, mut ap: ...) -> usize { continue_if!(ap.arg::<c_int>() == 1); continue_if!(ap.arg::<c_int>() == 2); @@ -100,7 +101,7 @@ pub unsafe extern "C" fn check_varargs_3(_: c_int, mut ap: ...) -> usize { 0 } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn check_varargs_4(_: c_double, mut ap: ...) -> usize { continue_if!(ap.arg::<c_double>() == 1.0); continue_if!(ap.arg::<c_double>() == 2.0); @@ -118,7 +119,7 @@ pub unsafe extern "C" fn check_varargs_4(_: c_double, mut ap: ...) -> usize { 0 } -#[no_mangle] +#[unsafe(no_mangle)] pub unsafe extern "C" fn check_varargs_5(_: c_int, mut ap: ...) -> usize { continue_if!(ap.arg::<c_double>() == 1.0); continue_if!(ap.arg::<c_int>() == 1); @@ -148,3 +149,42 @@ pub unsafe extern "C" fn check_varargs_5(_: c_int, mut ap: ...) -> usize { continue_if!(ap.arg::<c_double>() == 13.0); 0 } + +unsafe extern "C" { + fn test_variadic(_: c_int, ...) -> usize; + fn test_va_list_by_value(_: VaList) -> usize; + fn test_va_list_by_pointer(_: *mut VaListImpl) -> usize; + fn test_va_list_by_pointer_pointer(_: *mut *mut VaListImpl) -> usize; +} + +#[unsafe(no_mangle)] +extern "C" fn run_test_variadic() -> usize { + return unsafe { test_variadic(0, 1 as c_longlong, 2 as c_int, 3 as c_longlong) }; +} + +#[unsafe(no_mangle)] +extern "C" fn run_test_va_list_by_value() -> usize { + unsafe extern "C" fn helper(mut ap: ...) -> usize { + unsafe { test_va_list_by_value(ap.as_va_list()) } + } + + unsafe { helper(1 as c_longlong, 2 as c_int, 3 as c_longlong) } +} + +#[unsafe(no_mangle)] +extern "C" fn run_test_va_list_by_pointer() -> usize { + unsafe extern "C" fn helper(mut ap: ...) -> usize { + unsafe { test_va_list_by_pointer(&mut ap) } + } + + unsafe { helper(1 as c_longlong, 2 as c_int, 3 as c_longlong) } +} + +#[unsafe(no_mangle)] +extern "C" fn run_test_va_list_by_pointer_pointer() -> usize { + unsafe extern "C" fn helper(mut ap: ...) -> usize { + unsafe { test_va_list_by_pointer_pointer(&mut (&mut ap as *mut _)) } + } + + unsafe { helper(1 as c_longlong, 2 as c_int, 3 as c_longlong) } +} diff --git a/tests/run-make/c-link-to-rust-va-list-fn/rmake.rs b/tests/run-make/c-link-to-rust-va-list-fn/rmake.rs index 63904bea622..cca528c4252 100644 --- a/tests/run-make/c-link-to-rust-va-list-fn/rmake.rs +++ b/tests/run-make/c-link-to-rust-va-list-fn/rmake.rs @@ -3,7 +3,9 @@ // prevent the creation of a functional binary. // See https://github.com/rust-lang/rust/pull/49878 -//@ ignore-cross-compile +//@ needs-target-std +//@ ignore-android: FIXME(#142855) +//@ ignore-sgx: (x86 machine code cannot be directly executed) use run_make_support::{cc, extra_c_flags, run, rustc, static_lib_name}; diff --git a/tests/run-make/c-link-to-rust-va-list-fn/test.c b/tests/run-make/c-link-to-rust-va-list-fn/test.c index b47a9357880..2bb93c0b5d0 100644 --- a/tests/run-make/c-link-to-rust-va-list-fn/test.c +++ b/tests/run-make/c-link-to-rust-va-list-fn/test.c @@ -15,6 +15,11 @@ extern size_t check_varargs_3(int fixed, ...); extern size_t check_varargs_4(double fixed, ...); extern size_t check_varargs_5(int fixed, ...); +extern size_t run_test_variadic(); +extern size_t run_test_va_list_by_value(); +extern size_t run_test_va_list_by_pointer(); +extern size_t run_test_va_list_by_pointer_pointer(); + int test_rust(size_t (*fn)(va_list), ...) { size_t ret = 0; va_list ap; @@ -47,5 +52,53 @@ int main(int argc, char* argv[]) { assert(check_varargs_5(0, 1.0, 1, 2.0, 2, 3.0, 3, 4.0, 4, 5, 5.0, 6, 6.0, 7, 7.0, 8, 8.0, 9, 9.0, 10, 10.0, 11, 11.0, 12, 12.0, 13, 13.0) == 0); + assert(run_test_variadic() == 0); + assert(run_test_va_list_by_value() == 0); + assert(run_test_va_list_by_pointer() == 0); + assert(run_test_va_list_by_pointer_pointer() == 0); + + return 0; +} + +#define continue_if_else_end(cond) \ + do { if (!(cond)) { va_end(ap); return 0xff; } } while (0) + +size_t test_variadic(int unused, ...) { + va_list ap; + va_start(ap, unused); + + continue_if_else_end(va_arg(ap, long long) == 1); + continue_if_else_end(va_arg(ap, int) == 2); + continue_if_else_end(va_arg(ap, long long) == 3); + + va_end(ap); + + return 0; +} + +#define continue_if(cond) \ + do { if (!(cond)) { return 0xff; } } while (0) + +size_t test_va_list_by_value(va_list ap) { + continue_if(va_arg(ap, long long) == 1); + continue_if(va_arg(ap, int) == 2); + continue_if(va_arg(ap, long long) == 3); + + return 0; +} + +size_t test_va_list_by_pointer(va_list *ap) { + continue_if(va_arg(*ap, long long) == 1); + continue_if(va_arg(*ap, int) == 2); + continue_if(va_arg(*ap, long long) == 3); + + return 0; +} + +size_t test_va_list_by_pointer_pointer(va_list **ap) { + continue_if(va_arg(**ap, long long) == 1); + continue_if(va_arg(**ap, int) == 2); + continue_if(va_arg(**ap, long long) == 3); + return 0; } diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr index 82f57864d85..be3de580983 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-disabled.stderr @@ -1,10 +1,10 @@ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> const-super-trait.rs:7:12 | LL | trait Bar: ~const Foo {} | ^^^^^^ | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> const-super-trait.rs:7:1 | LL | trait Bar: ~const Foo {} @@ -30,7 +30,7 @@ LL | const fn foo<T: ~const Bar>(x: &T) { = help: add `#![feature(const_trait_impl)]` 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: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> const-super-trait.rs:7:12 | LL | trait Bar: ~const Foo {} @@ -41,7 +41,7 @@ help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[ LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> const-super-trait.rs:9:17 | LL | const fn foo<T: ~const Bar>(x: &T) { diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr index 8f4c78ccfa4..ef764a62b06 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-nightly-enabled.stderr @@ -1,16 +1,16 @@ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> const-super-trait.rs:7:12 | LL | trait Bar: ~const Foo {} | ^^^^^^ | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> const-super-trait.rs:7:1 | LL | trait Bar: ~const Foo {} | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> const-super-trait.rs:7:12 | LL | trait Bar: ~const Foo {} @@ -21,7 +21,7 @@ help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> const-super-trait.rs:9:17 | LL | const fn foo<T: ~const Bar>(x: &T) { diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr index b7cd7097f44..a23793580f7 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-disabled.stderr @@ -1,10 +1,10 @@ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> const-super-trait.rs:7:12 | 7 | trait Bar: ~const Foo {} | ^^^^^^ | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> const-super-trait.rs:7:1 | 7 | trait Bar: ~const Foo {} @@ -26,25 +26,25 @@ error[E0658]: const trait impls are experimental | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> const-super-trait.rs:7:12 | 7 | trait Bar: ~const Foo {} | ^^^^^^ can't be applied to `Foo` | -note: `Foo` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Foo` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> const-super-trait.rs:3:1 | 3 | trait Foo { | ^^^^^^^^^ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> const-super-trait.rs:9:17 | 9 | const fn foo<T: ~const Bar>(x: &T) { | ^^^^^^ can't be applied to `Bar` | -note: `Bar` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Bar` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> const-super-trait.rs:7:1 | 7 | trait Bar: ~const Foo {} diff --git a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr index 4c59d870671..2cdeb277ca4 100644 --- a/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr +++ b/tests/run-make/const-trait-stable-toolchain/const-super-trait-stable-enabled.stderr @@ -1,10 +1,10 @@ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> const-super-trait.rs:7:12 | 7 | trait Bar: ~const Foo {} | ^^^^^^ | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> const-super-trait.rs:7:1 | 7 | trait Bar: ~const Foo {} @@ -16,25 +16,25 @@ error[E0554]: `#![feature]` may not be used on the NIGHTLY release channel 1 | #![cfg_attr(feature_enabled, feature(const_trait_impl))] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> const-super-trait.rs:7:12 | 7 | trait Bar: ~const Foo {} | ^^^^^^ can't be applied to `Foo` | -note: `Foo` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Foo` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> const-super-trait.rs:3:1 | 3 | trait Foo { | ^^^^^^^^^ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> const-super-trait.rs:9:17 | 9 | const fn foo<T: ~const Bar>(x: &T) { | ^^^^^^ can't be applied to `Bar` | -note: `Bar` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Bar` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> const-super-trait.rs:7:1 | 7 | trait Bar: ~const Foo {} diff --git a/tests/run-make/crate-circular-deps-link/a.rs b/tests/run-make/crate-circular-deps-link/a.rs index a54f429550e..6deb449d873 100644 --- a/tests/run-make/crate-circular-deps-link/a.rs +++ b/tests/run-make/crate-circular-deps-link/a.rs @@ -1,6 +1,7 @@ #![crate_type = "rlib"] #![feature(lang_items)] #![feature(panic_unwind)] +#![feature(rustc_attrs)] #![no_std] extern crate panic_unwind; @@ -10,17 +11,23 @@ pub fn panic_handler(_: &core::panic::PanicInfo) -> ! { loop {} } -#[no_mangle] +#[rustc_std_internal_symbol] extern "C" fn __rust_drop_panic() -> ! { loop {} } -#[no_mangle] +#[rustc_std_internal_symbol] extern "C" fn __rust_foreign_exception() -> ! { loop {} } #[lang = "eh_personality"] -fn eh_personality() { +fn eh_personality( + _version: i32, + _actions: i32, + _exception_class: u64, + _exception_object: *mut (), + _context: *mut (), +) -> i32 { loop {} } diff --git a/tests/run-make/fmt-write-bloat/rmake.rs b/tests/run-make/fmt-write-bloat/rmake.rs index 6875ef9ddc0..3348651d501 100644 --- a/tests/run-make/fmt-write-bloat/rmake.rs +++ b/tests/run-make/fmt-write-bloat/rmake.rs @@ -15,14 +15,9 @@ //! `NO_DEBUG_ASSERTIONS=1`). If debug assertions are disabled, then we can check for the absence of //! additional `usize` formatting and padding related symbols. -//@ ignore-windows -// Reason: -// - MSVC targets really need to parse the .pdb file (aka the debug information). -// On Windows there's an API for that (dbghelp) which maybe we can use -// - MinGW targets have a lot of symbols included in their runtime which we can't avoid. -// We would need to make the symbols we're looking for more specific for this test to work. //@ ignore-cross-compile +use run_make_support::artifact_names::bin_name; use run_make_support::env::no_debug_assertions; use run_make_support::rustc; use run_make_support::symbols::any_symbol_contains; @@ -36,5 +31,5 @@ fn main() { // otherwise, add them to the list of symbols to deny. panic_syms.extend_from_slice(&["panicking", "panic_fmt", "pad_integral", "Display"]); } - assert!(!any_symbol_contains("main", &panic_syms)); + assert!(!any_symbol_contains(bin_name("main"), &panic_syms)); } diff --git a/tests/run-make/linker-warning/bar.rs b/tests/run-make/linker-warning/bar.rs new file mode 100644 index 00000000000..366816f31ea --- /dev/null +++ b/tests/run-make/linker-warning/bar.rs @@ -0,0 +1,2 @@ +#[repr(C)] +pub struct Bar(u32); diff --git a/tests/run-make/linker-warning/foo.rs b/tests/run-make/linker-warning/foo.rs new file mode 100644 index 00000000000..de3390c8c26 --- /dev/null +++ b/tests/run-make/linker-warning/foo.rs @@ -0,0 +1,2 @@ +#[repr(C)] +pub struct Foo(u32); diff --git a/tests/run-make/linker-warning/main.rs b/tests/run-make/linker-warning/main.rs index f328e4d9d04..fef5e3eb144 100644 --- a/tests/run-make/linker-warning/main.rs +++ b/tests/run-make/linker-warning/main.rs @@ -1 +1,10 @@ -fn main() {} +unsafe extern "C" { + #[cfg(only_foo)] + fn does_not_exist(p: *const u8) -> *const foo::Foo; + #[cfg(not(only_foo))] + fn does_not_exist(p: *const bar::Bar) -> *const foo::Foo; +} + +fn main() { + let _ = unsafe { does_not_exist(core::ptr::null()) }; +} diff --git a/tests/run-make/linker-warning/rmake.rs b/tests/run-make/linker-warning/rmake.rs index 344b880faab..57b68c65930 100644 --- a/tests/run-make/linker-warning/rmake.rs +++ b/tests/run-make/linker-warning/rmake.rs @@ -11,6 +11,7 @@ fn run_rustc() -> Rustc { .arg("-Clink-self-contained=-linker") .arg("-Zunstable-options") .arg("-Wlinker-messages") + .args(["--extern", "foo", "--extern", "bar"]) .output("main") .linker("./fake-linker"); if run_make_support::target() == "x86_64-unknown-linux-gnu" { @@ -21,8 +22,10 @@ fn run_rustc() -> Rustc { } fn main() { - // first, compile our linker + // first, compile our linker and our dependencies rustc().arg("fake-linker.rs").output("fake-linker").run(); + rustc().arg("foo.rs").crate_type("rlib").run(); + rustc().arg("bar.rs").crate_type("rlib").run(); // Run rustc with our fake linker, and make sure it shows warnings let warnings = run_rustc().link_arg("run_make_warn").run(); @@ -48,7 +51,8 @@ fn main() { let out = run_rustc().link_arg("run_make_error").run_fail(); out.assert_stderr_contains("fake-linker") .assert_stderr_contains("object files omitted") - .assert_stderr_contains_regex(r"\{") + .assert_stderr_contains("/{libfoo,libbar}.rlib\"") + .assert_stderr_contains("-*}.rlib\"") .assert_stderr_not_contains(r".rcgu.o") .assert_stderr_not_contains_regex(r"lib(/|\\\\)libstd"); @@ -57,7 +61,8 @@ fn main() { diff() .expected_file("short-error.txt") .actual_text("(linker error)", out.stderr()) - .normalize(r#"/rustc[^/]*/"#, "/rustc/") + .normalize(r#"/rustc[^/_-]*/"#, "/rustc/") + .normalize("libpanic_abort", "libpanic_unwind") .normalize( regex::escape(run_make_support::build_root().to_str().unwrap()), "/build-root", @@ -67,6 +72,10 @@ fn main() { .run(); } + // Make sure a single dependency doesn't use brace expansion. + let out1 = run_rustc().cfg("only_foo").link_arg("run_make_error").run_fail(); + out1.assert_stderr_contains("fake-linker").assert_stderr_contains("/libfoo.rlib\""); + // Make sure we show linker warnings even across `-Z no-link` rustc() .arg("-Zno-link") diff --git a/tests/run-make/linker-warning/short-error.txt b/tests/run-make/linker-warning/short-error.txt index 33d03832b7e..5b7c040bc50 100644 --- a/tests/run-make/linker-warning/short-error.txt +++ b/tests/run-make/linker-warning/short-error.txt @@ -1,6 +1,6 @@ error: linking with `./fake-linker` failed: exit status: 1 | - = note: "./fake-linker" "-m64" "/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/build-root/test/run-make/linker-warning/rmake_out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "run_make_error" + = note: "./fake-linker" "-m64" "/symbols.o" "<2 object files omitted>" "-Wl,--as-needed" "-Wl,-Bstatic" "/build-root/test/run-make/linker-warning/rmake_out/{libfoo,libbar}.rlib" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib/{libstd-*,libpanic_unwind-*,libobject-*,libmemchr-*,libaddr2line-*,libgimli-*,librustc_demangle-*,libstd_detect-*,libhashbrown-*,librustc_std_workspace_alloc-*,libminiz_oxide-*,libadler2-*,libunwind-*,libcfg_if-*,liblibc-*,librustc_std_workspace_core-*,liballoc-*,libcore-*,libcompiler_builtins-*}.rlib" "-Wl,-Bdynamic" "-lgcc_s" "-lutil" "-lrt" "-lpthread" "-lm" "-ldl" "-lc" "-L" "/raw-dylibs" "-Wl,--eh-frame-hdr" "-Wl,-z,noexecstack" "-L" "/build-root/test/run-make/linker-warning/rmake_out" "-L" "<sysroot>/lib/rustlib/x86_64-unknown-linux-gnu/lib" "-o" "main" "-Wl,--gc-sections" "-pie" "-Wl,-z,relro,-z,now" "-nodefaultlibs" "run_make_error" = note: some arguments are omitted. use `--verbose` to show all linker arguments = note: error: baz diff --git a/tests/run-make/no-alloc-shim/foo.rs b/tests/run-make/no-alloc-shim/foo.rs index b5d0d394d2b..a22307f41b3 100644 --- a/tests/run-make/no-alloc-shim/foo.rs +++ b/tests/run-make/no-alloc-shim/foo.rs @@ -12,7 +12,13 @@ fn panic_handler(_: &core::panic::PanicInfo) -> ! { } #[no_mangle] -extern "C" fn rust_eh_personality() { +extern "C" fn rust_eh_personality( + _version: i32, + _actions: i32, + _exception_class: u64, + _exception_object: *mut (), + _context: *mut (), +) -> i32 { loop {} } diff --git a/tests/run-make/reproducible-build-2/rmake.rs b/tests/run-make/reproducible-build-2/rmake.rs index 5971fa01f92..1de5ca1e6f7 100644 --- a/tests/run-make/reproducible-build-2/rmake.rs +++ b/tests/run-make/reproducible-build-2/rmake.rs @@ -7,22 +7,36 @@ // See https://github.com/rust-lang/rust/issues/34902 //@ ignore-cross-compile -//@ ignore-windows -// Reasons: -// 1. The object files are reproducible, but their paths are not, which causes -// the first assertion in the test to fail. -// 2. When the sysroot gets copied, some symlinks must be re-created, -// which is a privileged action on Windows. -use run_make_support::{rfs, rust_lib_name, rustc}; +//@ ignore-windows-gnu +// GNU Linker for Windows is non-deterministic. + +use run_make_support::{bin_name, is_windows_msvc, rfs, rust_lib_name, rustc}; fn main() { // test 1: fat lto rustc().input("reproducible-build-aux.rs").run(); - rustc().input("reproducible-build.rs").arg("-Clto=fat").output("reproducible-build").run(); - rfs::rename("reproducible-build", "reproducible-build-a"); - rustc().input("reproducible-build.rs").arg("-Clto=fat").output("reproducible-build").run(); - assert_eq!(rfs::read("reproducible-build"), rfs::read("reproducible-build-a")); + let make_reproducible_build = || { + let mut reproducible_build = rustc(); + reproducible_build + .input("reproducible-build.rs") + .arg("-Clto=fat") + .output(bin_name("reproducible-build")); + if is_windows_msvc() { + // Avoids timestamps, etc. when linking. + reproducible_build.arg("-Clink-arg=/Brepro"); + } + reproducible_build.run(); + }; + make_reproducible_build(); + rfs::rename(bin_name("reproducible-build"), "reproducible-build-a"); + if is_windows_msvc() { + // Linker acts differently if there is already a PDB file with the same + // name. + rfs::remove_file("reproducible-build.pdb"); + } + make_reproducible_build(); + assert_eq!(rfs::read(bin_name("reproducible-build")), rfs::read("reproducible-build-a")); // test 2: sysroot let sysroot = rustc().print("sysroot").run().stdout_utf8(); diff --git a/tests/run-make/sanitizer-dylib-link/program.rs b/tests/run-make/sanitizer-dylib-link/program.rs index 1026c7f89ba..dbf885d343f 100644 --- a/tests/run-make/sanitizer-dylib-link/program.rs +++ b/tests/run-make/sanitizer-dylib-link/program.rs @@ -1,4 +1,4 @@ -#[cfg_attr(windows, link(name = "library.dll.lib", modifiers = "+verbatim"))] +#[cfg_attr(windows, link(name = "library", kind = "raw-dylib"))] #[cfg_attr(not(windows), link(name = "library"))] extern "C" { fn overflow(); diff --git a/tests/run-make/short-ice/rmake.rs b/tests/run-make/short-ice/rmake.rs index 8377954f467..dbe0f692aef 100644 --- a/tests/run-make/short-ice/rmake.rs +++ b/tests/run-make/short-ice/rmake.rs @@ -5,8 +5,12 @@ // See https://github.com/rust-lang/rust/issues/107910 //@ needs-target-std -//@ ignore-windows -// Reason: the assert_eq! on line 32 fails, as error output on Windows is different. +//@ ignore-windows-msvc +// +// - FIXME(#143198): On `i686-pc-windows-msvc`: the assert_eq! on line 37 fails, almost seems like +// it missing debug info? Haven't been able to reproduce locally, but it happens on CI. +// - FIXME(#143198): On `x86_64-pc-windows-msvc`: full backtrace sometimes do not contain matching +// count of short backtrace markers (e.g. 5x end marker, but 3x start marker). use run_make_support::rustc; @@ -29,10 +33,16 @@ fn main() { let rustc_query_count_full = count_lines_with(rust_test_log_2, "rustc_query_"); - assert!(rust_test_log_1.lines().count() < rust_test_log_2.lines().count()); + assert!( + rust_test_log_1.lines().count() < rust_test_log_2.lines().count(), + "Short backtrace should be shorter than full backtrace.\nShort backtrace:\n\ + {rust_test_log_1}\nFull backtrace:\n{rust_test_log_2}" + ); assert_eq!( count_lines_with(rust_test_log_2, "__rust_begin_short_backtrace"), - count_lines_with(rust_test_log_2, "__rust_end_short_backtrace") + count_lines_with(rust_test_log_2, "__rust_end_short_backtrace"), + "Full backtrace should contain the short backtrace markers.\nFull backtrace:\n\ + {rust_test_log_2}" ); assert!(count_lines_with(rust_test_log_1, "rustc_query_") + 5 < rustc_query_count_full); assert!(rustc_query_count_full > 5); diff --git a/tests/run-make/textrel-on-minimal-lib/rmake.rs b/tests/run-make/textrel-on-minimal-lib/rmake.rs index 625ded70ad6..08e2b45a75f 100644 --- a/tests/run-make/textrel-on-minimal-lib/rmake.rs +++ b/tests/run-make/textrel-on-minimal-lib/rmake.rs @@ -6,25 +6,23 @@ // See https://github.com/rust-lang/rust/issues/68794 //@ ignore-cross-compile -//@ ignore-windows -// Reason: There is no `bar.dll` produced by CC to run readobj on use run_make_support::{ - cc, dynamic_lib_name, extra_c_flags, extra_cxx_flags, llvm_readobj, rustc, static_lib_name, + bin_name, cc, extra_c_flags, extra_cxx_flags, llvm_readobj, rustc, static_lib_name, }; fn main() { rustc().input("foo.rs").run(); cc().input("bar.c") .input(static_lib_name("foo")) - .out_exe(&dynamic_lib_name("bar")) + .out_exe(&bin_name("bar")) .arg("-fPIC") .arg("-shared") .args(extra_c_flags()) .args(extra_cxx_flags()) .run(); llvm_readobj() - .input(dynamic_lib_name("bar")) + .input(bin_name("bar")) .arg("--dynamic") .run() .assert_stdout_not_contains("TEXTREL"); diff --git a/tests/run-make/used-proc-macro/dep.rs b/tests/run-make/used-proc-macro/dep.rs new file mode 100644 index 00000000000..9f881d926d6 --- /dev/null +++ b/tests/run-make/used-proc-macro/dep.rs @@ -0,0 +1,4 @@ +#![crate_type = "lib"] + +#[used] +static VERY_IMPORTANT_SYMBOL: u32 = 12345; diff --git a/tests/run-make/used-proc-macro/proc_macro.rs b/tests/run-make/used-proc-macro/proc_macro.rs new file mode 100644 index 00000000000..af592ea0c7e --- /dev/null +++ b/tests/run-make/used-proc-macro/proc_macro.rs @@ -0,0 +1,3 @@ +#![crate_type = "proc-macro"] + +extern crate dep as _; diff --git a/tests/run-make/used-proc-macro/rmake.rs b/tests/run-make/used-proc-macro/rmake.rs new file mode 100644 index 00000000000..58b2760e64d --- /dev/null +++ b/tests/run-make/used-proc-macro/rmake.rs @@ -0,0 +1,18 @@ +// Test that #[used] statics are included in the final dylib for proc-macros too. + +//@ ignore-cross-compile +//@ ignore-windows llvm-readobj --all doesn't show local symbols on Windows +//@ needs-crate-type: proc-macro +//@ ignore-musl (FIXME: can't find `-lunwind`) + +use run_make_support::{dynamic_lib_name, llvm_readobj, rustc}; + +fn main() { + rustc().input("dep.rs").run(); + rustc().input("proc_macro.rs").run(); + llvm_readobj() + .input(dynamic_lib_name("proc_macro")) + .arg("--all") + .run() + .assert_stdout_contains("VERY_IMPORTANT_SYMBOL"); +} diff --git a/tests/rustdoc-gui/docblock-code-block-line-number.goml b/tests/rustdoc-gui/docblock-code-block-line-number.goml index 97273ceb195..0df9cc2a659 100644 --- a/tests/rustdoc-gui/docblock-code-block-line-number.goml +++ b/tests/rustdoc-gui/docblock-code-block-line-number.goml @@ -129,13 +129,13 @@ define-function: ("check-line-numbers-existence", [], block { wait-for-local-storage-false: {"rustdoc-line-numbers": "true" } assert-false: ".example-line-numbers" // Line numbers should still be there. - assert-css: ("[data-nosnippet]", { "display": "inline-block"}) + assert-css: ("[data-nosnippet]", { "display": "block"}) // Now disabling the setting. click: "input#line-numbers" wait-for-local-storage: {"rustdoc-line-numbers": "true" } assert-false: ".example-line-numbers" // Line numbers should still be there. - assert-css: ("[data-nosnippet]", { "display": "inline-block"}) + assert-css: ("[data-nosnippet]", { "display": "block"}) // Closing settings menu. click: "#settings-menu" wait-for-css: ("#settings", {"display": "none"}) diff --git a/tests/rustdoc-gui/scrape-examples-button-focus.goml b/tests/rustdoc-gui/scrape-examples-button-focus.goml index 12246a37661..f6e836e2360 100644 --- a/tests/rustdoc-gui/scrape-examples-button-focus.goml +++ b/tests/rustdoc-gui/scrape-examples-button-focus.goml @@ -5,7 +5,7 @@ go-to: "file://" + |DOC_PATH| + "/scrape_examples/fn.test.html" // The next/prev buttons vertically scroll the code viewport between examples move-cursor-to: ".scraped-example-list > .scraped-example" wait-for: ".scraped-example-list > .scraped-example .next" -store-value: (initialScrollTop, 250) +store-value: (initialScrollTop, 236) assert-property: (".scraped-example-list > .scraped-example .rust", { "scrollTop": |initialScrollTop|, }, NEAR) diff --git a/tests/rustdoc-gui/source-code-wrapping.goml b/tests/rustdoc-gui/source-code-wrapping.goml index cb2fd3052cd..0dab9c72ea9 100644 --- a/tests/rustdoc-gui/source-code-wrapping.goml +++ b/tests/rustdoc-gui/source-code-wrapping.goml @@ -31,17 +31,32 @@ go-to: "file://" + |DOC_PATH| + "/test_docs/trait_bounds/index.html" click: "#settings-menu" wait-for: "#settings" -store-size: (".example-wrap .rust code", {"width": rust_width, "height": rust_height}) -store-size: (".example-wrap .language-text code", {"width": txt_width, "height": txt_height}) +store-property: (".example-wrap .rust code", {"scrollWidth": rust_width, "scrollHeight": rust_height}) +store-property: (".example-wrap .language-text code", {"scrollWidth": txt_width, "scrollHeight": txt_height}) call-function: ("click-code-wrapping", {"expected": "true"}) -wait-for-size-false: (".example-wrap .rust code", {"width": |rust_width|, "height": |rust_height|}) +wait-for-property-false: ( + ".example-wrap .rust code", + {"scrollWidth": |rust_width|, "scrollHeight": |rust_height|}, +) -store-size: (".example-wrap .rust code", {"width": new_rust_width, "height": new_rust_height}) -store-size: (".example-wrap .language-text code", {"width": new_txt_width, "height": new_txt_height}) +store-property: ( + ".example-wrap .rust code", + {"scrollWidth": new_rust_width, "scrollHeight": new_rust_height}, +) +store-property: ( + ".example-wrap .language-text code", + {"scrollWidth": new_txt_width, "scrollHeight": new_txt_height}, +) assert: |rust_width| > |new_rust_width| && |rust_height| < |new_rust_height| assert: |txt_width| > |new_txt_width| && |txt_height| < |new_txt_height| call-function: ("click-code-wrapping", {"expected": "false"}) -wait-for-size: (".example-wrap .rust code", {"width": |rust_width|, "height": |rust_height|}) -assert-size: (".example-wrap .language-text code", {"width": |txt_width|, "height": |txt_height|}) +wait-for-property: ( + ".example-wrap .rust code", + {"scrollWidth": |rust_width|, "scrollHeight": |rust_height|}, +) +assert-property: ( + ".example-wrap .language-text code", + {"scrollWidth": |txt_width|, "scrollHeight": |txt_height|}, +) diff --git a/tests/rustdoc-js/big-result.rs b/tests/rustdoc-js/big-result.rs index 4dfecd6aaad..c7a52aac1a2 100644 --- a/tests/rustdoc-js/big-result.rs +++ b/tests/rustdoc-js/big-result.rs @@ -1,4 +1,3 @@ -#![feature(concat_idents)] #![allow(nonstandard_style)] /// Generate 250 items that all match the query, starting with the longest. /// Those long items should be dropped from the result set, and the short ones diff --git a/tests/rustdoc-json/attrs/cold.rs b/tests/rustdoc-json/attrs/cold.rs new file mode 100644 index 00000000000..e219345d669 --- /dev/null +++ b/tests/rustdoc-json/attrs/cold.rs @@ -0,0 +1,3 @@ +//@ is "$.index[?(@.name=='cold_fn')].attrs" '["#[attr = Cold]"]' +#[cold] +pub fn cold_fn() {} diff --git a/tests/rustdoc-json/attrs/link_section_2021.rs b/tests/rustdoc-json/attrs/link_section_2021.rs new file mode 100644 index 00000000000..a1312f4210b --- /dev/null +++ b/tests/rustdoc-json/attrs/link_section_2021.rs @@ -0,0 +1,6 @@ +//@ edition: 2021 +#![no_std] + +//@ is "$.index[?(@.name=='example')].attrs" '["#[link_section = \".text\"]"]' +#[link_section = ".text"] +pub extern "C" fn example() {} diff --git a/tests/rustdoc-json/attrs/link_section_2024.rs b/tests/rustdoc-json/attrs/link_section_2024.rs new file mode 100644 index 00000000000..edb028451a8 --- /dev/null +++ b/tests/rustdoc-json/attrs/link_section_2024.rs @@ -0,0 +1,9 @@ +//@ edition: 2024 +#![no_std] + +// Since the 2024 edition the link_section attribute must use the unsafe qualification. +// However, the unsafe qualification is not shown by rustdoc. + +//@ is "$.index[?(@.name=='example')].attrs" '["#[link_section = \".text\"]"]' +#[unsafe(link_section = ".text")] +pub extern "C" fn example() {} diff --git a/tests/rustdoc-json/attrs/must_use.rs b/tests/rustdoc-json/attrs/must_use.rs index 64df8e5f509..3ca6f5a75a5 100644 --- a/tests/rustdoc-json/attrs/must_use.rs +++ b/tests/rustdoc-json/attrs/must_use.rs @@ -1,9 +1,9 @@ #![no_std] -//@ is "$.index[?(@.name=='example')].attrs" '["#[must_use]"]' +//@ is "$.index[?(@.name=='example')].attrs" '["#[attr = MustUse]"]' #[must_use] pub fn example() -> impl Iterator<Item = i64> {} -//@ is "$.index[?(@.name=='explicit_message')].attrs" '["#[must_use = \"does nothing if you do not use it\"]"]' +//@ is "$.index[?(@.name=='explicit_message')].attrs" '["#[attr = MustUse {reason: \"does nothing if you do not use it\"}]"]' #[must_use = "does nothing if you do not use it"] pub fn explicit_message() -> impl Iterator<Item = i64> {} diff --git a/tests/rustdoc-json/attrs/optimize.rs b/tests/rustdoc-json/attrs/optimize.rs new file mode 100644 index 00000000000..0bed0ad18c3 --- /dev/null +++ b/tests/rustdoc-json/attrs/optimize.rs @@ -0,0 +1,13 @@ +#![feature(optimize_attribute)] + +//@ is "$.index[?(@.name=='speed')].attrs" '["#[attr = Optimize(Speed)]"]' +#[optimize(speed)] +pub fn speed() {} + +//@ is "$.index[?(@.name=='size')].attrs" '["#[attr = Optimize(Size)]"]' +#[optimize(size)] +pub fn size() {} + +//@ is "$.index[?(@.name=='none')].attrs" '["#[attr = Optimize(DoNotOptimize)]"]' +#[optimize(none)] +pub fn none() {} diff --git a/tests/rustdoc-json/attrs/target_feature.rs b/tests/rustdoc-json/attrs/target_feature.rs new file mode 100644 index 00000000000..ee2b3235f72 --- /dev/null +++ b/tests/rustdoc-json/attrs/target_feature.rs @@ -0,0 +1,17 @@ +//@ only-x86_64 + +//@ is "$.index[?(@.name=='test1')].attrs" '["#[target_feature(enable=\"avx\")]"]' +#[target_feature(enable = "avx")] +pub fn test1() {} + +//@ is "$.index[?(@.name=='test2')].attrs" '["#[target_feature(enable=\"avx\", enable=\"avx2\")]"]' +#[target_feature(enable = "avx,avx2")] +pub fn test2() {} + +//@ is "$.index[?(@.name=='test3')].attrs" '["#[target_feature(enable=\"avx\", enable=\"avx2\")]"]' +#[target_feature(enable = "avx", enable = "avx2")] +pub fn test3() {} + +//@ is "$.index[?(@.name=='test4')].attrs" '["#[target_feature(enable=\"avx\", enable=\"avx2\", enable=\"avx512f\")]"]' +#[target_feature(enable = "avx", enable = "avx2,avx512f")] +pub fn test4() {} diff --git a/tests/rustdoc-json/generic-args.rs b/tests/rustdoc-json/generic-args.rs index 0f588820da7..b4a73a046b5 100644 --- a/tests/rustdoc-json/generic-args.rs +++ b/tests/rustdoc-json/generic-args.rs @@ -17,4 +17,7 @@ pub fn my_fn1(_: <MyStruct as MyTrait>::MyType) {} //@ is "$.index[?(@.name=='my_fn2')].inner.function.sig.inputs[0][1].dyn_trait.traits[0].trait.args.angle_bracketed.constraints[0].args" null pub fn my_fn2(_: IntoIterator<Item = MyStruct, IntoIter = impl Clone>) {} +//@ is "$.index[?(@.name=='my_fn3')].inner.function.sig.inputs[0][1].impl_trait[0].trait_bound.trait.args.parenthesized.inputs" [] +pub fn my_fn3(f: impl FnMut()) {} + fn main() {} diff --git a/tests/rustdoc-ui/invalid_infered_static_and_const.stderr b/tests/rustdoc-ui/invalid_infered_static_and_const.stderr index 401020224d6..3e116826c49 100644 --- a/tests/rustdoc-ui/invalid_infered_static_and_const.stderr +++ b/tests/rustdoc-ui/invalid_infered_static_and_const.stderr @@ -1,10 +1,10 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/invalid_infered_static_and_const.rs:1:24 | LL | const FOO: dyn Fn() -> _ = ""; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/invalid_infered_static_and_const.rs:2:25 | LL | static BOO: dyn Fn() -> _ = ""; diff --git a/tests/rustdoc-ui/lints/redundant_explicit_links-expansion.rs b/tests/rustdoc-ui/lints/redundant_explicit_links-expansion.rs new file mode 100644 index 00000000000..2e42a0a5c5d --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant_explicit_links-expansion.rs @@ -0,0 +1,40 @@ +// This is a regression test for <https://github.com/rust-lang/rust/issues/141553>. +// If the link is generated from expansion, we should not emit the lint. + +#![deny(rustdoc::redundant_explicit_links)] + +macro_rules! mac1 { + () => { + "provided by a [`BufferProvider`](crate::BufferProvider)." + }; +} + +macro_rules! mac2 { + () => { + #[doc = mac1!()] + pub struct BufferProvider; + } +} + +macro_rules! mac3 { + () => { + "Provided by" + }; +} + +// Should not lint. +#[doc = mac1!()] +pub struct Foo; + +// Should not lint. +mac2!{} + +#[doc = "provided by a [`BufferProvider`](crate::BufferProvider)."] +/// bla +//~^^ ERROR: redundant_explicit_links +pub struct Bla; + +#[doc = mac3!()] +/// a [`BufferProvider`](crate::BufferProvider). +//~^ ERROR: redundant_explicit_links +pub fn f() {} diff --git a/tests/rustdoc-ui/lints/redundant_explicit_links-expansion.stderr b/tests/rustdoc-ui/lints/redundant_explicit_links-expansion.stderr new file mode 100644 index 00000000000..a81931fb073 --- /dev/null +++ b/tests/rustdoc-ui/lints/redundant_explicit_links-expansion.stderr @@ -0,0 +1,39 @@ +error: redundant explicit link target + --> $DIR/redundant_explicit_links-expansion.rs:32:43 + | +LL | #[doc = "provided by a [`BufferProvider`](crate::BufferProvider)."] + | ---------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +note: the lint level is defined here + --> $DIR/redundant_explicit_links-expansion.rs:4:9 + | +LL | #![deny(rustdoc::redundant_explicit_links)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: remove explicit link target + | +LL - #[doc = "provided by a [`BufferProvider`](crate::BufferProvider)."] +LL + #[doc = "provided by a [`BufferProvider`]."] + | + +error: redundant explicit link target + --> $DIR/redundant_explicit_links-expansion.rs:38:26 + | +LL | /// a [`BufferProvider`](crate::BufferProvider). + | ---------------- ^^^^^^^^^^^^^^^^^^^^^ explicit target is redundant + | | + | because label contains path that resolves to same destination + | + = note: when a link's destination is not specified, + the label is used to resolve intra-doc links +help: remove explicit link target + | +LL - /// a [`BufferProvider`](crate::BufferProvider). +LL + /// a [`BufferProvider`]. + | + +error: aborting due to 2 previous errors + diff --git a/tests/rustdoc-ui/track-diagnostics.rs b/tests/rustdoc-ui/track-diagnostics.rs index d18d26bf794..f8e710659a5 100644 --- a/tests/rustdoc-ui/track-diagnostics.rs +++ b/tests/rustdoc-ui/track-diagnostics.rs @@ -1,5 +1,4 @@ //@ compile-flags: -Z track-diagnostics -//@ error-pattern: created at // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. @@ -8,4 +7,7 @@ struct A; struct B; -pub const S: A = B; //~ ERROR mismatched types +pub const S: A = B; +//~^ ERROR mismatched types +//~| NOTE created at +//~| NOTE expected `A`, found `B` diff --git a/tests/rustdoc-ui/track-diagnostics.stderr b/tests/rustdoc-ui/track-diagnostics.stderr index fb0d7b86644..a25fd2862aa 100644 --- a/tests/rustdoc-ui/track-diagnostics.stderr +++ b/tests/rustdoc-ui/track-diagnostics.stderr @@ -3,7 +3,8 @@ error[E0308]: mismatched types | LL | pub const S: A = B; | ^ expected `A`, found `B` --Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs:LL:CC + | + = note: -Ztrack-diagnostics: created at compiler/rustc_trait_selection/src/error_reporting/infer/mod.rs:LL:CC error: aborting due to 1 previous error diff --git a/tests/rustdoc/attributes-re-export.rs b/tests/rustdoc/attributes-re-export.rs new file mode 100644 index 00000000000..458826ea8a3 --- /dev/null +++ b/tests/rustdoc/attributes-re-export.rs @@ -0,0 +1,13 @@ +// Tests that attributes are correctly copied onto a re-exported item. +//@ edition:2021 +#![crate_name = "re_export"] + +//@ has 're_export/fn.thingy2.html' '//pre[@class="rust item-decl"]' '#[no_mangle]' +pub use thingymod::thingy as thingy2; + +mod thingymod { + #[no_mangle] + pub fn thingy() { + + } +} diff --git a/tests/rustdoc/constant/const-effect-param.rs b/tests/rustdoc/constant/const-effect-param.rs index cceb0adac30..3dc63fb3d30 100644 --- a/tests/rustdoc/constant/const-effect-param.rs +++ b/tests/rustdoc/constant/const-effect-param.rs @@ -11,4 +11,4 @@ pub trait Tr { //@ has foo/fn.g.html //@ has - '//pre[@class="rust item-decl"]' 'pub const fn g<T: Tr>()' /// foo -pub const fn g<T: ~const Tr>() {} +pub const fn g<T: [const] Tr>() {} diff --git a/tests/rustdoc/constant/const-trait-and-impl-methods.rs b/tests/rustdoc/constant/const-trait-and-impl-methods.rs new file mode 100644 index 00000000000..30fc539e553 --- /dev/null +++ b/tests/rustdoc/constant/const-trait-and-impl-methods.rs @@ -0,0 +1,36 @@ +// check that we don't render `#[const_trait]` methods as `const` - even for +// const `trait`s and `impl`s. +#![crate_name = "foo"] +#![feature(const_trait_impl)] + +//@ has foo/trait.Tr.html +//@ has - '//*[@id="tymethod.required"]' 'fn required()' +//@ !has - '//*[@id="tymethod.required"]' 'const' +//@ has - '//*[@id="method.defaulted"]' 'fn defaulted()' +//@ !has - '//*[@id="method.defaulted"]' 'const' +#[const_trait] +pub trait Tr { + fn required(); + fn defaulted() {} +} + +pub struct ConstImpl {} +pub struct NonConstImpl {} + +//@ has foo/struct.ConstImpl.html +//@ has - '//*[@id="method.required"]' 'fn required()' +//@ !has - '//*[@id="method.required"]' 'const' +//@ has - '//*[@id="method.defaulted"]' 'fn defaulted()' +//@ !has - '//*[@id="method.defaulted"]' 'const' +impl const Tr for ConstImpl { + fn required() {} +} + +//@ has foo/struct.NonConstImpl.html +//@ has - '//*[@id="method.required"]' 'fn required()' +//@ !has - '//*[@id="method.required"]' 'const' +//@ has - '//*[@id="method.defaulted"]' 'fn defaulted()' +//@ !has - '//*[@id="method.defaulted"]' 'const' +impl Tr for NonConstImpl { + fn required() {} +} diff --git a/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs b/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs index 8a86e3e5e97..e304eff14e8 100644 --- a/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs +++ b/tests/rustdoc/constant/rfc-2632-const-trait-impl.rs @@ -1,12 +1,12 @@ -// Test that we do not currently display `~const` in rustdoc -// as that syntax is currently provisional; `~const Destruct` has +// Test that we do not currently display `[const]` in rustdoc +// as that syntax is currently provisional; `[const] Destruct` has // no effect on stable code so it should be hidden as well. // // To future blessers: make sure that `const_trait_impl` is // stabilized when changing `@!has` to `@has`, and please do // not remove this test. // -// FIXME(const_trait_impl) add `const_trait` to `Fn` so we use `~const` +// FIXME(const_trait_impl) add `const_trait` to `Fn` so we use `[const]` // FIXME(const_trait_impl) restore `const_trait` to `Destruct` #![feature(const_trait_impl)] #![crate_name = "foo"] @@ -15,58 +15,58 @@ use std::marker::Destruct; pub struct S<T>(T); -//@ !has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' +//@ !has foo/trait.Tr.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '[const]' //@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' -//@ !has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '~const' +//@ !has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' '[const]' //@ has - '//pre[@class="rust item-decl"]/code/span[@class="where"]' ': Fn' #[const_trait] pub trait Tr<T> { - //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]' '~const' + //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]' '[const]' //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' - //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '~const' + //@ !has - '//section[@id="method.a"]/h4[@class="code-header"]/span[@class="where"]' '[const]' //@ has - '//section[@id="method.a"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' - fn a<A: /* ~const */ Fn() /* + ~const Destruct */>() + fn a<A: /* [const] */ Fn() /* + [const] Destruct */>() where - Option<A>: /* ~const */ Fn() /* + ~const Destruct */, + Option<A>: /* [const] */ Fn() /* + [const] Destruct */, { } } //@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]' '' -//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '~const' +//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]' '[const]' //@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/a[@class="trait"]' 'Fn' -//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '~const' +//@ !has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/span[@class="where"]' '[const]' //@ has - '//section[@id="impl-Tr%3CT%3E-for-T"]/h3[@class="code-header"]/div[@class="where"]' ': Fn' -impl<T: /* ~const */ Fn() /* + ~const Destruct */> const Tr<T> for T +impl<T: /* [const] */ Fn() /* + [const] Destruct */> const Tr<T> for T where - Option<T>: /* ~const */ Fn() /* + ~const Destruct */, + Option<T>: /* [const] */ Fn() /* + [const] Destruct */, { - fn a<A: /* ~const */ Fn() /* + ~const Destruct */>() + fn a<A: /* [const] */ Fn() /* + [const] Destruct */>() where - Option<A>: /* ~const */ Fn() /* + ~const Destruct */, + Option<A>: /* [const] */ Fn() /* + [const] Destruct */, { } } -//@ !has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '~const' +//@ !has foo/fn.foo.html '//pre[@class="rust item-decl"]/code/a[@class="trait"]' '[const]' //@ has - '//pre[@class="rust item-decl"]/code/a[@class="trait"]' 'Fn' -//@ !has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' '~const' +//@ !has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' '[const]' //@ has - '//pre[@class="rust item-decl"]/code/div[@class="where"]' ': Fn' -pub const fn foo<F: /* ~const */ Fn() /* + ~const Destruct */>() +pub const fn foo<F: /* [const] */ Fn() /* + [const] Destruct */>() where - Option<F>: /* ~const */ Fn() /* + ~const Destruct */, + Option<F>: /* [const] */ Fn() /* + [const] Destruct */, { F::a() } impl<T> S<T> { - //@ !has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '~const' + //@ !has foo/struct.S.html '//section[@id="method.foo"]/h4[@class="code-header"]' '[const]' //@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/a[@class="trait"]' 'Fn' - //@ !has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '~const' + //@ !has - '//section[@id="method.foo"]/h4[@class="code-header"]/span[@class="where"]' '[const]' //@ has - '//section[@id="method.foo"]/h4[@class="code-header"]/div[@class="where"]' ': Fn' - pub const fn foo<B, C: /* ~const */ Fn() /* + ~const Destruct */>() + pub const fn foo<B, C: /* [const] */ Fn() /* + [const] Destruct */>() where - B: /* ~const */ Fn() /* + ~const Destruct */, + B: /* [const] */ Fn() /* + [const] Destruct */, { B::a() } diff --git a/tests/rustdoc/enum/enum-variant-non_exhaustive.rs b/tests/rustdoc/enum/enum-variant-non_exhaustive.rs new file mode 100644 index 00000000000..ea0234a49f6 --- /dev/null +++ b/tests/rustdoc/enum/enum-variant-non_exhaustive.rs @@ -0,0 +1,17 @@ +// regression test for https://github.com/rust-lang/rust/issues/142599 + +#![crate_name = "foo"] + +//@ snapshot type-code 'foo/enum.Type.html' '//pre[@class="rust item-decl"]/code' +pub enum Type { + #[non_exhaustive] + // attribute that should not be shown + #[warn(unsafe_code)] + Variant, +} + +// we would love to use the `following-sibling::` axis +// (along with an `h2[@id="aliased-type"]` query), +// but unfortunately python doesn't implement that. +//@ snapshot type-alias-code 'foo/type.TypeAlias.html' '//pre[@class="rust item-decl"][2]/code' +pub type TypeAlias = Type; diff --git a/tests/rustdoc/enum/enum-variant-non_exhaustive.type-alias-code.html b/tests/rustdoc/enum/enum-variant-non_exhaustive.type-alias-code.html new file mode 100644 index 00000000000..04eea709079 --- /dev/null +++ b/tests/rustdoc/enum/enum-variant-non_exhaustive.type-alias-code.html @@ -0,0 +1,4 @@ +<code>pub enum TypeAlias { + #[non_exhaustive] + Variant, +}</code> \ No newline at end of file diff --git a/tests/rustdoc/enum/enum-variant-non_exhaustive.type-code.html b/tests/rustdoc/enum/enum-variant-non_exhaustive.type-code.html new file mode 100644 index 00000000000..6c8851ea5df --- /dev/null +++ b/tests/rustdoc/enum/enum-variant-non_exhaustive.type-code.html @@ -0,0 +1,4 @@ +<code>pub enum Type { + #[non_exhaustive] + Variant, +}</code> \ No newline at end of file diff --git a/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs b/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs index db198e0fce9..d7d7b32e2b8 100644 --- a/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs +++ b/tests/rustdoc/inline_cross/auxiliary/const-effect-param.rs @@ -4,7 +4,7 @@ #[const_trait] pub trait Resource {} -pub const fn load<R: ~const Resource>() -> i32 { +pub const fn load<R: [const] Resource>() -> i32 { 0 } diff --git a/tests/rustdoc/intra-doc/deps.rs b/tests/rustdoc/intra-doc/deps.rs new file mode 100644 index 00000000000..fd40b8326d0 --- /dev/null +++ b/tests/rustdoc/intra-doc/deps.rs @@ -0,0 +1,23 @@ +// Checks that links to crates are correctly generated and only existing crates +// have a link generated. +// Regression test for <https://github.com/rust-lang/rust/issues/137857>. + +//@ compile-flags: --document-private-items -Z unstable-options +//@ compile-flags: --extern-html-root-url=empty=https://empty.example/ +// This one is to ensure that we don't link to any item we see which has +// an external html root URL unless it actually exists. +//@ compile-flags: --extern-html-root-url=non_existant=https://non-existant.example/ +//@ aux-build: empty.rs + +#![crate_name = "foo"] +#![expect(rustdoc::broken_intra_doc_links)] + +//@ has 'foo/index.html' +//@ has - '//a[@href="https://empty.example/empty/index.html"]' 'empty' +// There should only be one intra doc links, we should not link `non_existant`. +//@ count - '//*[@class="docblock"]//a' 1 +//! [`empty`] +//! +//! [`non_existant`] + +extern crate empty; diff --git a/tests/rustdoc/reexport/extern-135092.rs b/tests/rustdoc/reexport/extern-135092.rs new file mode 100644 index 00000000000..fb5c71d56d5 --- /dev/null +++ b/tests/rustdoc/reexport/extern-135092.rs @@ -0,0 +1,26 @@ +// Test to make sure reexports of extern items are combined +// <https://github.com/rust-lang/rust/issues/135092> + +#![crate_name = "foo"] + +mod native { + extern "C" { + /// bar. + pub fn bar(); + } + + /// baz. + pub fn baz() {} +} + +//@ has 'foo/fn.bar.html' +//@ has - '//div[@class="docblock"]' 'bar.' +//@ has - '//div[@class="docblock"]' 'foo' +/// foo +pub use native::bar; + +//@ has 'foo/fn.baz.html' +//@ has - '//div[@class="docblock"]' 'baz.' +//@ has - '//div[@class="docblock"]' 'foo' +/// foo +pub use native::baz; diff --git a/tests/rustdoc/target-feature.rs b/tests/rustdoc/target-feature.rs new file mode 100644 index 00000000000..59a08a0ca94 --- /dev/null +++ b/tests/rustdoc/target-feature.rs @@ -0,0 +1,38 @@ +#![crate_name = "foo"] + +//@ has 'foo/index.html' + +//@ has - '//dl[@class="item-table"]/dt[1]//a' 'f1_safe' +//@ has - '//dl[@class="item-table"]/dt[1]//code' 'popcnt' +//@ count - '//dl[@class="item-table"]/dt[1]//sup' 0 +//@ has - '//dl[@class="item-table"]/dt[2]//a' 'f2_not_safe' +//@ has - '//dl[@class="item-table"]/dt[2]//code' 'avx2' +//@ count - '//dl[@class="item-table"]/dt[2]//sup' 1 +//@ has - '//dl[@class="item-table"]/dt[2]//sup' '⚠' + +#[target_feature(enable = "popcnt")] +//@ has 'foo/fn.f1_safe.html' +//@ matches - '//pre[@class="rust item-decl"]' '^pub fn f1_safe' +//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ +// 'Available with target feature popcnt only.' +pub fn f1_safe() {} + +//@ has 'foo/fn.f2_not_safe.html' +//@ matches - '//pre[@class="rust item-decl"]' '^pub unsafe fn f2_not_safe()' +//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ +// 'Available with target feature avx2 only.' +#[target_feature(enable = "avx2")] +pub unsafe fn f2_not_safe() {} + +//@ has 'foo/fn.f3_multifeatures_in_attr.html' +//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ +// 'Available on target features popcnt and avx2 only.' +#[target_feature(enable = "popcnt", enable = "avx2")] +pub fn f3_multifeatures_in_attr() {} + +//@ has 'foo/fn.f4_multi_attrs.html' +//@ has - '//*[@id="main-content"]/*[@class="item-info"]/*[@class="stab portability"]' \ +// 'Available on target features popcnt and avx2 only.' +#[target_feature(enable = "popcnt")] +#[target_feature(enable = "avx2")] +pub fn f4_multi_attrs() {} diff --git a/tests/ui-fulldeps/run-compiler-twice.rs b/tests/ui-fulldeps/run-compiler-twice.rs index fa651baa7bc..87504b8301f 100644 --- a/tests/ui-fulldeps/run-compiler-twice.rs +++ b/tests/ui-fulldeps/run-compiler-twice.rs @@ -18,7 +18,7 @@ extern crate rustc_span; use std::path::{Path, PathBuf}; use rustc_interface::{Linker, interface}; -use rustc_session::config::{Input, Options, OutFileName, OutputType, OutputTypes}; +use rustc_session::config::{Input, Options, OutFileName, OutputType, OutputTypes, Sysroot}; use rustc_span::FileName; fn main() { @@ -32,7 +32,7 @@ fn main() { panic!("expected sysroot (and optional linker)"); } - let sysroot = PathBuf::from(&args[1]); + let sysroot = Sysroot::new(Some(PathBuf::from(&args[1]))); let linker = args.get(2).map(PathBuf::from); // compiletest sets the current dir to `output_base_dir` when running. @@ -43,7 +43,7 @@ fn main() { compile(src.to_string(), tmpdir.join("out"), sysroot.clone(), linker.as_deref()); } -fn compile(code: String, output: PathBuf, sysroot: PathBuf, linker: Option<&Path>) { +fn compile(code: String, output: PathBuf, sysroot: Sysroot, linker: Option<&Path>) { let mut opts = Options::default(); opts.output_types = OutputTypes::new(&[(OutputType::Exe, None)]); opts.sysroot = sysroot; diff --git a/tests/ui-fulldeps/rustc-dev-remap.only-remap.stderr b/tests/ui-fulldeps/rustc-dev-remap.only-remap.stderr index f54b6803b34..0c969b9c6d8 100644 --- a/tests/ui-fulldeps/rustc-dev-remap.only-remap.stderr +++ b/tests/ui-fulldeps/rustc-dev-remap.only-remap.stderr @@ -9,6 +9,7 @@ LL | type Result = NotAValidResultType; ControlFlow<T> note: required by a bound in `rustc_ast::visit::Visitor::Result` --> /rustc-dev/xyz/compiler/rustc_ast/src/visit.rs:LL:COL + = note: this error originates in the macro `common_visitor_and_walkers` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr b/tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr index 438c23458e2..6ac8c3046f6 100644 --- a/tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr +++ b/tests/ui-fulldeps/rustc-dev-remap.remap-unremap.stderr @@ -10,8 +10,9 @@ LL | type Result = NotAValidResultType; note: required by a bound in `rustc_ast::visit::Visitor::Result` --> $COMPILER_DIR_REAL/rustc_ast/src/visit.rs:LL:COL | -LL | type Result: VisitorResult = (); - | ^^^^^^^^^^^^^ required by this bound in `Visitor::Result` +LL | common_visitor_and_walkers!(Visitor<'a>); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Visitor::Result` + = note: this error originates in the macro `common_visitor_and_walkers` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui-fulldeps/stable-mir/check_abi.rs b/tests/ui-fulldeps/stable-mir/check_abi.rs index 15ef583709b..9d83dd9ce1a 100644 --- a/tests/ui-fulldeps/stable-mir/check_abi.rs +++ b/tests/ui-fulldeps/stable-mir/check_abi.rs @@ -11,10 +11,9 @@ extern crate rustc_hir; extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use stable_mir::abi::{ diff --git a/tests/ui-fulldeps/stable-mir/check_allocation.rs b/tests/ui-fulldeps/stable-mir/check_allocation.rs index 692c24f0544..c2d1d5d873b 100644 --- a/tests/ui-fulldeps/stable-mir/check_allocation.rs +++ b/tests/ui-fulldeps/stable-mir/check_allocation.rs @@ -13,18 +13,12 @@ extern crate rustc_hir; extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; -use stable_mir::crate_def::CrateDef; -use stable_mir::mir::alloc::GlobalAlloc; -use stable_mir::mir::mono::{Instance, InstanceKind, StaticDef}; -use stable_mir::mir::{Body, TerminatorKind}; -use stable_mir::ty::{Allocation, ConstantKind, RigidTy, TyKind}; -use stable_mir::{CrateItem, CrateItems, ItemKind}; use std::ascii::Char; use std::assert_matches::assert_matches; use std::cmp::{max, min}; @@ -33,6 +27,13 @@ use std::ffi::CStr; use std::io::Write; use std::ops::ControlFlow; +use stable_mir::crate_def::CrateDef; +use stable_mir::mir::Body; +use stable_mir::mir::alloc::GlobalAlloc; +use stable_mir::mir::mono::{Instance, StaticDef}; +use stable_mir::ty::{Allocation, ConstantKind}; +use stable_mir::{CrateItem, CrateItems, ItemKind}; + const CRATE_NAME: &str = "input"; /// This function uses the Stable MIR APIs to get information about the test crate. @@ -44,7 +45,6 @@ fn test_stable_mir() -> ControlFlow<()> { check_len(*get_item(&items, (ItemKind::Static, "LEN")).unwrap()); check_cstr(*get_item(&items, (ItemKind::Static, "C_STR")).unwrap()); check_other_consts(*get_item(&items, (ItemKind::Fn, "other_consts")).unwrap()); - check_type_id(*get_item(&items, (ItemKind::Fn, "check_type_id")).unwrap()); ControlFlow::Continue(()) } @@ -107,7 +107,9 @@ fn check_other_consts(item: CrateItem) { // Instance body will force constant evaluation. let body = Instance::try_from(item).unwrap().body().unwrap(); let assigns = collect_consts(&body); - assert_eq!(assigns.len(), 8); + assert_eq!(assigns.len(), 10); + let mut char_id = None; + let mut bool_id = None; for (name, alloc) in assigns { match name.as_str() { "_max_u128" => { @@ -149,35 +151,21 @@ fn check_other_consts(item: CrateItem) { assert_eq!(max(first, second) as u32, u32::MAX); assert_eq!(min(first, second), 10); } + "_bool_id" => { + bool_id = Some(alloc); + } + "_char_id" => { + char_id = Some(alloc); + } _ => { unreachable!("{name} -- {alloc:?}") } } } -} - -/// Check that we can retrieve the type id of char and bool, and that they have different values. -fn check_type_id(item: CrateItem) { - let body = Instance::try_from(item).unwrap().body().unwrap(); - let mut ids: Vec<u128> = vec![]; - for term in body.blocks.iter().map(|bb| &bb.terminator) { - match &term.kind { - TerminatorKind::Call { func, destination, .. } => { - let TyKind::RigidTy(ty) = func.ty(body.locals()).unwrap().kind() else { - unreachable!() - }; - let RigidTy::FnDef(def, args) = ty else { unreachable!() }; - let instance = Instance::resolve(def, &args).unwrap(); - assert_eq!(instance.kind, InstanceKind::Intrinsic); - let dest_ty = destination.ty(body.locals()).unwrap(); - let alloc = instance.try_const_eval(dest_ty).unwrap(); - ids.push(alloc.read_uint().unwrap()); - } - _ => { /* Do nothing */ } - } - } - assert_eq!(ids.len(), 2); - assert_ne!(ids[0], ids[1]); + let bool_id = bool_id.unwrap(); + let char_id = char_id.unwrap(); + // FIXME(stable_mir): add `read_ptr` to `Allocation` + assert_ne!(bool_id, char_id); } /// Collects all the constant assignments. @@ -235,6 +223,7 @@ fn generate_input(path: &str) -> std::io::Result<()> { file, r#" #![feature(core_intrinsics)] + #![expect(internal_features)] use std::intrinsics::type_id; static LEN: usize = 2; @@ -254,11 +243,8 @@ fn generate_input(path: &str) -> std::io::Result<()> { let _ptr = &BAR; let _null_ptr: *const u8 = NULL; let _tuple = TUPLE; - }} - - fn check_type_id() {{ - let _char_id = type_id::<char>(); - let _bool_id = type_id::<bool>(); + let _char_id = const {{ type_id::<char>() }}; + let _bool_id = const {{ type_id::<bool>() }}; }} pub fn main() {{ diff --git a/tests/ui-fulldeps/stable-mir/check_assoc_items.rs b/tests/ui-fulldeps/stable-mir/check_assoc_items.rs index bb95bedf973..574f7797854 100644 --- a/tests/ui-fulldeps/stable-mir/check_assoc_items.rs +++ b/tests/ui-fulldeps/stable-mir/check_assoc_items.rs @@ -11,8 +11,7 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; extern crate stable_mir; diff --git a/tests/ui-fulldeps/stable-mir/check_attribute.rs b/tests/ui-fulldeps/stable-mir/check_attribute.rs index e4cc7b104b6..f234c658dfd 100644 --- a/tests/ui-fulldeps/stable-mir/check_attribute.rs +++ b/tests/ui-fulldeps/stable-mir/check_attribute.rs @@ -9,10 +9,10 @@ extern crate rustc_hir; extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use stable_mir::{CrateDef, CrateItems}; diff --git a/tests/ui-fulldeps/stable-mir/check_binop.rs b/tests/ui-fulldeps/stable-mir/check_binop.rs index f9559d9958d..748c2088a30 100644 --- a/tests/ui-fulldeps/stable-mir/check_binop.rs +++ b/tests/ui-fulldeps/stable-mir/check_binop.rs @@ -9,10 +9,10 @@ extern crate rustc_hir; extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use stable_mir::mir::mono::Instance; diff --git a/tests/ui-fulldeps/stable-mir/check_coroutine_body.rs b/tests/ui-fulldeps/stable-mir/check_coroutine_body.rs new file mode 100644 index 00000000000..2af32afc1f7 --- /dev/null +++ b/tests/ui-fulldeps/stable-mir/check_coroutine_body.rs @@ -0,0 +1,105 @@ +//@ run-pass +//! Tests stable mir API for retrieving the body of a coroutine. + +//@ ignore-stage1 +//@ ignore-cross-compile +//@ ignore-remote +//@ edition: 2024 + +#![feature(rustc_private)] +#![feature(assert_matches)] + +extern crate rustc_middle; + +extern crate rustc_driver; +extern crate rustc_interface; +#[macro_use] +extern crate stable_mir; + +use std::io::Write; +use std::ops::ControlFlow; + +use stable_mir::mir::Body; +use stable_mir::ty::{RigidTy, TyKind}; + +const CRATE_NAME: &str = "crate_coroutine_body"; + +fn test_coroutine_body() -> ControlFlow<()> { + let crate_items = stable_mir::all_local_items(); + if let Some(body) = crate_items.iter().find_map(|item| { + let item_ty = item.ty(); + if let TyKind::RigidTy(RigidTy::Coroutine(def, ..)) = &item_ty.kind() { + if def.0.name() == "gbc::{closure#0}".to_string() { + def.body() + } else { + None + } + } else { + None + } + }) { + check_coroutine_body(body); + } else { + panic!("Cannot find `gbc::{{closure#0}}`. All local items are: {:#?}", crate_items); + } + + ControlFlow::Continue(()) +} + +fn check_coroutine_body(body: Body) { + let ret_ty = &body.locals()[0].ty; + let local_3 = &body.locals()[3].ty; + let local_4 = &body.locals()[4].ty; + + let TyKind::RigidTy(RigidTy::Adt(def, ..)) = &ret_ty.kind() + else { + panic!("Expected RigidTy::Adt, got: {:#?}", ret_ty); + }; + + assert_eq!("std::task::Poll", def.0.name()); + + let TyKind::RigidTy(RigidTy::Coroutine(def, ..)) = &local_3.kind() + else { + panic!("Expected RigidTy::Coroutine, got: {:#?}", local_3); + }; + + assert_eq!("gbc::{closure#0}::{closure#0}", def.0.name()); + + let TyKind::RigidTy(RigidTy::Coroutine(def, ..)) = &local_4.kind() + else { + panic!("Expected RigidTy::Coroutine, got: {:#?}", local_4); + }; + + assert_eq!("gbc::{closure#0}::{closure#0}", def.0.name()); +} + +fn main() { + let path = "coroutine_body.rs"; + generate_input(&path).unwrap(); + let args = &[ + "rustc".to_string(), + "-Cpanic=abort".to_string(), + "--edition".to_string(), + "2024".to_string(), + "--crate-name".to_string(), + CRATE_NAME.to_string(), + path.to_string(), + ]; + run!(args, test_coroutine_body).unwrap(); +} + +fn generate_input(path: &str) -> std::io::Result<()> { + let mut file = std::fs::File::create(path)?; + write!( + file, + r#" + async fn gbc() -> i32 {{ + let a = async {{ 1 }}.await; + a + }} + + fn main() {{}} + "# + )?; + Ok(()) +} diff --git a/tests/ui-fulldeps/stable-mir/check_crate_defs.rs b/tests/ui-fulldeps/stable-mir/check_crate_defs.rs index 6863242f225..d3929c5e48b 100644 --- a/tests/ui-fulldeps/stable-mir/check_crate_defs.rs +++ b/tests/ui-fulldeps/stable-mir/check_crate_defs.rs @@ -10,10 +10,10 @@ extern crate rustc_hir; extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use stable_mir::CrateDef; diff --git a/tests/ui-fulldeps/stable-mir/check_def_ty.rs b/tests/ui-fulldeps/stable-mir/check_def_ty.rs index f86a8e0ae61..101e7eb9121 100644 --- a/tests/ui-fulldeps/stable-mir/check_def_ty.rs +++ b/tests/ui-fulldeps/stable-mir/check_def_ty.rs @@ -11,8 +11,7 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; extern crate stable_mir; diff --git a/tests/ui-fulldeps/stable-mir/check_defs.rs b/tests/ui-fulldeps/stable-mir/check_defs.rs index ab741378bb7..65db50ee3ff 100644 --- a/tests/ui-fulldeps/stable-mir/check_defs.rs +++ b/tests/ui-fulldeps/stable-mir/check_defs.rs @@ -10,8 +10,7 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; extern crate stable_mir; diff --git a/tests/ui-fulldeps/stable-mir/check_foreign.rs b/tests/ui-fulldeps/stable-mir/check_foreign.rs index 398024c4ff0..2947d51b63b 100644 --- a/tests/ui-fulldeps/stable-mir/check_foreign.rs +++ b/tests/ui-fulldeps/stable-mir/check_foreign.rs @@ -10,8 +10,7 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; extern crate rustc_span; diff --git a/tests/ui-fulldeps/stable-mir/check_instance.rs b/tests/ui-fulldeps/stable-mir/check_instance.rs index b19e5b033c4..9b1e4176531 100644 --- a/tests/ui-fulldeps/stable-mir/check_instance.rs +++ b/tests/ui-fulldeps/stable-mir/check_instance.rs @@ -10,8 +10,7 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; extern crate stable_mir; diff --git a/tests/ui-fulldeps/stable-mir/check_intrinsics.rs b/tests/ui-fulldeps/stable-mir/check_intrinsics.rs index 52424857dc1..2fce367c7a0 100644 --- a/tests/ui-fulldeps/stable-mir/check_intrinsics.rs +++ b/tests/ui-fulldeps/stable-mir/check_intrinsics.rs @@ -14,10 +14,10 @@ extern crate rustc_middle; extern crate rustc_hir; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use stable_mir::mir::mono::{Instance, InstanceKind}; diff --git a/tests/ui-fulldeps/stable-mir/check_item_kind.rs b/tests/ui-fulldeps/stable-mir/check_item_kind.rs index d1124c75a89..20b9e86ff92 100644 --- a/tests/ui-fulldeps/stable-mir/check_item_kind.rs +++ b/tests/ui-fulldeps/stable-mir/check_item_kind.rs @@ -10,8 +10,7 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; extern crate stable_mir; diff --git a/tests/ui-fulldeps/stable-mir/check_normalization.rs b/tests/ui-fulldeps/stable-mir/check_normalization.rs index 16e8c0339ed..bb5cd49e1b0 100644 --- a/tests/ui-fulldeps/stable-mir/check_normalization.rs +++ b/tests/ui-fulldeps/stable-mir/check_normalization.rs @@ -9,8 +9,7 @@ #![feature(rustc_private)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; extern crate stable_mir; diff --git a/tests/ui-fulldeps/stable-mir/check_trait_queries.rs b/tests/ui-fulldeps/stable-mir/check_trait_queries.rs index fcf04a1fc3a..73ba0ea23c9 100644 --- a/tests/ui-fulldeps/stable-mir/check_trait_queries.rs +++ b/tests/ui-fulldeps/stable-mir/check_trait_queries.rs @@ -10,10 +10,10 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use stable_mir::CrateDef; diff --git a/tests/ui-fulldeps/stable-mir/check_transform.rs b/tests/ui-fulldeps/stable-mir/check_transform.rs index 9087c1cf450..460f1b9e963 100644 --- a/tests/ui-fulldeps/stable-mir/check_transform.rs +++ b/tests/ui-fulldeps/stable-mir/check_transform.rs @@ -11,10 +11,10 @@ extern crate rustc_hir; extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use stable_mir::mir::alloc::GlobalAlloc; diff --git a/tests/ui-fulldeps/stable-mir/check_ty_fold.rs b/tests/ui-fulldeps/stable-mir/check_ty_fold.rs index 18b9e32e4e8..1a21757d038 100644 --- a/tests/ui-fulldeps/stable-mir/check_ty_fold.rs +++ b/tests/ui-fulldeps/stable-mir/check_ty_fold.rs @@ -11,10 +11,10 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use stable_mir::mir::{ diff --git a/tests/ui-fulldeps/stable-mir/check_variant.rs b/tests/ui-fulldeps/stable-mir/check_variant.rs index b0de3369830..4cff57308f6 100644 --- a/tests/ui-fulldeps/stable-mir/check_variant.rs +++ b/tests/ui-fulldeps/stable-mir/check_variant.rs @@ -11,10 +11,10 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use std::io::Write; diff --git a/tests/ui-fulldeps/stable-mir/closure-generic-body.rs b/tests/ui-fulldeps/stable-mir/closure-generic-body.rs index 2a23345a9d3..6b3447e5839 100644 --- a/tests/ui-fulldeps/stable-mir/closure-generic-body.rs +++ b/tests/ui-fulldeps/stable-mir/closure-generic-body.rs @@ -10,10 +10,10 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use std::io::Write; diff --git a/tests/ui-fulldeps/stable-mir/closure_body.rs b/tests/ui-fulldeps/stable-mir/closure_body.rs index 7ed0dabd2c3..a1c97e7549b 100644 --- a/tests/ui-fulldeps/stable-mir/closure_body.rs +++ b/tests/ui-fulldeps/stable-mir/closure_body.rs @@ -10,10 +10,10 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use std::io::Write; diff --git a/tests/ui-fulldeps/stable-mir/compilation-result.rs b/tests/ui-fulldeps/stable-mir/compilation-result.rs index 19b9c8b7de5..d577de48c55 100644 --- a/tests/ui-fulldeps/stable-mir/compilation-result.rs +++ b/tests/ui-fulldeps/stable-mir/compilation-result.rs @@ -10,10 +10,10 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use std::io::Write; diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index 7fc4edafb93..fd7c2032b6d 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -11,10 +11,10 @@ extern crate rustc_hir; extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use rustc_hir::def::DefKind; diff --git a/tests/ui-fulldeps/stable-mir/projections.rs b/tests/ui-fulldeps/stable-mir/projections.rs index 103c97bc48e..f8104287700 100644 --- a/tests/ui-fulldeps/stable-mir/projections.rs +++ b/tests/ui-fulldeps/stable-mir/projections.rs @@ -11,10 +11,10 @@ extern crate rustc_hir; extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; +#[macro_use] extern crate stable_mir; use stable_mir::ItemKind; diff --git a/tests/ui-fulldeps/stable-mir/smir_internal.rs b/tests/ui-fulldeps/stable-mir/smir_internal.rs index 0519b9de680..287f4353d51 100644 --- a/tests/ui-fulldeps/stable-mir/smir_internal.rs +++ b/tests/ui-fulldeps/stable-mir/smir_internal.rs @@ -10,15 +10,14 @@ #![feature(rustc_private)] #![feature(assert_matches)] -#[macro_use] -extern crate rustc_smir; extern crate rustc_driver; extern crate rustc_interface; extern crate rustc_middle; +#[macro_use] extern crate stable_mir; use rustc_middle::ty::TyCtxt; -use rustc_smir::rustc_internal; +use stable_mir::rustc_internal; use std::io::Write; use std::ops::ControlFlow; diff --git a/tests/ui-fulldeps/stable-mir/smir_serde.rs b/tests/ui-fulldeps/stable-mir/smir_serde.rs index 0b39ec05002..c2f00e56c2c 100644 --- a/tests/ui-fulldeps/stable-mir/smir_serde.rs +++ b/tests/ui-fulldeps/stable-mir/smir_serde.rs @@ -9,13 +9,13 @@ #![feature(rustc_private)] #![feature(assert_matches)] -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; extern crate rustc_middle; extern crate serde; extern crate serde_json; +#[macro_use] extern crate stable_mir; use rustc_middle::ty::TyCtxt; diff --git a/tests/ui-fulldeps/stable-mir/smir_visitor.rs b/tests/ui-fulldeps/stable-mir/smir_visitor.rs index caf71de2556..46f85a992ef 100644 --- a/tests/ui-fulldeps/stable-mir/smir_visitor.rs +++ b/tests/ui-fulldeps/stable-mir/smir_visitor.rs @@ -10,8 +10,7 @@ #![feature(assert_matches)] extern crate rustc_middle; -#[macro_use] -extern crate rustc_smir; + extern crate rustc_driver; extern crate rustc_interface; extern crate stable_mir; diff --git a/tests/ui/SUMMARY.md b/tests/ui/SUMMARY.md new file mode 100644 index 00000000000..8de74d41f39 --- /dev/null +++ b/tests/ui/SUMMARY.md @@ -0,0 +1,1592 @@ +# UI Test Suite Categories + +This is a high-level summary of the organization of the UI test suite (`tests/ui/`). It is not intended to be *prescriptive*, but instead provide a quick survey of existing groupings. + +For now, only immediate subdirectories under `tests/ui/` are described, but these subdirectories can themselves include a `SUMMARY.md` to further describe their own organization and intent, should that be helpful. + +## `tests/ui/abi` + +These tests deal with *Application Binary Interfaces* (ABI), mostly relating to function name mangling (and the `#[no_mangle]` attribute), calling conventions, or compiler flags which affect ABI. + +Tests for unsupported ABIs can be made cross-platform by using the `extern "rust-invalid"` ABI, which is considered unsupported on every platform. + +## `tests/ui/allocator` + +These tests exercise `#![feature(allocator_api)]` and the `#[global_allocator]` attribute. + +See [Allocator traits and `std::heap` #32838](https://github.com/rust-lang/rust/issues/32838). + +## `tests/ui/alloc-error` + +These tests exercise alloc error handling. + +See <https://doc.rust-lang.org/std/alloc/fn.handle_alloc_error.html>. + +## `tests/ui/annotate-snippet` + +These tests exercise the [`annotate-snippets`]-based emitter implementation. + +[`annotate-snippets`] is an initiative to share the diagnostics emitting infrastructure between rustc and cargo to reduce duplicate maintenance effort and divergence. See <https://github.com/rust-lang/rust/issues/59346> about the initiative. + +[`annotate-snippets`]: https://github.com/rust-lang/annotate-snippets-rs + +## `tests/ui/anon-params` + +These tests deal with anonymous parameters (no name, only type), a deprecated feature that becomes a hard error in Edition 2018. + +## `tests/ui/argfile`: External files providing command line arguments + +These tests exercise rustc reading command line arguments from an externally provided argfile (`@argsfile`). + +See [Implement `@argsfile` to read arguments from command line #63576](https://github.com/rust-lang/rust/issues/63576). + +## `tests/ui/array-slice-vec`: Arrays, slices and vectors + +Exercises various aspects surrounding basic collection types `[]`, `&[]` and `Vec`. E.g. type-checking, out-of-bounds indices, attempted instructions which are allowed in other programming languages, and more. + +## `tests/ui/argument-suggestions`: Argument suggestions + +Calling a function with the wrong number of arguments causes a compilation failure, but the compiler is able to, in some cases, provide suggestions on how to fix the error, such as which arguments to add or delete. These tests exercise the quality of such diagnostics. + +## `tests/ui/asm`: `asm!` macro + +These tests exercise the `asm!` macro, which is used for adding inline assembly. + +See: + +- [Inline assembly | Reference](https://doc.rust-lang.org/reference/inline-assembly.html) +- [`core::arch::asm`](https://doc.rust-lang.org/core/arch/macro.asm.html) +- [`core::arch::global_asm`](https://doc.rust-lang.org/core/arch/macro.global_asm.html) + +This directory contains subdirectories representing various architectures such as `riscv` or `aarch64`. If a test is specifically related to an architecture's particularities, it should be placed within the appropriate subdirectory.Architecture-agnostic tests should be placed below `tests/ui/asm/` directly. + +## `tests/ui/associated-consts`: Associated Constants + +These tests exercise associated constants in traits and impls, on aspects such as definitions, usage, and type checking in associated contexts. + +## `tests/ui/associated-inherent-types`: Inherent Associated Types + +These tests cover associated types defined directly within inherent impls (not in traits). + +See [RFC 0195 Associated items - Inherent associated items](https://github.com/rust-lang/rfcs/blob/master/text/0195-associated-items.md#inherent-associated-items). + +## `tests/ui/associated-item`: Associated Items + +Tests for all kinds of associated items within traits and implementations. This directory serves as a catch-all for tests that don't fit the other more specific associated item directories. + +## `tests/ui/associated-type-bounds`: Associated Type Bounds + +These tests exercise associated type bounds, the feature that gives users a shorthand to express nested type bounds that would otherwise need to be expressed with nested `impl Trait` or broken into several `where` clauses. + +See: + +- [RFC 2289 Associated Type Bounds](https://rust-lang.github.io/rfcs/2289-associated-type-bounds.html) +- [Stabilize associated type bounds (RFC 2289) #122055](https://github.com/rust-lang/rust/pull/122055) + +## `tests/ui/associated-types`: Trait Associated Types + +Tests focused on associated types. If the associated type is not in a trait definition, it belongs in the `tests/ui/associated-inherent-types/` directory. Aspects exercised include e.g. default associated types, overriding defaults, and type inference. + +See [Associated Types | Reference](https://doc.rust-lang.org/reference/items/associated-items.html#associated-types). + +## `tests/ui/async-await`: Async/Await + +Tests for the async/await related features. E.g. async functions, await expressions, and their interaction with other language features. + +## `tests/ui/attributes`: Compiler Attributes + +Tests for language attributes and compiler attributes. E.g. built-in attributes like `#[derive(..)]`, `#[cfg(..)]`, and `#[repr(..)]`, or proc-macro attributes. See [Attributes | Reference](https://doc.rust-lang.org/reference/attributes.html). + +## `tests/ui/auto-traits`: Auto Traits + +There are built-in auto traits (`Send`, `Sync`, etc.) but it is possible to define more with the unstable keyword `auto` through `#![feature(auto_traits)]`. + +See [Tracking Issue for auto traits (`auto_traits`) -- formerly called opt-in built-in traits (`optin_builtin_traits`) #13231](https://github.com/rust-lang/rust/issues/13231). + +## `tests/ui/autodiff`: Automatic Differentiation + +The `#[autodiff]` macro supports automatic differentiation. + +See [Tracking Issue for autodiff #124509](https://github.com/rust-lang/rust/issues/124509). + +## `tests/ui/autoref-autoderef`: Automatic Referencing/Dereferencing + +Tests for automatic referencing and dereferencing behavior, such as automatically adding reference operations (`&` or `&mut`) to make a value match a method's receiver type. Sometimes abbreviated as "auto-ref" or "auto-deref". + +## `tests/ui/auxiliary/`: Auxiliary files for tests directly under `tests/ui`. + +This top-level `auxiliary` subdirectory contains support files for tests immediately under `tests/ui/`. + +**FIXME(#133895)**: tests immediately under `tests/ui/` should be rehomed to more suitable subdirectories, after which this subdirectory can be removed. + +## `tests/ui/backtrace/`: Backtraces + +Runtime panics and error handling generate backtraces to assist in debugging and diagnostics. + +## `tests/ui/bench/`: Benchmarks and performance + +This directory was originally meant to contain tests related to time complexity and benchmarking. + +However, only a single test was ever added to this category: https://github.com/rust-lang/rust/pull/32062 + +**FIXME**: It is also unclear what would happen were this test to "fail" - would it cause the test suite to remain stuck on this test for a much greater duration than normal? + +## `tests/ui/binding/`: Pattern Binding + +Tests for pattern binding in match expressions, let statements, and other binding contexts. E.g. binding modes and refutability. See [Patterns | Reference](https://doc.rust-lang.org/reference/patterns.html). + +## `tests/ui/binop/`: Binary operators + +Tests for binary operators (such as `==`, `&&` or `^`). E.g. overloading, type checking, and diagnostics for invalid operations. + +## `tests/ui/blind/`: `struct` or `mod` inside a `mod` having a duplicate identifier + +Tests exercising name resolution. + +**FIXME**: Probably move to `tests/ui/resolve/`. + +## `tests/ui/block-result/`: Block results and returning + +Tests for block expression results. E.g. specifying the correct return types, semicolon handling, type inference, and expression/statement differences (for example, the difference between `1` and `1;`). + +## `tests/ui/bootstrap/`: RUSTC_BOOTSTRAP environment variable + +Meta tests for stability mechanisms surrounding [`RUSTC_BOOTSTRAP`](https://doc.rust-lang.org/nightly/unstable-book/compiler-environment-variables/RUSTC_BOOTSTRAP.html), which is coordinated between `rustc` and the build system, `bootstrap`. + +## `tests/ui/borrowck/`: Borrow Checking + +Tests for borrow checking. E.g. lifetime analysis, borrowing rules, and diagnostics. + +## `tests/ui/box/`: Box Behavior + +Tests for `Box<T>` smart pointer and `#![feature(box_patterns)]`. E.g. allocation, deref coercion, and edge cases in box pattern matching and placement. + +See: + +- [`std::box::Boxed`](https://doc.rust-lang.org/std/boxed/struct.Box.html) +- [Tracking issue for `box_patterns` feature #29641](https://github.com/rust-lang/rust/issues/29641) + +## `tests/ui/btreemap/`: B-Tree Maps + +Tests focused on `BTreeMap` collections and their compiler interactions. E.g. collection patterns, iterator behavior, and trait implementations specific to `BTreeMap`. See [`std::collections::BTreeMap`](https://doc.rust-lang.org/std/collections/struct.BTreeMap.html). + +## `tests/ui/builtin-superkinds/`: Built-in Trait Hierarchy Tests + +Tests for built-in trait hierarchy (Send, Sync, Sized, etc.) and their supertrait relationships. E.g. auto traits and marker trait constraints. + +See [RFC 3729: Hierarchy of Sized traits](https://github.com/rust-lang/rfcs/pull/3729). + +Defining custom auto traits with the `auto` keyword belongs to `tests/ui/auto-traits/` instead. + +## `tests/ui/cast/`: Type Casting + +Tests for type casting using the `as` operator. Includes tests for valid/invalid casts between primitive types, trait objects, and custom types. For example, check that trying to cast `i32` into `bool` results in a helpful error message. + +See [Type cast expressions | Reference](https://doc.rust-lang.org/reference/expressions/operator-expr.html). + +## `tests/ui/cfg/`: Configuration Attribute + +Tests for `#[cfg]` conditional compilation attribute. E.g. feature flags, target architectures, and other configuration predicates and options. + +See [Conditional compilation | Reference](https://doc.rust-lang.org/reference/conditional-compilation.html). + +## `tests/ui/check-cfg/`: Configuration Checks + +Tests for the `--check-cfg` compiler mechanism for checking cfg configurations, for `#[cfg(..)]` and `cfg!(..)`. + +See [Checking conditional configurations | The rustc book](https://doc.rust-lang.org/rustc/check-cfg.html). + +## `tests/ui/closure_context/`: Closure type inference in context + +Tests for closure type inference with respect to surrounding scopes, mostly quality of diagnostics. + +## `tests/ui/closure-expected-type/`: Closure type inference + +Tests targeted at how we deduce the types of closure arguments. This process is a result of some heuristics which take into account the *expected type* we have alongside the *actual types* that we get from inputs. + +**FIXME**: Appears to have significant overlap with `tests/ui/closure_context` and `tests/ui/functions-closures/closure-expected-type`. Needs further investigation. + +## `tests/ui/closures/`: General Closure Tests + +Any closure-focused tests that does not fit in the other more specific closure subdirectories belong here. E.g. syntax, `move`, lifetimes. + +## `tests/ui/cmse-nonsecure/`: `cmse-nonsecure` ABIs + +Tests for `extern "cmse-nonsecure-call"` and `extern "cmse-nonsecure-entry"` functions. Used specifically for the Armv8-M architecture, the former marks Secure functions with additional behaviours, such as adding a special symbol and constraining the number of parameters, while the latter alters function pointers to indicate they are non-secure and to handle them differently than usual. + +See: + +- [`cmse_nonsecure_entry` | The Unstable book](https://doc.rust-lang.org/nightly/unstable-book/language-features/cmse-nonsecure-entry.html) +- [`abi_cmse_nonsecure_call` | The Unstable book](https://doc.rust-lang.org/nightly/unstable-book/language-features/abi-cmse-nonsecure-call.html) + +## `tests/ui/codegen/`: Code Generation + +Tests that exercise code generation. E.g. codegen flags (starting with `-C` on the command line), LLVM IR output, optimizations (and the various `opt-level`s), and target-specific code generation (such as tests specific to `x86_64`). + +## `tests/ui/codemap_tests/`: Source Mapping + +Tests that exercise source code mapping. + +## `tests/ui/coercion/`: Type Coercion + +Tests for implicit type coercion behavior, where the types of some values are changed automatically when compatible depending on the context. E.g. automatic dereferencing or downgrading a `&mut` into a `&`. + +See [Type coercions | Reference](https://doc.rust-lang.org/reference/type-coercions.html). + +## `tests/ui/coherence/`: Trait Implementation Coherence + +Tests for trait coherence rules, which govern where trait implementations can be defined. E.g. orphan rule, and overlap checks. + +See [Coherence | rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/coherence.html#coherence). + +## `tests/ui/coinduction/`: Coinductive Trait Resolution + +Tests for coinduction in trait solving which may involve infinite proof trees. + +See: + +- [Coinduction | rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/solve/coinduction.html). +- [Inductive cycles | Chalk](https://rust-lang.github.io/chalk/book/recursive/inductive_cycles.html#inductive-cycles)/ + +This directory only contains one highly specific test. Other coinduction tests can be found down the deeply located `tests/ui/traits/next-solver/cycles/coinduction/` subdirectory. + +## `tests/ui/command/`: `std::process::Command` + +This directory is actually for the standard library [`std::process::Command`](https://doc.rust-lang.org/std/process/struct.Command.html) type, where some tests are too difficult or inconvenient to write as unit tests or integration tests within the standard library itself. + +**FIXME**: the test `command-line-diagnostics` seems to have been misplaced in this category. + +## `tests/ui/compare-method/`: Trait implementation and definition comparisons + +Some traits' implementation must be compared with their definition, checking for problems such as the implementation having stricter requirements (such as needing to implement `Copy`). + +This subdirectory is *not* intended comparison traits (`PartialEq`, `Eq`, `PartialOrd`, `Ord`). + +## `tests/ui/compiletest-self-test/`: compiletest "meta" tests + +Meta test suite of the test harness `compiletest` itself. + +## `tests/ui/conditional-compilation/`: Conditional Compilation + +Tests for `#[cfg]` attribute or `--cfg` flags, used to compile certain files or code blocks only if certain conditions are met (such as developing on a specific architecture). + +**FIXME**: There is significant overlap with `tests/ui/cfg`, which even contains a `tests/ui/cfg/conditional-compile.rs` test. Also investigate `tests/ui/check-cfg`. + +## `tests/ui/confuse-field-and-method/`: Field/Method Ambiguity + +If a developer tries to create a `struct` where one of the fields is a closure function, it becomes unclear whether `struct.field()` is accessing the field itself or trying to call the closure function within as a method. + +**FIXME**: does this really need to be its own immediate subdirectory? + +## `tests/ui/const-generics/`: Constant Generics + +Tests for const generics, allowing types to be parameterized by constant values. It is generally observed in the form `<const N: Type>` after the `fn` or `struct` keywords. Includes tests for const expressions in generic contexts and associated type bounds. + +See: + +- [Tracking Issue for complex generic constants: `feature(generic_const_exprs)` #76560](https://github.com/rust-lang/rust/issues/76560) +- [Const generics | Reference](https://doc.rust-lang.org/reference/items/generics.html#const-generics) + +## `tests/ui/const_prop/`: Constant Propagation + +Tests exercising `ConstProp` mir-opt pass (mostly regression tests). See <https://blog.rust-lang.org/inside-rust/2019/12/02/const-prop-on-by-default/>. + +## `tests/ui/const-ptr/`: Constant Pointers + +Tests exercise const raw pointers. E.g. pointer arithmetic, casting and dereferencing, always with a `const`. + +See: + +- [`std::primitive::pointer`](https://doc.rust-lang.org/std/primitive.pointer.html) +- [`std::ptr`](https://doc.rust-lang.org/std/ptr/index.html) +- [Pointer types | Reference](https://doc.rust-lang.org/reference/types/pointer.html) + +## `tests/ui/consts/`: General Constant Evaluation + +Anything to do with constants, which does not fit in the previous two `const` categories, goes here. This does not always imply use of the `const` keyword - other values considered constant, such as defining an enum variant as `enum Foo { Variant = 5 }` also counts. + +## `tests/ui/contracts/`: Contracts feature + +Tests exercising `#![feature(contracts)]`. + +See [Tracking Issue for Contracts #128044](https://github.com/rust-lang/rust/issues/128044). + +## `tests/ui/coroutine/`: Coroutines feature and `gen` blocks + +Tests for `#![feature(coroutines)]` and `gen` blocks, it belongs here. + +See: + +- [Coroutines | The Unstable book](https://doc.rust-lang.org/beta/unstable-book/language-features/coroutines.html) +- [RFC 3513 Gen blocks](https://rust-lang.github.io/rfcs/3513-gen-blocks.html) + +## `tests/ui/coverage-attr/`: `#[coverage]` attribute + +Tests for `#![feature(coverage_attribute)]`. See [Tracking issue for function attribute `#[coverage]`](https://github.com/rust-lang/rust/issues/84605). + +## `tests/ui/crate-loading/`: Crate Loading + +Tests for crate resolution and loading behavior, including `extern crate` declarations, `--extern` flags, or the `use` keyword. + +## `tests/ui/cross/`: Various tests related to the concept of "cross" + +**FIXME**: The unifying topic of these tests appears to be that their filenames begin with the word "cross". The similarities end there - one test is about "cross-borrowing" a `Box<T>` into `&T`, while another is about a global trait used "across" files. Some of these terminology are really outdated and does not match the current terminology. Additionally, "cross" is also way too generic, it's easy to confuse with cross-compile. + +## `tests/ui/cross-crate/`: Cross-Crate Interaction + +Tests for behavior spanning multiple crates, including visibility rules, trait implementations, and type resolution across crate boundaries. + +## `tests/ui/custom_test_frameworks/` + +Tests for `#[bench]`, `#[test_case]` attributes and the `custom_test_frameworks` lang item. + +See [Tracking issue for eRFC 2318, Custom test frameworks #50297](https://github.com/rust-lang/rust/issues/50297). + +## `tests/ui/c-variadic/`: C Variadic Function + +Tests for FFI with C varargs (`va_list`). + +## `tests/ui/cycle-trait/`: Trait Cycle Detection + +Tests for detection and handling of cyclic trait dependencies. + +## `tests/ui/dataflow_const_prop/` + +Contains a single regression test for const prop in `SwitchInt` pass crashing when `ptr2int` transmute is involved. + +**FIXME**: A category with a single test. Maybe it would fit inside the category `const-prop` or some kind of `mir-opt` directory. + +## `tests/ui/debuginfo/` + +Tests for generation of debug information (DWARF, etc.) including variable locations, type information, and source line mapping. Also exercises `-C split-debuginfo` and `-C debuginfo`. + +## `tests/ui/definition-reachable/`: Definition Reachability + +Tests to check whether definitions are reachable. + +## `tests/ui/delegation/`: `#![feature(fn_delegation)]` + +Tests for `#![feature(fn_delegation)]`. See [Implement function delegation in rustc #3530](https://github.com/rust-lang/rfcs/pull/3530) for the proposed prototype experimentation. + +## `tests/ui/dep-graph/`: `-Z query-dep-graph` + +These tests use the unstable command line option `query-dep-graph` to examine the dependency graph of a Rust program, which is useful for debugging. + +## `tests/ui/deprecation/`: Deprecation Attribute + +Tests for `#[deprecated]` attribute and `deprecated_in_future` internal lint. + +## `tests/ui/deref-patterns/`: `#![feature(deref_patterns)]` and `#![feature(string_deref_patterns)]` + +Tests for `#![feature(deref_patterns)]` and `#![feature(string_deref_patterns)]`. See [Deref patterns | The Unstable book](https://doc.rust-lang.org/nightly/unstable-book/language-features/deref-patterns.html). + +**FIXME**: May have some overlap with `tests/ui/pattern/deref-patterns`. + +## `tests/ui/derived-errors/`: Derived Error Messages + +Tests for quality of diagnostics involving suppression of cascading errors in some cases to avoid overwhelming the user. + +## `tests/ui/derives/`: Derive Macro + +Tests for built-in derive macros (`Debug`, `Clone`, etc.) when used in conjunction with built-in `#[derive(..)]` attributes. + +## `tests/ui/deriving/`: Derive Macro + +**FIXME**: Coalesce with `tests/ui/derives`. + +## `tests/ui/dest-prop/` Destination Propagation + +**FIXME**: Contains a single test for the `DestProp` mir-opt, should probably be rehomed. + +## `tests/ui/destructuring-assignment/` + +Exercises destructuring assignments. See [RFC 2909 Destructuring assignment](https://github.com/rust-lang/rfcs/blob/master/text/2909-destructuring-assignment.md). + +## `tests/ui/diagnostic-flags/` + +These tests revolve around command-line flags which change the way error/warning diagnostics are emitted. For example, `--error-format=human --color=always`. + +**FIXME**: Check redundancy with `annotate-snippet`, which is another emitter. + +## `tests/ui/diagnostic_namespace/` + +Exercises `#[diagnostic::*]` namespaced attributes. See [RFC 3368 Diagnostic attribute namepsace](https://github.com/rust-lang/rfcs/blob/master/text/3368-diagnostic-attribute-namespace.md). + +## `tests/ui/diagnostic-width/`: `--diagnostic-width` + +Everything to do with `--diagnostic-width`. + +## `tests/ui/did_you_mean/` + +Tests for miscellaneous suggestions. + +## `tests/ui/directory_ownership/`: Declaring `mod` inside a block + +Exercises diagnostics for when a code block attempts to gain ownership of a non-inline module with a `mod` keyword placed inside of it. + +## `tests/ui/disallowed-deconstructing/`: Incorrect struct deconstruction + +Exercises diagnostics for disallowed struct destructuring. + +## `tests/ui/dollar-crate/`: `$crate` used with the `use` keyword + +There are a few rules - which are checked in this directory - to follow when using `$crate` - it must be used in the start of a `use` line and is a reserved identifier. + +**FIXME**: There are a few other tests in other directories with a filename starting with `dollar-crate`. They should perhaps be redirected here. + +## `tests/ui/drop/`: `Drop` and drop order + +Not necessarily about `Drop` and its implementation, but also about the drop order of fields inside a struct. + +## `tests/ui/drop-bounds/` + +Tests for linting on bounding a generic type on `Drop`. + +## `tests/ui/dropck/`: Drop Checking + +Mostly about checking the validity of `Drop` implementations. + +See: + +- [Dropck | The Nomicon](https://doc.rust-lang.org/nomicon/dropck.html) +- [Drop check | rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/borrow_check/drop_check.html) + +## `tests/ui/dst/`: Dynamically Sized Types + +Tests for dynamically-sized types (DSTs). See [Dynamically Sized Types | Reference](https://doc.rust-lang.org/reference/dynamically-sized-types.html). + +## `tests/ui/duplicate/`: Duplicate Symbols + +Tests about duplicated symbol names and associated errors, such as using the `#[export_name]` attribute to rename a function with the same name as another function. + +## `tests/ui/dynamically-sized-types/`: Dynamically Sized Types + +**FIXME**: should be coalesced with `tests/ui/dst`. + +## `tests/ui/dyn-compatibility/`: Dyn-compatibility + +Tests for dyn-compatibility of traits. + +See: + +- [Trait object | Reference](https://doc.rust-lang.org/reference/types/trait-object.html) +- [Dyn compatibility | Reference](https://doc.rust-lang.org/reference/items/traits.html#dyn-compatibility) + +Previously known as "object safety". + +## `tests/ui/dyn-drop/`: `dyn Drop` + +**FIXME**: Contains a single test, used only to check the `dyn_drop` lint (which is normally `warn` level). + +## `tests/ui/dyn-keyword/`: `dyn` and Dynamic Dispatch + +The `dyn` keyword is used to highlight that calls to methods on the associated Trait are dynamically dispatched. To use the trait this way, it must be dyn-compatible - tests about dyn-compatibility belong in `tests/ui/dyn-compatibility/`, while more general tests on dynamic dispatch belong here. + +See [`dyn` keyword](https://doc.rust-lang.org/std/keyword.dyn.html). + +## `tests/ui/editions/`: Rust edition-specific peculiarities + +These tests run in specific Rust editions, such as Rust 2015 or Rust 2018, and check errors and functionality related to specific now-deprecated idioms and features. + +**FIXME**: Maybe regroup `rust-2018`, `rust-2021` and `rust-2024` under this umbrella? + +## `tests/ui/empty/`: Various tests related to the concept of "empty" + +**FIXME**: These tests need better homes, this is not very informative. + +## `tests/ui/entry-point/`: `main` function + +Tests exercising the `main` entry-point. + +## `tests/ui/enum/` + +General-purpose tests on `enum`s. See [Enumerations | Reference](https://doc.rust-lang.org/reference/items/enumerations.html). + +## `tests/ui/enum-discriminant/` + +`enum` variants can be differentiated independently of their potential field contents with `discriminant`, which returns the type `Discriminant<T>`. See [`std::mem::discriminant`](https://doc.rust-lang.org/std/mem/fn.discriminant.html). + +## `tests/ui/env-macro/`: `env!` + +Exercises `env!` and `option_env!` macros. + +## `tests/ui/ergonomic-clones/` + +See [RFC 3680 Ergonomic clones](https://github.com/rust-lang/rfcs/pull/3680). + +## `tests/ui/error-codes/`: Error codes + +Tests for errors with dedicated error codes. + +## `tests/ui/error-emitter/` + +Quite similar to `ui/diagnostic-flags` in some of its tests, this category checks some behaviours of Rust's error emitter into the user's terminal window, such as truncating error in the case of an excessive amount of them. + +## `tests/ui/errors/` + +These tests are about very different topics, only unified by the fact that they result in errors. + +**FIXME**: "Errors" is way too generic, the tests probably need to be rehomed into more descriptive subdirectories. + +## `tests/ui/explain/`: `rustc --explain EXXXX` + +Accompanies `tests/ui/error-codes/`, exercises the `--explain` cli flag. + +## `tests/ui/explicit/`: Errors involving the concept of "explicit" + +This category contains three tests: two which are about the specific error `explicit use of destructor method`, and one which is about explicit annotation of lifetimes: https://doc.rust-lang.org/stable/rust-by-example/scope/lifetime/explicit.html. + +**FIXME**: Rehome the two tests about the destructor method with `drop`-related categories, and rehome the last test with a category related to lifetimes. + +## `tests/ui/explicit-tail-calls/` + +Exercises `#![feature(explicit_tail_calls)]` and the `become` keyword. See [Explicit Tail Calls #3407](https://github.com/rust-lang/rfcs/pull/3407). + +## `tests/ui/expr/`: Expressions + +A broad directory for tests on expressions. + +## `tests/ui/extern/` + +Tests on the `extern` keyword and `extern` blocks and functions. + +## `tests/ui/extern-flag/`: `--extern` command line flag + +Tests for the `--extern` CLI flag. + +## `tests/ui/feature-gates/` + +Tests on feature-gating, and the `#![feature(..)]` mechanism itself. + +## `tests/ui/ffi-attrs/`: `#![feature(ffi_const, ffi_pure)]` + +The `#[ffi_const]` and `#[ffi_pure]` attributes applies clang's `const` and `pure` attributes to foreign functions declarations, respectively. These attributes are the core element of the tests in this category. + +See: + +- [`ffi_const` | The Unstable book](https://doc.rust-lang.org/unstable-book/language-features/ffi-const.html) +- [`ffi_pure` | The Unstable book](https://doc.rust-lang.org/beta/unstable-book/language-features/ffi-pure.html) + +## `tests/ui/fmt/` + +Exercises the `format!` macro. + +## `tests/ui/fn/` + +A broad category of tests on functions. + +## `tests/ui/fn-main/` + +**FIXME**: Serves a duplicate purpose with `ui/entry-point`, should be combined. + +## `tests/ui/for/`: `for` keyword + +Tests on the `for` keyword and some of its associated errors, such as attempting to write the faulty pattern `for _ in 0..1 {} else {}`. + +**FIXME**: Should be merged with `ui/for-loop-while`. + +## `tests/ui/force-inlining/`: `#[rustc_force_inline]` + +Tests for `#[rustc_force_inline]`, which will force a function to always be labelled as inline by the compiler (it will be inserted at the point of its call instead of being used as a normal function call.) If the compiler is unable to inline the function, an error will be reported. See <https://github.com/rust-lang/rust/pull/134082>. + +## `tests/ui/foreign/`: Foreign Function Interface (FFI) + +Tests for `extern "C"` and `extern "Rust`. + +**FIXME**: Check for potential overlap/merge with `ui/c-variadic` and/or `ui/extern`. + +## `tests/ui/for-loop-while/` + +Anything to do with loops and `for`, `loop` and `while` keywords to express them. + +**FIXME**: After `ui/for` is merged into this, also carry over its SUMMARY text. + +## `tests/ui/frontmatter/` + +Tests for `#![feature(frontmatter)]`. See [Tracking Issue for `frontmatter` #136889](https://github.com/rust-lang/rust/issues/136889). + +## `tests/ui/fully-qualified-type/` + +Tests for diagnostics when there may be identically named types that need further qualifications to disambiguate. + +## `tests/ui/functional-struct-update/` + +Functional Struct Update is the name for the idiom by which one can write `..<expr>` at the end of a struct literal expression to fill in all remaining fields of the struct literal by using `<expr>` as the source for them. + +See [RFC 0736 Privacy-respecting Functional Struct Update](https://github.com/rust-lang/rfcs/blob/master/text/0736-privacy-respecting-fru.md). + +## `tests/ui/function-pointer/` + +Tests on function pointers, such as testing their compatibility with higher-ranked trait bounds. + +See: + +- [Function pointer types | Reference](https://doc.rust-lang.org/reference/types/function-pointer.html) +- [Higher-ranked trait bounds | Nomicon](https://doc.rust-lang.org/nomicon/hrtb.html) + +## `tests/ui/functions-closures/` + +Tests on closures. See [Closure expressions | Reference](https://doc.rust-lang.org/reference/expressions/closure-expr.html). + +## `tests/ui/generic-associated-types/` + +Tests on Generic Associated Types (GATs). + +## `tests/ui/generic-const-items/` + +Tests for `#![feature(generic_const_items)]`. See [Tracking issue for generic const items #113521](https://github.com/rust-lang/rust/issues/113521). + +## `tests/ui/generics/` + +A broad category of tests on generics, usually used when no more specific subdirectories are fitting. + +## `tests/ui/half-open-range-patterns/`: `x..` or `..x` range patterns + +Tests on range patterns where one of the bounds is not a direct value. + +**FIXME**: Overlaps with `ui/range`. `impossible_range.rs` is particularly suspected to be a duplicate test. + +## `tests/ui/hashmap/` + +Tests for the standard library collection [`std::collections::HashMap`](https://doc.rust-lang.org/std/collections/struct.HashMap.html). + +## `tests/ui/hello_world/` + +Tests that the basic hello-world program is not somehow broken. + +## `tests/ui/higher-ranked/` + +Tests for higher-ranked trait bounds. + +See: + +- [Higher-ranked trait bounds | rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/traits/hrtb.html) +- [Higher-ranked trait bounds | Nomicon](https://doc.rust-lang.org/nomicon/hrtb.html) + +## `tests/ui/hygiene/` + +This seems to have been originally intended for "hygienic macros" - macros which work in all contexts, independent of what surrounds them. However, this category has grown into a mish-mash of many tests that may belong in the other directories. + +**FIXME**: Reorganize this directory properly. + +## `tests/ui/illegal-sized-bound/` + +This test category revolves around trait objects with `Sized` having illegal operations performed on them. + +**FIXME**: There seems to be unrelated testing in this directory, such as `tests/ui/illegal-sized-bound/mutability-mismatch-arg.rs`. Investigate. + +## `tests/ui/impl-header-lifetime-elision/` + +Tests on lifetime elision in impl function signatures. See [Lifetime elision | Nomicon](https://doc.rust-lang.org/nomicon/lifetime-elision.html). + +## `tests/ui/implied-bounds/` + +See [Implied bounds | Reference](https://doc.rust-lang.org/reference/trait-bounds.html#implied-bounds). + +## `tests/ui/impl-trait/` + +Tests for trait impls. + +## `tests/ui/imports/` + +Tests for module system and imports. + +## `tests/ui/include-macros/` + +Exercise `include!`, `include_str!`, and `include_bytes!` macros. + +## `tests/ui/incoherent-inherent-impls/` + +Exercise forbidding inherent impls on a type defined in a different crate. + +## `tests/ui/indexing/` + +Tests on collection types (arrays, slices, vectors) and various errors encountered when indexing their contents, such as accessing out-of-bounds values. + +**FIXME**: (low-priority) could maybe be a subdirectory of `ui/array-slice-vec` + +## `tests/ui/inference/` + +Tests on type inference. + +## `tests/ui/infinite/` + +Tests for diagnostics on infinitely recursive types without indirection. + +## `tests/ui/inherent-impls-overlap-check/` + +Checks that repeating the same function names across separate `impl` blocks triggers an informative error, but not if the `impl` are for different types, such as `Bar<u8>` and `Bar<u16>`. + +NOTE: This should maybe be a subdirectory within another related to duplicate definitions, such as `tests/ui/duplicate/`. + +## `tests/ui/inline-const/` + +These tests revolve around the inline `const` block that forces the compiler to const-eval its content. + +## `tests/ui/instrument-coverage/`: `-Cinstrument-coverage` command line flag + +See [Instrument coverage | The rustc book](https://doc.rust-lang.org/rustc/instrument-coverage.html). + +## `tests/ui/instrument-xray/`: `-Z instrument-xray` + +See [Tracking issue for `-Z instrument-xray` #102921](https://github.com/rust-lang/rust/issues/102921). + +## `tests/ui/interior-mutability/` + +**FIXME**: contains a single test, probably better rehomed. + +## `tests/ui/internal/` + +Tests for `internal_unstable` and the attribute header `#![feature(allow_internal_unstable)]`, which lets compiler developers mark features as internal to the compiler, and unstable for standard library use. + +## `tests/ui/internal-lints/` + +Tests for rustc-internal lints. + +## `tests/ui/intrinsics/` + +Tests for the `{std,core}::intrinsics`, internal implementation detail. + +## `tests/ui/invalid/` + +Various tests related to rejecting invalid inputs. + +**FIXME**: This is rather uninformative, possibly rehome into more meaningful directories. + +## `tests/ui/invalid-compile-flags/` + +Tests for checking that invalid usage of compiler flags are rejected. + +## `tests/ui/invalid-module-declaration/` + +**FIXME**: Consider merging into module/resolve directories. + +## `tests/ui/invalid-self-argument/`: `self` as a function argument incorrectly + +Tests with erroneous ways of using `self`, such as having it not be the first argument, or using it in a non-associated function (no `impl` or `trait`). + +**FIXME**: Maybe merge with `ui/self`. + +## `tests/ui/io-checks/` + +Contains a single test. The test tries to output a file into an invalid directory with `-o`, then checks that the result is an error, not an internal compiler error. + +**FIXME**: Rehome to invalid compiler flags maybe. + +## `tests/ui/issues/`: Tests directly related to GitHub issues + +**FIXME (#133895)**: Random collection of regression tests and tests for issues, tests in this directory should be audited and rehomed. + +## `tests/ui/iterators/` + +These tests revolve around anything to do with iterators, e.g. mismatched types. + +**FIXME**: Check for potential overlap with `ui/for-loop-while`. + +## `tests/ui/json/` + +These tests revolve around the `--json` compiler flag. See [JSON Output](https://doc.rust-lang.org/rustc/json.html#json-output). + +## `tests/ui/keyword/` + +Tests exercising keywords, such as attempting to use them as identifiers when not contextual keywords. + +## `tests/ui/kindck/` + +**FIXME**: `kindck` is no longer a thing, these tests probably need to be audited and rehomed. + +## `tests/ui/label/` + +Exercises block and loop `'label`s. + +## `tests/ui/lang-items/` + +See [Lang items | The Unstable book](https://doc.rust-lang.org/unstable-book/language-features/lang-items.html). + +## `tests/ui/late-bound-lifetimes/` + +See [Early vs Late bound parameters | rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/early_late_parameters.html#early-vs-late-bound-parameters). + +## `tests/ui/layout/` + +See [Type Layout | Reference](https://doc.rust-lang.org/reference/type-layout.html). + +## `tests/ui/lazy-type-alias/` + +Tests for `#![feature(lazy_type_alias)]`. See [Tracking issue for lazy type aliases #112792 +](https://github.com/rust-lang/rust/issues/112792). + +## `tests/ui/lazy-type-alias-impl-trait/` + +This feature allows use of an `impl Trait` in multiple locations while actually using the same concrete type (`type Alias = impl Trait;`) everywhere, keeping the original `impl Trait` hidden. + +**FIXME**: merge this with `tests/ui/type-alias-impl-trait/`? + +## `tests/ui/let-else/` + +Exercises let-else constructs. + +## `tests/ui/lexer/` + +Exercises of the lexer. + +## `tests/ui/lifetimes/` + +Broad directory on lifetimes, including proper specifiers, lifetimes not living long enough, or undeclared lifetime names. + +## `tests/ui/limits/` + +These tests exercises numerical limits, such as `[[u8; 1518599999]; 1518600000]`. + +## `tests/ui/linkage-attr/` + +Tests for the linkage attribute `#[linkage]` of `#![feature(linkage)]`. + +**FIXME**: Some of these tests do not use the feature at all, which should be moved under `ui/linking` instead. + +## `tests/ui/linking/` + +Tests on code which fails during the linking stage, or which contain arguments and lines that have been known to cause unjustified errors in the past, such as specifying an unusual `#[export_name]`. + +See [Linkage | Reference](https://doc.rust-lang.org/reference/linkage.html). + +## `tests/ui/link-native-libs/` + +Tests for `#[link(name = "", kind = "")]` and `-l` command line flag. + +See [Tracking Issue for linking modifiers for native libraries #81490](https://github.com/rust-lang/rust/issues/81490). + +## `tests/ui/lint/` + +Tests for the lint infrastructure, lint levels, lint reasons, etc. + +See: + +- [Lints | The rustc book](https://doc.rust-lang.org/rustc/lints/index.html) +- [Lint reasons | Reference](https://doc.rust-lang.org/reference/attributes/diagnostics.html#lint-reasons) + +## `tests/ui/liveness/` + +Tests exercising analysis for unused variables, unreachable statements, functions which are supposed to return a value but do not, as well as values moved elsewhere before they could be used by a function. + +**FIXME**: This seems unrelated to "liveness" as defined in the rustc compiler guide. Is this misleadingly named? https://rustc-dev-guide.rust-lang.org/borrow_check/region_inference/lifetime_parameters.html#liveness-and-universal-regions + +## `tests/ui/loops/` + +Tests on the `loop` construct. + +**FIXME**: Consider merging with `ui/for-loop-while`. + +## `tests/ui/lowering/` + +Tests on [AST lowering](https://rustc-dev-guide.rust-lang.org/ast-lowering.html). + +## `tests/ui/lto/` + +Exercise *Link-Time Optimization* (LTO), involving the flags `-C lto` or `-Z thinlto`. + +## `tests/ui/lub-glb/`: LUB/GLB algorithm update + +Tests on changes to inference variable lattice LUB/GLB, see <https://github.com/rust-lang/rust/pull/45853>. + +## `tests/ui/macro_backtrace/`: `-Zmacro-backtrace` + +Contains a single test, checking the unstable command-line flag to enable detailed macro backtraces. + +**FIXME**: This could be merged with `ui/macros`, which already contains other macro backtrace tests. + +## `tests/ui/macros/` + +Broad category of tests on macros. + +## `tests/ui/malformed/` + +Broad category of tests on malformed inputs. + +**FIXME**: this is kinda vague, probably best to audit and rehome tests. + +## `tests/ui/marker_trait_attr/` + +See [Tracking issue for allowing overlapping implementations for marker trait #29864](https://github.com/rust-lang/rust/issues/29864). + +## `tests/ui/match/` + +Broad category of tests on `match` constructs. + +## `tests/ui/meta/`: Tests for compiletest itself + +These tests check the function of the UI test suite at large and Compiletest in itself. + +**FIXME**: This should absolutely be merged with `tests/ui/compiletest-self-test/`. + +## `tests/ui/methods/` + +A broad category for anything related to methods and method resolution. + +## `tests/ui/mir/` + +Certain mir-opt regression tests. + +## `tests/ui/mir-dataflow` + +Tests for MIR dataflow analysis. + +See [MIR Dataflow | rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/mir/dataflow.html). + +## `tests/ui/mismatched_types/` + +Exercises on mismatched type diagnostics. + +## `tests/ui/missing/` + +Something is missing which could be added to fix (e.g. suggestions). + +**FIXME**: this is way too vague, tests should be rehomed. + +## `tests/ui/missing_non_modrs_mod/` + +This directory is a small tree of `mod` dependencies, but the root, `foo.rs`, is looking for a file which does not exist. The test checks that the error is reported at the top-level module. + +**FIXME**: Merge with `tests/ui/modules/`. + +## `tests/ui/missing-trait-bounds/` + +Tests for checking missing trait bounds, and their diagnostics. + +**FIMXE**: Maybe a subdirectory of `ui/trait-bounds` would be more appropriate. + +## `tests/ui/modules/` + +Tests on the module system. + +**FIXME**: `tests/ui/imports/` should probably be merged with this. + +## `tests/ui/modules_and_files_visibility/` + +**FIXME**: Merge with `tests/ui/modules/`. + +## `tests/ui/moves` + +Tests on moves (destructive moves). + +## `tests/ui/mut/` + +Broad category of tests on mutability, such as the `mut` keyword, borrowing a value as both immutable and mutable (and the associated error), or adding mutable references to `const` declarations. + +## `tests/ui/namespace/` + +Contains a single test. It imports a massive amount of very similar types from a crate, then attempts various permutations of their namespace paths, checking for errors or the lackthereof. + +**FIXME**: Move under either `tests/ui/modules/` or `tests/ui/resolve/`. + +## `tests/ui/never_type/` + +See [Tracking issue for promoting `!` to a type (RFC 1216) #35121](https://github.com/rust-lang/rust/issues/35121). + +## `tests/ui/new-range/` + +See [RFC 3550 New Range](https://github.com/rust-lang/rfcs/blob/master/text/3550-new-range.md). + +## `tests/ui/nll/`: Non-lexical lifetimes + +Tests for Non-lexical lifetimes. See [RFC 2094 NLL](https://rust-lang.github.io/rfcs/2094-nll.html). + +## `tests/ui/non_modrs_mods/` + +Despite the size of the directory, this is a single test, spawning a sprawling `mod` dependency tree and checking its successful build. + +**FIXME**: Consider merge with `tests/ui/modules/`, keeping the directory structure. + +## `tests/ui/non_modrs_mods_and_inline_mods/` + +A very similar principle as `non_modrs_mods`, but with an added inline `mod` statement inside another `mod`'s code block. + +**FXIME**: Consider merge with `tests/ui/modules/`, keeping the directory structure. + +## `tests/ui/no_std/` + +Tests for where the standard library is disabled through `#![no_std]`. + +## `tests/ui/not-panic/` + +Tests checking various types, such as `&RefCell<i32>`, and whether they are not `UnwindSafe` as expected. + +## `tests/ui/numbers-arithmetic/` + +Tests that exercises edge cases, such as specific floats, large or very small numbers, or bit conversion, and check that the arithmetic results are as expected. + +## `tests/ui/numeric/` + +Tests that checks numeric types and their interactions, such as casting among them with `as` or providing the wrong numeric suffix. + +## `tests/ui/object-lifetime/` + +Tests on lifetimes on objects, such as a lifetime bound not being able to be deduced from context, or checking that lifetimes are inherited properly. + +**FIXME**: Just a more specific subset of `ui/lifetimes`. + +## `tests/ui/obsolete-in-place/` + +Contains a single test. Check that we reject the ancient Rust syntax `x <- y` and `in(BINDING) {}` construct. + +**FIXME**: Definitely should be rehomed, maybe to `tests/ui/deprecation/`. + +## `tests/ui/offset-of/` + +Exercises the [`std::mem::offset_of` macro](https://doc.rust-lang.org/beta/std/mem/macro.offset_of.html). + +## `tests/ui/on-unimplemented/` + +Exercises the `#[rustc_on_unimplemented]`. + +## `tests/ui/operator-recovery/` + +**FIXME**: Probably move under `tests/ui/binop/` or `tests/ui/parser/`. + +## `tests/ui/or-patterns/` + +Exercises `||` and `|` in patterns. + +## `tests/ui/overloaded/` + +Exercises operator overloading via [`std::ops`](https://doc.rust-lang.org/std/ops/index.html). + +## `tests/ui/packed/` + +See [`repr(packed)` | Nomicon](https://doc.rust-lang.org/nomicon/other-reprs.html#reprpacked-reprpackedn). + +## `tests/ui/panic-handler/` + +See [panic handler | Nomicon](https://doc.rust-lang.org/nomicon/panic-handler.html). + +## `tests/ui/panic-runtime/` + +Exercises `#![panic_runtime]`, `-C panic`, panic runtimes and panic unwind strategy. + +See [RFC 1513 Less unwinding](https://github.com/rust-lang/rfcs/blob/master/text/1513-less-unwinding.md). + +## `tests/ui/panics/` + +Broad category of tests about panics in general, often but not necessarily using the `panic!` macro. + +## `tests/ui/parallel-rustc/` + +Efforts towards a [Parallel Rustc Front-end](https://github.com/rust-lang/rust/issues/113349). Includes `-Zthreads=`. + +## `tests/ui/parser/` + +Various parser tests + +**FIXME**: Maybe move `tests/ui/keywords/` under this? + +## `tests/ui/patchable-function-entry/` + +See [Patchable function entry | The Unstable book](https://doc.rust-lang.org/unstable-book/compiler-flags/patchable-function-entry.html). + +## `tests/ui/pattern/` + +Broad category of tests surrounding patterns. See [Patterns | Reference](https://doc.rust-lang.org/reference/patterns.html). + +**FIXME**: Some overlap with `tests/ui/match/`. + +## `tests/ui/pin-macro/` + +See [`std::pin`](https://doc.rust-lang.org/std/pin/). + +## `tests/ui/precondition-checks/` + +Exercises on some unsafe precondition checks. + +## `tests/ui/print-request/` + +Tests on `--print` compiler flag. See [print options | The rustc book](https://doc.rust-lang.org/rustc/command-line-arguments/print-options.html). + +## `tests/ui/print_type_sizes/` + +Exercises the `-Z print-type-sizes` flag. + +## `tests/ui/privacy/` + +Exercises on name privacy. E.g. the meaning of `pub`, `pub(crate)`, etc. + +## `tests/ui/process/` + +Some standard library process tests which are hard to write within standard library crate tests. + +## `tests/ui/process-termination/` + +Some standard library process termination tests which are hard to write within standard library crate tests. + +## `tests/ui/proc-macro/` + +Broad category of tests on proc-macros. See [Procedural Macros | Reference](https://doc.rust-lang.org/reference/procedural-macros.html). + +## `tests/ui/ptr_ops/`: Using operations on a pointer + +Contains only 2 tests, related to a single issue, which was about an error caused by using addition on a pointer to `i8`. + +**FIXME**: Probably rehome under some typecheck / binop directory. + +## `tests/ui/pub/`: `pub` keyword + +A large category about function and type public/private visibility, and its impact when using features across crates. Checks both visibility-related error messages and previously buggy cases. + +**FIXME**: merge with `tests/ui/privacy/`. + +## `tests/ui/qualified/` + +Contains few tests on qualified paths where a type parameter is provided at the end: `type A = <S as Tr>::A::f<u8>;`. The tests check if this fails during type checking, not parsing. + +**FIXME**: Should be rehomed to `ui/typeck`. + +## `tests/ui/query-system/` + +Tests on Rust methods and functions which use the query system, such as `std::mem::size_of`. These compute information about the current runtime and return it. See [Query system | rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/query.html). + +## `tests/ui/range/` + +Broad category of tests ranges, both in their `..` or `..=` form, as well as the standard library `Range`, `RangeTo`, `RangeFrom` or `RangeBounds` types. + +**FIXME**: May have some duplicate tests with `ui/new-range`. + +## `tests/ui/raw-ref-op/`: Using operators on `&raw` values + +Exercises `&raw mut <place>` and `&raw const <place>`. See [RFC 2582 Raw reference MIR operator](https://github.com/rust-lang/rfcs/blob/master/text/2582-raw-reference-mir-operator.md). + +## `tests/ui/reachable` + +Reachability tests, primarily unreachable code and coercions into the never type `!` from diverging expressions. + +**FIXME**: Check for overlap with `ui/liveness`. + +## `tests/ui/recursion/` + +Broad category of tests exercising recursions (compile test and run time), in functions, macros, `type` definitions, and more. + +Also exercises the `#![recursion_limit = ""]` attribute. + +## `tests/ui/recursion_limit/`: `#![recursion_limit = ""]` + +Sets a recursion limit on recursive code. + +**FIXME**: Should be merged with `tests/ui/recursion/`. + +## `tests/ui/regions/` + +**FIXME**: Maybe merge with `ui/lifetimes`. + +## `tests/ui/repeat-expr/` + +Exercises `[Type; n]` syntax for creating arrays with repeated types across a set size. + +**FIXME**: Maybe make this a subdirectory of `ui/array-slice-vec`. + +## `tests/ui/repr/`: `#[repr(_)]` + +Tests on the `#[repr(..)]` attribute. See [Representations | Reference](https://doc.rust-lang.org/reference/type-layout.html#representations). + +## `tests/ui/reserved/` + +Reserved keywords and attribute names. + +See e.g. [Reserved keywords | Reference](https://doc.rust-lang.org/reference/keywords.html). + +**FIXME**: maybe merge under `tests/ui/keyword/`. + +## `tests/ui/resolve/`: Name resolution + +See [Name resolution | rustc-dev-guide](https://rustc-dev-guide.rust-lang.org/name-resolution.html). + +## `tests/ui/return/` + +Exercises the `return` keyword, return expressions and statements. + +## `tests/ui/rfcs/` + +Tests that accompanies an implementation for an RFC. + +## `tests/ui/rmeta/` + +Exercises `.rmeta` crate metadata and the `--emit=metadata` cli flag. + +## `tests/ui/runtime/` + +Tests for runtime environment on which Rust programs are executed. E.g. Unix `SIGPIPE`. + +## `tests/ui/rust-{2018,2021,2024}/` + +Tests that exercise behaviors and features that are specific to editions. + +## `tests/ui/rustc-env` + +Tests on environmental variables that affect `rustc`. + +## `tests/ui/rustdoc` + +Hybrid tests that exercises `rustdoc`, and also some joint `rustdoc`/`rustc` interactions. + +## `tests/ui/sanitizer/` + +Exercises sanitizer support. See [Sanitizer | The rustc book](https://doc.rust-lang.org/unstable-book/compiler-flags/sanitizer.html). + +## `tests/ui/self/`: `self` keyword + +Tests with erroneous ways of using `self`, such as using `this.x` syntax as seen in other languages, having it not be the first argument, or using it in a non-associated function (no `impl` or `trait`). It also contains correct uses of `self` which have previously been observed to cause ICEs. + +## `tests/ui/sepcomp/`: Separate Compilation + +In this directory, multiple crates are compiled, but some of them have `inline` functions, meaning they must be inlined into a different crate despite having been compiled separately. + +**FIXME**: this directory might need some better docs, also this directory might want a better name. + +## `tests/ui/shadowed/` + +Tests on name shadowing. + +## `tests/ui/shell-argfiles/`: `-Z shell-argfiles` command line flag + +The `-Zshell-argfiles` compiler flag allows argfiles to be parsed using POSIX "shell-style" quoting. When enabled, the compiler will use shlex to parse the arguments from argfiles specified with `@shell:<path>`. + +Because this feature controls the parsing of input arguments, the `-Zshell-argfiles` flag must be present before the argument specifying the shell-style argument file. + +**FIXME**: maybe group this with `tests/ui/argfile/` + +## `tests/ui/simd/` + +Some tests exercising SIMD support. + +## `tests/ui/single-use-lifetime/` + +This is a test directory for the specific error case where a lifetime never gets used beyond a single annotation on, for example, a `struct`. + +## `tests/ui/sized/`: `Sized` trait, sized types + +While many tests here involve the `Sized` trait directly, some instead test, for example the slight variations between returning a zero-sized `Vec` and a `Vec` with one item, where one has no known type and the other does. + +## `tests/ui/span/` + +An assorted collection of tests that involves specific diagnostic spans. + +**FIXME**: This is a big directory with numerous only-tangentially related tests. Maybe some moving is in order. + +## `tests/ui/specialization` + +See [Tracking issue for specialization (RFC 1210) #31844](https://github.com/rust-lang/rust/issues/31844). + +## `tests/ui/stability-attribute/` + +Stability attributes used internally by the standard library: `#[stable()]` and `#[unstable()]`. + +## `tests/ui/stable-mir-print/` + +Some tests for pretty printing of StableMIR. + +## `tests/ui/stack-protector/`: `-Z stack-protector` command line flag + +See [Tracking Issue for stabilizing stack smashing protection (i.e., `-Z stack-protector`) #114903](https://github.com/rust-lang/rust/issues/114903). + +## `tests/ui/static/` + +Tests on static items. + +## `tests/ui/statics/` + +**FIXME**: should probably be merged with `tests/ui/static/`. + +## `tests/ui/stats/` + +Tests for compiler-internal stats; `-Z meta-stats` and `-Z input-stats` flags. + +## `tests/ui/std/`: Tests which use features from the standard library + +A catch-all category about anything that can come from `std`. + +**FIXME**: this directory is probably too vague, tests might need to be audited and rehomed. + +## `tests/ui/stdlib-unit-tests/` + +Some standard library tests which are too inconvenient or annoying to implement as std crate tests. + +## `tests/ui/str/` + +Exercise `str` keyword and string slices. + +## `tests/ui/structs/` + +Assorted tests surrounding the `struct` keyword, struct type definitions and usages. + +## `tests/ui/structs-enums/` + +Tests on both structs and enums. + +**FIXME**: maybe coalesce {`tests/ui/structs/`, `tests/ui/structs-enums/`, `tests/ui/enums/`} into one `tests/ui/adts` directory... + +## `tests/ui/suggestions/` + +Generic collection of tests for suggestions, when no more specific directories are applicable. + +**FIXME**: Some overlap with `tests/ui/did_you_mean/`, that directory should probably be moved under here. + +## `tests/ui/svh/`: Strict Version Hash + +Tests on the *Strict Version Hash* (SVH, also known as the "crate hash"). + +See [Strict Version Hash](https://rustc-dev-guide.rust-lang.org/backend/libs-and-metadata.html#strict-version-hash). + +## `tests/ui/symbol-mangling-version/`: `-Csymbol-mangling-version` command line flag + +**FIXME**: Should be merged with `ui/symbol-names`. + +## `tests/ui/symbol-names/`: Symbol mangling and related attributes + +These tests revolve around `#[no_mangle]` attribute, as well as consistently mangled symbol names (checked with the `rustc_symbol_name` attribute), which is important to build reproducible binaries. + +## `tests/ui/sync/`: `Sync` trait + +Exercises `Sync` trait and auto-derive thereof. + +## `tests/ui/target-cpu/`: `-C target-cpu` command line flag + +This command line option instructs rustc to generate code specifically for a particular processor. + +**FIXME**: Contains a single test, maybe put it in a directory about misc codegen options? + +## `tests/ui/target-feature/`: `#[target_feature(enable = "relaxed-simd")]` + +Exercises the `#[target_feature(..)]` attribute. See [Target feature attribute | Reference](https://doc.rust-lang.org/reference/attributes/codegen.html#the-target_feature-attribute). + +## `tests/ui/target_modifiers/` + +Tests for [RFC 3716: Target Modifiers](https://github.com/rust-lang/rfcs/pull/3716). + +See [Tracking Issue for target modifiers #136966](https://github.com/rust-lang/rust/issues/136966). + +## `tests/ui/test-attrs/` + +Exercises the [`#[test]` attribute](https://doc.rust-lang.org/reference/attributes/testing.html#testing-attributes). + +## `tests/ui/thir-print/` + +Pretty print of THIR trees via `-Zunpretty=thir-tree`. + +## `tests/ui/thread-local/` + +Exercises thread local values and `#[thread_local]` attribute. + +See [Tracking issue for thread_local stabilization #29594](https://github.com/rust-lang/rust/issues/29594). + +## `tests/ui/threads-sendsync/` + +Broad category for parallelism and multi-threaded tests, including attempting to send types across threads which are not thread-safe. + +## `tests/ui/tool-attributes/`: External tool attributes + +Exercises [tool attributes](https://doc.rust-lang.org/reference/attributes.html#tool-attributes). + +## `tests/ui/track-diagnostics/` + +Exercises `#[track_caller]` and `-Z track-diagnostics`. + +## `tests/ui/trait-bounds/` + +Collection of tests for [trait bounds](https://doc.rust-lang.org/reference/trait-bounds.html). + +## `tests/ui/traits/` + +Broad collection of tests on traits in general. + +**FIXME**: This could be better organized in subdirectories containing tests such as `ui/traits/trait-bounds`. + +## `tests/ui/transmutability/`: `#![feature(transmutability)]` + +See [Tracking Issue for Transmutability Trait: `#[transmutability]` #99571](https://github.com/rust-lang/rust/issues/99571). + +See also [Project Safe Transmute](https://github.com/rust-lang/project-safe-transmute). + +## `tests/ui/transmute/` + +Tests surrounding [`std::mem::transmute`](https://doc.rust-lang.org/std/mem/fn.transmute.html). + +## `tests/ui/treat-err-as-bug/` + +Exercises compiler development support flag `-Z treat-err-as-bug`. + +## `tests/ui/trivial-bounds/` + +`#![feature(trivial_bounds)]`. See [RFC 2056 Allow trivial where clause constraints](https://github.com/rust-lang/rfcs/blob/master/text/2056-allow-trivial-where-clause-constraints.md). + +## `tests/ui/try-block/` + +`#![feature(try_blocks)]`. See [Tracking issue for `?` operator and `try` blocks (RFC 243, `question_mark` & `try_blocks` features)](https://github.com/rust-lang/rust/issues/31436). + +## `tests/ui/try-trait/` + +`#![feature(try_trait_v2)]`. See [RFC 3058 Try Trait v2](https://github.com/rust-lang/rfcs/blob/master/text/3058-try-trait-v2.md). + +## `tests/ui/tuple/` + +Tests surrounding the tuple type `()`. + +## `tests/ui/type/` + +Assorted collection of tests surrounding the concept of a "type". + +**FIXME**: There is very little consistency across tests of this category, and should probably be sent to other subdirectories. + +## `tests/ui/type-alias/` + +Exercises [type aliases](https://doc.rust-lang.org/reference/items/type-aliases.html). + +## `tests/ui/type-alias-enum-variants/` + +Tests for `type` aliases in the context of `enum` variants, such as that applied type arguments of enums are respected independently of being the original type or the `type` alias. + +## `tests/ui/type-alias-impl-trait/` + +`#![feature(type_alias_impl_trait)]`. See [Type Alias Impl Trait | The Unstable book](https://doc.rust-lang.org/nightly/unstable-book/language-features/type-alias-impl-trait.html). + +## `tests/ui/typeck/` + +General collection of type checking related tests. + +## `tests/ui/type-inference/` + +General collection of type inference related tests. + +## `tests/ui/typeof/` + +`typeof` keyword, reserved but unimplemented. + +## `tests/ui/ufcs/` + +See [RFC 0132 Unified Function Call Syntax](https://github.com/rust-lang/rfcs/blob/master/text/0132-ufcs.md). + +## `tests/ui/unboxed-closures/` + +`#![feature(unboxed_closures)]`, `Fn`, `FnMut` and `FnOnce` traits + +See [Tracking issue for Fn traits (`unboxed_closures` & `fn_traits` feature)](https://github.com/rust-lang/rust/issues/29625). + +## `tests/ui/underscore-imports/` + +See [Underscore imports | Reference](https://doc.rust-lang.org/reference/items/use-declarations.html#underscore-imports). + +**FIXME**: should become a subdirectory of `tests/ui/imports/`. + +## `tests/ui/underscore-lifetime/`: `'_` elided lifetime + +Exercises [anonymous elided lifetimes](https://doc.rust-lang.org/reference/lifetime-elision.html). + +## `tests/ui/uniform-paths/` + +In uniform paths, if a submodule and an external dependencies have the same name, to depend on the external dependency, one needs to disambiguate it from the submodule using `use ::foo`. Tests revolve around this, for example, check that `self::foo` and `::foo` are not considered ambiguously identical by the compiler. + +Remark: As they are an important Rust 2018 feature, they also get a big subdirectory in `ui/rust-2018/uniform-paths` + +## `tests/ui/uninhabited/`: Uninhabited types + +See [Uninhabited | Reference](https://doc.rust-lang.org/reference/glossary.html?highlight=Uninhabit#uninhabited). + +## `tests/ui/union/` + +See [Unions | Reference](https://doc.rust-lang.org/reference/items/unions.html). + +## `tests/ui/unknown-unstable-lints/`: Attempting to refer to an unstable lint which does not exist + +Tests for trying to use non-existent unstable lints. + +**FIXME**: move this under `tests/ui/lints/`. + +## `tests/ui/unop/`: Unary operators `-`, `*` and `!` + +Tests the three unary operators for negating, dereferencing and inverting, across different contexts. + +## `tests/ui/unpretty/`: `-Z unpretty` command line flag + +The `-Z unpretty` flag outputs various representations of a program's tree in a certain way. + +## `tests/ui/unresolved/` + +Exercises various unresolved errors, ranging from earlier name resolution failures to later method resolution failures. + +## `tests/ui/unsafe/` + +A broad category of tests about unsafe Rust code. + +## `tests/ui/unsafe-binders/`: `#![feature(unsafe_binders)]` + +See [Tracking issue for unsafe binder types #130516](https://github.com/rust-lang/rust/issues/130516). + +## `tests/ui/unsafe-fields/`: `struct`s and `enum`s with an `unsafe` field + +See [Tracking issue for RFC 3458: Unsafe fields #132922](https://github.com/rust-lang/rust/issues/132922). + +## `tests/ui/unsized/`: Zero-sized types, `Sized` trait, object has no known size at compile time + +**FIXME**: between `tests/ui/zero-sized/`, `tests/ui/sized/` and this directory, might need to reorganize them a bit. + +## `tests/ui/unsized-locals/`: `#![feature(unsized_locals, unsized_fn_params)]` + +See: + +- [RFC 1909 Unsized rvalues](https://github.com/rust-lang/rfcs/blob/master/text/1909-unsized-rvalues.md) +- [de-RFC 3829: Remove unsized_locals](https://github.com/rust-lang/rfcs/pull/3829) +- [Tracking issue for RFC #1909: Unsized Rvalues (`unsized_locals`, `unsized_fn_params`)](https://github.com/rust-lang/rust/issues/48055) + +**FIXME**: Seems to also contain more generic tests that fit in `tests/ui/unsized/`. + +## `tests/ui/unused-crate-deps/` + +Exercises the `unused_crate_dependencies` lint. + +## `tests/ui/unwind-abis/` + +**FIXME**: Contains a single test, should likely be rehomed to `tests/ui/abi/`. + +## `tests/ui/use/` + +**FIXME**: merge with `ui/imports`. + +## `tests/ui/variance/`: Covariants, invariants and contravariants + +See [Variance | Reference](https://doc.rust-lang.org/reference/subtyping.html#variance). + +## `tests/ui/variants/`: `enum` variants + +Tests on `enum` variants. + +**FIXME**: Should be rehomed with `tests/ui/enum/`. + +## `tests/ui/version/` + +**FIXME**: Contains a single test described as "Check that rustc accepts various version info flags.", should be rehomed. + +## `tests/ui/warnings/` + +**FIXME**: Contains a single test on non-explicit paths (`::one()`). Should be rehomed probably to `tests/ui/resolve/`. + +## `tests/ui/wasm/` + +These tests target the `wasm32` architecture specifically. They are usually regression tests for WASM-specific bugs which were observed in the past. + +## `tests/ui/wf/`: Well-formedness checking + +Tests on various well-formedness checks, e.g. [Type-checking normal functions](https://rustc-dev-guide.rust-lang.org/traits/lowering-to-logic.html). + +## `tests/ui/where-clauses/` + +Tests on `where` clauses. See [Where clauses | Reference](https://doc.rust-lang.org/reference/items/generics.html#where-clauses). + +## `tests/ui/while/` + +Tests on the `while` keyword and the `while` construct. + +**FIXME**: merge with `ui/for-loop-while`. + +## `tests/ui/windows-subsystem/`: `#![windows_subsystem = ""]` + +See [the `windows_subsystem` attribute](https://doc.rust-lang.org/reference/runtime.html#the-windows_subsystem-attribute). + +## `tests/ui/zero-sized/`: Zero-sized types + +See [Zero-Sized Types | Reference](https://doc.rust-lang.org/nomicon/exotic-sizes.html#zero-sized-types-zsts). diff --git a/tests/ui/abi/bad-custom.rs b/tests/ui/abi/bad-custom.rs index a3b15f244b7..7c881134ccb 100644 --- a/tests/ui/abi/bad-custom.rs +++ b/tests/ui/abi/bad-custom.rs @@ -5,7 +5,7 @@ #[unsafe(naked)] extern "custom" fn must_be_unsafe(a: i64) -> i64 { - //~^ ERROR functions with the `"custom"` ABI must be unsafe + //~^ ERROR functions with the "custom" ABI must be unsafe //~| ERROR invalid signature for `extern "custom"` function std::arch::naked_asm!("") } @@ -23,7 +23,7 @@ unsafe extern "custom" fn no_return_type() -> i64 { } unsafe extern "custom" fn double(a: i64) -> i64 { - //~^ ERROR items with the `"custom"` ABI can only be declared externally or defined via naked functions + //~^ ERROR items with the "custom" ABI can only be declared externally or defined via naked functions //~| ERROR invalid signature for `extern "custom"` function unimplemented!() } @@ -32,7 +32,7 @@ struct Thing(i64); impl Thing { unsafe extern "custom" fn is_even(self) -> bool { - //~^ ERROR items with the `"custom"` ABI can only be declared externally or defined via naked functions + //~^ ERROR items with the "custom" ABI can only be declared externally or defined via naked functions //~| ERROR invalid signature for `extern "custom"` function unimplemented!() } @@ -40,7 +40,7 @@ impl Thing { trait BitwiseNot { unsafe extern "custom" fn bitwise_not(a: i64) -> i64 { - //~^ ERROR items with the `"custom"` ABI can only be declared externally or defined via naked functions + //~^ ERROR items with the "custom" ABI can only be declared externally or defined via naked functions //~| ERROR invalid signature for `extern "custom"` function unimplemented!() } @@ -50,14 +50,14 @@ impl BitwiseNot for Thing {} trait Negate { extern "custom" fn negate(a: i64) -> i64; - //~^ ERROR functions with the `"custom"` ABI must be unsafe + //~^ ERROR functions with the "custom" ABI must be unsafe //~| ERROR invalid signature for `extern "custom"` function } impl Negate for Thing { extern "custom" fn negate(a: i64) -> i64 { - //~^ ERROR items with the `"custom"` ABI can only be declared externally or defined via naked functions - //~| ERROR functions with the `"custom"` ABI must be unsafe + //~^ ERROR items with the "custom" ABI can only be declared externally or defined via naked functions + //~| ERROR functions with the "custom" ABI must be unsafe //~| ERROR invalid signature for `extern "custom"` function -a } @@ -68,7 +68,7 @@ unsafe extern "custom" { //~^ ERROR invalid signature for `extern "custom"` function safe fn extern_cannot_be_safe(); - //~^ ERROR foreign functions with the `"custom"` ABI cannot be safe + //~^ ERROR foreign functions with the "custom" ABI cannot be safe } fn caller(f: unsafe extern "custom" fn(i64) -> i64, mut x: i64) -> i64 { @@ -95,8 +95,8 @@ const unsafe extern "custom" fn no_const_fn() { } async unsafe extern "custom" fn no_async_fn() { - //~^ ERROR items with the `"custom"` ABI can only be declared externally or defined via naked functions - //~| ERROR functions with the `"custom"` ABI cannot be `async` + //~^ ERROR items with the "custom" ABI can only be declared externally or defined via naked functions + //~| ERROR functions with the "custom" ABI cannot be `async` } fn no_promotion_to_fn_trait(f: unsafe extern "custom" fn()) -> impl Fn() { diff --git a/tests/ui/abi/bad-custom.stderr b/tests/ui/abi/bad-custom.stderr index 77cad1b872b..372ef71375c 100644 --- a/tests/ui/abi/bad-custom.stderr +++ b/tests/ui/abi/bad-custom.stderr @@ -1,4 +1,4 @@ -error: functions with the `"custom"` ABI must be unsafe +error: functions with the "custom" ABI must be unsafe --> $DIR/bad-custom.rs:7:1 | LL | extern "custom" fn must_be_unsafe(a: i64) -> i64 { @@ -15,7 +15,7 @@ error: invalid signature for `extern "custom"` function LL | extern "custom" fn must_be_unsafe(a: i64) -> i64 { | ^^^^^^ ^^^ | - = note: functions with the `"custom"` ABI cannot have any parameters or return type + = note: functions with the "custom" ABI cannot have any parameters or return type help: remove the parameters and return type | LL - extern "custom" fn must_be_unsafe(a: i64) -> i64 { @@ -28,7 +28,7 @@ error: invalid signature for `extern "custom"` function LL | unsafe extern "custom" fn no_parameters(a: i64) { | ^^^^^^ | - = note: functions with the `"custom"` ABI cannot have any parameters or return type + = note: functions with the "custom" ABI cannot have any parameters or return type help: remove the parameters and return type | LL - unsafe extern "custom" fn no_parameters(a: i64) { @@ -41,7 +41,7 @@ error: invalid signature for `extern "custom"` function LL | unsafe extern "custom" fn no_return_type() -> i64 { | ^^^ | - = note: functions with the `"custom"` ABI cannot have any parameters or return type + = note: functions with the "custom" ABI cannot have any parameters or return type help: remove the parameters and return type | LL - unsafe extern "custom" fn no_return_type() -> i64 { @@ -54,7 +54,7 @@ error: invalid signature for `extern "custom"` function LL | unsafe extern "custom" fn double(a: i64) -> i64 { | ^^^^^^ ^^^ | - = note: functions with the `"custom"` ABI cannot have any parameters or return type + = note: functions with the "custom" ABI cannot have any parameters or return type help: remove the parameters and return type | LL - unsafe extern "custom" fn double(a: i64) -> i64 { @@ -67,7 +67,7 @@ error: invalid signature for `extern "custom"` function LL | unsafe extern "custom" fn is_even(self) -> bool { | ^^^^ ^^^^ | - = note: functions with the `"custom"` ABI cannot have any parameters or return type + = note: functions with the "custom" ABI cannot have any parameters or return type help: remove the parameters and return type | LL - unsafe extern "custom" fn is_even(self) -> bool { @@ -80,14 +80,14 @@ error: invalid signature for `extern "custom"` function LL | unsafe extern "custom" fn bitwise_not(a: i64) -> i64 { | ^^^^^^ ^^^ | - = note: functions with the `"custom"` ABI cannot have any parameters or return type + = note: functions with the "custom" ABI cannot have any parameters or return type help: remove the parameters and return type | LL - unsafe extern "custom" fn bitwise_not(a: i64) -> i64 { LL + unsafe extern "custom" fn bitwise_not() { | -error: functions with the `"custom"` ABI must be unsafe +error: functions with the "custom" ABI must be unsafe --> $DIR/bad-custom.rs:52:5 | LL | extern "custom" fn negate(a: i64) -> i64; @@ -104,14 +104,14 @@ error: invalid signature for `extern "custom"` function LL | extern "custom" fn negate(a: i64) -> i64; | ^^^^^^ ^^^ | - = note: functions with the `"custom"` ABI cannot have any parameters or return type + = note: functions with the "custom" ABI cannot have any parameters or return type help: remove the parameters and return type | LL - extern "custom" fn negate(a: i64) -> i64; LL + extern "custom" fn negate(); | -error: functions with the `"custom"` ABI must be unsafe +error: functions with the "custom" ABI must be unsafe --> $DIR/bad-custom.rs:58:5 | LL | extern "custom" fn negate(a: i64) -> i64 { @@ -128,7 +128,7 @@ error: invalid signature for `extern "custom"` function LL | extern "custom" fn negate(a: i64) -> i64 { | ^^^^^^ ^^^ | - = note: functions with the `"custom"` ABI cannot have any parameters or return type + = note: functions with the "custom" ABI cannot have any parameters or return type help: remove the parameters and return type | LL - extern "custom" fn negate(a: i64) -> i64 { @@ -141,14 +141,14 @@ error: invalid signature for `extern "custom"` function LL | fn increment(a: i64) -> i64; | ^^^^^^ ^^^ | - = note: functions with the `"custom"` ABI cannot have any parameters or return type + = note: functions with the "custom" ABI cannot have any parameters or return type help: remove the parameters and return type | LL - fn increment(a: i64) -> i64; LL + fn increment(); | -error: foreign functions with the `"custom"` ABI cannot be safe +error: foreign functions with the "custom" ABI cannot be safe --> $DIR/bad-custom.rs:70:5 | LL | safe fn extern_cannot_be_safe(); @@ -160,19 +160,19 @@ LL - safe fn extern_cannot_be_safe(); LL + fn extern_cannot_be_safe(); | -error: functions with the `"custom"` ABI cannot be `async` +error: functions with the "custom" ABI cannot be `async` --> $DIR/bad-custom.rs:97:1 | LL | async unsafe extern "custom" fn no_async_fn() { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -help: remove the `async` keyword from this definiton +help: remove the `async` keyword from this definition | LL - async unsafe extern "custom" fn no_async_fn() { LL + unsafe extern "custom" fn no_async_fn() { | -error: items with the `"custom"` ABI can only be declared externally or defined via naked functions +error: items with the "custom" ABI can only be declared externally or defined via naked functions --> $DIR/bad-custom.rs:97:1 | LL | async unsafe extern "custom" fn no_async_fn() { @@ -197,7 +197,7 @@ LL | f = note: unsafe function cannot be called generically without an unsafe block = note: wrap the `unsafe extern "custom" fn()` in a closure with no arguments: `|| { /* code */ }` -error: items with the `"custom"` ABI can only be declared externally or defined via naked functions +error: items with the "custom" ABI can only be declared externally or defined via naked functions --> $DIR/bad-custom.rs:25:1 | LL | unsafe extern "custom" fn double(a: i64) -> i64 { @@ -209,7 +209,7 @@ LL + #[unsafe(naked)] LL | unsafe extern "custom" fn double(a: i64) -> i64 { | -error: items with the `"custom"` ABI can only be declared externally or defined via naked functions +error: items with the "custom" ABI can only be declared externally or defined via naked functions --> $DIR/bad-custom.rs:34:5 | LL | unsafe extern "custom" fn is_even(self) -> bool { @@ -221,7 +221,7 @@ LL + #[unsafe(naked)] LL | unsafe extern "custom" fn is_even(self) -> bool { | -error: items with the `"custom"` ABI can only be declared externally or defined via naked functions +error: items with the "custom" ABI can only be declared externally or defined via naked functions --> $DIR/bad-custom.rs:42:5 | LL | unsafe extern "custom" fn bitwise_not(a: i64) -> i64 { @@ -233,7 +233,7 @@ LL + #[unsafe(naked)] LL | unsafe extern "custom" fn bitwise_not(a: i64) -> i64 { | -error: items with the `"custom"` ABI can only be declared externally or defined via naked functions +error: items with the "custom" ABI can only be declared externally or defined via naked functions --> $DIR/bad-custom.rs:58:5 | LL | extern "custom" fn negate(a: i64) -> i64 { diff --git a/tests/ui/abi/cannot-be-called.avr.stderr b/tests/ui/abi/cannot-be-called.avr.stderr index 64ce3efe52b..1129893cbfa 100644 --- a/tests/ui/abi/cannot-be-called.avr.stderr +++ b/tests/ui/abi/cannot-be-called.avr.stderr @@ -1,63 +1,50 @@ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:60:18 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:37:8 | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | extern "msp430-interrupt" fn msp430() {} + | ^^^^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/cannot-be-called.rs:74:19 - | -LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:41:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "riscv-interrupt-m" fn riscv_m() {} + | ^^^^^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-s" is not supported on this target - --> $DIR/cannot-be-called.rs:81:19 - | -LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "riscv-interrupt-s" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:43:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "riscv-interrupt-s" fn riscv_s() {} + | ^^^^^^^^^^^^^^^^^^^ -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:88:15 +error[E0570]: "x86-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:45:8 | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "x86-interrupt" fn x86() {} + | ^^^^^^^^^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:36:1 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:70:25 | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { + | ^^^^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:40:1 +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:76:26 | -LL | extern "riscv-interrupt-m" fn riscv_m() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-s"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:42:1 +error[E0570]: "riscv-interrupt-s" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:82:26 | -LL | extern "riscv-interrupt-s" fn riscv_s() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:44:1 +error[E0570]: "x86-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:88:22 | -LL | extern "x86-interrupt" fn x86() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { + | ^^^^^^^^^^^^^^^ error: functions with the "avr-interrupt" ABI cannot be called --> $DIR/cannot-be-called.rs:50:5 @@ -72,61 +59,17 @@ LL | avr(); | ^^^^^ error: functions with the "avr-interrupt" ABI cannot be called - --> $DIR/cannot-be-called.rs:70:5 + --> $DIR/cannot-be-called.rs:66:5 | LL | f() | ^^^ | note: an `extern "avr-interrupt"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:70:5 + --> $DIR/cannot-be-called.rs:66:5 | LL | f() | ^^^ -error: aborting due to 6 previous errors; 4 warnings emitted +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/cannot-be-called.rs:74:19 - | -LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-s" is not supported on this target - --> $DIR/cannot-be-called.rs:81:19 - | -LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:88:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - diff --git a/tests/ui/abi/cannot-be-called.i686.stderr b/tests/ui/abi/cannot-be-called.i686.stderr index 113b40eb67b..024d5e2e93d 100644 --- a/tests/ui/abi/cannot-be-called.i686.stderr +++ b/tests/ui/abi/cannot-be-called.i686.stderr @@ -1,132 +1,75 @@ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:60:18 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:37:8 | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | extern "msp430-interrupt" fn msp430() {} + | ^^^^^^^^^^^^^^^^^^ -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:67:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:39:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "avr-interrupt" fn avr() {} + | ^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/cannot-be-called.rs:74:19 - | -LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:41:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "riscv-interrupt-m" fn riscv_m() {} + | ^^^^^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-s" is not supported on this target - --> $DIR/cannot-be-called.rs:81:19 +error[E0570]: "riscv-interrupt-s" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:43:8 | -LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "riscv-interrupt-s" fn riscv_s() {} + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:36:1 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:64:22 | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { + | ^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:38:1 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:70:25 | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { + | ^^^^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:40:1 +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:76:26 | -LL | extern "riscv-interrupt-m" fn riscv_m() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-s"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:42:1 +error[E0570]: "riscv-interrupt-s" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:82:26 | -LL | extern "riscv-interrupt-s" fn riscv_s() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { + | ^^^^^^^^^^^^^^^^^^^ error: functions with the "x86-interrupt" ABI cannot be called - --> $DIR/cannot-be-called.rs:56:5 + --> $DIR/cannot-be-called.rs:58:5 | LL | x86(); | ^^^^^ | note: an `extern "x86-interrupt"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:56:5 + --> $DIR/cannot-be-called.rs:58:5 | LL | x86(); | ^^^^^ error: functions with the "x86-interrupt" ABI cannot be called - --> $DIR/cannot-be-called.rs:91:5 + --> $DIR/cannot-be-called.rs:90:5 | LL | f() | ^^^ | note: an `extern "x86-interrupt"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:91:5 + --> $DIR/cannot-be-called.rs:90:5 | LL | f() | ^^^ -error: aborting due to 6 previous errors; 4 warnings emitted +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:67:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/cannot-be-called.rs:74:19 - | -LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-s" is not supported on this target - --> $DIR/cannot-be-called.rs:81:19 - | -LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - diff --git a/tests/ui/abi/cannot-be-called.msp430.stderr b/tests/ui/abi/cannot-be-called.msp430.stderr index d7630d96f8c..52d7d792510 100644 --- a/tests/ui/abi/cannot-be-called.msp430.stderr +++ b/tests/ui/abi/cannot-be-called.msp430.stderr @@ -1,132 +1,75 @@ -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:67:15 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:39:8 | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | extern "avr-interrupt" fn avr() {} + | ^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/cannot-be-called.rs:74:19 - | -LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:41:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "riscv-interrupt-m" fn riscv_m() {} + | ^^^^^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-s" is not supported on this target - --> $DIR/cannot-be-called.rs:81:19 - | -LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "riscv-interrupt-s" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:43:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "riscv-interrupt-s" fn riscv_s() {} + | ^^^^^^^^^^^^^^^^^^^ -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:88:15 +error[E0570]: "x86-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:45:8 | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "x86-interrupt" fn x86() {} + | ^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:38:1 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:64:22 | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { + | ^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:40:1 +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:76:26 | -LL | extern "riscv-interrupt-m" fn riscv_m() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-s"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:42:1 +error[E0570]: "riscv-interrupt-s" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:82:26 | -LL | extern "riscv-interrupt-s" fn riscv_s() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:44:1 +error[E0570]: "x86-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:88:22 | -LL | extern "x86-interrupt" fn x86() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { + | ^^^^^^^^^^^^^^^ error: functions with the "msp430-interrupt" ABI cannot be called - --> $DIR/cannot-be-called.rs:48:5 + --> $DIR/cannot-be-called.rs:52:5 | LL | msp430(); | ^^^^^^^^ | note: an `extern "msp430-interrupt"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:48:5 + --> $DIR/cannot-be-called.rs:52:5 | LL | msp430(); | ^^^^^^^^ error: functions with the "msp430-interrupt" ABI cannot be called - --> $DIR/cannot-be-called.rs:63:5 + --> $DIR/cannot-be-called.rs:72:5 | LL | f() | ^^^ | note: an `extern "msp430-interrupt"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:63:5 + --> $DIR/cannot-be-called.rs:72:5 | LL | f() | ^^^ -error: aborting due to 6 previous errors; 4 warnings emitted +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:67:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/cannot-be-called.rs:74:19 - | -LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-s" is not supported on this target - --> $DIR/cannot-be-called.rs:81:19 - | -LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:88:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - diff --git a/tests/ui/abi/cannot-be-called.riscv32.stderr b/tests/ui/abi/cannot-be-called.riscv32.stderr index 9fadbd639b8..119d93bd58e 100644 --- a/tests/ui/abi/cannot-be-called.riscv32.stderr +++ b/tests/ui/abi/cannot-be-called.riscv32.stderr @@ -1,81 +1,71 @@ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:60:18 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:37:8 | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | extern "msp430-interrupt" fn msp430() {} + | ^^^^^^^^^^^^^^^^^^ -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:67:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:39:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "avr-interrupt" fn avr() {} + | ^^^^^^^^^^^^^^^ -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:88:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "x86-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:45:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "x86-interrupt" fn x86() {} + | ^^^^^^^^^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:36:1 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:64:22 | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { + | ^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:38:1 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:70:25 | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { + | ^^^^^^^^^^^^^^^^^^ -error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:44:1 +error[E0570]: "x86-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:88:22 | -LL | extern "x86-interrupt" fn x86() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { + | ^^^^^^^^^^^^^^^ error: functions with the "riscv-interrupt-m" ABI cannot be called - --> $DIR/cannot-be-called.rs:52:5 + --> $DIR/cannot-be-called.rs:54:5 | LL | riscv_m(); | ^^^^^^^^^ | note: an `extern "riscv-interrupt-m"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:52:5 + --> $DIR/cannot-be-called.rs:54:5 | LL | riscv_m(); | ^^^^^^^^^ error: functions with the "riscv-interrupt-s" ABI cannot be called - --> $DIR/cannot-be-called.rs:54:5 + --> $DIR/cannot-be-called.rs:56:5 | LL | riscv_s(); | ^^^^^^^^^ | note: an `extern "riscv-interrupt-s"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:54:5 + --> $DIR/cannot-be-called.rs:56:5 | LL | riscv_s(); | ^^^^^^^^^ error: functions with the "riscv-interrupt-m" ABI cannot be called - --> $DIR/cannot-be-called.rs:77:5 + --> $DIR/cannot-be-called.rs:78:5 | LL | f() | ^^^ | note: an `extern "riscv-interrupt-m"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:77:5 + --> $DIR/cannot-be-called.rs:78:5 | LL | f() | ^^^ @@ -92,39 +82,6 @@ note: an `extern "riscv-interrupt-s"` function can only be called using inline a LL | f() | ^^^ -error: aborting due to 7 previous errors; 3 warnings emitted +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:67:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:88:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - diff --git a/tests/ui/abi/cannot-be-called.riscv64.stderr b/tests/ui/abi/cannot-be-called.riscv64.stderr index 9fadbd639b8..119d93bd58e 100644 --- a/tests/ui/abi/cannot-be-called.riscv64.stderr +++ b/tests/ui/abi/cannot-be-called.riscv64.stderr @@ -1,81 +1,71 @@ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:60:18 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:37:8 | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | extern "msp430-interrupt" fn msp430() {} + | ^^^^^^^^^^^^^^^^^^ -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:67:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:39:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "avr-interrupt" fn avr() {} + | ^^^^^^^^^^^^^^^ -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:88:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "x86-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:45:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "x86-interrupt" fn x86() {} + | ^^^^^^^^^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:36:1 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:64:22 | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { + | ^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:38:1 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:70:25 | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { + | ^^^^^^^^^^^^^^^^^^ -error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:44:1 +error[E0570]: "x86-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:88:22 | -LL | extern "x86-interrupt" fn x86() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { + | ^^^^^^^^^^^^^^^ error: functions with the "riscv-interrupt-m" ABI cannot be called - --> $DIR/cannot-be-called.rs:52:5 + --> $DIR/cannot-be-called.rs:54:5 | LL | riscv_m(); | ^^^^^^^^^ | note: an `extern "riscv-interrupt-m"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:52:5 + --> $DIR/cannot-be-called.rs:54:5 | LL | riscv_m(); | ^^^^^^^^^ error: functions with the "riscv-interrupt-s" ABI cannot be called - --> $DIR/cannot-be-called.rs:54:5 + --> $DIR/cannot-be-called.rs:56:5 | LL | riscv_s(); | ^^^^^^^^^ | note: an `extern "riscv-interrupt-s"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:54:5 + --> $DIR/cannot-be-called.rs:56:5 | LL | riscv_s(); | ^^^^^^^^^ error: functions with the "riscv-interrupt-m" ABI cannot be called - --> $DIR/cannot-be-called.rs:77:5 + --> $DIR/cannot-be-called.rs:78:5 | LL | f() | ^^^ | note: an `extern "riscv-interrupt-m"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:77:5 + --> $DIR/cannot-be-called.rs:78:5 | LL | f() | ^^^ @@ -92,39 +82,6 @@ note: an `extern "riscv-interrupt-s"` function can only be called using inline a LL | f() | ^^^ -error: aborting due to 7 previous errors; 3 warnings emitted +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:67:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:88:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - diff --git a/tests/ui/abi/cannot-be-called.rs b/tests/ui/abi/cannot-be-called.rs index 89173655a4a..af979d65d33 100644 --- a/tests/ui/abi/cannot-be-called.rs +++ b/tests/ui/abi/cannot-be-called.rs @@ -1,3 +1,8 @@ +/*! Tests entry-point ABIs cannot be called + +Interrupt ABIs share similar semantics, in that they are special entry-points unusable by Rust. +So we test that they error in essentially all of the same places. +*/ //@ add-core-stubs //@ revisions: x64 x64_win i686 riscv32 riscv64 avr msp430 // @@ -18,21 +23,17 @@ #![no_core] #![feature( no_core, - lang_items, - abi_ptx, abi_msp430_interrupt, abi_avr_interrupt, - abi_gpu_kernel, abi_x86_interrupt, - abi_riscv_interrupt, - abi_c_cmse_nonsecure_call, - abi_vectorcall, - cmse_nonsecure_entry + abi_riscv_interrupt )] extern crate minicore; use minicore::*; +/* extern "interrupt" definition */ + extern "msp430-interrupt" fn msp430() {} //[x64,x64_win,i686,riscv32,riscv64,avr]~^ ERROR is not a supported ABI extern "avr-interrupt" fn avr() {} @@ -44,11 +45,12 @@ extern "riscv-interrupt-s" fn riscv_s() {} extern "x86-interrupt" fn x86() {} //[riscv32,riscv64,avr,msp430]~^ ERROR is not a supported ABI +/* extern "interrupt" calls */ fn call_the_interrupts() { - msp430(); - //[msp430]~^ ERROR functions with the "msp430-interrupt" ABI cannot be called avr(); //[avr]~^ ERROR functions with the "avr-interrupt" ABI cannot be called + msp430(); + //[msp430]~^ ERROR functions with the "msp430-interrupt" ABI cannot be called riscv_m(); //[riscv32,riscv64]~^ ERROR functions with the "riscv-interrupt-m" ABI cannot be called riscv_s(); @@ -57,37 +59,34 @@ fn call_the_interrupts() { //[x64,x64_win,i686]~^ ERROR functions with the "x86-interrupt" ABI cannot be called } -fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - //[x64,x64_win,i686,riscv32,riscv64,avr]~^ WARN unsupported_fn_ptr_calling_conventions - //[x64,x64_win,i686,riscv32,riscv64,avr]~^^ WARN this was previously accepted - f() - //[msp430]~^ ERROR functions with the "msp430-interrupt" ABI cannot be called -} +/* extern "interrupt" fnptr calls */ fn avr_ptr(f: extern "avr-interrupt" fn()) { - //[x64,x64_win,i686,riscv32,riscv64,msp430]~^ WARN unsupported_fn_ptr_calling_conventions - //[x64,x64_win,i686,riscv32,riscv64,msp430]~^^ WARN this was previously accepted + //[x64,x64_win,i686,riscv32,riscv64,msp430]~^ ERROR is not a supported ABI f() //[avr]~^ ERROR functions with the "avr-interrupt" ABI cannot be called } +fn msp430_ptr(f: extern "msp430-interrupt" fn()) { + //[x64,x64_win,i686,riscv32,riscv64,avr]~^ ERROR is not a supported ABI + f() + //[msp430]~^ ERROR functions with the "msp430-interrupt" ABI cannot be called +} + fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { - //[x64,x64_win,i686,avr,msp430]~^ WARN unsupported_fn_ptr_calling_conventions - //[x64,x64_win,i686,avr,msp430]~^^ WARN this was previously accepted + //[x64,x64_win,i686,avr,msp430]~^ ERROR is not a supported ABI f() //[riscv32,riscv64]~^ ERROR functions with the "riscv-interrupt-m" ABI cannot be called } fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { - //[x64,x64_win,i686,avr,msp430]~^ WARN unsupported_fn_ptr_calling_conventions - //[x64,x64_win,i686,avr,msp430]~^^ WARN this was previously accepted + //[x64,x64_win,i686,avr,msp430]~^ ERROR is not a supported ABI f() //[riscv32,riscv64]~^ ERROR functions with the "riscv-interrupt-s" ABI cannot be called } fn x86_ptr(f: extern "x86-interrupt" fn()) { - //[riscv32,riscv64,avr,msp430]~^ WARN unsupported_fn_ptr_calling_conventions - //[riscv32,riscv64,avr,msp430]~^^ WARN this was previously accepted + //[riscv32,riscv64,avr,msp430]~^ ERROR is not a supported ABI f() //[x64,x64_win,i686]~^ ERROR functions with the "x86-interrupt" ABI cannot be called } diff --git a/tests/ui/abi/cannot-be-called.x64.stderr b/tests/ui/abi/cannot-be-called.x64.stderr index 113b40eb67b..024d5e2e93d 100644 --- a/tests/ui/abi/cannot-be-called.x64.stderr +++ b/tests/ui/abi/cannot-be-called.x64.stderr @@ -1,132 +1,75 @@ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:60:18 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:37:8 | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | extern "msp430-interrupt" fn msp430() {} + | ^^^^^^^^^^^^^^^^^^ -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:67:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:39:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "avr-interrupt" fn avr() {} + | ^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/cannot-be-called.rs:74:19 - | -LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:41:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "riscv-interrupt-m" fn riscv_m() {} + | ^^^^^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-s" is not supported on this target - --> $DIR/cannot-be-called.rs:81:19 +error[E0570]: "riscv-interrupt-s" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:43:8 | -LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "riscv-interrupt-s" fn riscv_s() {} + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:36:1 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:64:22 | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { + | ^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:38:1 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:70:25 | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { + | ^^^^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:40:1 +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:76:26 | -LL | extern "riscv-interrupt-m" fn riscv_m() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-s"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:42:1 +error[E0570]: "riscv-interrupt-s" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:82:26 | -LL | extern "riscv-interrupt-s" fn riscv_s() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { + | ^^^^^^^^^^^^^^^^^^^ error: functions with the "x86-interrupt" ABI cannot be called - --> $DIR/cannot-be-called.rs:56:5 + --> $DIR/cannot-be-called.rs:58:5 | LL | x86(); | ^^^^^ | note: an `extern "x86-interrupt"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:56:5 + --> $DIR/cannot-be-called.rs:58:5 | LL | x86(); | ^^^^^ error: functions with the "x86-interrupt" ABI cannot be called - --> $DIR/cannot-be-called.rs:91:5 + --> $DIR/cannot-be-called.rs:90:5 | LL | f() | ^^^ | note: an `extern "x86-interrupt"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:91:5 + --> $DIR/cannot-be-called.rs:90:5 | LL | f() | ^^^ -error: aborting due to 6 previous errors; 4 warnings emitted +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:67:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/cannot-be-called.rs:74:19 - | -LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-s" is not supported on this target - --> $DIR/cannot-be-called.rs:81:19 - | -LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - diff --git a/tests/ui/abi/cannot-be-called.x64_win.stderr b/tests/ui/abi/cannot-be-called.x64_win.stderr index 113b40eb67b..024d5e2e93d 100644 --- a/tests/ui/abi/cannot-be-called.x64_win.stderr +++ b/tests/ui/abi/cannot-be-called.x64_win.stderr @@ -1,132 +1,75 @@ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:60:18 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:37:8 | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | extern "msp430-interrupt" fn msp430() {} + | ^^^^^^^^^^^^^^^^^^ -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:67:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:39:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "avr-interrupt" fn avr() {} + | ^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/cannot-be-called.rs:74:19 - | -LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:41:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "riscv-interrupt-m" fn riscv_m() {} + | ^^^^^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-s" is not supported on this target - --> $DIR/cannot-be-called.rs:81:19 +error[E0570]: "riscv-interrupt-s" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:43:8 | -LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "riscv-interrupt-s" fn riscv_s() {} + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:36:1 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:64:22 | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { + | ^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:38:1 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:70:25 | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { + | ^^^^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:40:1 +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:76:26 | -LL | extern "riscv-interrupt-m" fn riscv_m() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-s"` is not a supported ABI for the current target - --> $DIR/cannot-be-called.rs:42:1 +error[E0570]: "riscv-interrupt-s" is not a supported ABI for the current target + --> $DIR/cannot-be-called.rs:82:26 | -LL | extern "riscv-interrupt-s" fn riscv_s() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { + | ^^^^^^^^^^^^^^^^^^^ error: functions with the "x86-interrupt" ABI cannot be called - --> $DIR/cannot-be-called.rs:56:5 + --> $DIR/cannot-be-called.rs:58:5 | LL | x86(); | ^^^^^ | note: an `extern "x86-interrupt"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:56:5 + --> $DIR/cannot-be-called.rs:58:5 | LL | x86(); | ^^^^^ error: functions with the "x86-interrupt" ABI cannot be called - --> $DIR/cannot-be-called.rs:91:5 + --> $DIR/cannot-be-called.rs:90:5 | LL | f() | ^^^ | note: an `extern "x86-interrupt"` function can only be called using inline assembly - --> $DIR/cannot-be-called.rs:91:5 + --> $DIR/cannot-be-called.rs:90:5 | LL | f() | ^^^ -error: aborting due to 6 previous errors; 4 warnings emitted +error: aborting due to 10 previous errors For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/cannot-be-called.rs:67:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/cannot-be-called.rs:74:19 - | -LL | fn riscv_m_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-s" is not supported on this target - --> $DIR/cannot-be-called.rs:81:19 - | -LL | fn riscv_s_ptr(f: extern "riscv-interrupt-s" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - diff --git a/tests/ui/abi/cannot-be-coroutine.avr.stderr b/tests/ui/abi/cannot-be-coroutine.avr.stderr new file mode 100644 index 00000000000..027f98c95c4 --- /dev/null +++ b/tests/ui/abi/cannot-be-coroutine.avr.stderr @@ -0,0 +1,23 @@ +error: functions with the "avr-interrupt" ABI cannot be `async` + --> $DIR/cannot-be-coroutine.rs:36:1 + | +LL | async extern "avr-interrupt" fn avr() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `async` keyword from this definition + | +LL - async extern "avr-interrupt" fn avr() { +LL + extern "avr-interrupt" fn avr() { + | + +error: requires `ResumeTy` lang_item + --> $DIR/cannot-be-coroutine.rs:32:19 + | +LL | async fn vanilla(){ + | ___________________^ +LL | | +LL | | } + | |_^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/abi/cannot-be-coroutine.i686.stderr b/tests/ui/abi/cannot-be-coroutine.i686.stderr new file mode 100644 index 00000000000..8c9292b6a32 --- /dev/null +++ b/tests/ui/abi/cannot-be-coroutine.i686.stderr @@ -0,0 +1,23 @@ +error: functions with the "x86-interrupt" ABI cannot be `async` + --> $DIR/cannot-be-coroutine.rs:52:1 + | +LL | async extern "x86-interrupt" fn x86() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `async` keyword from this definition + | +LL - async extern "x86-interrupt" fn x86() { +LL + extern "x86-interrupt" fn x86() { + | + +error: requires `ResumeTy` lang_item + --> $DIR/cannot-be-coroutine.rs:32:19 + | +LL | async fn vanilla(){ + | ___________________^ +LL | | +LL | | } + | |_^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/abi/cannot-be-coroutine.msp430.stderr b/tests/ui/abi/cannot-be-coroutine.msp430.stderr new file mode 100644 index 00000000000..4b639cea9c1 --- /dev/null +++ b/tests/ui/abi/cannot-be-coroutine.msp430.stderr @@ -0,0 +1,23 @@ +error: functions with the "msp430-interrupt" ABI cannot be `async` + --> $DIR/cannot-be-coroutine.rs:40:1 + | +LL | async extern "msp430-interrupt" fn msp430() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `async` keyword from this definition + | +LL - async extern "msp430-interrupt" fn msp430() { +LL + extern "msp430-interrupt" fn msp430() { + | + +error: requires `ResumeTy` lang_item + --> $DIR/cannot-be-coroutine.rs:32:19 + | +LL | async fn vanilla(){ + | ___________________^ +LL | | +LL | | } + | |_^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/abi/cannot-be-coroutine.riscv32.stderr b/tests/ui/abi/cannot-be-coroutine.riscv32.stderr new file mode 100644 index 00000000000..1b18bc51f83 --- /dev/null +++ b/tests/ui/abi/cannot-be-coroutine.riscv32.stderr @@ -0,0 +1,35 @@ +error: functions with the "riscv-interrupt-m" ABI cannot be `async` + --> $DIR/cannot-be-coroutine.rs:44:1 + | +LL | async extern "riscv-interrupt-m" fn riscv_m() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `async` keyword from this definition + | +LL - async extern "riscv-interrupt-m" fn riscv_m() { +LL + extern "riscv-interrupt-m" fn riscv_m() { + | + +error: functions with the "riscv-interrupt-s" ABI cannot be `async` + --> $DIR/cannot-be-coroutine.rs:48:1 + | +LL | async extern "riscv-interrupt-s" fn riscv_s() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `async` keyword from this definition + | +LL - async extern "riscv-interrupt-s" fn riscv_s() { +LL + extern "riscv-interrupt-s" fn riscv_s() { + | + +error: requires `ResumeTy` lang_item + --> $DIR/cannot-be-coroutine.rs:32:19 + | +LL | async fn vanilla(){ + | ___________________^ +LL | | +LL | | } + | |_^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/abi/cannot-be-coroutine.riscv64.stderr b/tests/ui/abi/cannot-be-coroutine.riscv64.stderr new file mode 100644 index 00000000000..1b18bc51f83 --- /dev/null +++ b/tests/ui/abi/cannot-be-coroutine.riscv64.stderr @@ -0,0 +1,35 @@ +error: functions with the "riscv-interrupt-m" ABI cannot be `async` + --> $DIR/cannot-be-coroutine.rs:44:1 + | +LL | async extern "riscv-interrupt-m" fn riscv_m() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `async` keyword from this definition + | +LL - async extern "riscv-interrupt-m" fn riscv_m() { +LL + extern "riscv-interrupt-m" fn riscv_m() { + | + +error: functions with the "riscv-interrupt-s" ABI cannot be `async` + --> $DIR/cannot-be-coroutine.rs:48:1 + | +LL | async extern "riscv-interrupt-s" fn riscv_s() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `async` keyword from this definition + | +LL - async extern "riscv-interrupt-s" fn riscv_s() { +LL + extern "riscv-interrupt-s" fn riscv_s() { + | + +error: requires `ResumeTy` lang_item + --> $DIR/cannot-be-coroutine.rs:32:19 + | +LL | async fn vanilla(){ + | ___________________^ +LL | | +LL | | } + | |_^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/abi/cannot-be-coroutine.rs b/tests/ui/abi/cannot-be-coroutine.rs new file mode 100644 index 00000000000..7270a55f69e --- /dev/null +++ b/tests/ui/abi/cannot-be-coroutine.rs @@ -0,0 +1,54 @@ +//@ add-core-stubs +//@ edition: 2021 +//@ revisions: x64 x64_win i686 riscv32 riscv64 avr msp430 +// +//@ [x64] needs-llvm-components: x86 +//@ [x64] compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=rlib +//@ [x64_win] needs-llvm-components: x86 +//@ [x64_win] compile-flags: --target=x86_64-pc-windows-msvc --crate-type=rlib +//@ [i686] needs-llvm-components: x86 +//@ [i686] compile-flags: --target=i686-unknown-linux-gnu --crate-type=rlib +//@ [riscv32] needs-llvm-components: riscv +//@ [riscv32] compile-flags: --target=riscv32i-unknown-none-elf --crate-type=rlib +//@ [riscv64] needs-llvm-components: riscv +//@ [riscv64] compile-flags: --target=riscv64gc-unknown-none-elf --crate-type=rlib +//@ [avr] needs-llvm-components: avr +//@ [avr] compile-flags: --target=avr-none -C target-cpu=atmega328p --crate-type=rlib +//@ [msp430] needs-llvm-components: msp430 +//@ [msp430] compile-flags: --target=msp430-none-elf --crate-type=rlib +#![no_core] +#![feature( + no_core, + abi_msp430_interrupt, + abi_avr_interrupt, + abi_x86_interrupt, + abi_riscv_interrupt +)] + +extern crate minicore; +use minicore::*; + +// We ignore this error; implementing all of the async-related lang items is not worth it. +async fn vanilla(){ + //~^ ERROR requires `ResumeTy` lang_item +} + +async extern "avr-interrupt" fn avr() { + //[avr]~^ ERROR functions with the "avr-interrupt" ABI cannot be `async` +} + +async extern "msp430-interrupt" fn msp430() { + //[msp430]~^ ERROR functions with the "msp430-interrupt" ABI cannot be `async` +} + +async extern "riscv-interrupt-m" fn riscv_m() { + //[riscv32,riscv64]~^ ERROR functions with the "riscv-interrupt-m" ABI cannot be `async` +} + +async extern "riscv-interrupt-s" fn riscv_s() { + //[riscv32,riscv64]~^ ERROR functions with the "riscv-interrupt-s" ABI cannot be `async` +} + +async extern "x86-interrupt" fn x86() { + //[x64,x64_win,i686]~^ ERROR functions with the "x86-interrupt" ABI cannot be `async` +} diff --git a/tests/ui/abi/cannot-be-coroutine.x64.stderr b/tests/ui/abi/cannot-be-coroutine.x64.stderr new file mode 100644 index 00000000000..8c9292b6a32 --- /dev/null +++ b/tests/ui/abi/cannot-be-coroutine.x64.stderr @@ -0,0 +1,23 @@ +error: functions with the "x86-interrupt" ABI cannot be `async` + --> $DIR/cannot-be-coroutine.rs:52:1 + | +LL | async extern "x86-interrupt" fn x86() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `async` keyword from this definition + | +LL - async extern "x86-interrupt" fn x86() { +LL + extern "x86-interrupt" fn x86() { + | + +error: requires `ResumeTy` lang_item + --> $DIR/cannot-be-coroutine.rs:32:19 + | +LL | async fn vanilla(){ + | ___________________^ +LL | | +LL | | } + | |_^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/abi/cannot-be-coroutine.x64_win.stderr b/tests/ui/abi/cannot-be-coroutine.x64_win.stderr new file mode 100644 index 00000000000..8c9292b6a32 --- /dev/null +++ b/tests/ui/abi/cannot-be-coroutine.x64_win.stderr @@ -0,0 +1,23 @@ +error: functions with the "x86-interrupt" ABI cannot be `async` + --> $DIR/cannot-be-coroutine.rs:52:1 + | +LL | async extern "x86-interrupt" fn x86() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: remove the `async` keyword from this definition + | +LL - async extern "x86-interrupt" fn x86() { +LL + extern "x86-interrupt" fn x86() { + | + +error: requires `ResumeTy` lang_item + --> $DIR/cannot-be-coroutine.rs:32:19 + | +LL | async fn vanilla(){ + | ___________________^ +LL | | +LL | | } + | |_^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/abi/debug.stderr b/tests/ui/abi/debug.generic.stderr index 8ed6dedf4d5..3b29efc8102 100644 --- a/tests/ui/abi/debug.stderr +++ b/tests/ui/abi/debug.generic.stderr @@ -89,9 +89,9 @@ error: fn_abi_of(test) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:16:1 + --> $DIR/debug.rs:27:1 | -LL | fn test(_x: u8) -> bool { true } +LL | fn test(_x: u8) -> bool { | ^^^^^^^^^^^^^^^^^^^^^^^ error: fn_abi_of(TestFnPtr) = FnAbi { @@ -185,7 +185,7 @@ error: fn_abi_of(TestFnPtr) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:19:1 + --> $DIR/debug.rs:33:1 | LL | type TestFnPtr = fn(bool) -> u8; | ^^^^^^^^^^^^^^ @@ -263,13 +263,13 @@ error: fn_abi_of(test_generic) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:22:1 + --> $DIR/debug.rs:36:1 | -LL | fn test_generic<T>(_x: *const T) { } +LL | fn test_generic<T>(_x: *const T) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions - --> $DIR/debug.rs:25:1 + --> $DIR/debug.rs:39:1 | LL | const C: () = (); | ^^^^^^^^^^^ @@ -419,7 +419,7 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:41:1 + --> $DIR/debug.rs:55:1 | LL | type TestAbiNe = (fn(u8), fn(u32)); | ^^^^^^^^^^^^^^ @@ -571,7 +571,7 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:44:1 + --> $DIR/debug.rs:58:1 | LL | type TestAbiNeLarger = (fn([u8; 32]), fn([u32; 32])); | ^^^^^^^^^^^^^^^^^^^^ @@ -720,7 +720,7 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:47:1 + --> $DIR/debug.rs:61:1 | LL | type TestAbiNeFloat = (fn(f32), fn(u32)); | ^^^^^^^^^^^^^^^^^^^ @@ -870,13 +870,13 @@ error: ABIs are not compatible conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:51:1 + --> $DIR/debug.rs:65:1 | LL | type TestAbiNeSign = (fn(i32), fn(u32)); | ^^^^^^^^^^^^^^^^^^ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/debug.rs:54:46 + --> $DIR/debug.rs:68:46 | LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); | ^^^^^^^^^^ doesn't have a size known at compile-time @@ -885,13 +885,13 @@ LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); = note: only the last element of a tuple may have a dynamically sized type error: unrecognized argument - --> $DIR/debug.rs:56:13 + --> $DIR/debug.rs:70:13 | LL | #[rustc_abi("assert_eq")] | ^^^^^^^^^^^ error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions - --> $DIR/debug.rs:29:5 + --> $DIR/debug.rs:43:5 | LL | const C: () = (); | ^^^^^^^^^^^ @@ -981,9 +981,9 @@ error: fn_abi_of(assoc_test) = FnAbi { conv: Rust, can_unwind: $SOME_BOOL, } - --> $DIR/debug.rs:34:5 + --> $DIR/debug.rs:48:5 | -LL | fn assoc_test(&self) { } +LL | fn assoc_test(&self) {} | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 12 previous errors diff --git a/tests/ui/abi/debug.riscv64.stderr b/tests/ui/abi/debug.riscv64.stderr new file mode 100644 index 00000000000..2417396de2f --- /dev/null +++ b/tests/ui/abi/debug.riscv64.stderr @@ -0,0 +1,991 @@ +error: fn_abi_of(test) = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: u8, + layout: Layout { + size: Size(1 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=255, + }, + ), + fields: Primitive, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: Zext, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: bool, + layout: Layout { + size: Size(1 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), + fields: Primitive, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: Zext, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + --> $DIR/debug.rs:27:1 + | +LL | fn test(_x: u8) -> bool { + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: fn_abi_of(TestFnPtr) = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: bool, + layout: Layout { + size: Size(1 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), + fields: Primitive, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Int( + I8, + false, + ), + valid_range: 0..=1, + }, + ), + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: Zext, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: u8, + layout: Layout { + size: Size(1 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=255, + }, + ), + fields: Primitive, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: None, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + --> $DIR/debug.rs:33:1 + | +LL | type TestFnPtr = fn(bool) -> u8; + | ^^^^^^^^^^^^^^ + +error: fn_abi_of(test_generic) = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: *const T, + layout: Layout { + size: $SOME_SIZE, + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Pointer( + AddressSpace( + 0, + ), + ), + valid_range: $FULL, + }, + ), + fields: Primitive, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: None, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + --> $DIR/debug.rs:36:1 + | +LL | fn test_generic<T>(_x: *const T) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions + --> $DIR/debug.rs:39:1 + | +LL | const C: () = (); + | ^^^^^^^^^^^ + +error: ABIs are not compatible + left ABI = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: u8, + layout: Layout { + size: Size(1 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Int( + I8, + false, + ), + valid_range: 0..=255, + }, + ), + fields: Primitive, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: Zext, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + right ABI = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: u32, + layout: Layout { + size: $SOME_SIZE, + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: $FULL, + }, + ), + fields: Primitive, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: Sext, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + --> $DIR/debug.rs:55:1 + | +LL | type TestAbiNe = (fn(u8), fn(u32)); + | ^^^^^^^^^^^^^^ + +error: ABIs are not compatible + left ABI = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: [u8; 32], + layout: Layout { + size: Size(32 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: true, + }, + fields: Array { + stride: Size(1 bytes), + count: 32, + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Indirect { + attrs: ArgAttributes { + regular: NoAlias | NoCapture | NonNull | NoUndef, + arg_ext: None, + pointee_size: Size(32 bytes), + pointee_align: Some( + Align(1 bytes), + ), + }, + meta_attrs: None, + on_stack: false, + }, + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + right ABI = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: [u32; 32], + layout: Layout { + size: Size(128 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: true, + }, + fields: Array { + stride: Size(4 bytes), + count: 32, + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Indirect { + attrs: ArgAttributes { + regular: NoAlias | NoCapture | NonNull | NoUndef, + arg_ext: None, + pointee_size: Size(128 bytes), + pointee_align: Some( + Align(4 bytes), + ), + }, + meta_attrs: None, + on_stack: false, + }, + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + --> $DIR/debug.rs:58:1 + | +LL | type TestAbiNeLarger = (fn([u8; 32]), fn([u32; 32])); + | ^^^^^^^^^^^^^^^^^^^^ + +error: ABIs are not compatible + left ABI = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: f32, + layout: Layout { + size: $SOME_SIZE, + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Float( + F32, + ), + valid_range: $FULL, + }, + ), + fields: Primitive, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: None, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + right ABI = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: u32, + layout: Layout { + size: $SOME_SIZE, + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: $FULL, + }, + ), + fields: Primitive, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: Sext, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + --> $DIR/debug.rs:61:1 + | +LL | type TestAbiNeFloat = (fn(f32), fn(u32)); + | ^^^^^^^^^^^^^^^^^^^ + +error: ABIs are not compatible + left ABI = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: i32, + layout: Layout { + size: $SOME_SIZE, + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Int( + I32, + true, + ), + valid_range: $FULL, + }, + ), + fields: Primitive, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: Sext, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + right ABI = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: u32, + layout: Layout { + size: $SOME_SIZE, + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Int( + I32, + false, + ), + valid_range: $FULL, + }, + ), + fields: Primitive, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoUndef, + arg_ext: Sext, + pointee_size: Size(0 bytes), + pointee_align: None, + }, + ), + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + --> $DIR/debug.rs:65:1 + | +LL | type TestAbiNeSign = (fn(i32), fn(u32)); + | ^^^^^^^^^^^^^^^^^^ + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/debug.rs:68:46 + | +LL | type TestAbiEqNonsense = (fn((str, str)), fn((str, str))); + | ^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: only the last element of a tuple may have a dynamically sized type + +error: unrecognized argument + --> $DIR/debug.rs:70:13 + | +LL | #[rustc_abi("assert_eq")] + | ^^^^^^^^^^^ + +error: `#[rustc_abi]` can only be applied to function items, type aliases, and associated functions + --> $DIR/debug.rs:43:5 + | +LL | const C: () = (); + | ^^^^^^^^^^^ + +error: fn_abi_of(assoc_test) = FnAbi { + args: [ + ArgAbi { + layout: TyAndLayout { + ty: &S, + layout: Layout { + size: $SOME_SIZE, + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Scalar( + Initialized { + value: Pointer( + AddressSpace( + 0, + ), + ), + valid_range: $NON_NULL, + }, + ), + fields: Primitive, + largest_niche: Some( + Niche { + offset: Size(0 bytes), + value: Pointer( + AddressSpace( + 0, + ), + ), + valid_range: $NON_NULL, + }, + ), + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Direct( + ArgAttributes { + regular: NoAlias | NonNull | ReadOnly | NoUndef, + arg_ext: None, + pointee_size: Size(2 bytes), + pointee_align: Some( + Align(2 bytes), + ), + }, + ), + }, + ], + ret: ArgAbi { + layout: TyAndLayout { + ty: (), + layout: Layout { + size: Size(0 bytes), + align: AbiAlign { + abi: $SOME_ALIGN, + }, + backend_repr: Memory { + sized: true, + }, + fields: Arbitrary { + offsets: [], + memory_index: [], + }, + largest_niche: None, + uninhabited: false, + variants: Single { + index: 0, + }, + max_repr_align: None, + unadjusted_abi_align: $SOME_ALIGN, + randomization_seed: $SEED, + }, + }, + mode: Ignore, + }, + c_variadic: false, + fixed_count: 1, + conv: Rust, + can_unwind: $SOME_BOOL, + } + --> $DIR/debug.rs:48:5 + | +LL | fn assoc_test(&self) {} + | ^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 12 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/abi/debug.rs b/tests/ui/abi/debug.rs index c0d8de05fda..cc1589d8621 100644 --- a/tests/ui/abi/debug.rs +++ b/tests/ui/abi/debug.rs @@ -1,3 +1,4 @@ +//@ add-core-stubs //@ normalize-stderr: "(abi|pref|unadjusted_abi_align): Align\([1-8] bytes\)" -> "$1: $$SOME_ALIGN" //@ normalize-stderr: "randomization_seed: \d+" -> "randomization_seed: $$SEED" //@ normalize-stderr: "(size): Size\([48] bytes\)" -> "$1: $$SOME_SIZE" @@ -7,19 +8,32 @@ //@ normalize-stderr: "(valid_range): [1-9]\.\.=(429496729[0-9]|1844674407370955161[0-9])" -> "$1: $$NON_NULL" // Some attributes are only computed for release builds: //@ compile-flags: -O +//@ revisions: generic riscv64 +//@ [riscv64] compile-flags: --target riscv64gc-unknown-linux-gnu +//@ [riscv64] needs-llvm-components: riscv +//@ [generic] ignore-riscv64 #![feature(rustc_attrs)] #![crate_type = "lib"] +#![feature(no_core)] +#![no_std] +#![no_core] + +extern crate minicore; +use minicore::*; struct S(u16); #[rustc_abi(debug)] -fn test(_x: u8) -> bool { true } //~ ERROR: fn_abi +fn test(_x: u8) -> bool { + //~^ ERROR: fn_abi + true +} #[rustc_abi(debug)] type TestFnPtr = fn(bool) -> u8; //~ ERROR: fn_abi #[rustc_abi(debug)] -fn test_generic<T>(_x: *const T) { } //~ ERROR: fn_abi +fn test_generic<T>(_x: *const T) {} //~ ERROR: fn_abi #[rustc_abi(debug)] const C: () = (); //~ ERROR: can only be applied to @@ -31,7 +45,7 @@ impl S { impl S { #[rustc_abi(debug)] - fn assoc_test(&self) { } //~ ERROR: fn_abi + fn assoc_test(&self) {} //~ ERROR: fn_abi } #[rustc_abi(assert_eq)] diff --git a/tests/ui/abi/invalid-call-abi-ctfe.rs b/tests/ui/abi/invalid-call-abi-ctfe.rs new file mode 100644 index 00000000000..343cc728fe3 --- /dev/null +++ b/tests/ui/abi/invalid-call-abi-ctfe.rs @@ -0,0 +1,14 @@ +// Fix for #142969 where an invalid ABI in a signature still had its call ABI computed +// because CTFE tried to evaluate it, despite previous errors during AST-to-HIR lowering. + +#![feature(rustc_attrs)] + +const extern "rust-invalid" fn foo() { + //~^ ERROR "rust-invalid" is not a supported ABI for the current target + panic!() +} + +const _: () = foo(); + + +fn main() {} diff --git a/tests/ui/abi/invalid-call-abi-ctfe.stderr b/tests/ui/abi/invalid-call-abi-ctfe.stderr new file mode 100644 index 00000000000..402de4b69b9 --- /dev/null +++ b/tests/ui/abi/invalid-call-abi-ctfe.stderr @@ -0,0 +1,9 @@ +error[E0570]: "rust-invalid" is not a supported ABI for the current target + --> $DIR/invalid-call-abi-ctfe.rs:6:14 + | +LL | const extern "rust-invalid" fn foo() { + | ^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/invalid-call-abi.rs b/tests/ui/abi/invalid-call-abi.rs new file mode 100644 index 00000000000..076ddd91ab0 --- /dev/null +++ b/tests/ui/abi/invalid-call-abi.rs @@ -0,0 +1,12 @@ +// Tests the `"rustc-invalid"` ABI, which is never canonizable. + +#![feature(rustc_attrs)] + +const extern "rust-invalid" fn foo() { + //~^ ERROR "rust-invalid" is not a supported ABI for the current target + panic!() +} + +fn main() { + foo(); +} diff --git a/tests/ui/abi/invalid-call-abi.stderr b/tests/ui/abi/invalid-call-abi.stderr new file mode 100644 index 00000000000..c4a90158dcf --- /dev/null +++ b/tests/ui/abi/invalid-call-abi.stderr @@ -0,0 +1,9 @@ +error[E0570]: "rust-invalid" is not a supported ABI for the current target + --> $DIR/invalid-call-abi.rs:5:14 + | +LL | const extern "rust-invalid" fn foo() { + | ^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/rust-cold-works-with-rustic-args.rs b/tests/ui/abi/rust-cold-works-with-rustic-args.rs index 57027364699..551485469d3 100644 --- a/tests/ui/abi/rust-cold-works-with-rustic-args.rs +++ b/tests/ui/abi/rust-cold-works-with-rustic-args.rs @@ -1,6 +1,15 @@ -//@build-pass -//@compile-flags: -Clink-dead-code=true --crate-type lib +//@ add-core-stubs +//@ build-pass +//@ compile-flags: -Clink-dead-code=true // We used to not handle all "rustic" ABIs in a (relatively) uniform way, // so we failed to fix up arguments for actually passing through the ABI... #![feature(rust_cold_cc)] +#![crate_type = "lib"] +#![feature(no_core)] +#![no_std] +#![no_core] + +extern crate minicore; +use minicore::*; + pub extern "rust-cold" fn foo(_: [usize; 3]) {} diff --git a/tests/ui/abi/unsupported-abi-transmute.rs b/tests/ui/abi/unsupported-abi-transmute.rs new file mode 100644 index 00000000000..42aa180e1fd --- /dev/null +++ b/tests/ui/abi/unsupported-abi-transmute.rs @@ -0,0 +1,12 @@ +// Check we error before unsupported ABIs reach codegen stages. + +//@ edition: 2018 +//@ compile-flags: --crate-type=lib +#![feature(rustc_attrs)] + +use core::mem; + +fn anything() { + let a = unsafe { mem::transmute::<usize, extern "rust-invalid" fn(i32)>(4) }(2); + //~^ ERROR: is not a supported ABI for the current target [E0570] +} diff --git a/tests/ui/abi/unsupported-abi-transmute.stderr b/tests/ui/abi/unsupported-abi-transmute.stderr new file mode 100644 index 00000000000..f1d202b1a1c --- /dev/null +++ b/tests/ui/abi/unsupported-abi-transmute.stderr @@ -0,0 +1,9 @@ +error[E0570]: "rust-invalid" is not a supported ABI for the current target + --> $DIR/unsupported-abi-transmute.rs:10:53 + | +LL | let a = unsafe { mem::transmute::<usize, extern "rust-invalid" fn(i32)>(4) }(2); + | ^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported-in-impls.rs b/tests/ui/abi/unsupported-in-impls.rs new file mode 100644 index 00000000000..71797954865 --- /dev/null +++ b/tests/ui/abi/unsupported-in-impls.rs @@ -0,0 +1,36 @@ +// Test for https://github.com/rust-lang/rust/issues/86232 +// Due to AST-to-HIR lowering nuances, we used to allow unsupported ABIs to "leak" into the HIR +// without being checked, as we would check after generating the ExternAbi. +// Checking afterwards only works if we examine every HIR construct that contains an ExternAbi, +// and those may be very different in HIR, even if they read the same in source. +// This made it very easy to make mistakes. +// +// Here we test that an unsupported ABI in various impl-related positions will be rejected, +// both in the original declarations and the actual implementations. + +#![feature(rustc_attrs)] +//@ compile-flags: --crate-type lib + +pub struct FnPtrBearer { + pub ptr: extern "rust-invalid" fn(), + //~^ ERROR: is not a supported ABI +} + +impl FnPtrBearer { + pub extern "rust-invalid" fn inherent_fn(self) { + //~^ ERROR: is not a supported ABI + (self.ptr)() + } +} + +pub trait Trait { + extern "rust-invalid" fn trait_fn(self); + //~^ ERROR: is not a supported ABI +} + +impl Trait for FnPtrBearer { + extern "rust-invalid" fn trait_fn(self) { + //~^ ERROR: is not a supported ABI + self.inherent_fn() + } +} diff --git a/tests/ui/abi/unsupported-in-impls.stderr b/tests/ui/abi/unsupported-in-impls.stderr new file mode 100644 index 00000000000..d7a188f8a04 --- /dev/null +++ b/tests/ui/abi/unsupported-in-impls.stderr @@ -0,0 +1,27 @@ +error[E0570]: "rust-invalid" is not a supported ABI for the current target + --> $DIR/unsupported-in-impls.rs:15:21 + | +LL | pub ptr: extern "rust-invalid" fn(), + | ^^^^^^^^^^^^^^ + +error[E0570]: "rust-invalid" is not a supported ABI for the current target + --> $DIR/unsupported-in-impls.rs:20:16 + | +LL | pub extern "rust-invalid" fn inherent_fn(self) { + | ^^^^^^^^^^^^^^ + +error[E0570]: "rust-invalid" is not a supported ABI for the current target + --> $DIR/unsupported-in-impls.rs:27:12 + | +LL | extern "rust-invalid" fn trait_fn(self); + | ^^^^^^^^^^^^^^ + +error[E0570]: "rust-invalid" is not a supported ABI for the current target + --> $DIR/unsupported-in-impls.rs:32:12 + | +LL | extern "rust-invalid" fn trait_fn(self) { + | ^^^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported-varargs-fnptr.rs b/tests/ui/abi/unsupported-varargs-fnptr.rs new file mode 100644 index 00000000000..1d23916d039 --- /dev/null +++ b/tests/ui/abi/unsupported-varargs-fnptr.rs @@ -0,0 +1,19 @@ +// FIXME(workingjubilee): add revisions and generalize to other platform-specific varargs ABIs, +// preferably after the only-arch directive is enhanced with an "or pattern" syntax +// NOTE: This deliberately tests an ABI that supports varargs, so no `extern "rust-invalid"` +//@ only-x86_64 + +// We have to use this flag to force ABI computation of an invalid ABI +//@ compile-flags: -Clink-dead-code + +#![feature(extended_varargs_abi_support)] + +// sometimes fn ptrs with varargs make layout and ABI computation ICE +// as found in https://github.com/rust-lang/rust/issues/142107 + +fn aapcs(f: extern "aapcs" fn(usize, ...)) { +//~^ ERROR [E0570] +// Note we DO NOT have to actually make a call to trigger the ICE! +} + +fn main() {} diff --git a/tests/ui/abi/unsupported-varargs-fnptr.stderr b/tests/ui/abi/unsupported-varargs-fnptr.stderr new file mode 100644 index 00000000000..238f2b31330 --- /dev/null +++ b/tests/ui/abi/unsupported-varargs-fnptr.stderr @@ -0,0 +1,9 @@ +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported-varargs-fnptr.rs:14:20 + | +LL | fn aapcs(f: extern "aapcs" fn(usize, ...)) { + | ^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.aarch64.stderr b/tests/ui/abi/unsupported.aarch64.stderr index 7b9b9d5c978..61d07f29fd7 100644 --- a/tests/ui/abi/unsupported.aarch64.stderr +++ b/tests/ui/abi/unsupported.aarch64.stderr @@ -1,403 +1,202 @@ -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:36:8 | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "ptx-kernel" fn ptx() {} + | ^^^^^^^^^^^^ + +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:38:22 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { + | ^^^^^^^^^^^^ -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:42:8 | LL | extern "ptx-kernel" {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ -warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:50:17 +error[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:44:8 | -LL | fn aapcs_ptr(f: extern "aapcs" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "gpu-kernel" fn gpu() {} + | ^^^^^^^^^^^^ -error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:55:1 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:47:8 | -LL | extern "aapcs" {} - | ^^^^^^^^^^^^^^^^^ +LL | extern "aapcs" fn aapcs() {} + | ^^^^^^^ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:49:24 | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | fn aapcs_ptr(f: extern "aapcs" fn()) { + | ^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:65:1 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:53:8 | -LL | extern "msp430-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "aapcs" {} + | ^^^^^^^ -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:56:8 | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "msp430-interrupt" {} + | ^^^^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:75:1 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:59:8 | LL | extern "avr-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:80:17 - | -LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + | ^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:86:1 +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/unsupported.rs:62:8 | LL | extern "riscv-interrupt-m" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:91:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "x86-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:65:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "x86-interrupt" {} + | ^^^^^^^^^^^^^^^ -error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:97:1 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:68:8 | -LL | extern "x86-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "thiscall" fn thiscall() {} + | ^^^^^^^^^^ -warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:102:20 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:70:27 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + | ^^^^^^^^^^ -error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:107:1 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:74:8 | LL | extern "thiscall" {} - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ + +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:77:8 + | +LL | extern "stdcall" fn stdcall() {} + | ^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:114:19 +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:81:26 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:121:1 +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:87:8 | LL | extern "stdcall" {} - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:125:1 +error[E0570]: "stdcall-unwind" is not a supported ABI for the current target + --> $DIR/unsupported.rs:91:8 | LL | extern "stdcall-unwind" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:133:17 - | -LL | fn cdecl_ptr(f: extern "cdecl" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> - = help: use `extern "C"` instead - = note: `#[warn(unsupported_calling_conventions)]` on by default - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:138:1 - | -LL | extern "cdecl" {} - | ^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> - = help: use `extern "C"` instead - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:141:1 - | -LL | extern "cdecl-unwind" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "vectorcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:111:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> - = help: use `extern "C-unwind"` instead +LL | extern "vectorcall" fn vectorcall() {} + | ^^^^^^^^^^^^ -warning: the calling convention "vectorcall" is not supported on this target - --> $DIR/unsupported.rs:147:22 +error[E0570]: "vectorcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:113:29 | LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + | ^^^^^^^^^^^^ -error[E0570]: `"vectorcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:152:1 +error[E0570]: "vectorcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:117:8 | LL | extern "vectorcall" {} - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 - | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 - | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + | ^^^^^^^^^^^^ -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:168:1 +error[E0570]: "cmse-nonsecure-call" is not a supported ABI for the current target + --> $DIR/unsupported.rs:120:28 | -LL | extern "C-cmse-nonsecure-entry" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn cmse_call_ptr(f: extern "cmse-nonsecure-call" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:36:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:125:8 | -LL | extern "ptx-kernel" fn ptx() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cmse-nonsecure-entry" fn cmse_entry() {} + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:45:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:127:29 | -LL | extern "gpu-kernel" fn gpu() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn cmse_entry_ptr(f: extern "cmse-nonsecure-entry" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:48:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:131:8 | -LL | extern "aapcs" fn aapcs() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cmse-nonsecure-entry" {} + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:58:1 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:99:17 | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:68:1 - | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:78:1 - | -LL | extern "riscv-interrupt-m" fn riscv() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:89:1 - | -LL | extern "x86-interrupt" fn x86() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:100:1 - | -LL | extern "thiscall" fn thiscall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:110:1 - | -LL | extern "stdcall" fn stdcall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:130:1 - | -LL | extern "cdecl" fn cdecl() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default -error[E0570]: `"vectorcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:145:1 - | -LL | extern "vectorcall" fn vectorcall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:161:1 - | -LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 22 previous errors; 15 warnings emitted - -For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 - | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:50:17 - | -LL | fn aapcs_ptr(f: extern "aapcs" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:80:17 - | -LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:91:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:102:20 - | -LL | fn thiscall_ptr(f: extern "thiscall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:114:19 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:104:1 | -LL | fn stdcall_ptr(f: extern "stdcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead -Future breakage diagnostic: -warning: the calling convention "vectorcall" is not supported on this target - --> $DIR/unsupported.rs:147:22 +warning: "cdecl-unwind" is not a supported ABI for the current target + --> $DIR/unsupported.rs:107:1 | -LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:96:1 | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 - | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +error: aborting due to 25 previous errors; 4 warnings emitted +For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.arm.stderr b/tests/ui/abi/unsupported.arm.stderr index 5b057bdcbae..37b6e2316b0 100644 --- a/tests/ui/abi/unsupported.arm.stderr +++ b/tests/ui/abi/unsupported.arm.stderr @@ -1,371 +1,184 @@ -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:36:8 | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "ptx-kernel" fn ptx() {} + | ^^^^^^^^^^^^ + +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:38:22 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { + | ^^^^^^^^^^^^ -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:42:8 | LL | extern "ptx-kernel" {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 +error[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:44:8 | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "gpu-kernel" fn gpu() {} + | ^^^^^^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:65:1 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:56:8 | LL | extern "msp430-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + | ^^^^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:75:1 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:59:8 | LL | extern "avr-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:80:17 - | -LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:86:1 +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/unsupported.rs:62:8 | LL | extern "riscv-interrupt-m" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:91:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "x86-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:65:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "x86-interrupt" {} + | ^^^^^^^^^^^^^^^ -error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:97:1 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:68:8 | -LL | extern "x86-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "thiscall" fn thiscall() {} + | ^^^^^^^^^^ -warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:102:20 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:70:27 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + | ^^^^^^^^^^ -error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:107:1 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:74:8 | LL | extern "thiscall" {} - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ -warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:114:19 +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:77:8 + | +LL | extern "stdcall" fn stdcall() {} + | ^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:81:26 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:121:1 +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:87:8 | LL | extern "stdcall" {} - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:125:1 +error[E0570]: "stdcall-unwind" is not a supported ABI for the current target + --> $DIR/unsupported.rs:91:8 | LL | extern "stdcall-unwind" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:133:17 - | -LL | fn cdecl_ptr(f: extern "cdecl" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> - = help: use `extern "C"` instead - = note: `#[warn(unsupported_calling_conventions)]` on by default - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:138:1 - | -LL | extern "cdecl" {} - | ^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> - = help: use `extern "C"` instead - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:141:1 - | -LL | extern "cdecl-unwind" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "vectorcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:111:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> - = help: use `extern "C-unwind"` instead +LL | extern "vectorcall" fn vectorcall() {} + | ^^^^^^^^^^^^ -warning: the calling convention "vectorcall" is not supported on this target - --> $DIR/unsupported.rs:147:22 +error[E0570]: "vectorcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:113:29 | LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + | ^^^^^^^^^^^^ -error[E0570]: `"vectorcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:152:1 +error[E0570]: "vectorcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:117:8 | LL | extern "vectorcall" {} - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 - | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 - | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:168:1 - | -LL | extern "C-cmse-nonsecure-entry" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:36:1 - | -LL | extern "ptx-kernel" fn ptx() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:45:1 - | -LL | extern "gpu-kernel" fn gpu() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:58:1 - | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:68:1 - | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:78:1 +error[E0570]: "cmse-nonsecure-call" is not a supported ABI for the current target + --> $DIR/unsupported.rs:120:28 | -LL | extern "riscv-interrupt-m" fn riscv() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn cmse_call_ptr(f: extern "cmse-nonsecure-call" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:89:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:125:8 | -LL | extern "x86-interrupt" fn x86() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cmse-nonsecure-entry" fn cmse_entry() {} + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:100:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:127:29 | -LL | extern "thiscall" fn thiscall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn cmse_entry_ptr(f: extern "cmse-nonsecure-entry" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:110:1 - | -LL | extern "stdcall" fn stdcall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:131:8 | - = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` +LL | extern "cmse-nonsecure-entry" {} + | ^^^^^^^^^^^^^^^^^^^^^^ -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:130:1 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:99:17 | -LL | extern "cdecl" fn cdecl() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default -error[E0570]: `"vectorcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:145:1 - | -LL | extern "vectorcall" fn vectorcall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:161:1 - | -LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 20 previous errors; 14 warnings emitted - -For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 - | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:80:17 - | -LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:91:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:102:20 - | -LL | fn thiscall_ptr(f: extern "thiscall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:114:19 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:104:1 | -LL | fn stdcall_ptr(f: extern "stdcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead -Future breakage diagnostic: -warning: the calling convention "vectorcall" is not supported on this target - --> $DIR/unsupported.rs:147:22 +warning: "cdecl-unwind" is not a supported ABI for the current target + --> $DIR/unsupported.rs:107:1 | -LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:96:1 | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 - | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +error: aborting due to 22 previous errors; 4 warnings emitted +For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.i686.stderr b/tests/ui/abi/unsupported.i686.stderr index 56884166019..8478c481941 100644 --- a/tests/ui/abi/unsupported.i686.stderr +++ b/tests/ui/abi/unsupported.i686.stderr @@ -1,234 +1,87 @@ -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:36:8 | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "ptx-kernel" fn ptx() {} + | ^^^^^^^^^^^^ + +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:38:22 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { + | ^^^^^^^^^^^^ -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:42:8 | LL | extern "ptx-kernel" {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ -warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:50:17 +error[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:44:8 | -LL | fn aapcs_ptr(f: extern "aapcs" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "gpu-kernel" fn gpu() {} + | ^^^^^^^^^^^^ -error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:55:1 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:47:8 | -LL | extern "aapcs" {} - | ^^^^^^^^^^^^^^^^^ +LL | extern "aapcs" fn aapcs() {} + | ^^^^^^^ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:49:24 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | fn aapcs_ptr(f: extern "aapcs" fn()) { + | ^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:65:1 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:53:8 | -LL | extern "msp430-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "aapcs" {} + | ^^^^^^^ -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:56:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "msp430-interrupt" {} + | ^^^^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:75:1 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:59:8 | LL | extern "avr-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:80:17 - | -LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:86:1 +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/unsupported.rs:62:8 | LL | extern "riscv-interrupt-m" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 - | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 - | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:168:1 - | -LL | extern "C-cmse-nonsecure-entry" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:36:1 - | -LL | extern "ptx-kernel" fn ptx() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:45:1 - | -LL | extern "gpu-kernel" fn gpu() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:48:1 - | -LL | extern "aapcs" fn aapcs() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:58:1 +error[E0570]: "cmse-nonsecure-call" is not a supported ABI for the current target + --> $DIR/unsupported.rs:120:28 | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn cmse_call_ptr(f: extern "cmse-nonsecure-call" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:68:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:125:8 | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cmse-nonsecure-entry" fn cmse_entry() {} + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:78:1 - | -LL | extern "riscv-interrupt-m" fn riscv() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: functions with the "x86-interrupt" ABI cannot be called - --> $DIR/unsupported.rs:94:5 - | -LL | f() - | ^^^ - | -note: an `extern "x86-interrupt"` function can only be called using inline assembly - --> $DIR/unsupported.rs:94:5 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:127:29 | -LL | f() - | ^^^ +LL | fn cmse_entry_ptr(f: extern "cmse-nonsecure-entry" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:161:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:131:8 | -LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cmse-nonsecure-entry" {} + | ^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 14 previous errors; 7 warnings emitted +error: aborting due to 14 previous errors For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 - | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:50:17 - | -LL | fn aapcs_ptr(f: extern "aapcs" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:80:17 - | -LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 - | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 - | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - diff --git a/tests/ui/abi/unsupported.riscv32.stderr b/tests/ui/abi/unsupported.riscv32.stderr index 124ba13cc23..d7eb222eb76 100644 --- a/tests/ui/abi/unsupported.riscv32.stderr +++ b/tests/ui/abi/unsupported.riscv32.stderr @@ -1,383 +1,196 @@ -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:36:8 | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "ptx-kernel" fn ptx() {} + | ^^^^^^^^^^^^ + +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:38:22 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { + | ^^^^^^^^^^^^ -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:42:8 | LL | extern "ptx-kernel" {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ -warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:50:17 +error[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:44:8 | -LL | fn aapcs_ptr(f: extern "aapcs" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "gpu-kernel" fn gpu() {} + | ^^^^^^^^^^^^ -error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:55:1 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:47:8 | -LL | extern "aapcs" {} - | ^^^^^^^^^^^^^^^^^ +LL | extern "aapcs" fn aapcs() {} + | ^^^^^^^ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:49:24 | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | fn aapcs_ptr(f: extern "aapcs" fn()) { + | ^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:65:1 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:53:8 | -LL | extern "msp430-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "aapcs" {} + | ^^^^^^^ -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:56:8 | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "msp430-interrupt" {} + | ^^^^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:75:1 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:59:8 | LL | extern "avr-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:91:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "x86-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:65:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "x86-interrupt" {} + | ^^^^^^^^^^^^^^^ -error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:97:1 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:68:8 | -LL | extern "x86-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "thiscall" fn thiscall() {} + | ^^^^^^^^^^ -warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:102:20 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:70:27 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + | ^^^^^^^^^^ -error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:107:1 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:74:8 | LL | extern "thiscall" {} - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ -warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:114:19 +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:77:8 + | +LL | extern "stdcall" fn stdcall() {} + | ^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:81:26 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:121:1 +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:87:8 | LL | extern "stdcall" {} - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:125:1 +error[E0570]: "stdcall-unwind" is not a supported ABI for the current target + --> $DIR/unsupported.rs:91:8 | LL | extern "stdcall-unwind" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:133:17 +error[E0570]: "vectorcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:111:8 | -LL | fn cdecl_ptr(f: extern "cdecl" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> - = help: use `extern "C"` instead - = note: `#[warn(unsupported_calling_conventions)]` on by default - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:138:1 - | -LL | extern "cdecl" {} - | ^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> - = help: use `extern "C"` instead - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:141:1 - | -LL | extern "cdecl-unwind" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> - = help: use `extern "C-unwind"` instead +LL | extern "vectorcall" fn vectorcall() {} + | ^^^^^^^^^^^^ -warning: the calling convention "vectorcall" is not supported on this target - --> $DIR/unsupported.rs:147:22 +error[E0570]: "vectorcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:113:29 | LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + | ^^^^^^^^^^^^ -error[E0570]: `"vectorcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:152:1 +error[E0570]: "vectorcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:117:8 | LL | extern "vectorcall" {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 - | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "cmse-nonsecure-call" is not a supported ABI for the current target + --> $DIR/unsupported.rs:120:28 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | fn cmse_call_ptr(f: extern "cmse-nonsecure-call" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^ -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:125:8 | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "cmse-nonsecure-entry" fn cmse_entry() {} + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:168:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:127:29 | -LL | extern "C-cmse-nonsecure-entry" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn cmse_entry_ptr(f: extern "cmse-nonsecure-entry" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:36:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:131:8 | -LL | extern "ptx-kernel" fn ptx() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cmse-nonsecure-entry" {} + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:45:1 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:99:17 | -LL | extern "gpu-kernel" fn gpu() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:48:1 - | -LL | extern "aapcs" fn aapcs() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:58:1 - | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:68:1 - | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: functions with the "riscv-interrupt-m" ABI cannot be called - --> $DIR/unsupported.rs:83:5 - | -LL | f() - | ^^^ - | -note: an `extern "riscv-interrupt-m"` function can only be called using inline assembly - --> $DIR/unsupported.rs:83:5 - | -LL | f() - | ^^^ - -error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:89:1 - | -LL | extern "x86-interrupt" fn x86() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:100:1 - | -LL | extern "thiscall" fn thiscall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:110:1 - | -LL | extern "stdcall" fn stdcall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:130:1 - | -LL | extern "cdecl" fn cdecl() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default -error[E0570]: `"vectorcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:145:1 - | -LL | extern "vectorcall" fn vectorcall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:161:1 - | -LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 21 previous errors; 14 warnings emitted - -For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 - | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:50:17 - | -LL | fn aapcs_ptr(f: extern "aapcs" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:91:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:102:20 - | -LL | fn thiscall_ptr(f: extern "thiscall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:114:19 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:104:1 | -LL | fn stdcall_ptr(f: extern "stdcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead -Future breakage diagnostic: -warning: the calling convention "vectorcall" is not supported on this target - --> $DIR/unsupported.rs:147:22 +warning: "cdecl-unwind" is not a supported ABI for the current target + --> $DIR/unsupported.rs:107:1 | -LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:96:1 | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 - | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +error: aborting due to 24 previous errors; 4 warnings emitted +For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.riscv64.stderr b/tests/ui/abi/unsupported.riscv64.stderr index 124ba13cc23..d7eb222eb76 100644 --- a/tests/ui/abi/unsupported.riscv64.stderr +++ b/tests/ui/abi/unsupported.riscv64.stderr @@ -1,383 +1,196 @@ -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:36:8 | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "ptx-kernel" fn ptx() {} + | ^^^^^^^^^^^^ + +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:38:22 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { + | ^^^^^^^^^^^^ -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:42:8 | LL | extern "ptx-kernel" {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ -warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:50:17 +error[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:44:8 | -LL | fn aapcs_ptr(f: extern "aapcs" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "gpu-kernel" fn gpu() {} + | ^^^^^^^^^^^^ -error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:55:1 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:47:8 | -LL | extern "aapcs" {} - | ^^^^^^^^^^^^^^^^^ +LL | extern "aapcs" fn aapcs() {} + | ^^^^^^^ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:49:24 | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | fn aapcs_ptr(f: extern "aapcs" fn()) { + | ^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:65:1 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:53:8 | -LL | extern "msp430-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "aapcs" {} + | ^^^^^^^ -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:56:8 | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "msp430-interrupt" {} + | ^^^^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:75:1 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:59:8 | LL | extern "avr-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:91:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "x86-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:65:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "x86-interrupt" {} + | ^^^^^^^^^^^^^^^ -error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:97:1 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:68:8 | -LL | extern "x86-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "thiscall" fn thiscall() {} + | ^^^^^^^^^^ -warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:102:20 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:70:27 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + | ^^^^^^^^^^ -error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:107:1 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:74:8 | LL | extern "thiscall" {} - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ -warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:114:19 +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:77:8 + | +LL | extern "stdcall" fn stdcall() {} + | ^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` + +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:81:26 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:121:1 +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:87:8 | LL | extern "stdcall" {} - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:125:1 +error[E0570]: "stdcall-unwind" is not a supported ABI for the current target + --> $DIR/unsupported.rs:91:8 | LL | extern "stdcall-unwind" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:133:17 +error[E0570]: "vectorcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:111:8 | -LL | fn cdecl_ptr(f: extern "cdecl" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> - = help: use `extern "C"` instead - = note: `#[warn(unsupported_calling_conventions)]` on by default - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:138:1 - | -LL | extern "cdecl" {} - | ^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> - = help: use `extern "C"` instead - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:141:1 - | -LL | extern "cdecl-unwind" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> - = help: use `extern "C-unwind"` instead +LL | extern "vectorcall" fn vectorcall() {} + | ^^^^^^^^^^^^ -warning: the calling convention "vectorcall" is not supported on this target - --> $DIR/unsupported.rs:147:22 +error[E0570]: "vectorcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:113:29 | LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + | ^^^^^^^^^^^^ -error[E0570]: `"vectorcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:152:1 +error[E0570]: "vectorcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:117:8 | LL | extern "vectorcall" {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 - | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "cmse-nonsecure-call" is not a supported ABI for the current target + --> $DIR/unsupported.rs:120:28 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | fn cmse_call_ptr(f: extern "cmse-nonsecure-call" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^ -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:125:8 | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "cmse-nonsecure-entry" fn cmse_entry() {} + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:168:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:127:29 | -LL | extern "C-cmse-nonsecure-entry" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn cmse_entry_ptr(f: extern "cmse-nonsecure-entry" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:36:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:131:8 | -LL | extern "ptx-kernel" fn ptx() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cmse-nonsecure-entry" {} + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:45:1 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:99:17 | -LL | extern "gpu-kernel" fn gpu() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:48:1 - | -LL | extern "aapcs" fn aapcs() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:58:1 - | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:68:1 - | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: functions with the "riscv-interrupt-m" ABI cannot be called - --> $DIR/unsupported.rs:83:5 - | -LL | f() - | ^^^ - | -note: an `extern "riscv-interrupt-m"` function can only be called using inline assembly - --> $DIR/unsupported.rs:83:5 - | -LL | f() - | ^^^ - -error[E0570]: `"x86-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:89:1 - | -LL | extern "x86-interrupt" fn x86() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:100:1 - | -LL | extern "thiscall" fn thiscall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:110:1 - | -LL | extern "stdcall" fn stdcall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:130:1 - | -LL | extern "cdecl" fn cdecl() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn cdecl_ptr(f: extern "cdecl" fn()) { + | ^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead + = note: `#[warn(unsupported_calling_conventions)]` on by default -error[E0570]: `"vectorcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:145:1 - | -LL | extern "vectorcall" fn vectorcall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:161:1 - | -LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 21 previous errors; 14 warnings emitted - -For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 - | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:50:17 - | -LL | fn aapcs_ptr(f: extern "aapcs" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "x86-interrupt" is not supported on this target - --> $DIR/unsupported.rs:91:15 - | -LL | fn x86_ptr(f: extern "x86-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:102:20 - | -LL | fn thiscall_ptr(f: extern "thiscall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:114:19 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:104:1 | -LL | fn stdcall_ptr(f: extern "stdcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cdecl" {} + | ^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead -Future breakage diagnostic: -warning: the calling convention "vectorcall" is not supported on this target - --> $DIR/unsupported.rs:147:22 +warning: "cdecl-unwind" is not a supported ABI for the current target + --> $DIR/unsupported.rs:107:1 | -LL | fn vectorcall_ptr(f: extern "vectorcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cdecl-unwind" {} + | ^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C-unwind"` instead -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:96:1 | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cdecl" fn cdecl() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default + = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> + = help: use `extern "C"` instead -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 - | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +error: aborting due to 24 previous errors; 4 warnings emitted +For more information about this error, try `rustc --explain E0570`. diff --git a/tests/ui/abi/unsupported.rs b/tests/ui/abi/unsupported.rs index 4ddcbae409b..828fcc147a5 100644 --- a/tests/ui/abi/unsupported.rs +++ b/tests/ui/abi/unsupported.rs @@ -25,7 +25,7 @@ abi_gpu_kernel, abi_x86_interrupt, abi_riscv_interrupt, - abi_c_cmse_nonsecure_call, + abi_cmse_nonsecure_call, abi_vectorcall, cmse_nonsecure_entry )] @@ -36,8 +36,7 @@ use minicore::*; extern "ptx-kernel" fn ptx() {} //~^ ERROR is not a supported ABI fn ptx_ptr(f: extern "ptx-kernel" fn()) { - //~^ WARN unsupported_fn_ptr_calling_conventions - //~^^ WARN this was previously accepted +//~^ ERROR is not a supported ABI f() } extern "ptx-kernel" {} @@ -48,60 +47,28 @@ extern "gpu-kernel" fn gpu() {} extern "aapcs" fn aapcs() {} //[x64,x64_win,i686,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI fn aapcs_ptr(f: extern "aapcs" fn()) { - //[x64,x64_win,i686,aarch64,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions - //[x64,x64_win,i686,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted + //[x64,x64_win,i686,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI f() } extern "aapcs" {} //[x64,x64_win,i686,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI -extern "msp430-interrupt" fn msp430() {} -//~^ ERROR is not a supported ABI -fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - //~^ WARN unsupported_fn_ptr_calling_conventions - //~^^ WARN this was previously accepted - f() -} extern "msp430-interrupt" {} //~^ ERROR is not a supported ABI -extern "avr-interrupt" fn avr() {} -//~^ ERROR is not a supported ABI -fn avr_ptr(f: extern "avr-interrupt" fn()) { - //~^ WARN unsupported_fn_ptr_calling_conventions - //~^^ WARN this was previously accepted - f() -} extern "avr-interrupt" {} //~^ ERROR is not a supported ABI -extern "riscv-interrupt-m" fn riscv() {} -//[x64,x64_win,i686,arm,aarch64]~^ ERROR is not a supported ABI -fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { - //[x64,x64_win,i686,arm,aarch64]~^ WARN unsupported_fn_ptr_calling_conventions - //[x64,x64_win,i686,arm,aarch64]~^^ WARN this was previously accepted - f() - //[riscv32,riscv64]~^ ERROR functions with the "riscv-interrupt-m" ABI cannot be called -} extern "riscv-interrupt-m" {} //[x64,x64_win,i686,arm,aarch64]~^ ERROR is not a supported ABI -extern "x86-interrupt" fn x86() {} -//[aarch64,arm,riscv32,riscv64]~^ ERROR is not a supported ABI -fn x86_ptr(f: extern "x86-interrupt" fn()) { - //[aarch64,arm,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions - //[aarch64,arm,riscv32,riscv64]~^^ WARN this was previously accepted - f() - //[x64,x64_win,i686]~^ ERROR functions with the "x86-interrupt" ABI cannot be called -} extern "x86-interrupt" {} //[aarch64,arm,riscv32,riscv64]~^ ERROR is not a supported ABI extern "thiscall" fn thiscall() {} //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI fn thiscall_ptr(f: extern "thiscall" fn()) { - //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions - //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted + //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI f() } extern "thiscall" {} @@ -112,10 +79,9 @@ extern "stdcall" fn stdcall() {} //[x64_win]~^^ WARN unsupported_calling_conventions //[x64_win]~^^^ WARN this was previously accepted fn stdcall_ptr(f: extern "stdcall" fn()) { - //[x64_win]~^ WARN unsupported_calling_conventions - //[x64_win]~| WARN this was previously accepted - //[x64,arm,aarch64,riscv32,riscv64]~^^^ WARN unsupported_fn_ptr_calling_conventions - //[x64,arm,aarch64,riscv32,riscv64]~| WARN this was previously accepted + //[x64,arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI + //[x64_win]~^^ WARN unsupported_calling_conventions + //[x64_win]~| WARN this was previously accepted f() } extern "stdcall" {} @@ -132,7 +98,7 @@ extern "cdecl" fn cdecl() {} //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted fn cdecl_ptr(f: extern "cdecl" fn()) { //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^ WARN unsupported_calling_conventions - //[x64,x64_win,arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted + //[x64,x64_win,arm,aarch64,riscv32,riscv64]~| WARN this was previously accepted f() } extern "cdecl" {} @@ -145,31 +111,28 @@ extern "cdecl-unwind" {} extern "vectorcall" fn vectorcall() {} //[arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI fn vectorcall_ptr(f: extern "vectorcall" fn()) { - //[arm,aarch64,riscv32,riscv64]~^ WARN unsupported_fn_ptr_calling_conventions - //[arm,aarch64,riscv32,riscv64]~^^ WARN this was previously accepted + //[arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI f() } extern "vectorcall" {} //[arm,aarch64,riscv32,riscv64]~^ ERROR is not a supported ABI -fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - //~^ WARN unsupported_fn_ptr_calling_conventions - //~^^ WARN this was previously accepted +fn cmse_call_ptr(f: extern "cmse-nonsecure-call" fn()) { +//~^ ERROR is not a supported ABI f() } -extern "C-cmse-nonsecure-entry" fn cmse_entry() {} +extern "cmse-nonsecure-entry" fn cmse_entry() {} +//~^ ERROR is not a supported ABI +fn cmse_entry_ptr(f: extern "cmse-nonsecure-entry" fn()) { //~^ ERROR is not a supported ABI -fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - //~^ WARN unsupported_fn_ptr_calling_conventions - //~^^ WARN this was previously accepted f() } -extern "C-cmse-nonsecure-entry" {} +extern "cmse-nonsecure-entry" {} //~^ ERROR is not a supported ABI #[cfg(windows)] #[link(name = "foo", kind = "raw-dylib")] extern "cdecl" {} -//[x64_win]~^ WARN use of calling convention not supported on this target +//[x64_win]~^ WARN unsupported_calling_conventions //[x64_win]~^^ WARN this was previously accepted diff --git a/tests/ui/abi/unsupported.x64.stderr b/tests/ui/abi/unsupported.x64.stderr index 737c4c670b8..cf04680b587 100644 --- a/tests/ui/abi/unsupported.x64.stderr +++ b/tests/ui/abi/unsupported.x64.stderr @@ -1,121 +1,139 @@ -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:36:8 | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "ptx-kernel" fn ptx() {} + | ^^^^^^^^^^^^ + +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:38:22 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { + | ^^^^^^^^^^^^ -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:42:8 | LL | extern "ptx-kernel" {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ -warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:50:17 - | -LL | fn aapcs_ptr(f: extern "aapcs" fn()) { - | ^^^^^^^^^^^^^^^^^^^ +error[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:44:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "gpu-kernel" fn gpu() {} + | ^^^^^^^^^^^^ -error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:55:1 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:47:8 | -LL | extern "aapcs" {} - | ^^^^^^^^^^^^^^^^^ +LL | extern "aapcs" fn aapcs() {} + | ^^^^^^^ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:49:24 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | fn aapcs_ptr(f: extern "aapcs" fn()) { + | ^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:65:1 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:53:8 | -LL | extern "msp430-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "aapcs" {} + | ^^^^^^^ -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:56:8 | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "msp430-interrupt" {} + | ^^^^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:75:1 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:59:8 | LL | extern "avr-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:80:17 +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/unsupported.rs:62:8 | -LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "riscv-interrupt-m" {} + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:86:1 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:68:8 | -LL | extern "riscv-interrupt-m" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "thiscall" fn thiscall() {} + | ^^^^^^^^^^ -warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:102:20 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:70:27 | LL | fn thiscall_ptr(f: extern "thiscall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + | ^^^^^^^^^^ -error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:107:1 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:74:8 | LL | extern "thiscall" {} - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^ + +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:77:8 + | +LL | extern "stdcall" fn stdcall() {} + | ^^^^^^^^^ + | + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:114:19 +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:81:26 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> + = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:121:1 +error[E0570]: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:87:8 | LL | extern "stdcall" {} - | ^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -error[E0570]: `"stdcall-unwind"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:125:1 +error[E0570]: "stdcall-unwind" is not a supported ABI for the current target + --> $DIR/unsupported.rs:91:8 | LL | extern "stdcall-unwind" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^ | = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:133:17 +error[E0570]: "cmse-nonsecure-call" is not a supported ABI for the current target + --> $DIR/unsupported.rs:120:28 + | +LL | fn cmse_call_ptr(f: extern "cmse-nonsecure-call" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:125:8 + | +LL | extern "cmse-nonsecure-entry" fn cmse_entry() {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:127:29 + | +LL | fn cmse_entry_ptr(f: extern "cmse-nonsecure-entry" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:131:8 + | +LL | extern "cmse-nonsecure-entry" {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:99:17 | LL | fn cdecl_ptr(f: extern "cdecl" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -125,8 +143,8 @@ LL | fn cdecl_ptr(f: extern "cdecl" fn()) { = help: use `extern "C"` instead = note: `#[warn(unsupported_calling_conventions)]` on by default -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:138:1 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:104:1 | LL | extern "cdecl" {} | ^^^^^^^^^^^^^^^^^ @@ -135,8 +153,8 @@ LL | extern "cdecl" {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:141:1 +warning: "cdecl-unwind" is not a supported ABI for the current target + --> $DIR/unsupported.rs:107:1 | LL | extern "cdecl-unwind" {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -145,94 +163,8 @@ LL | extern "cdecl-unwind" {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C-unwind"` instead -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 - | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 - | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:168:1 - | -LL | extern "C-cmse-nonsecure-entry" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:36:1 - | -LL | extern "ptx-kernel" fn ptx() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:45:1 - | -LL | extern "gpu-kernel" fn gpu() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:48:1 - | -LL | extern "aapcs" fn aapcs() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:58:1 - | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:68:1 - | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:78:1 - | -LL | extern "riscv-interrupt-m" fn riscv() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: functions with the "x86-interrupt" ABI cannot be called - --> $DIR/unsupported.rs:94:5 - | -LL | f() - | ^^^ - | -note: an `extern "x86-interrupt"` function can only be called using inline assembly - --> $DIR/unsupported.rs:94:5 - | -LL | f() - | ^^^ - -error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:100:1 - | -LL | extern "thiscall" fn thiscall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"stdcall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:110:1 - | -LL | extern "stdcall" fn stdcall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:130:1 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:96:1 | LL | extern "cdecl" fn cdecl() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -241,111 +173,6 @@ LL | extern "cdecl" fn cdecl() {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:161:1 - | -LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 19 previous errors; 13 warnings emitted +error: aborting due to 21 previous errors; 4 warnings emitted For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 - | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:50:17 - | -LL | fn aapcs_ptr(f: extern "aapcs" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:80:17 - | -LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:102:20 - | -LL | fn thiscall_ptr(f: extern "thiscall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "stdcall" is not supported on this target - --> $DIR/unsupported.rs:114:19 - | -LL | fn stdcall_ptr(f: extern "stdcall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 - | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 - | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - diff --git a/tests/ui/abi/unsupported.x64_win.stderr b/tests/ui/abi/unsupported.x64_win.stderr index f201a089d3f..d383a4df732 100644 --- a/tests/ui/abi/unsupported.x64_win.stderr +++ b/tests/ui/abi/unsupported.x64_win.stderr @@ -1,96 +1,107 @@ -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:36:8 | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "ptx-kernel" fn ptx() {} + | ^^^^^^^^^^^^ + +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:38:22 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default +LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { + | ^^^^^^^^^^^^ -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:43:1 +error[E0570]: "ptx-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:42:8 | LL | extern "ptx-kernel" {} - | ^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^ -warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:50:17 - | -LL | fn aapcs_ptr(f: extern "aapcs" fn()) { - | ^^^^^^^^^^^^^^^^^^^ +error[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/unsupported.rs:44:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "gpu-kernel" fn gpu() {} + | ^^^^^^^^^^^^ -error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:55:1 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:47:8 | -LL | extern "aapcs" {} - | ^^^^^^^^^^^^^^^^^ +LL | extern "aapcs" fn aapcs() {} + | ^^^^^^^ -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:49:24 | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn aapcs_ptr(f: extern "aapcs" fn()) { + | ^^^^^^^ + +error[E0570]: "aapcs" is not a supported ABI for the current target + --> $DIR/unsupported.rs:53:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "aapcs" {} + | ^^^^^^^ -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:65:1 +error[E0570]: "msp430-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:56:8 | LL | extern "msp430-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^ -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 +error[E0570]: "avr-interrupt" is not a supported ABI for the current target + --> $DIR/unsupported.rs:59:8 | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "avr-interrupt" {} + | ^^^^^^^^^^^^^^^ + +error[E0570]: "riscv-interrupt-m" is not a supported ABI for the current target + --> $DIR/unsupported.rs:62:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "riscv-interrupt-m" {} + | ^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:75:1 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:68:8 | -LL | extern "avr-interrupt" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "thiscall" fn thiscall() {} + | ^^^^^^^^^^ -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:80:17 +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:70:27 | -LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn thiscall_ptr(f: extern "thiscall" fn()) { + | ^^^^^^^^^^ + +error[E0570]: "thiscall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:74:8 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | extern "thiscall" {} + | ^^^^^^^^^^ -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:86:1 +error[E0570]: "cmse-nonsecure-call" is not a supported ABI for the current target + --> $DIR/unsupported.rs:120:28 | -LL | extern "riscv-interrupt-m" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | fn cmse_call_ptr(f: extern "cmse-nonsecure-call" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^ -warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:102:20 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:125:8 | -LL | fn thiscall_ptr(f: extern "thiscall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cmse-nonsecure-entry" fn cmse_entry() {} + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:127:29 | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +LL | fn cmse_entry_ptr(f: extern "cmse-nonsecure-entry" fn()) { + | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:107:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/unsupported.rs:131:8 | -LL | extern "thiscall" {} - | ^^^^^^^^^^^^^^^^^^^^ +LL | extern "cmse-nonsecure-entry" {} + | ^^^^^^^^^^^^^^^^^^^^^^ -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:114:19 +warning: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:81:19 | LL | fn stdcall_ptr(f: extern "stdcall" fn()) { | ^^^^^^^^^^^^^^^^^^^^^ @@ -100,8 +111,8 @@ LL | fn stdcall_ptr(f: extern "stdcall" fn()) { = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` = note: `#[warn(unsupported_calling_conventions)]` on by default -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:121:1 +warning: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:87:1 | LL | extern "stdcall" {} | ^^^^^^^^^^^^^^^^^^^ @@ -110,8 +121,8 @@ LL | extern "stdcall" {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:125:1 +warning: "stdcall-unwind" is not a supported ABI for the current target + --> $DIR/unsupported.rs:91:1 | LL | extern "stdcall-unwind" {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -120,8 +131,8 @@ LL | extern "stdcall-unwind" {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: if you need `extern "stdcall-unwind"` on win32 and `extern "C-unwind"` everywhere else, use `extern "system-unwind"` -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:133:17 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:99:17 | LL | fn cdecl_ptr(f: extern "cdecl" fn()) { | ^^^^^^^^^^^^^^^^^^^ @@ -130,8 +141,8 @@ LL | fn cdecl_ptr(f: extern "cdecl" fn()) { = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:138:1 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:104:1 | LL | extern "cdecl" {} | ^^^^^^^^^^^^^^^^^ @@ -140,8 +151,8 @@ LL | extern "cdecl" {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:141:1 +warning: "cdecl-unwind" is not a supported ABI for the current target + --> $DIR/unsupported.rs:107:1 | LL | extern "cdecl-unwind" {} | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -150,32 +161,8 @@ LL | extern "cdecl-unwind" {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C-unwind"` instead -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 - | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 - | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:168:1 - | -LL | extern "C-cmse-nonsecure-entry" {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:173:1 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:136:1 | LL | extern "cdecl" {} | ^^^^^^^^^^^^^^^^^ @@ -184,62 +171,8 @@ LL | extern "cdecl" {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead -error[E0570]: `"ptx-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:36:1 - | -LL | extern "ptx-kernel" fn ptx() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:45:1 - | -LL | extern "gpu-kernel" fn gpu() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"aapcs"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:48:1 - | -LL | extern "aapcs" fn aapcs() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"msp430-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:58:1 - | -LL | extern "msp430-interrupt" fn msp430() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"avr-interrupt"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:68:1 - | -LL | extern "avr-interrupt" fn avr() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"riscv-interrupt-m"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:78:1 - | -LL | extern "riscv-interrupt-m" fn riscv() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: functions with the "x86-interrupt" ABI cannot be called - --> $DIR/unsupported.rs:94:5 - | -LL | f() - | ^^^ - | -note: an `extern "x86-interrupt"` function can only be called using inline assembly - --> $DIR/unsupported.rs:94:5 - | -LL | f() - | ^^^ - -error[E0570]: `"thiscall"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:100:1 - | -LL | extern "thiscall" fn thiscall() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:110:1 +warning: "stdcall" is not a supported ABI for the current target + --> $DIR/unsupported.rs:77:1 | LL | extern "stdcall" fn stdcall() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -248,8 +181,8 @@ LL | extern "stdcall" fn stdcall() {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: if you need `extern "stdcall"` on win32 and `extern "C"` everywhere else, use `extern "system"` -warning: use of calling convention not supported on this target - --> $DIR/unsupported.rs:130:1 +warning: "cdecl" is not a supported ABI for the current target + --> $DIR/unsupported.rs:96:1 | LL | extern "cdecl" fn cdecl() {} | ^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -258,100 +191,6 @@ LL | extern "cdecl" fn cdecl() {} = note: for more information, see issue #137018 <https://github.com/rust-lang/rust/issues/137018> = help: use `extern "C"` instead -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/unsupported.rs:161:1 - | -LL | extern "C-cmse-nonsecure-entry" fn cmse_entry() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 16 previous errors; 17 warnings emitted +error: aborting due to 17 previous errors; 9 warnings emitted For more information about this error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "ptx-kernel" is not supported on this target - --> $DIR/unsupported.rs:38:15 - | -LL | fn ptx_ptr(f: extern "ptx-kernel" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "aapcs" is not supported on this target - --> $DIR/unsupported.rs:50:17 - | -LL | fn aapcs_ptr(f: extern "aapcs" fn()) { - | ^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "msp430-interrupt" is not supported on this target - --> $DIR/unsupported.rs:60:18 - | -LL | fn msp430_ptr(f: extern "msp430-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "avr-interrupt" is not supported on this target - --> $DIR/unsupported.rs:70:15 - | -LL | fn avr_ptr(f: extern "avr-interrupt" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "riscv-interrupt-m" is not supported on this target - --> $DIR/unsupported.rs:80:17 - | -LL | fn riscv_ptr(f: extern "riscv-interrupt-m" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "thiscall" is not supported on this target - --> $DIR/unsupported.rs:102:20 - | -LL | fn thiscall_ptr(f: extern "thiscall" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/unsupported.rs:155:21 - | -LL | fn cmse_call_ptr(f: extern "C-cmse-nonsecure-call" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-entry" is not supported on this target - --> $DIR/unsupported.rs:163:22 - | -LL | fn cmse_entry_ptr(f: extern "C-cmse-nonsecure-entry" fn()) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - diff --git a/tests/ui/realloc-16687.rs b/tests/ui/allocator/alloc-shrink-oob-read.rs index 43810a469df..b9edfca3b7b 100644 --- a/tests/ui/realloc-16687.rs +++ b/tests/ui/allocator/alloc-shrink-oob-read.rs @@ -1,13 +1,13 @@ +//! Sanity check for out-of-bounds read caused by copying the entire original buffer on shrink. +//! +//! Regression test for: <https://github.com/rust-lang/rust/issues/16687> + //@ run-pass -// alloc::heap::reallocate test. -// -// Ideally this would be revised to use no_std, but for now it serves -// well enough to reproduce (and illustrate) the bug from #16687. #![feature(allocator_api)] #![feature(slice_ptr_get)] -use std::alloc::{handle_alloc_error, Allocator, Global, Layout}; +use std::alloc::{Allocator, Global, Layout, handle_alloc_error}; use std::ptr::{self, NonNull}; fn main() { diff --git a/tests/ui/empty-allocation-non-null.rs b/tests/ui/allocator/empty-alloc-nonnull-guarantee.rs index 45035a42a5f..f4081306c77 100644 --- a/tests/ui/empty-allocation-non-null.rs +++ b/tests/ui/allocator/empty-alloc-nonnull-guarantee.rs @@ -1,3 +1,7 @@ +//! Check that the default global Rust allocator produces non-null Box allocations for ZSTs. +//! +//! See https://github.com/rust-lang/rust/issues/11998 + //@ run-pass pub fn main() { diff --git a/tests/ui/allocator/no_std-alloc-error-handler-custom.rs b/tests/ui/allocator/no_std-alloc-error-handler-custom.rs index 6bbfb72510d..1b0f0608fc6 100644 --- a/tests/ui/allocator/no_std-alloc-error-handler-custom.rs +++ b/tests/ui/allocator/no_std-alloc-error-handler-custom.rs @@ -6,13 +6,14 @@ //@ compile-flags:-C panic=abort //@ aux-build:helper.rs -#![feature(rustc_private, lang_items)] +#![feature(rustc_private, lang_items, panic_unwind)] #![feature(alloc_error_handler)] #![no_std] #![no_main] extern crate alloc; extern crate libc; +extern crate unwind; // For _Unwind_Resume // ARM targets need these symbols #[no_mangle] @@ -70,7 +71,15 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! { // in these libraries will refer to `rust_eh_personality` if LLVM can not *prove* the contents won't // unwind. So, for this test case we will define the symbol. #[lang = "eh_personality"] -extern "C" fn rust_eh_personality() {} +extern "C" fn rust_eh_personality( + _version: i32, + _actions: i32, + _exception_class: u64, + _exception_object: *mut (), + _context: *mut (), +) -> i32 { + loop {} +} #[derive(Default, Debug)] struct Page(#[allow(dead_code)] [[u64; 32]; 16]); diff --git a/tests/ui/allocator/no_std-alloc-error-handler-default.rs b/tests/ui/allocator/no_std-alloc-error-handler-default.rs index 8bcf054ac85..51ecf1a6731 100644 --- a/tests/ui/allocator/no_std-alloc-error-handler-default.rs +++ b/tests/ui/allocator/no_std-alloc-error-handler-default.rs @@ -6,12 +6,13 @@ //@ compile-flags:-C panic=abort //@ aux-build:helper.rs -#![feature(rustc_private, lang_items)] +#![feature(rustc_private, lang_items, panic_unwind)] #![no_std] #![no_main] extern crate alloc; extern crate libc; +extern crate unwind; // For _Unwind_Resume // ARM targets need these symbols #[no_mangle] @@ -57,7 +58,15 @@ fn panic(panic_info: &core::panic::PanicInfo) -> ! { // in these libraries will refer to `rust_eh_personality` if LLVM can not *prove* the contents won't // unwind. So, for this test case we will define the symbol. #[lang = "eh_personality"] -extern "C" fn rust_eh_personality() {} +extern "C" fn rust_eh_personality( + _version: i32, + _actions: i32, + _exception_class: u64, + _exception_object: *mut (), + _context: *mut (), +) -> i32 { + loop {} +} #[derive(Default, Debug)] struct Page(#[allow(dead_code)] [[u64; 32]; 16]); diff --git a/tests/ui/argument-suggestions/issue-100154.stderr b/tests/ui/argument-suggestions/issue-100154.stderr index 7eaebcafb59..9732beac449 100644 --- a/tests/ui/argument-suggestions/issue-100154.stderr +++ b/tests/ui/argument-suggestions/issue-100154.stderr @@ -17,10 +17,8 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/issue-100154.rs:4:11 | LL | foo::<()>(()); - | ^^ `()` cannot be formatted with the default formatter + | ^^ the trait `std::fmt::Display` is not implemented for `()` | - = help: the trait `std::fmt::Display` is not implemented for `()` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `foo` --> $DIR/issue-100154.rs:1:16 | diff --git a/tests/ui/argument-suggestions/issue-100478.rs b/tests/ui/argument-suggestions/issue-100478.rs index b0a9703112e..219870f3b23 100644 --- a/tests/ui/argument-suggestions/issue-100478.rs +++ b/tests/ui/argument-suggestions/issue-100478.rs @@ -32,8 +32,8 @@ fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {} fn main() { three_diff(T2::new(0)); //~ ERROR function takes - four_shuffle(T3::default(), T4::default(), T1::default(), T2::default()); //~ ERROR 35:5: 35:17: arguments to this function are incorrect [E0308] - four_shuffle(T3::default(), T2::default(), T1::default(), T3::default()); //~ ERROR 36:5: 36:17: arguments to this function are incorrect [E0308] + four_shuffle(T3::default(), T4::default(), T1::default(), T2::default()); //~ ERROR arguments to this function are incorrect [E0308] + four_shuffle(T3::default(), T2::default(), T1::default(), T3::default()); //~ ERROR arguments to this function are incorrect [E0308] let p1 = T1::new(0); let p2 = Arc::new(T2::new(0)); diff --git a/tests/ui/asm/naked-functions-inline.stderr b/tests/ui/asm/naked-functions-inline.stderr index 07d5f3bc49a..91140a301ed 100644 --- a/tests/ui/asm/naked-functions-inline.stderr +++ b/tests/ui/asm/naked-functions-inline.stderr @@ -1,26 +1,26 @@ error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-functions-inline.rs:12:1 + --> $DIR/naked-functions-inline.rs:12:3 | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here LL | #[inline] - | ^^^^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` + | ^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-functions-inline.rs:19:1 + --> $DIR/naked-functions-inline.rs:19:3 | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here LL | #[inline(always)] - | ^^^^^^^^^^^^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` + | ^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-functions-inline.rs:26:1 + --> $DIR/naked-functions-inline.rs:26:3 | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here LL | #[inline(never)] - | ^^^^^^^^^^^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` + | ^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` error[E0736]: attribute incompatible with `#[unsafe(naked)]` --> $DIR/naked-functions-inline.rs:33:19 @@ -28,7 +28,7 @@ error[E0736]: attribute incompatible with `#[unsafe(naked)]` LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here LL | #[cfg_attr(all(), inline(never))] - | ^^^^^^^^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` + | ^^^^^^ the `inline` attribute is incompatible with `#[unsafe(naked)]` error: aborting due to 4 previous errors diff --git a/tests/ui/asm/naked-invalid-attr.stderr b/tests/ui/asm/naked-invalid-attr.stderr index 6661084861e..915b54b3fc2 100644 --- a/tests/ui/asm/naked-invalid-attr.stderr +++ b/tests/ui/asm/naked-invalid-attr.stderr @@ -4,6 +4,15 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `a` LL | #[::a] | ^ use of unresolved module or unlinked crate `a` +error[E0736]: attribute incompatible with `#[unsafe(naked)]` + --> $DIR/naked-invalid-attr.rs:56:3 + | +LL | #[::a] + | ^^^ the `{{root}}::a` attribute is incompatible with `#[unsafe(naked)]` +... +LL | #[unsafe(naked)] + | ---------------- function marked with `#[unsafe(naked)]` here + error: attribute should be applied to a function definition --> $DIR/naked-invalid-attr.rs:13:1 | @@ -33,15 +42,6 @@ LL | #[unsafe(naked)] LL | || {}; | ----- not a function definition -error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/naked-invalid-attr.rs:56:1 - | -LL | #[::a] - | ^^^^^^ the `::a` attribute is incompatible with `#[unsafe(naked)]` -... -LL | #[unsafe(naked)] - | ---------------- function marked with `#[unsafe(naked)]` here - error: attribute should be applied to a function definition --> $DIR/naked-invalid-attr.rs:22:5 | diff --git a/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs b/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs index a718eb23bed..e583b12b1d7 100644 --- a/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs +++ b/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.rs @@ -12,7 +12,7 @@ fn take( K = { () } >, ) {} -//~^^^^^^ ERROR implementation of `Project` is not general enough +//~^^^^^ ERROR implementation of `Project` is not general enough //~^^^^ ERROR higher-ranked subtype error //~| ERROR higher-ranked subtype error diff --git a/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr b/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr index 967814c9c3d..42e084f39c0 100644 --- a/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr +++ b/tests/ui/associated-consts/assoc-const-eq-bound-var-in-ty-not-wf.stderr @@ -13,10 +13,14 @@ LL | K = { () } = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `Project` is not general enough - --> $DIR/assoc-const-eq-bound-var-in-ty-not-wf.rs:9:4 + --> $DIR/assoc-const-eq-bound-var-in-ty-not-wf.rs:10:13 | -LL | fn take( - | ^^^^ implementation of `Project` is not general enough +LL | _: impl Trait< + | _____________^ +LL | | <<for<'a> fn(&'a str) -> &'a str as Project>::Out as Discard>::Out, +LL | | K = { () } +LL | | >, + | |_____^ implementation of `Project` is not general enough | = note: `Project` would have to be implemented for the type `for<'a> fn(&'a str) -> &'a str` = note: ...but `Project` is actually implemented for the type `fn(&'0 str) -> &'0 str`, for some specific lifetime `'0` diff --git a/tests/ui/associated-consts/assoc-const-eq-const_evaluatable_unchecked.rs b/tests/ui/associated-consts/assoc-const-eq-const_evaluatable_unchecked.rs new file mode 100644 index 00000000000..4b6de6f56d5 --- /dev/null +++ b/tests/ui/associated-consts/assoc-const-eq-const_evaluatable_unchecked.rs @@ -0,0 +1,17 @@ +// The impl of lint `const_evaluatable_unchecked` used to wrongly assume and `assert!` that +// successfully evaluating a type-system constant that has non-region args had to be an anon const. +// In the case below however we have a type-system assoc const (here: `<() as TraitA<T>>::K`). +// +// issue: <https://github.com/rust-lang/rust/issues/108220> +//@ check-pass +#![feature(associated_const_equality)] + +pub trait TraitA<T> { const K: u8 = 0; } +pub trait TraitB<T> {} + +impl<T> TraitA<T> for () {} +impl<T> TraitB<T> for () where (): TraitA<T, K = 0> {} + +fn check<T>() where (): TraitB<T> {} + +fn main() {} diff --git a/tests/ui/associated-inherent-types/issue-109299.stderr b/tests/ui/associated-inherent-types/issue-109299.stderr index 1e11c0e8c2a..f29d3cc7834 100644 --- a/tests/ui/associated-inherent-types/issue-109299.stderr +++ b/tests/ui/associated-inherent-types/issue-109299.stderr @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'d` --> $DIR/issue-109299.rs:6:12 | LL | impl Lexer<'d> { - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'d` here: `<'d>` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'d` here + | +LL | impl<'d> Lexer<'d> { + | ++++ error: aborting due to 1 previous error diff --git a/tests/ui/associated-inherent-types/issue-111879-0.stderr b/tests/ui/associated-inherent-types/issue-111879-0.stderr index f60fd58c23b..144f6486b3b 100644 --- a/tests/ui/associated-inherent-types/issue-111879-0.stderr +++ b/tests/ui/associated-inherent-types/issue-111879-0.stderr @@ -1,8 +1,8 @@ error: overflow evaluating associated type `Carrier<'b>::Focus<i32>` - --> $DIR/issue-111879-0.rs:9:25 + --> $DIR/issue-111879-0.rs:9:5 | LL | pub type Focus<T> = &'a mut for<'b> fn(Carrier<'b>::Focus<i32>); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/associated-inherent-types/normalization-overflow.stderr b/tests/ui/associated-inherent-types/normalization-overflow.stderr index 7f991a53c9b..05aad31c5f4 100644 --- a/tests/ui/associated-inherent-types/normalization-overflow.stderr +++ b/tests/ui/associated-inherent-types/normalization-overflow.stderr @@ -1,8 +1,8 @@ error: overflow evaluating associated type `T::This` - --> $DIR/normalization-overflow.rs:9:17 + --> $DIR/normalization-overflow.rs:9:5 | LL | type This = Self::This; - | ^^^^^^^^^^ + | ^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/associated-inherent-types/regionck-1.stderr b/tests/ui/associated-inherent-types/regionck-1.stderr index 62a00868248..4e0ecc3c80e 100644 --- a/tests/ui/associated-inherent-types/regionck-1.stderr +++ b/tests/ui/associated-inherent-types/regionck-1.stderr @@ -1,10 +1,11 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regionck-1.rs:9:30 + --> $DIR/regionck-1.rs:9:5 | LL | type NoTyOutliv<'a, T> = &'a T; - | -- ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at - | | - | the parameter type `T` must be valid for the lifetime `'a` as defined here... + | ^^^^^^^^^^^^^^^^--^^^^ + | | | + | | the parameter type `T` must be valid for the lifetime `'a` as defined here... + | ...so that the reference type `&'a T` does not outlive the data it points at | help: consider adding an explicit lifetime bound | @@ -12,10 +13,10 @@ LL | type NoTyOutliv<'a, T: 'a> = &'a T; | ++++ error[E0491]: in type `&'a &'b ()`, reference has a longer lifetime than the data it references - --> $DIR/regionck-1.rs:10:31 + --> $DIR/regionck-1.rs:10:5 | LL | type NoReOutliv<'a, 'b> = &'a &'b (); - | ^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/regionck-1.rs:10:21 diff --git a/tests/ui/associated-type-bounds/dedup-normalized-2-higher-ranked.current.stderr b/tests/ui/associated-type-bounds/dedup-normalized-2-higher-ranked.current.stderr index 64304be9d6b..eaa212c6ce8 100644 --- a/tests/ui/associated-type-bounds/dedup-normalized-2-higher-ranked.current.stderr +++ b/tests/ui/associated-type-bounds/dedup-normalized-2-higher-ranked.current.stderr @@ -2,7 +2,9 @@ error[E0283]: type annotations needed --> $DIR/dedup-normalized-2-higher-ranked.rs:28:5 | LL | impls(rigid); - | ^^^^^ cannot infer type of the type parameter `U` declared on the function `impls` + | ^^^^^ ----- type must be known at this point + | | + | cannot infer type of the type parameter `U` declared on the function `impls` | = note: cannot satisfy `for<'b> <P as Trait>::Rigid: Bound<'b, _>` note: required by a bound in `impls` diff --git a/tests/ui/associated-types/defaults-unsound-62211-1.current.stderr b/tests/ui/associated-types/defaults-unsound-62211-1.current.stderr index 8b6f0a47aed..b17e26b608d 100644 --- a/tests/ui/associated-types/defaults-unsound-62211-1.current.stderr +++ b/tests/ui/associated-types/defaults-unsound-62211-1.current.stderr @@ -2,9 +2,8 @@ error[E0277]: `Self` doesn't implement `std::fmt::Display` --> $DIR/defaults-unsound-62211-1.rs:24:96 | LL | type Output: Copy + Deref<Target = str> + AddAssign<&'static str> + From<Self> + Display = Self; - | ^^^^ `Self` cannot be formatted with the default formatter + | ^^^^ the trait `std::fmt::Display` is not implemented for `Self` | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-1.rs:24:86 | diff --git a/tests/ui/associated-types/defaults-unsound-62211-1.next.stderr b/tests/ui/associated-types/defaults-unsound-62211-1.next.stderr index 010f51df15a..a858c9c1ba0 100644 --- a/tests/ui/associated-types/defaults-unsound-62211-1.next.stderr +++ b/tests/ui/associated-types/defaults-unsound-62211-1.next.stderr @@ -2,9 +2,8 @@ error[E0277]: `Self` doesn't implement `std::fmt::Display` --> $DIR/defaults-unsound-62211-1.rs:24:96 | LL | type Output: Copy + Deref<Target = str> + AddAssign<&'static str> + From<Self> + Display = Self; - | ^^^^ `Self` cannot be formatted with the default formatter + | ^^^^ the trait `std::fmt::Display` is not implemented for `Self` | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-1.rs:24:86 | diff --git a/tests/ui/associated-types/defaults-unsound-62211-2.current.stderr b/tests/ui/associated-types/defaults-unsound-62211-2.current.stderr index 7552b089133..facfec85afe 100644 --- a/tests/ui/associated-types/defaults-unsound-62211-2.current.stderr +++ b/tests/ui/associated-types/defaults-unsound-62211-2.current.stderr @@ -2,9 +2,8 @@ error[E0277]: `Self` doesn't implement `std::fmt::Display` --> $DIR/defaults-unsound-62211-2.rs:24:96 | LL | type Output: Copy + Deref<Target = str> + AddAssign<&'static str> + From<Self> + Display = Self; - | ^^^^ `Self` cannot be formatted with the default formatter + | ^^^^ the trait `std::fmt::Display` is not implemented for `Self` | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-2.rs:24:86 | diff --git a/tests/ui/associated-types/defaults-unsound-62211-2.next.stderr b/tests/ui/associated-types/defaults-unsound-62211-2.next.stderr index 93478946570..1360843172f 100644 --- a/tests/ui/associated-types/defaults-unsound-62211-2.next.stderr +++ b/tests/ui/associated-types/defaults-unsound-62211-2.next.stderr @@ -2,9 +2,8 @@ error[E0277]: `Self` doesn't implement `std::fmt::Display` --> $DIR/defaults-unsound-62211-2.rs:24:96 | LL | type Output: Copy + Deref<Target = str> + AddAssign<&'static str> + From<Self> + Display = Self; - | ^^^^ `Self` cannot be formatted with the default formatter + | ^^^^ the trait `std::fmt::Display` is not implemented for `Self` | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `UncheckedCopy::Output` --> $DIR/defaults-unsound-62211-2.rs:24:86 | diff --git a/tests/ui/associated-types/impl-wf-cycle-4.stderr b/tests/ui/associated-types/impl-wf-cycle-4.stderr index c966579aecf..fac06e64a31 100644 --- a/tests/ui/associated-types/impl-wf-cycle-4.stderr +++ b/tests/ui/associated-types/impl-wf-cycle-4.stderr @@ -1,4 +1,4 @@ -error[E0391]: cycle detected when computing normalized predicates of `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` +error[E0391]: cycle detected when computing whether `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` has a guaranteed unsized self type --> $DIR/impl-wf-cycle-4.rs:5:1 | LL | / impl<T> Filter for T @@ -6,14 +6,14 @@ LL | | where LL | | T: Fn(Self::ToMatch), | |_________________________^ | -note: ...which requires computing whether `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` has a guaranteed unsized self type... +note: ...which requires computing normalized predicates of `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>`... --> $DIR/impl-wf-cycle-4.rs:5:1 | LL | / impl<T> Filter for T LL | | where LL | | T: Fn(Self::ToMatch), | |_________________________^ - = note: ...which again requires computing normalized predicates of `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>`, completing the cycle + = note: ...which again requires computing whether `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` has a guaranteed unsized self type, completing the cycle note: cycle used when checking that `<impl at $DIR/impl-wf-cycle-4.rs:5:1: 7:26>` is well-formed --> $DIR/impl-wf-cycle-4.rs:5:1 | diff --git a/tests/ui/associated-types/issue-38821.rs b/tests/ui/associated-types/issue-38821.rs index c9be1369f16..60d3b224a5b 100644 --- a/tests/ui/associated-types/issue-38821.rs +++ b/tests/ui/associated-types/issue-38821.rs @@ -32,16 +32,16 @@ pub trait Column: Expression {} //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied +pub enum ColumnInsertValue<Col, Expr> where +//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied + Col: Column, + Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, +//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied //~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied -pub enum ColumnInsertValue<Col, Expr> where -//~^ ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied -//~| ERROR the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - Col: Column, - Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, { Expression(Col, Expr), Default(Col), diff --git a/tests/ui/associated-types/issue-38821.stderr b/tests/ui/associated-types/issue-38821.stderr index 8a19142b730..b03a3cf7f47 100644 --- a/tests/ui/associated-types/issue-38821.stderr +++ b/tests/ui/associated-types/issue-38821.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:40:1 + --> $DIR/issue-38821.rs:35:1 | LL | pub enum ColumnInsertValue<Col, Expr> where | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` @@ -17,16 +17,10 @@ LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Co | +++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:40:1 + --> $DIR/issue-38821.rs:38:22 | -LL | / pub enum ColumnInsertValue<Col, Expr> where -LL | | -LL | | -LL | | Col: Column, -... | -LL | | Default(Col), -LL | | } - | |_^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | note: required for `<Col as Expression>::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -71,11 +65,6 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: consider further restricting the associated type - | -LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull, - | +++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied --> $DIR/issue-38821.rs:23:10 @@ -90,12 +79,13 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:23:10 + --> $DIR/issue-38821.rs:38:22 | -LL | #[derive(Debug, Copy, Clone)] - | ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | note: required for `<Col as Expression>::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -104,7 +94,10 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider further restricting the associated type + | +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull, + | +++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied --> $DIR/issue-38821.rs:23:17 @@ -125,10 +118,10 @@ LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Co | +++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:23:17 + --> $DIR/issue-38821.rs:38:22 | -LL | #[derive(Debug, Copy, Clone)] - | ^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | note: required for `<Col as Expression>::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -137,7 +130,6 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting the associated type | LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull, @@ -174,11 +166,6 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -help: consider further restricting the associated type - | -LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull, - | +++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied --> $DIR/issue-38821.rs:23:23 @@ -193,12 +180,13 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:23:23 + --> $DIR/issue-38821.rs:38:22 | -LL | #[derive(Debug, Copy, Clone)] - | ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | note: required for `<Col as Expression>::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -207,7 +195,10 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +help: consider further restricting the associated type + | +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, <Col as Expression>::SqlType: NotNull, + | +++++++++++++++++++++++++++++++++++++++ error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied --> $DIR/issue-38821.rs:23:10 @@ -225,10 +216,10 @@ LL | impl<T: NotNull> IntoNullable for T { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:23:10 + --> $DIR/issue-38821.rs:38:22 | -LL | #[derive(Debug, Copy, Clone)] - | ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | note: required for `<Col as Expression>::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 @@ -237,7 +228,6 @@ LL | impl<T: NotNull> IntoNullable for T { | ------- ^^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied --> $DIR/issue-38821.rs:23:23 @@ -255,10 +245,10 @@ LL | impl<T: NotNull> IntoNullable for T { = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: the trait bound `<Col as Expression>::SqlType: NotNull` is not satisfied - --> $DIR/issue-38821.rs:23:23 + --> $DIR/issue-38821.rs:38:22 | -LL | #[derive(Debug, Copy, Clone)] - | ^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` +LL | Expr: Expression<SqlType=<Col::SqlType as IntoNullable>::Nullable>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `NotNull` is not implemented for `<Col as Expression>::SqlType` | note: required for `<Col as Expression>::SqlType` to implement `IntoNullable` --> $DIR/issue-38821.rs:9:18 diff --git a/tests/ui/associated-types/issue-59324.rs b/tests/ui/associated-types/issue-59324.rs index 3abe8473052..9d4c7cb39ae 100644 --- a/tests/ui/associated-types/issue-59324.rs +++ b/tests/ui/associated-types/issue-59324.rs @@ -10,8 +10,8 @@ pub trait Service { pub trait ThriftService<Bug: NotFoo>: //~^ ERROR the trait bound `Bug: Foo` is not satisfied -//~| ERROR the trait bound `Bug: Foo` is not satisfied Service<AssocType = <Bug as Foo>::OnlyFoo> +//~^ ERROR the trait bound `Bug: Foo` is not satisfied { fn get_service( //~^ ERROR the trait bound `Bug: Foo` is not satisfied diff --git a/tests/ui/associated-types/issue-59324.stderr b/tests/ui/associated-types/issue-59324.stderr index f79afc89d10..3e2b0f41889 100644 --- a/tests/ui/associated-types/issue-59324.stderr +++ b/tests/ui/associated-types/issue-59324.stderr @@ -2,7 +2,7 @@ error[E0277]: the trait bound `Bug: Foo` is not satisfied --> $DIR/issue-59324.rs:11:1 | LL | / pub trait ThriftService<Bug: NotFoo>: -... | +LL | | LL | | Service<AssocType = <Bug as Foo>::OnlyFoo> | |______________________________________________^ the trait `Foo` is not implemented for `Bug` | @@ -12,15 +12,10 @@ LL | pub trait ThriftService<Bug: NotFoo + Foo>: | +++++ error[E0277]: the trait bound `Bug: Foo` is not satisfied - --> $DIR/issue-59324.rs:11:1 + --> $DIR/issue-59324.rs:13:13 | -LL | / pub trait ThriftService<Bug: NotFoo>: -LL | | -LL | | -LL | | Service<AssocType = <Bug as Foo>::OnlyFoo> -... | -LL | | } - | |_^ the trait `Foo` is not implemented for `Bug` +LL | Service<AssocType = <Bug as Foo>::OnlyFoo> + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Foo` is not implemented for `Bug` | help: consider further restricting type parameter `Bug` with trait `Foo` | diff --git a/tests/ui/associated-types/unconstrained-lifetime-assoc-type.rs b/tests/ui/associated-types/unconstrained-lifetime-assoc-type.rs new file mode 100644 index 00000000000..2c4af7da921 --- /dev/null +++ b/tests/ui/associated-types/unconstrained-lifetime-assoc-type.rs @@ -0,0 +1,21 @@ +//! Regression test for issue #22077 +//! lifetime parameters must be constrained in associated type definitions + +trait Fun { + type Output; + fn call<'x>(&'x self) -> Self::Output; +} + +struct Holder { + x: String, +} + +impl<'a> Fun for Holder { + //~^ ERROR E0207 + type Output = &'a str; + fn call<'b>(&'b self) -> &'b str { + &self.x[..] + } +} + +fn main() {} diff --git a/tests/ui/impl-unused-rps-in-assoc-type.stderr b/tests/ui/associated-types/unconstrained-lifetime-assoc-type.stderr index ef61fa4be48..15d0820c895 100644 --- a/tests/ui/impl-unused-rps-in-assoc-type.stderr +++ b/tests/ui/associated-types/unconstrained-lifetime-assoc-type.stderr @@ -1,5 +1,5 @@ error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-rps-in-assoc-type.rs:11:6 + --> $DIR/unconstrained-lifetime-assoc-type.rs:13:6 | LL | impl<'a> Fun for Holder { | ^^ unconstrained lifetime parameter diff --git a/tests/ui/async-await/async-fn/impl-header.stderr b/tests/ui/async-await/async-fn/impl-header.stderr index 64a98aab17b..2fc7a900a1e 100644 --- a/tests/ui/async-await/async-fn/impl-header.stderr +++ b/tests/ui/async-await/async-fn/impl-header.stderr @@ -22,6 +22,14 @@ LL | impl async Fn<()> for F {} | = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable +error[E0046]: not all trait items implemented, missing: `call` + --> $DIR/impl-header.rs:5:1 + | +LL | impl async Fn<()> for F {} + | ^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation + | + = help: implement the missing item: `fn call(&self, _: ()) -> <Self as FnOnce<()>>::Output { todo!() }` + error[E0277]: expected a `FnMut()` closure, found `F` --> $DIR/impl-header.rs:5:23 | @@ -33,14 +41,6 @@ LL | impl async Fn<()> for F {} note: required by a bound in `Fn` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error[E0046]: not all trait items implemented, missing: `call` - --> $DIR/impl-header.rs:5:1 - | -LL | impl async Fn<()> for F {} - | ^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation - | - = help: implement the missing item: `fn call(&self, _: ()) -> <Self as FnOnce<()>>::Output { todo!() }` - error: aborting due to 5 previous errors Some errors have detailed explanations: E0046, E0183, E0277, E0658. diff --git a/tests/ui/async-await/async-fn/mbe-async-trait-bound-theoretical-regression.rs b/tests/ui/async-await/async-fn/macro-async-trait-bound-theoretical-regression.rs index ea67831b68e..ea67831b68e 100644 --- a/tests/ui/async-await/async-fn/mbe-async-trait-bound-theoretical-regression.rs +++ b/tests/ui/async-await/async-fn/macro-async-trait-bound-theoretical-regression.rs diff --git a/tests/ui/async-await/async-fn/mbe-async-trait-bound-theoretical-regression.stderr b/tests/ui/async-await/async-fn/macro-async-trait-bound-theoretical-regression.stderr index a463944d113..6c3044e64d2 100644 --- a/tests/ui/async-await/async-fn/mbe-async-trait-bound-theoretical-regression.stderr +++ b/tests/ui/async-await/async-fn/macro-async-trait-bound-theoretical-regression.stderr @@ -1,5 +1,5 @@ error: ty - --> $DIR/mbe-async-trait-bound-theoretical-regression.rs:8:19 + --> $DIR/macro-async-trait-bound-theoretical-regression.rs:8:19 | LL | ($ty:ty) => { compile_error!("ty"); }; | ^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | demo! { impl async Trait } = note: this error originates in the macro `demo` (in Nightly builds, run with -Z macro-backtrace for more info) error: ty - --> $DIR/mbe-async-trait-bound-theoretical-regression.rs:8:19 + --> $DIR/macro-async-trait-bound-theoretical-regression.rs:8:19 | LL | ($ty:ty) => { compile_error!("ty"); }; | ^^^^^^^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | demo! { dyn async Trait } = note: this error originates in the macro `demo` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0658]: `async` trait bounds are unstable - --> $DIR/mbe-async-trait-bound-theoretical-regression.rs:15:14 + --> $DIR/macro-async-trait-bound-theoretical-regression.rs:15:14 | LL | demo! { impl async Trait } | ^^^^^ @@ -32,7 +32,7 @@ LL | demo! { impl async Trait } = help: use the desugared name of the async trait, such as `AsyncFn` error[E0658]: `async` trait bounds are unstable - --> $DIR/mbe-async-trait-bound-theoretical-regression.rs:18:13 + --> $DIR/macro-async-trait-bound-theoretical-regression.rs:18:13 | LL | demo! { dyn async Trait } | ^^^^^ diff --git a/tests/ui/issues-71798.rs b/tests/ui/async-await/impl-future-escaping-bound-vars-ice.rs index 14b6c0f3581..ea30e8c839f 100644 --- a/tests/ui/issues-71798.rs +++ b/tests/ui/async-await/impl-future-escaping-bound-vars-ice.rs @@ -1,3 +1,7 @@ +//! Regression test for issue https://github.com/rust-lang/rust/issues/71798 +// ICE with escaping bound variables when impl Future + '_ +// returns non-Future type combined with syntax errors + fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ { //~^ ERROR `u32` is not a future *x diff --git a/tests/ui/issues-71798.stderr b/tests/ui/async-await/impl-future-escaping-bound-vars-ice.stderr index 52dd14ccb0a..5beca58e13c 100644 --- a/tests/ui/issues-71798.stderr +++ b/tests/ui/async-await/impl-future-escaping-bound-vars-ice.stderr @@ -1,11 +1,11 @@ error[E0425]: cannot find value `u` in this scope - --> $DIR/issues-71798.rs:7:24 + --> $DIR/impl-future-escaping-bound-vars-ice.rs:11:24 | LL | let _ = test_ref & u; | ^ not found in this scope error[E0277]: `u32` is not a future - --> $DIR/issues-71798.rs:1:25 + --> $DIR/impl-future-escaping-bound-vars-ice.rs:5:25 | LL | fn test_ref(x: &u32) -> impl std::future::Future<Output = u32> + '_ { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `u32` is not a future diff --git a/tests/ui/async-await/incorrect-move-async-order-issue-79694.fixed b/tests/ui/async-await/incorrect-move-async-order-issue-79694.fixed index c74a32e442f..9e5e889506c 100644 --- a/tests/ui/async-await/incorrect-move-async-order-issue-79694.fixed +++ b/tests/ui/async-await/incorrect-move-async-order-issue-79694.fixed @@ -4,5 +4,5 @@ // Regression test for issue 79694 fn main() { - let _ = async move { }; //~ ERROR 7:13: 7:23: the order of `move` and `async` is incorrect + let _ = async move { }; //~ ERROR the order of `move` and `async` is incorrect } diff --git a/tests/ui/async-await/incorrect-move-async-order-issue-79694.rs b/tests/ui/async-await/incorrect-move-async-order-issue-79694.rs index 81ffbacc327..9c36a6c96da 100644 --- a/tests/ui/async-await/incorrect-move-async-order-issue-79694.rs +++ b/tests/ui/async-await/incorrect-move-async-order-issue-79694.rs @@ -4,5 +4,5 @@ // Regression test for issue 79694 fn main() { - let _ = move async { }; //~ ERROR 7:13: 7:23: the order of `move` and `async` is incorrect + let _ = move async { }; //~ ERROR the order of `move` and `async` is incorrect } diff --git a/tests/ui/async-await/issues/issue-95307.rs b/tests/ui/async-await/issues/issue-95307.rs index 83df65612b4..40905c239c3 100644 --- a/tests/ui/async-await/issues/issue-95307.rs +++ b/tests/ui/async-await/issues/issue-95307.rs @@ -5,7 +5,10 @@ pub trait C { async fn new() -> [u8; _]; - //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for opaque types + //~| ERROR: the placeholder `_` is not allowed within types on item signatures for opaque types + //~| ERROR: the placeholder `_` is not allowed within types on item signatures for opaque types + //~| ERROR: the placeholder `_` is not allowed within types on item signatures for opaque types } fn main() {} diff --git a/tests/ui/async-await/issues/issue-95307.stderr b/tests/ui/async-await/issues/issue-95307.stderr index c670686f7c9..0aae7a215cd 100644 --- a/tests/ui/async-await/issues/issue-95307.stderr +++ b/tests/ui/async-await/issues/issue-95307.stderr @@ -1,9 +1,33 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for opaque types --> $DIR/issue-95307.rs:7:28 | LL | async fn new() -> [u8; _]; | ^ not allowed in type signatures -error: aborting due to 1 previous error +error[E0121]: the placeholder `_` is not allowed within types on item signatures for opaque types + --> $DIR/issue-95307.rs:7:28 + | +LL | async fn new() -> [u8; _]; + | ^ not allowed in type signatures + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for opaque types + --> $DIR/issue-95307.rs:7:28 + | +LL | async fn new() -> [u8; _]; + | ^ not allowed in type signatures + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for opaque types + --> $DIR/issue-95307.rs:7:28 + | +LL | async fn new() -> [u8; _]; + | ^ not allowed in type signatures + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/attributes/crate-type-macro-empty.rs b/tests/ui/attributes/crate-type-macro-empty.rs index 5ff7fc002fd..217ff598f7a 100644 --- a/tests/ui/attributes/crate-type-macro-empty.rs +++ b/tests/ui/attributes/crate-type-macro-empty.rs @@ -2,6 +2,6 @@ #[crate_type = foo!()] //~^ ERROR cannot find macro `foo` in this scope -macro_rules! foo {} //~ ERROR unexpected end of macro invocation +macro_rules! foo {} //~ ERROR macros must contain at least one rule fn main() {} diff --git a/tests/ui/attributes/crate-type-macro-empty.stderr b/tests/ui/attributes/crate-type-macro-empty.stderr index e48d3d95470..130fa454ca1 100644 --- a/tests/ui/attributes/crate-type-macro-empty.stderr +++ b/tests/ui/attributes/crate-type-macro-empty.stderr @@ -1,8 +1,8 @@ -error: unexpected end of macro invocation +error: macros must contain at least one rule --> $DIR/crate-type-macro-empty.rs:5:1 | LL | macro_rules! foo {} - | ^^^^^^^^^^^^^^^^^^^ missing tokens in macro arguments + | ^^^^^^^^^^^^^^^^^^^ error: cannot find macro `foo` in this scope --> $DIR/crate-type-macro-empty.rs:2:16 diff --git a/tests/ui/attributes/fn-align-dyn.rs b/tests/ui/attributes/fn-align-dyn.rs new file mode 100644 index 00000000000..8ba4d5e2897 --- /dev/null +++ b/tests/ui/attributes/fn-align-dyn.rs @@ -0,0 +1,16 @@ +//@ run-pass +//@ ignore-wasm32 aligning functions is not currently supported on wasm (#143368) +#![feature(fn_align)] + +trait Test { + #[align(4096)] + fn foo(&self); + + #[align(4096)] + fn foo1(&self); +} + +fn main() { + assert_eq!((<dyn Test>::foo as fn(_) as usize & !1) % 4096, 0); + assert_eq!((<dyn Test>::foo1 as fn(_) as usize & !1) % 4096, 0); +} diff --git a/tests/ui/inline-disallow-on-variant.rs b/tests/ui/attributes/inline-attribute-enum-variant-error.rs index d92a4e8cc8d..305b285d2a4 100644 --- a/tests/ui/inline-disallow-on-variant.rs +++ b/tests/ui/attributes/inline-attribute-enum-variant-error.rs @@ -1,3 +1,5 @@ +//! Test that #[inline] attribute cannot be applied to enum variants + enum Foo { #[inline] //~^ ERROR attribute should be applied diff --git a/tests/ui/inline-disallow-on-variant.stderr b/tests/ui/attributes/inline-attribute-enum-variant-error.stderr index 255f6bc6a19..a4564d8f722 100644 --- a/tests/ui/inline-disallow-on-variant.stderr +++ b/tests/ui/attributes/inline-attribute-enum-variant-error.stderr @@ -1,5 +1,5 @@ error[E0518]: attribute should be applied to function or closure - --> $DIR/inline-disallow-on-variant.rs:2:5 + --> $DIR/inline-attribute-enum-variant-error.rs:4:5 | LL | #[inline] | ^^^^^^^^^ diff --git a/tests/ui/attributes/inline-main.rs b/tests/ui/attributes/inline-main.rs new file mode 100644 index 00000000000..7181ee19b67 --- /dev/null +++ b/tests/ui/attributes/inline-main.rs @@ -0,0 +1,6 @@ +//! Test that #[inline(always)] can be applied to main function + +//@ run-pass + +#[inline(always)] +fn main() {} diff --git a/tests/ui/attributes/inner-attrs-impl-cfg.rs b/tests/ui/attributes/inner-attrs-impl-cfg.rs new file mode 100644 index 00000000000..e7a5cfa9e2f --- /dev/null +++ b/tests/ui/attributes/inner-attrs-impl-cfg.rs @@ -0,0 +1,36 @@ +//! Test inner attributes (#![...]) behavior in impl blocks with cfg conditions. +//! +//! This test verifies that: +//! - Inner attributes can conditionally exclude entire impl blocks +//! - Regular attributes within impl blocks work independently +//! - Attribute parsing doesn't consume too eagerly + +//@ run-pass + +struct Foo; + +impl Foo { + #![cfg(false)] + + fn method(&self) -> bool { + false + } +} + +impl Foo { + #![cfg(not(FALSE))] + + // Check that we don't eat attributes too eagerly. + #[cfg(false)] + fn method(&self) -> bool { + false + } + + fn method(&self) -> bool { + true + } +} + +pub fn main() { + assert!(Foo.method()); +} diff --git a/tests/ui/attributes/lint_on_root.rs b/tests/ui/attributes/lint_on_root.rs new file mode 100644 index 00000000000..93d47bf0d71 --- /dev/null +++ b/tests/ui/attributes/lint_on_root.rs @@ -0,0 +1,7 @@ +// NOTE: this used to panic in debug builds (by a sanity assertion) +// and not emit any lint on release builds. See https://github.com/rust-lang/rust/issues/142891. +#![inline = ""] +//~^ ERROR valid forms for the attribute are `#[inline(always|never)]` and `#[inline]` +//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +fn main() {} diff --git a/tests/ui/attributes/lint_on_root.stderr b/tests/ui/attributes/lint_on_root.stderr new file mode 100644 index 00000000000..aaa46e6f54b --- /dev/null +++ b/tests/ui/attributes/lint_on_root.stderr @@ -0,0 +1,12 @@ +error: valid forms for the attribute are `#[inline(always|never)]` and `#[inline]` + --> $DIR/lint_on_root.rs:3:1 + | +LL | #![inline = ""] + | ^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +error: aborting due to 1 previous error + diff --git a/tests/ui/attributes/malformed-attrs.rs b/tests/ui/attributes/malformed-attrs.rs new file mode 100644 index 00000000000..aa52de63a60 --- /dev/null +++ b/tests/ui/attributes/malformed-attrs.rs @@ -0,0 +1,230 @@ +// This file contains a bunch of malformed attributes. +// We enable a bunch of features to not get feature-gate errs in this test. +#![feature(rustc_attrs)] +#![feature(rustc_allow_const_fn_unstable)] +#![feature(allow_internal_unstable)] +#![feature(fn_align)] +#![feature(optimize_attribute)] +#![feature(dropck_eyepatch)] +#![feature(export_stable)] +#![allow(incomplete_features)] +#![feature(min_generic_const_args)] +#![feature(ffi_const, ffi_pure)] +#![feature(coverage_attribute)] +#![feature(no_sanitize)] +#![feature(marker_trait_attr)] +#![feature(thread_local)] +#![feature(must_not_suspend)] +#![feature(coroutines)] +#![feature(linkage)] +#![feature(cfi_encoding, extern_types)] +#![feature(patchable_function_entry)] +#![feature(omit_gdb_pretty_printer_section)] +#![feature(fundamental)] + + +#![omit_gdb_pretty_printer_section = 1] +//~^ ERROR malformed `omit_gdb_pretty_printer_section` attribute input + +#![windows_subsystem] +//~^ ERROR malformed + +#[unsafe(export_name)] +//~^ ERROR malformed +#[rustc_allow_const_fn_unstable] +//~^ ERROR `rustc_allow_const_fn_unstable` expects a list of feature names +//~| ERROR attribute should be applied to `const fn` +#[allow_internal_unstable] +//~^ ERROR `allow_internal_unstable` expects a list of feature names +#[rustc_confusables] +//~^ ERROR malformed +#[deprecated = 5] +//~^ ERROR malformed +#[doc] +//~^ ERROR valid forms for the attribute are +//~| WARN this was previously accepted by the compiler +#[rustc_macro_transparency] +//~^ ERROR malformed +#[repr] +//~^ ERROR malformed +//~| ERROR is not supported on function items +#[rustc_as_ptr = 5] +//~^ ERROR malformed +#[inline = 5] +//~^ ERROR valid forms for the attribute are +//~| WARN this was previously accepted by the compiler +#[align] +//~^ ERROR malformed +#[optimize] +//~^ ERROR malformed +#[cold = 1] +//~^ ERROR malformed +#[must_use()] +//~^ ERROR valid forms for the attribute are +#[no_mangle = 1] +//~^ ERROR malformed +#[unsafe(naked())] +//~^ ERROR malformed +#[track_caller()] +//~^ ERROR malformed +#[export_name()] +//~^ ERROR malformed +#[used()] +//~^ ERROR malformed +#[crate_name] +//~^ ERROR malformed +#[doc] +//~^ ERROR valid forms for the attribute are +//~| WARN this was previously accepted by the compiler +#[target_feature] +//~^ ERROR malformed +#[export_stable = 1] +//~^ ERROR malformed +#[link] +//~^ ERROR attribute must be of the form +//~| WARN this was previously accepted by the compiler +#[link_name] +//~^ ERROR malformed +#[link_section] +//~^ ERROR malformed +#[coverage] +//~^ ERROR malformed `coverage` attribute input +#[no_sanitize] +//~^ ERROR malformed +#[ignore()] +//~^ ERROR valid forms for the attribute are +//~| WARN this was previously accepted by the compiler +#[no_implicit_prelude = 23] +//~^ ERROR malformed +#[proc_macro = 18] +//~^ ERROR malformed +//~| ERROR the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type +#[cfg] +//~^ ERROR is not followed by parentheses +#[cfg_attr] +//~^ ERROR malformed +#[instruction_set] +//~^ ERROR malformed +#[patchable_function_entry] +//~^ ERROR malformed +fn test() { + #[coroutine = 63] || {} + //~^ ERROR malformed `coroutine` attribute input + //~| ERROR mismatched types [E0308] +} + +#[proc_macro_attribute = 19] +//~^ ERROR malformed +//~| ERROR the `#[proc_macro_attribute]` attribute is only usable with crates of the `proc-macro` crate type +#[must_use = 1] +//~^ ERROR malformed +fn test2() { } + +#[proc_macro_derive] +//~^ ERROR malformed `proc_macro_derive` attribute +//~| ERROR the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type +pub fn test3() {} + +#[rustc_layout_scalar_valid_range_start] +//~^ ERROR malformed +#[rustc_layout_scalar_valid_range_end] +//~^ ERROR malformed +#[must_not_suspend()] +//~^ ERROR malformed +#[cfi_encoding] +//~^ ERROR malformed +struct Test; + +#[diagnostic::on_unimplemented] +//~^ WARN missing options for `on_unimplemented` attribute +#[diagnostic::on_unimplemented = 1] +//~^ WARN malformed +trait Hey { + #[type_const = 1] + //~^ ERROR malformed + const HEY: usize = 5; +} + +struct Empty; +#[diagnostic::do_not_recommend()] +//~^ WARN does not expect any arguments +impl Hey for Empty { + +} + +#[marker = 3] +//~^ ERROR malformed +#[fundamental()] +//~^ ERROR malformed +trait EmptyTrait { + +} + + +extern "C" { + #[unsafe(ffi_pure = 1)] + //~^ ERROR malformed + #[link_ordinal] + //~^ ERROR malformed + pub fn baz(); + + #[unsafe(ffi_const = 1)] + //~^ ERROR malformed + #[linkage] + //~^ ERROR malformed + pub fn bar(); +} + +#[allow] +//~^ ERROR malformed +#[expect] +//~^ ERROR malformed +#[warn] +//~^ ERROR malformed +#[deny] +//~^ ERROR malformed +#[forbid] +//~^ ERROR malformed +#[debugger_visualizer] +//~^ ERROR invalid argument +//~| ERROR malformed `debugger_visualizer` attribute input +#[automatically_derived = 18] +//~^ ERROR malformed +mod yooo { + +} + +#[non_exhaustive = 1] +//~^ ERROR malformed +enum Slenum { + +} + +#[thread_local()] +//~^ ERROR malformed +static mut TLS: u8 = 42; + +#[no_link()] +//~^ ERROR malformed +#[macro_use = 1] +//~^ ERROR malformed +extern crate wloop; +//~^ ERROR can't find crate for `wloop` [E0463] + +#[macro_export = 18] +//~^ ERROR malformed `macro_export` attribute input +#[allow_internal_unsafe = 1] +//~^ ERROR malformed +//~| ERROR allow_internal_unsafe side-steps the unsafe_code lint +macro_rules! slump { + () => {} +} + +#[ignore = 1] +//~^ ERROR valid forms for the attribute are +//~| WARN this was previously accepted by the compiler +fn thing() { + +} + +fn main() {} diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr new file mode 100644 index 00000000000..2f7bf50ead5 --- /dev/null +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -0,0 +1,638 @@ +error: `cfg` is not followed by parentheses + --> $DIR/malformed-attrs.rs:102:1 + | +LL | #[cfg] + | ^^^^^^ help: expected syntax is: `cfg(/* predicate */)` + +error: malformed `cfg_attr` attribute input + --> $DIR/malformed-attrs.rs:104:1 + | +LL | #[cfg_attr] + | ^^^^^^^^^^^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg_attr-attribute> +help: missing condition and attribute + | +LL | #[cfg_attr(condition, attribute, other_attribute, ...)] + | ++++++++++++++++++++++++++++++++++++++++++++ + +error[E0463]: can't find crate for `wloop` + --> $DIR/malformed-attrs.rs:211:1 + | +LL | extern crate wloop; + | ^^^^^^^^^^^^^^^^^^^ can't find crate + +error: malformed `omit_gdb_pretty_printer_section` attribute input + --> $DIR/malformed-attrs.rs:26:1 + | +LL | #![omit_gdb_pretty_printer_section = 1] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![omit_gdb_pretty_printer_section]` + +error: malformed `windows_subsystem` attribute input + --> $DIR/malformed-attrs.rs:29:1 + | +LL | #![windows_subsystem] + | ^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![windows_subsystem = "windows|console"]` + +error: malformed `crate_name` attribute input + --> $DIR/malformed-attrs.rs:74:1 + | +LL | #[crate_name] + | ^^^^^^^^^^^^^ help: must be of the form: `#[crate_name = "name"]` + +error: malformed `export_stable` attribute input + --> $DIR/malformed-attrs.rs:81:1 + | +LL | #[export_stable = 1] + | ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_stable]` + +error: malformed `coverage` attribute input + --> $DIR/malformed-attrs.rs:90:1 + | +LL | #[coverage] + | ^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL | #[coverage(off)] + | +++++ +LL | #[coverage(on)] + | ++++ + +error: malformed `no_sanitize` attribute input + --> $DIR/malformed-attrs.rs:92:1 + | +LL | #[no_sanitize] + | ^^^^^^^^^^^^^^ help: must be of the form: `#[no_sanitize(address, kcfi, memory, thread)]` + +error: malformed `proc_macro` attribute input + --> $DIR/malformed-attrs.rs:99:1 + | +LL | #[proc_macro = 18] + | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[proc_macro]` + +error: malformed `instruction_set` attribute input + --> $DIR/malformed-attrs.rs:106:1 + | +LL | #[instruction_set] + | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[instruction_set(set)]` + +error: malformed `patchable_function_entry` attribute input + --> $DIR/malformed-attrs.rs:108:1 + | +LL | #[patchable_function_entry] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` + +error: malformed `coroutine` attribute input + --> $DIR/malformed-attrs.rs:111:5 + | +LL | #[coroutine = 63] || {} + | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[coroutine]` + +error: malformed `proc_macro_attribute` attribute input + --> $DIR/malformed-attrs.rs:116:1 + | +LL | #[proc_macro_attribute = 19] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[proc_macro_attribute]` + +error: malformed `proc_macro_derive` attribute input + --> $DIR/malformed-attrs.rs:123:1 + | +LL | #[proc_macro_derive] + | ^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[proc_macro_derive(TraitName, /*opt*/ attributes(name1, name2, ...))]` + +error: malformed `must_not_suspend` attribute input + --> $DIR/malformed-attrs.rs:132:1 + | +LL | #[must_not_suspend()] + | ^^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL - #[must_not_suspend()] +LL + #[must_not_suspend = "reason"] + | +LL - #[must_not_suspend()] +LL + #[must_not_suspend] + | + +error: malformed `cfi_encoding` attribute input + --> $DIR/malformed-attrs.rs:134:1 + | +LL | #[cfi_encoding] + | ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]` + +error: malformed `type_const` attribute input + --> $DIR/malformed-attrs.rs:143:5 + | +LL | #[type_const = 1] + | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[type_const]` + +error: malformed `marker` attribute input + --> $DIR/malformed-attrs.rs:155:1 + | +LL | #[marker = 3] + | ^^^^^^^^^^^^^ help: must be of the form: `#[marker]` + +error: malformed `fundamental` attribute input + --> $DIR/malformed-attrs.rs:157:1 + | +LL | #[fundamental()] + | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[fundamental]` + +error: malformed `ffi_pure` attribute input + --> $DIR/malformed-attrs.rs:165:5 + | +LL | #[unsafe(ffi_pure = 1)] + | ^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[ffi_pure]` + +error: malformed `link_ordinal` attribute input + --> $DIR/malformed-attrs.rs:167:5 + | +LL | #[link_ordinal] + | ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_ordinal(ordinal)]` + +error: malformed `ffi_const` attribute input + --> $DIR/malformed-attrs.rs:171:5 + | +LL | #[unsafe(ffi_const = 1)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[ffi_const]` + +error: malformed `linkage` attribute input + --> $DIR/malformed-attrs.rs:173:5 + | +LL | #[linkage] + | ^^^^^^^^^^ help: must be of the form: `#[linkage = "external|internal|..."]` + +error: malformed `allow` attribute input + --> $DIR/malformed-attrs.rs:178:1 + | +LL | #[allow] + | ^^^^^^^^ help: must be of the form: `#[allow(lint1, lint2, ..., /*opt*/ reason = "...")]` + +error: malformed `expect` attribute input + --> $DIR/malformed-attrs.rs:180:1 + | +LL | #[expect] + | ^^^^^^^^^ help: must be of the form: `#[expect(lint1, lint2, ..., /*opt*/ reason = "...")]` + +error: malformed `warn` attribute input + --> $DIR/malformed-attrs.rs:182:1 + | +LL | #[warn] + | ^^^^^^^ help: must be of the form: `#[warn(lint1, lint2, ..., /*opt*/ reason = "...")]` + +error: malformed `deny` attribute input + --> $DIR/malformed-attrs.rs:184:1 + | +LL | #[deny] + | ^^^^^^^ help: must be of the form: `#[deny(lint1, lint2, ..., /*opt*/ reason = "...")]` + +error: malformed `forbid` attribute input + --> $DIR/malformed-attrs.rs:186:1 + | +LL | #[forbid] + | ^^^^^^^^^ help: must be of the form: `#[forbid(lint1, lint2, ..., /*opt*/ reason = "...")]` + +error: malformed `debugger_visualizer` attribute input + --> $DIR/malformed-attrs.rs:188:1 + | +LL | #[debugger_visualizer] + | ^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[debugger_visualizer(natvis_file = "...", gdb_script_file = "...")]` + +error: malformed `automatically_derived` attribute input + --> $DIR/malformed-attrs.rs:191:1 + | +LL | #[automatically_derived = 18] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[automatically_derived]` + +error: malformed `thread_local` attribute input + --> $DIR/malformed-attrs.rs:203:1 + | +LL | #[thread_local()] + | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[thread_local]` + +error: malformed `no_link` attribute input + --> $DIR/malformed-attrs.rs:207:1 + | +LL | #[no_link()] + | ^^^^^^^^^^^^ help: must be of the form: `#[no_link]` + +error: malformed `macro_use` attribute input + --> $DIR/malformed-attrs.rs:209:1 + | +LL | #[macro_use = 1] + | ^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL - #[macro_use = 1] +LL + #[macro_use(name1, name2, ...)] + | +LL - #[macro_use = 1] +LL + #[macro_use] + | + +error: malformed `macro_export` attribute input + --> $DIR/malformed-attrs.rs:214:1 + | +LL | #[macro_export = 18] + | ^^^^^^^^^^^^^^^^^^^^ + | +help: the following are the possible correct uses + | +LL - #[macro_export = 18] +LL + #[macro_export(local_inner_macros)] + | +LL - #[macro_export = 18] +LL + #[macro_export] + | + +error: malformed `allow_internal_unsafe` attribute input + --> $DIR/malformed-attrs.rs:216:1 + | +LL | #[allow_internal_unsafe = 1] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[allow_internal_unsafe]` + +error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type + --> $DIR/malformed-attrs.rs:99:1 + | +LL | #[proc_macro = 18] + | ^^^^^^^^^^^^^^^^^^ + +error: the `#[proc_macro_attribute]` attribute is only usable with crates of the `proc-macro` crate type + --> $DIR/malformed-attrs.rs:116:1 + | +LL | #[proc_macro_attribute = 19] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: the `#[proc_macro_derive]` attribute is only usable with crates of the `proc-macro` crate type + --> $DIR/malformed-attrs.rs:123:1 + | +LL | #[proc_macro_derive] + | ^^^^^^^^^^^^^^^^^^^^ + +error[E0658]: allow_internal_unsafe side-steps the unsafe_code lint + --> $DIR/malformed-attrs.rs:216:1 + | +LL | #[allow_internal_unsafe = 1] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(allow_internal_unsafe)]` 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: valid forms for the attribute are `#[doc(hidden|inline|...)]` and `#[doc = "string"]` + --> $DIR/malformed-attrs.rs:43:1 + | +LL | #[doc] + | ^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + = note: `#[deny(ill_formed_attribute_input)]` on by default + +error: valid forms for the attribute are `#[doc(hidden|inline|...)]` and `#[doc = "string"]` + --> $DIR/malformed-attrs.rs:76:1 + | +LL | #[doc] + | ^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + +error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated")]` + --> $DIR/malformed-attrs.rs:83:1 + | +LL | #[link] + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + +error: invalid argument + --> $DIR/malformed-attrs.rs:188:1 + | +LL | #[debugger_visualizer] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = note: expected: `natvis_file = "..."` + = note: OR + = note: expected: `gdb_script_file = "..."` + +error[E0539]: malformed `export_name` attribute input + --> $DIR/malformed-attrs.rs:32:1 + | +LL | #[unsafe(export_name)] + | ^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_name = "name"]` + +error: `rustc_allow_const_fn_unstable` expects a list of feature names + --> $DIR/malformed-attrs.rs:34:1 + | +LL | #[rustc_allow_const_fn_unstable] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `allow_internal_unstable` expects a list of feature names + --> $DIR/malformed-attrs.rs:37:1 + | +LL | #[allow_internal_unstable] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0539]: malformed `rustc_confusables` attribute input + --> $DIR/malformed-attrs.rs:39:1 + | +LL | #[rustc_confusables] + | ^^^^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[rustc_confusables("name1", "name2", ...)]` + +error[E0539]: malformed `deprecated` attribute input + --> $DIR/malformed-attrs.rs:41:1 + | +LL | #[deprecated = 5] + | ^^^^^^^^^^^^^^^-^ + | | + | expected a string literal here + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[deprecated = 5] +LL + #[deprecated = "reason"] + | +LL - #[deprecated = 5] +LL + #[deprecated(/*opt*/ since = "version", /*opt*/ note = "reason")] + | +LL - #[deprecated = 5] +LL + #[deprecated] + | + +error[E0539]: malformed `rustc_macro_transparency` attribute input + --> $DIR/malformed-attrs.rs:46:1 + | +LL | #[rustc_macro_transparency] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[rustc_macro_transparency = "transparent|semitransparent|opaque"]` + +error[E0539]: malformed `repr` attribute input + --> $DIR/malformed-attrs.rs:48:1 + | +LL | #[repr] + | ^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]` + +error[E0565]: malformed `rustc_as_ptr` attribute input + --> $DIR/malformed-attrs.rs:51:1 + | +LL | #[rustc_as_ptr = 5] + | ^^^^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[rustc_as_ptr]` + +error[E0539]: malformed `align` attribute input + --> $DIR/malformed-attrs.rs:56:1 + | +LL | #[align] + | ^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[align(<alignment in bytes>)]` + +error[E0539]: malformed `optimize` attribute input + --> $DIR/malformed-attrs.rs:58:1 + | +LL | #[optimize] + | ^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[optimize(size|speed|none)]` + +error[E0565]: malformed `cold` attribute input + --> $DIR/malformed-attrs.rs:60:1 + | +LL | #[cold = 1] + | ^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[cold]` + +error: valid forms for the attribute are `#[must_use = "reason"]` and `#[must_use]` + --> $DIR/malformed-attrs.rs:62:1 + | +LL | #[must_use()] + | ^^^^^^^^^^^^^ + +error[E0565]: malformed `no_mangle` attribute input + --> $DIR/malformed-attrs.rs:64:1 + | +LL | #[no_mangle = 1] + | ^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[no_mangle]` + +error[E0565]: malformed `naked` attribute input + --> $DIR/malformed-attrs.rs:66:1 + | +LL | #[unsafe(naked())] + | ^^^^^^^^^^^^^^--^^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[naked]` + +error[E0565]: malformed `track_caller` attribute input + --> $DIR/malformed-attrs.rs:68:1 + | +LL | #[track_caller()] + | ^^^^^^^^^^^^^^--^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[track_caller]` + +error[E0539]: malformed `export_name` attribute input + --> $DIR/malformed-attrs.rs:70:1 + | +LL | #[export_name()] + | ^^^^^^^^^^^^^^^^ help: must be of the form: `#[export_name = "name"]` + +error[E0805]: malformed `used` attribute input + --> $DIR/malformed-attrs.rs:72:1 + | +LL | #[used()] + | ^^^^^^--^ + | | + | expected a single argument here + | +help: try changing it to one of the following valid forms of the attribute + | +LL | #[used(compiler|linker)] + | +++++++++++++++ +LL - #[used()] +LL + #[used] + | + +error[E0539]: malformed `target_feature` attribute input + --> $DIR/malformed-attrs.rs:79:1 + | +LL | #[target_feature] + | ^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]` + +error[E0539]: malformed `link_name` attribute input + --> $DIR/malformed-attrs.rs:86:1 + | +LL | #[link_name] + | ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]` + +error[E0539]: malformed `link_section` attribute input + --> $DIR/malformed-attrs.rs:88:1 + | +LL | #[link_section] + | ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_section = "name"]` + +error[E0565]: malformed `no_implicit_prelude` attribute input + --> $DIR/malformed-attrs.rs:97:1 + | +LL | #[no_implicit_prelude = 23] + | ^^^^^^^^^^^^^^^^^^^^^^----^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[no_implicit_prelude]` + +error[E0539]: malformed `must_use` attribute input + --> $DIR/malformed-attrs.rs:119:1 + | +LL | #[must_use = 1] + | ^^^^^^^^^^^^^-^ + | | + | expected a string literal here + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[must_use = 1] +LL + #[must_use = "reason"] + | +LL - #[must_use = 1] +LL + #[must_use] + | + +error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input + --> $DIR/malformed-attrs.rs:128:1 + | +LL | #[rustc_layout_scalar_valid_range_start] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` + +error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input + --> $DIR/malformed-attrs.rs:130:1 + | +LL | #[rustc_layout_scalar_valid_range_end] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` + +error[E0565]: malformed `non_exhaustive` attribute input + --> $DIR/malformed-attrs.rs:197:1 + | +LL | #[non_exhaustive = 1] + | ^^^^^^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[non_exhaustive]` + +error: attribute should be applied to `const fn` + --> $DIR/malformed-attrs.rs:34:1 + | +LL | #[rustc_allow_const_fn_unstable] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | / fn test() { +LL | | #[coroutine = 63] || {} +... | +LL | | } + | |_- not a `const fn` + +error: `#[repr(align(...))]` is not supported on function items + --> $DIR/malformed-attrs.rs:48:1 + | +LL | #[repr] + | ^^^^^^^ + | +help: use `#[align(...)]` instead + --> $DIR/malformed-attrs.rs:48:1 + | +LL | #[repr] + | ^^^^^^^ + +warning: `#[diagnostic::do_not_recommend]` does not expect any arguments + --> $DIR/malformed-attrs.rs:149:1 + | +LL | #[diagnostic::do_not_recommend()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `#[warn(unknown_or_malformed_diagnostic_attributes)]` on by default + +warning: missing options for `on_unimplemented` attribute + --> $DIR/malformed-attrs.rs:138:1 + | +LL | #[diagnostic::on_unimplemented] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: at least one of the `message`, `note` and `label` options are expected + +warning: malformed `on_unimplemented` attribute + --> $DIR/malformed-attrs.rs:140:1 + | +LL | #[diagnostic::on_unimplemented = 1] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here + | + = help: only `message`, `note` and `label` are allowed as options + +error: valid forms for the attribute are `#[inline(always|never)]` and `#[inline]` + --> $DIR/malformed-attrs.rs:53:1 + | +LL | #[inline = 5] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + +error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` + --> $DIR/malformed-attrs.rs:94:1 + | +LL | #[ignore()] + | ^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + +error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` + --> $DIR/malformed-attrs.rs:223:1 + | +LL | #[ignore = 1] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + +error[E0308]: mismatched types + --> $DIR/malformed-attrs.rs:111:23 + | +LL | fn test() { + | - help: a return type might be missing here: `-> _` +LL | #[coroutine = 63] || {} + | ^^^^^ expected `()`, found coroutine + | + = note: expected unit type `()` + found coroutine `{coroutine@$DIR/malformed-attrs.rs:111:23: 111:25}` + +error: aborting due to 75 previous errors; 3 warnings emitted + +Some errors have detailed explanations: E0308, E0463, E0539, E0565, E0658, E0805. +For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/attributes/malformed-fn-align.rs b/tests/ui/attributes/malformed-fn-align.rs index f5ab9555e56..e06e6116842 100644 --- a/tests/ui/attributes/malformed-fn-align.rs +++ b/tests/ui/attributes/malformed-fn-align.rs @@ -21,5 +21,29 @@ fn f3() {} #[repr(align(16))] //~ ERROR `#[repr(align(...))]` is not supported on function items fn f4() {} +#[align(-1)] //~ ERROR expected unsuffixed literal, found `-` +fn f5() {} + +#[align(3)] //~ ERROR invalid alignment value: not a power of two +fn f6() {} + +#[align(4usize)] //~ ERROR invalid alignment value: not an unsuffixed integer [E0589] +//~^ ERROR suffixed literals are not allowed in attributes +fn f7() {} + +#[align(16)] +#[align(3)] //~ ERROR invalid alignment value: not a power of two +#[align(16)] +fn f8() {} + #[align(16)] //~ ERROR `#[align(...)]` is not supported on struct items struct S1; + +#[align(32)] //~ ERROR `#[align(...)]` should be applied to a function item +const FOO: i32 = 42; + +#[align(32)] //~ ERROR `#[align(...)]` should be applied to a function item +mod test {} + +#[align(32)] //~ ERROR `#[align(...)]` should be applied to a function item +use ::std::iter; diff --git a/tests/ui/attributes/malformed-fn-align.stderr b/tests/ui/attributes/malformed-fn-align.stderr index b769d0b457d..af3625b1f3b 100644 --- a/tests/ui/attributes/malformed-fn-align.stderr +++ b/tests/ui/attributes/malformed-fn-align.stderr @@ -1,3 +1,17 @@ +error: expected unsuffixed literal, found `-` + --> $DIR/malformed-fn-align.rs:24:9 + | +LL | #[align(-1)] + | ^ + +error: suffixed literals are not allowed in attributes + --> $DIR/malformed-fn-align.rs:30:9 + | +LL | #[align(4usize)] + | ^^^^^^ + | + = help: instead of using a suffixed literal (`1u8`, `1.0f32`, etc.), use an unsuffixed version (`1`, `1.0`, etc.) + error[E0539]: malformed `align` attribute input --> $DIR/malformed-fn-align.rs:5:5 | @@ -37,6 +51,24 @@ error[E0589]: invalid alignment value: not a power of two LL | #[align(0)] | ^ +error[E0589]: invalid alignment value: not a power of two + --> $DIR/malformed-fn-align.rs:27:9 + | +LL | #[align(3)] + | ^ + +error[E0589]: invalid alignment value: not an unsuffixed integer + --> $DIR/malformed-fn-align.rs:30:9 + | +LL | #[align(4usize)] + | ^^^^^^ + +error[E0589]: invalid alignment value: not a power of two + --> $DIR/malformed-fn-align.rs:35:9 + | +LL | #[align(3)] + | ^ + error: `#[repr(align(...))]` is not supported on function items --> $DIR/malformed-fn-align.rs:21:8 | @@ -50,7 +82,7 @@ LL | #[repr(align(16))] | ^^^^^^^^^ error: `#[align(...)]` is not supported on struct items - --> $DIR/malformed-fn-align.rs:24:1 + --> $DIR/malformed-fn-align.rs:39:1 | LL | #[align(16)] | ^^^^^^^^^^^^ @@ -61,7 +93,31 @@ LL - #[align(16)] LL + #[repr(align(16))] | -error: aborting due to 7 previous errors +error: `#[align(...)]` should be applied to a function item + --> $DIR/malformed-fn-align.rs:42:1 + | +LL | #[align(32)] + | ^^^^^^^^^^^^ +LL | const FOO: i32 = 42; + | -------------------- not a function item + +error: `#[align(...)]` should be applied to a function item + --> $DIR/malformed-fn-align.rs:45:1 + | +LL | #[align(32)] + | ^^^^^^^^^^^^ +LL | mod test {} + | ----------- not a function item + +error: `#[align(...)]` should be applied to a function item + --> $DIR/malformed-fn-align.rs:48:1 + | +LL | #[align(32)] + | ^^^^^^^^^^^^ +LL | use ::std::iter; + | ---------------- not a function item + +error: aborting due to 15 previous errors Some errors have detailed explanations: E0539, E0589, E0805. For more information about an error, try `rustc --explain E0539`. diff --git a/tests/ui/attributes/malformed-must_use.rs b/tests/ui/attributes/malformed-must_use.rs new file mode 100644 index 00000000000..4b98affa8ab --- /dev/null +++ b/tests/ui/attributes/malformed-must_use.rs @@ -0,0 +1,4 @@ +#[must_use()] //~ ERROR valid forms for the attribute are `#[must_use = "reason"]` and `#[must_use]` +struct Test; + +fn main() {} diff --git a/tests/ui/attributes/malformed-must_use.stderr b/tests/ui/attributes/malformed-must_use.stderr new file mode 100644 index 00000000000..c948ba67744 --- /dev/null +++ b/tests/ui/attributes/malformed-must_use.stderr @@ -0,0 +1,8 @@ +error: valid forms for the attribute are `#[must_use = "reason"]` and `#[must_use]` + --> $DIR/malformed-must_use.rs:1:1 + | +LL | #[must_use()] + | ^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/attributes/malformed-reprs.rs b/tests/ui/attributes/malformed-reprs.rs new file mode 100644 index 00000000000..4f99239d21b --- /dev/null +++ b/tests/ui/attributes/malformed-reprs.rs @@ -0,0 +1,14 @@ +// Tests a few different invalid repr attributes + +// This is a regression test for https://github.com/rust-lang/rust/issues/143522 +#![repr] +//~^ ERROR malformed `repr` attribute input [E0539] +//~| ERROR `repr` attribute cannot be used at crate level + +// This is a regression test for https://github.com/rust-lang/rust/issues/143479 +#[repr(align(0))] +//~^ ERROR invalid `repr(align)` attribute: not a power of two +//~| ERROR unsupported representation for zero-variant enum [E0084] +enum Foo {} + +fn main() {} diff --git a/tests/ui/attributes/malformed-reprs.stderr b/tests/ui/attributes/malformed-reprs.stderr new file mode 100644 index 00000000000..c39c98dde31 --- /dev/null +++ b/tests/ui/attributes/malformed-reprs.stderr @@ -0,0 +1,43 @@ +error[E0539]: malformed `repr` attribute input + --> $DIR/malformed-reprs.rs:4:1 + | +LL | #![repr] + | ^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[repr(C | Rust | align(...) | packed(...) | <integer type> | transparent)]` + +error[E0589]: invalid `repr(align)` attribute: not a power of two + --> $DIR/malformed-reprs.rs:9:14 + | +LL | #[repr(align(0))] + | ^ + +error: `repr` attribute cannot be used at crate level + --> $DIR/malformed-reprs.rs:4:1 + | +LL | #![repr] + | ^^^^^^^^ +... +LL | enum Foo {} + | --- the inner attribute doesn't annotate this enum + | +help: perhaps you meant to use an outer attribute + | +LL - #![repr] +LL + #[repr] + | + +error[E0084]: unsupported representation for zero-variant enum + --> $DIR/malformed-reprs.rs:9:1 + | +LL | #[repr(align(0))] + | ^^^^^^^^^^^^^^^^^ +... +LL | enum Foo {} + | -------- zero-variant enum + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0084, E0539, E0589. +For more information about an error, try `rustc --explain E0084`. 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 d8b5235c52f..55c196f6dec 100644 --- a/tests/ui/attributes/mixed_export_name_and_no_mangle.fixed +++ b/tests/ui/attributes/mixed_export_name_and_no_mangle.fixed @@ -3,11 +3,11 @@ //@ check-pass #![warn(unused_attributes)] -//~^ WARN `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[export_name]` [unused_attributes] +//~^ WARN `#[no_mangle]` attribute may not be used in combination with `#[export_name]` [unused_attributes] #[export_name = "foo"] pub fn bar() {} -//~^ WARN `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[export_name]` [unused_attributes] +//~^ WARN `#[no_mangle]` attribute may not be used in combination with `#[export_name]` [unused_attributes] #[export_name = "baz"] pub fn bak() {} 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 83a673a7d13..79f1e5c19c5 100644 --- a/tests/ui/attributes/mixed_export_name_and_no_mangle.rs +++ b/tests/ui/attributes/mixed_export_name_and_no_mangle.rs @@ -4,12 +4,12 @@ #![warn(unused_attributes)] #[no_mangle] -//~^ WARN `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[export_name]` [unused_attributes] +//~^ WARN `#[no_mangle]` attribute may not be used in combination with `#[export_name]` [unused_attributes] #[export_name = "foo"] pub fn bar() {} #[unsafe(no_mangle)] -//~^ WARN `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[export_name]` [unused_attributes] +//~^ WARN `#[no_mangle]` attribute may not be used in combination with `#[export_name]` [unused_attributes] #[export_name = "baz"] pub fn bak() {} 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 c760d27db25..1dcaa636800 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: `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[export_name]` +warning: `#[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] - | ^^^^^^^^^^^^ `#[unsafe(no_mangle)]` is ignored + | ^^^^^^^^^^^^ `#[no_mangle]` is ignored | note: `#[export_name]` takes precedence --> $DIR/mixed_export_name_and_no_mangle.rs:8:1 @@ -14,23 +14,23 @@ note: the lint level is defined here | LL | #![warn(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -help: remove the `#[unsafe(no_mangle)]` attribute +help: remove the `#[no_mangle]` attribute | LL - #[no_mangle] | -warning: `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[export_name]` +warning: `#[no_mangle]` attribute may not be used in combination with `#[export_name]` --> $DIR/mixed_export_name_and_no_mangle.rs:11:1 | LL | #[unsafe(no_mangle)] - | ^^^^^^^^^^^^^^^^^^^^ `#[unsafe(no_mangle)]` is ignored + | ^^^^^^^^^^^^^^^^^^^^ `#[no_mangle]` is ignored | note: `#[export_name]` takes precedence --> $DIR/mixed_export_name_and_no_mangle.rs:13:1 | LL | #[export_name = "baz"] | ^^^^^^^^^^^^^^^^^^^^^^ -help: remove the `#[unsafe(no_mangle)]` attribute +help: remove the `#[no_mangle]` attribute | LL - #[unsafe(no_mangle)] | diff --git a/tests/ui/attributes/mixed_export_name_and_no_mangle_2024.fixed b/tests/ui/attributes/mixed_export_name_and_no_mangle_2024.fixed new file mode 100644 index 00000000000..581cb200770 --- /dev/null +++ b/tests/ui/attributes/mixed_export_name_and_no_mangle_2024.fixed @@ -0,0 +1,15 @@ +// issue: rust-lang/rust#47446 +//@ run-rustfix +//@ check-pass +//@ edition:2024 + +#![warn(unused_attributes)] +//~^ WARN `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[unsafe(export_name)]` [unused_attributes] +#[unsafe(export_name = "foo")] +pub fn bar() {} + +//~^ WARN `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[unsafe(export_name)]` [unused_attributes] +#[unsafe(export_name = "baz")] +pub fn bak() {} + +fn main() {} diff --git a/tests/ui/attributes/mixed_export_name_and_no_mangle_2024.rs b/tests/ui/attributes/mixed_export_name_and_no_mangle_2024.rs new file mode 100644 index 00000000000..1e4a06132f2 --- /dev/null +++ b/tests/ui/attributes/mixed_export_name_and_no_mangle_2024.rs @@ -0,0 +1,17 @@ +// issue: rust-lang/rust#47446 +//@ run-rustfix +//@ check-pass +//@ edition:2024 + +#![warn(unused_attributes)] +#[unsafe(no_mangle)] +//~^ WARN `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[unsafe(export_name)]` [unused_attributes] +#[unsafe(export_name = "foo")] +pub fn bar() {} + +#[unsafe(no_mangle)] +//~^ WARN `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[unsafe(export_name)]` [unused_attributes] +#[unsafe(export_name = "baz")] +pub fn bak() {} + +fn main() {} diff --git a/tests/ui/attributes/mixed_export_name_and_no_mangle_2024.stderr b/tests/ui/attributes/mixed_export_name_and_no_mangle_2024.stderr new file mode 100644 index 00000000000..09804f9f92b --- /dev/null +++ b/tests/ui/attributes/mixed_export_name_and_no_mangle_2024.stderr @@ -0,0 +1,39 @@ +warning: `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[unsafe(export_name)]` + --> $DIR/mixed_export_name_and_no_mangle_2024.rs:7:1 + | +LL | #[unsafe(no_mangle)] + | ^^^^^^^^^^^^^^^^^^^^ `#[unsafe(no_mangle)]` is ignored + | +note: `#[unsafe(export_name)]` takes precedence + --> $DIR/mixed_export_name_and_no_mangle_2024.rs:9:1 + | +LL | #[unsafe(export_name = "foo")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/mixed_export_name_and_no_mangle_2024.rs:6:9 + | +LL | #![warn(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ +help: remove the `#[unsafe(no_mangle)]` attribute + | +LL - #[unsafe(no_mangle)] + | + +warning: `#[unsafe(no_mangle)]` attribute may not be used in combination with `#[unsafe(export_name)]` + --> $DIR/mixed_export_name_and_no_mangle_2024.rs:12:1 + | +LL | #[unsafe(no_mangle)] + | ^^^^^^^^^^^^^^^^^^^^ `#[unsafe(no_mangle)]` is ignored + | +note: `#[unsafe(export_name)]` takes precedence + --> $DIR/mixed_export_name_and_no_mangle_2024.rs:14:1 + | +LL | #[unsafe(export_name = "baz")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: remove the `#[unsafe(no_mangle)]` attribute + | +LL - #[unsafe(no_mangle)] + | + +warning: 2 warnings emitted + diff --git a/tests/ui/reexport-test-harness-main.rs b/tests/ui/attributes/reexport-test-harness-entry-point.rs index f79828fc7d6..95765a719ed 100644 --- a/tests/ui/reexport-test-harness-main.rs +++ b/tests/ui/attributes/reexport-test-harness-entry-point.rs @@ -1,3 +1,6 @@ +//! Check that `#[reexport_test_harness_main]` correctly reexports the test harness entry point +//! and allows it to be called from within the code. + //@ run-pass //@ compile-flags:--test diff --git a/tests/ui/attributes/rustc_skip_during_method_dispatch.rs b/tests/ui/attributes/rustc_skip_during_method_dispatch.rs new file mode 100644 index 00000000000..25b473d5a58 --- /dev/null +++ b/tests/ui/attributes/rustc_skip_during_method_dispatch.rs @@ -0,0 +1,38 @@ +#![feature(rustc_attrs)] + +#[rustc_skip_during_method_dispatch] +//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input [E0539] +trait NotAList {} + +#[rustc_skip_during_method_dispatch = "array"] +//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input [E0539] +trait AlsoNotAList {} + +#[rustc_skip_during_method_dispatch()] +//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input +trait Argless {} + +#[rustc_skip_during_method_dispatch(array, boxed_slice, array)] +//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input +trait Duplicate {} + +#[rustc_skip_during_method_dispatch(slice)] +//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input +trait Unexpected {} + +#[rustc_skip_during_method_dispatch(array = true)] +//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input +trait KeyValue {} + +#[rustc_skip_during_method_dispatch("array")] +//~^ ERROR: malformed `rustc_skip_during_method_dispatch` attribute input +trait String {} + +#[rustc_skip_during_method_dispatch(array, boxed_slice)] +trait OK {} + +#[rustc_skip_during_method_dispatch(array)] +//~^ ERROR: attribute should be applied to a trait +impl OK for () {} + +fn main() {} diff --git a/tests/ui/attributes/rustc_skip_during_method_dispatch.stderr b/tests/ui/attributes/rustc_skip_during_method_dispatch.stderr new file mode 100644 index 00000000000..2f5d7968489 --- /dev/null +++ b/tests/ui/attributes/rustc_skip_during_method_dispatch.stderr @@ -0,0 +1,76 @@ +error[E0539]: malformed `rustc_skip_during_method_dispatch` attribute input + --> $DIR/rustc_skip_during_method_dispatch.rs:3:1 + | +LL | #[rustc_skip_during_method_dispatch] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]` + +error[E0539]: malformed `rustc_skip_during_method_dispatch` attribute input + --> $DIR/rustc_skip_during_method_dispatch.rs:7:1 + | +LL | #[rustc_skip_during_method_dispatch = "array"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]` + +error[E0539]: malformed `rustc_skip_during_method_dispatch` attribute input + --> $DIR/rustc_skip_during_method_dispatch.rs:11:1 + | +LL | #[rustc_skip_during_method_dispatch()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--^ + | | | + | | expected at least 1 argument here + | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]` + +error[E0538]: malformed `rustc_skip_during_method_dispatch` attribute input + --> $DIR/rustc_skip_during_method_dispatch.rs:15:1 + | +LL | #[rustc_skip_during_method_dispatch(array, boxed_slice, array)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----^^ + | | | + | | found `array` used as a key more than once + | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]` + +error[E0539]: malformed `rustc_skip_during_method_dispatch` attribute input + --> $DIR/rustc_skip_during_method_dispatch.rs:19:1 + | +LL | #[rustc_skip_during_method_dispatch(slice)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----^^ + | | | + | | valid arguments are `array` or `boxed_slice` + | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]` + +error[E0565]: malformed `rustc_skip_during_method_dispatch` attribute input + --> $DIR/rustc_skip_during_method_dispatch.rs:23:1 + | +LL | #[rustc_skip_during_method_dispatch(array = true)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------^^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]` + +error[E0565]: malformed `rustc_skip_during_method_dispatch` attribute input + --> $DIR/rustc_skip_during_method_dispatch.rs:27:1 + | +LL | #[rustc_skip_during_method_dispatch("array")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------^^ + | | | + | | didn't expect a literal here + | help: must be of the form: `#[rustc_skip_during_method_dispatch(array, boxed_slice)]` + +error: attribute should be applied to a trait + --> $DIR/rustc_skip_during_method_dispatch.rs:34:1 + | +LL | #[rustc_skip_during_method_dispatch(array)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | +LL | impl OK for () {} + | ----------------- not a trait + +error: aborting due to 8 previous errors + +Some errors have detailed explanations: E0538, E0539, E0565. +For more information about an error, try `rustc --explain E0538`. diff --git a/tests/ui/attributes/used_with_arg.rs b/tests/ui/attributes/used_with_arg.rs index ad80ff53f0e..bc7a6f07442 100644 --- a/tests/ui/attributes/used_with_arg.rs +++ b/tests/ui/attributes/used_with_arg.rs @@ -1,3 +1,4 @@ +#![deny(unused_attributes)] #![feature(used_with_arg)] #[used(linker)] @@ -6,14 +7,22 @@ static mut USED_LINKER: [usize; 1] = [0]; #[used(compiler)] static mut USED_COMPILER: [usize; 1] = [0]; -#[used(compiler)] //~ ERROR `used(compiler)` and `used(linker)` can't be used together +#[used(compiler)] #[used(linker)] static mut USED_COMPILER_LINKER2: [usize; 1] = [0]; -#[used(compiler)] //~ ERROR `used(compiler)` and `used(linker)` can't be used together -#[used(linker)] #[used(compiler)] #[used(linker)] +#[used(compiler)] //~ ERROR unused attribute +#[used(linker)] //~ ERROR unused attribute static mut USED_COMPILER_LINKER3: [usize; 1] = [0]; +#[used(compiler)] +#[used] +static mut USED_WITHOUT_ATTR1: [usize; 1] = [0]; + +#[used(linker)] +#[used] //~ ERROR unused attribute +static mut USED_WITHOUT_ATTR2: [usize; 1] = [0]; + fn main() {} diff --git a/tests/ui/attributes/used_with_arg.stderr b/tests/ui/attributes/used_with_arg.stderr index 440e5c4a5a0..9ff91a4e03b 100644 --- a/tests/ui/attributes/used_with_arg.stderr +++ b/tests/ui/attributes/used_with_arg.stderr @@ -1,18 +1,43 @@ -error: `used(compiler)` and `used(linker)` can't be used together - --> $DIR/used_with_arg.rs:9:1 +error: unused attribute + --> $DIR/used_with_arg.rs:16:1 + | +LL | #[used(compiler)] + | ^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/used_with_arg.rs:14:1 | LL | #[used(compiler)] | ^^^^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/used_with_arg.rs:1:9 + | +LL | #![deny(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + +error: unused attribute + --> $DIR/used_with_arg.rs:17:1 + | +LL | #[used(linker)] + | ^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/used_with_arg.rs:15:1 + | LL | #[used(linker)] | ^^^^^^^^^^^^^^^ -error: `used(compiler)` and `used(linker)` can't be used together - --> $DIR/used_with_arg.rs:13:1 +error: unused attribute + --> $DIR/used_with_arg.rs:25:1 + | +LL | #[used] + | ^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/used_with_arg.rs:24:1 | -LL | #[used(compiler)] - | ^^^^^^^^^^^^^^^^^ LL | #[used(linker)] | ^^^^^^^^^^^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/attributes/used_with_multi_args.rs b/tests/ui/attributes/used_with_multi_args.rs index d3109cc6444..1c054f792eb 100644 --- a/tests/ui/attributes/used_with_multi_args.rs +++ b/tests/ui/attributes/used_with_multi_args.rs @@ -1,6 +1,6 @@ #![feature(used_with_arg)] -#[used(compiler, linker)] //~ ERROR expected `used`, `used(compiler)` or `used(linker)` +#[used(compiler, linker)] //~ ERROR malformed `used` attribute input static mut USED_COMPILER_LINKER: [usize; 1] = [0]; fn main() {} diff --git a/tests/ui/attributes/used_with_multi_args.stderr b/tests/ui/attributes/used_with_multi_args.stderr index d4417a202d5..e48209cf204 100644 --- a/tests/ui/attributes/used_with_multi_args.stderr +++ b/tests/ui/attributes/used_with_multi_args.stderr @@ -1,8 +1,20 @@ -error: expected `used`, `used(compiler)` or `used(linker)` +error[E0805]: malformed `used` attribute input --> $DIR/used_with_multi_args.rs:3:1 | LL | #[used(compiler, linker)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^------------------^ + | | + | expected a single argument here + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[used(compiler, linker)] +LL + #[used(compiler|linker)] + | +LL - #[used(compiler, linker)] +LL + #[used] + | error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0805`. diff --git a/tests/ui/phantom-auto-trait.rs b/tests/ui/auto-traits/auto-trait-phantom-data-bounds.rs index 0172ca335c3..6d1c4c87fad 100644 --- a/tests/ui/phantom-auto-trait.rs +++ b/tests/ui/auto-traits/auto-trait-phantom-data-bounds.rs @@ -1,9 +1,9 @@ -// Ensure that auto trait checks `T` when it encounters a `PhantomData<T>` field, instead of -// checking the `PhantomData<T>` type itself (which almost always implements an auto trait). +//! Ensure that auto trait checks `T` when it encounters a `PhantomData<T>` field, instead of +//! checking the `PhantomData<T>` type itself (which almost always implements an auto trait). #![feature(auto_traits)] -use std::marker::{PhantomData}; +use std::marker::PhantomData; unsafe auto trait Zen {} diff --git a/tests/ui/phantom-auto-trait.stderr b/tests/ui/auto-traits/auto-trait-phantom-data-bounds.stderr index ffd4c3a0e1a..56c2e8ff257 100644 --- a/tests/ui/phantom-auto-trait.stderr +++ b/tests/ui/auto-traits/auto-trait-phantom-data-bounds.stderr @@ -1,5 +1,5 @@ error[E0277]: `T` cannot be shared between threads safely - --> $DIR/phantom-auto-trait.rs:21:12 + --> $DIR/auto-trait-phantom-data-bounds.rs:21:12 | LL | is_zen(x) | ------ ^ `T` cannot be shared between threads safely @@ -7,19 +7,19 @@ LL | is_zen(x) | required by a bound introduced by this call | note: required for `&T` to implement `Zen` - --> $DIR/phantom-auto-trait.rs:10:24 + --> $DIR/auto-trait-phantom-data-bounds.rs:10:24 | LL | unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {} | ^^^ ^^^^^ ---- unsatisfied trait bound introduced here note: required because it appears within the type `PhantomData<&T>` --> $SRC_DIR/core/src/marker.rs:LL:COL note: required because it appears within the type `Guard<'_, T>` - --> $DIR/phantom-auto-trait.rs:12:8 + --> $DIR/auto-trait-phantom-data-bounds.rs:12:8 | LL | struct Guard<'a, T: 'a> { | ^^^^^ note: required by a bound in `is_zen` - --> $DIR/phantom-auto-trait.rs:18:14 + --> $DIR/auto-trait-phantom-data-bounds.rs:18:14 | LL | fn is_zen<T: Zen>(_: T) {} | ^^^ required by this bound in `is_zen` @@ -29,7 +29,7 @@ LL | fn not_sync<T: std::marker::Sync>(x: Guard<T>) { | +++++++++++++++++++ error[E0277]: `T` cannot be shared between threads safely - --> $DIR/phantom-auto-trait.rs:26:12 + --> $DIR/auto-trait-phantom-data-bounds.rs:26:12 | LL | is_zen(x) | ------ ^ `T` cannot be shared between threads safely @@ -37,24 +37,24 @@ LL | is_zen(x) | required by a bound introduced by this call | note: required for `&T` to implement `Zen` - --> $DIR/phantom-auto-trait.rs:10:24 + --> $DIR/auto-trait-phantom-data-bounds.rs:10:24 | LL | unsafe impl<'a, T: 'a> Zen for &'a T where T: Sync {} | ^^^ ^^^^^ ---- unsatisfied trait bound introduced here note: required because it appears within the type `PhantomData<&T>` --> $SRC_DIR/core/src/marker.rs:LL:COL note: required because it appears within the type `Guard<'_, T>` - --> $DIR/phantom-auto-trait.rs:12:8 + --> $DIR/auto-trait-phantom-data-bounds.rs:12:8 | LL | struct Guard<'a, T: 'a> { | ^^^^^ note: required because it appears within the type `Nested<Guard<'_, T>>` - --> $DIR/phantom-auto-trait.rs:16:8 + --> $DIR/auto-trait-phantom-data-bounds.rs:16:8 | LL | struct Nested<T>(T); | ^^^^^^ note: required by a bound in `is_zen` - --> $DIR/phantom-auto-trait.rs:18:14 + --> $DIR/auto-trait-phantom-data-bounds.rs:18:14 | LL | fn is_zen<T: Zen>(_: T) {} | ^^^ required by this bound in `is_zen` diff --git a/tests/ui/binop/binop-evaluation-order-primitive.rs b/tests/ui/binop/binop-evaluation-order-primitive.rs new file mode 100644 index 00000000000..33266d1c047 --- /dev/null +++ b/tests/ui/binop/binop-evaluation-order-primitive.rs @@ -0,0 +1,15 @@ +//! Test evaluation order in binary operations with primitive types. + +//@ run-pass + +fn main() { + let x = Box::new(0); + assert_eq!( + 0, + *x + { + drop(x); + let _ = Box::new(main); + 0 + } + ); +} diff --git a/tests/ui/op-assign-builtins-by-ref.rs b/tests/ui/binop/compound-assign-by-ref.rs index 73788da9232..e1f519a137f 100644 --- a/tests/ui/op-assign-builtins-by-ref.rs +++ b/tests/ui/binop/compound-assign-by-ref.rs @@ -1,9 +1,8 @@ +//! Test compound assignment operators with reference right-hand side. + //@ run-pass fn main() { - // test compound assignment operators with ref as right-hand side, - // for each operator, with various types as operands. - // test AddAssign { let mut x = 3i8; diff --git a/tests/ui/binop/issue-77910-1.stderr b/tests/ui/binop/issue-77910-1.stderr index 74deac900d4..80c384f39bd 100644 --- a/tests/ui/binop/issue-77910-1.stderr +++ b/tests/ui/binop/issue-77910-1.stderr @@ -16,9 +16,8 @@ LL | fn foo(s: &i32) -> &i32 { | --- consider calling this function ... LL | assert_eq!(foo, y); - | ^^^^^^^^^^^^^^^^^^ `for<'a> fn(&'a i32) -> &'a i32 {foo}` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for fn item `for<'a> fn(&'a i32) -> &'a i32 {foo}` | - = help: the trait `Debug` is not implemented for fn item `for<'a> fn(&'a i32) -> &'a i32 {foo}` = help: use parentheses to call this function: `foo(/* &i32 */)` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/borrowck/borrowck-move-by-capture.stderr b/tests/ui/borrowck/borrowck-move-by-capture.stderr index 9915acfe065..58d5e90e990 100644 --- a/tests/ui/borrowck/borrowck-move-by-capture.stderr +++ b/tests/ui/borrowck/borrowck-move-by-capture.stderr @@ -12,7 +12,7 @@ LL | let _h = to_fn_once(move || -> isize { *bar }); | | move occurs because `bar` has type `Box<isize>`, which does not implement the `Copy` trait | `bar` is moved here | -help: clone the value before moving it into the closure +help: consider cloning the value before moving it into the closure | LL ~ let value = bar.clone(); LL ~ let _h = to_fn_once(move || -> isize { value }); diff --git a/tests/ui/borrowck/borrowck-move-moved-value-into-closure.stderr b/tests/ui/borrowck/borrowck-move-moved-value-into-closure.stderr index 6a77d86f250..5ddc6a6d82d 100644 --- a/tests/ui/borrowck/borrowck-move-moved-value-into-closure.stderr +++ b/tests/ui/borrowck/borrowck-move-moved-value-into-closure.stderr @@ -12,6 +12,12 @@ LL | call_f(move|| { *t + 1 }); | ^^^^^^ -- use occurs due to use in closure | | | value used here after move + | +help: consider cloning the value before moving it into the closure + | +LL ~ let value = t.clone(); +LL ~ call_f(move|| { value + 1 }); + | error: aborting due to 1 previous error diff --git a/tests/ui/borrowck/generic_const_early_param.stderr b/tests/ui/borrowck/generic_const_early_param.stderr index 3f56d6a3325..6447f92aba8 100644 --- a/tests/ui/borrowck/generic_const_early_param.stderr +++ b/tests/ui/borrowck/generic_const_early_param.stderr @@ -7,19 +7,24 @@ LL | struct DataWrapper<'static> { error[E0261]: use of undeclared lifetime name `'a` --> $DIR/generic_const_early_param.rs:6:12 | -LL | struct DataWrapper<'static> { - | - help: consider introducing lifetime `'a` here: `'a,` -LL | LL | data: &'a [u8; Self::SIZE], | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | struct DataWrapper<'a, 'static> { + | +++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/generic_const_early_param.rs:10:18 | LL | impl DataWrapper<'a> { - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `<'a>` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | impl<'a> DataWrapper<'a> { + | ++++ warning: the feature `generic_const_exprs` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/generic_const_early_param.rs:1:12 diff --git a/tests/ui/cast/ice-cast-type-with-error-124848.stderr b/tests/ui/cast/ice-cast-type-with-error-124848.stderr index 0b2ab1dfc4c..316a484d971 100644 --- a/tests/ui/cast/ice-cast-type-with-error-124848.stderr +++ b/tests/ui/cast/ice-cast-type-with-error-124848.stderr @@ -2,27 +2,34 @@ error[E0261]: use of undeclared lifetime name `'unpinned` --> $DIR/ice-cast-type-with-error-124848.rs:7:32 | LL | struct MyType<'a>(Cell<Option<&'unpinned mut MyType<'a>>>, Pin); - | - ^^^^^^^^^ undeclared lifetime - | | - | help: consider introducing lifetime `'unpinned` here: `'unpinned,` + | ^^^^^^^^^ undeclared lifetime + | +help: consider introducing lifetime `'unpinned` here + | +LL | struct MyType<'unpinned, 'a>(Cell<Option<&'unpinned mut MyType<'a>>>, Pin); + | ++++++++++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/ice-cast-type-with-error-124848.rs:14:53 | -LL | fn main() { - | - help: consider introducing lifetime `'a` here: `<'a>` -... LL | let bad_addr = &unpinned as *const Cell<Option<&'a mut MyType<'a>>> as usize; | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn main<'a>() { + | ++++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/ice-cast-type-with-error-124848.rs:14:67 | -LL | fn main() { - | - help: consider introducing lifetime `'a` here: `<'a>` -... LL | let bad_addr = &unpinned as *const Cell<Option<&'a mut MyType<'a>>> as usize; | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn main<'a>() { + | ++++ error[E0412]: cannot find type `Pin` in this scope --> $DIR/ice-cast-type-with-error-124848.rs:7:60 diff --git a/tests/ui/cast/non-primitive-cast-suggestion.fixed b/tests/ui/cast/non-primitive-cast-suggestion.fixed new file mode 100644 index 00000000000..9a1a3c022c7 --- /dev/null +++ b/tests/ui/cast/non-primitive-cast-suggestion.fixed @@ -0,0 +1,23 @@ +//! Test that casting non-primitive types with `as` is rejected with a helpful suggestion. +//! +//! You can't use `as` to cast between non-primitive types, even if they have +//! `From`/`Into` implementations. The compiler should suggest using `From::from()` +//! or `.into()` instead, and rustfix should be able to apply the suggestion. + +//@ run-rustfix + +#[derive(Debug)] +struct Foo { + x: isize, +} + +impl From<Foo> for isize { + fn from(val: Foo) -> isize { + val.x + } +} + +fn main() { + let _ = isize::from(Foo { x: 1 }); + //~^ ERROR non-primitive cast: `Foo` as `isize` [E0605] +} diff --git a/tests/ui/cast/non-primitive-cast-suggestion.rs b/tests/ui/cast/non-primitive-cast-suggestion.rs new file mode 100644 index 00000000000..79006f4ba26 --- /dev/null +++ b/tests/ui/cast/non-primitive-cast-suggestion.rs @@ -0,0 +1,23 @@ +//! Test that casting non-primitive types with `as` is rejected with a helpful suggestion. +//! +//! You can't use `as` to cast between non-primitive types, even if they have +//! `From`/`Into` implementations. The compiler should suggest using `From::from()` +//! or `.into()` instead, and rustfix should be able to apply the suggestion. + +//@ run-rustfix + +#[derive(Debug)] +struct Foo { + x: isize, +} + +impl From<Foo> for isize { + fn from(val: Foo) -> isize { + val.x + } +} + +fn main() { + let _ = Foo { x: 1 } as isize; + //~^ ERROR non-primitive cast: `Foo` as `isize` [E0605] +} diff --git a/tests/ui/cast/non-primitive-cast-suggestion.stderr b/tests/ui/cast/non-primitive-cast-suggestion.stderr new file mode 100644 index 00000000000..bd35ded15a4 --- /dev/null +++ b/tests/ui/cast/non-primitive-cast-suggestion.stderr @@ -0,0 +1,15 @@ +error[E0605]: non-primitive cast: `Foo` as `isize` + --> $DIR/non-primitive-cast-suggestion.rs:21:13 + | +LL | let _ = Foo { x: 1 } as isize; + | ^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object + | +help: consider using the `From` trait instead + | +LL - let _ = Foo { x: 1 } as isize; +LL + let _ = isize::from(Foo { x: 1 }); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/cfg/nested-cfg-attr-conditional-compilation.rs b/tests/ui/cfg/nested-cfg-attr-conditional-compilation.rs new file mode 100644 index 00000000000..7618e83a642 --- /dev/null +++ b/tests/ui/cfg/nested-cfg-attr-conditional-compilation.rs @@ -0,0 +1,18 @@ +//! Test that nested `cfg_attr` attributes work correctly for conditional compilation. +//! This checks that `cfg_attr` can be arbitrarily deeply nested and that the +//! expansion works from outside to inside, eventually applying the innermost +//! conditional compilation directive. +//! +//! In this test, `cfg_attr(all(), cfg_attr(all(), cfg(false)))` should expand to: +//! 1. `cfg_attr(all(), cfg(false))` (outer cfg_attr applied) +//! 2. `cfg(false)` (inner cfg_attr applied) +//! 3. Function `f` is excluded from compilation +//! +//! Added in <https://github.com/rust-lang/rust/pull/34216>. + +#[cfg_attr(all(), cfg_attr(all(), cfg(false)))] +fn f() {} + +fn main() { + f() //~ ERROR cannot find function `f` in this scope +} diff --git a/tests/ui/nested-cfg-attrs.stderr b/tests/ui/cfg/nested-cfg-attr-conditional-compilation.stderr index 16c29307143..ddb8ea1e13a 100644 --- a/tests/ui/nested-cfg-attrs.stderr +++ b/tests/ui/cfg/nested-cfg-attr-conditional-compilation.stderr @@ -1,8 +1,8 @@ error[E0425]: cannot find function `f` in this scope - --> $DIR/nested-cfg-attrs.rs:4:13 + --> $DIR/nested-cfg-attr-conditional-compilation.rs:17:5 | -LL | fn main() { f() } - | ^ not found in this scope +LL | f() + | ^ not found in this scope error: aborting due to 1 previous error diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 532c1ab13d1..2484974cdc2 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -129,7 +129,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_abi = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_abi` are: ``, `abi64`, `abiv2`, `abiv2hf`, `eabi`, `eabihf`, `fortanix`, `ilp32`, `ilp32e`, `llvm`, `macabi`, `sim`, `softfloat`, `spe`, `uwp`, `vec-extabi`, and `x32` + = note: expected values for `target_abi` are: ``, `abi64`, `abiv2`, `abiv2hf`, `eabi`, `eabihf`, `elfv1`, `elfv2`, `fortanix`, `ilp32`, `ilp32e`, `llvm`, `macabi`, `sim`, `softfloat`, `spe`, `uwp`, `vec-extabi`, and `x32` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` diff --git a/tests/ui/closures/basic-closure-syntax.rs b/tests/ui/closures/basic-closure-syntax.rs new file mode 100644 index 00000000000..1d968f8cf4a --- /dev/null +++ b/tests/ui/closures/basic-closure-syntax.rs @@ -0,0 +1,35 @@ +//! Test basic closure syntax and usage with generic functions. +//! +//! This test checks that closure syntax works correctly for: +//! - Closures with parameters and return values +//! - Closures without parameters (both expression and block forms) +//! - Integration with generic functions and FnOnce trait bounds + +//@ run-pass + +fn f<F>(i: isize, f: F) -> isize +where + F: FnOnce(isize) -> isize, +{ + f(i) +} + +fn g<G>(_g: G) +where + G: FnOnce(), +{ +} + +pub fn main() { + // Closure with parameter that returns the same value + assert_eq!(f(10, |a| a), 10); + + // Closure without parameters - expression form + g(|| ()); + + // Test closure reuse in generic context + assert_eq!(f(10, |a| a), 10); + + // Closure without parameters - block form + g(|| {}); +} diff --git a/tests/ui/closures/closure-capture-after-clone.rs b/tests/ui/closures/closure-capture-after-clone.rs new file mode 100644 index 00000000000..29fba147909 --- /dev/null +++ b/tests/ui/closures/closure-capture-after-clone.rs @@ -0,0 +1,39 @@ +//! Regression test for issue #1399 +//! +//! This tests that when a variable is used (via clone) and then later +//! captured by a closure, the last-use analysis doesn't incorrectly optimize +//! the earlier use as a "last use" and perform an invalid move. +//! +//! The sequence being tested: +//! 1. Create variable `k` +//! 2. Use `k.clone()` for some purpose +//! 3. Later capture `k` in a closure +//! +//! The analysis must not treat step 2 as the "last use" since step 3 needs `k`. +//! +//! See: https://github.com/rust-lang/rust/issues/1399 + +//@ run-pass + +struct A { + _a: Box<isize>, +} + +pub fn main() { + fn invoke<F>(f: F) + where + F: FnOnce(), + { + f(); + } + + let k: Box<_> = 22.into(); + + // This clone should NOT be treated as "last use" of k + // even though k is not used again until the closure + let _u = A { _a: k.clone() }; + + // Here k is actually captured by the closure + // The last-use analyzer must have accounted for this when processing the clone above + invoke(|| println!("{}", k.clone())); +} diff --git a/tests/ui/closures/closure-clone-requires-captured-clone.rs b/tests/ui/closures/closure-clone-requires-captured-clone.rs new file mode 100644 index 00000000000..80938e50b67 --- /dev/null +++ b/tests/ui/closures/closure-clone-requires-captured-clone.rs @@ -0,0 +1,19 @@ +//! Test that closures only implement `Clone` if all captured values implement `Clone`. +//! +//! When a closure captures variables from its environment, it can only be cloned +//! if all those captured variables are cloneable. This test makes sure the compiler +//! properly rejects attempts to clone closures that capture non-Clone types. + +//@ compile-flags: --diagnostic-width=300 + +struct NonClone(i32); + +fn main() { + let captured_value = NonClone(5); + let closure = move || { + let _ = captured_value.0; + }; + + closure.clone(); + //~^ ERROR the trait bound `NonClone: Clone` is not satisfied +} diff --git a/tests/ui/closures/closure-clone-requires-captured-clone.stderr b/tests/ui/closures/closure-clone-requires-captured-clone.stderr new file mode 100644 index 00000000000..785cc8a3032 --- /dev/null +++ b/tests/ui/closures/closure-clone-requires-captured-clone.stderr @@ -0,0 +1,23 @@ +error[E0277]: the trait bound `NonClone: Clone` is not satisfied in `{closure@$DIR/closure-clone-requires-captured-clone.rs:13:19: 13:26}` + --> $DIR/closure-clone-requires-captured-clone.rs:17:13 + | +LL | let closure = move || { + | ------- within this `{closure@$DIR/closure-clone-requires-captured-clone.rs:13:19: 13:26}` +... +LL | closure.clone(); + | ^^^^^ within `{closure@$DIR/closure-clone-requires-captured-clone.rs:13:19: 13:26}`, the trait `Clone` is not implemented for `NonClone` + | +note: required because it's used within this closure + --> $DIR/closure-clone-requires-captured-clone.rs:13:19 + | +LL | let closure = move || { + | ^^^^^^^ +help: consider annotating `NonClone` with `#[derive(Clone)]` + | +LL + #[derive(Clone)] +LL | struct NonClone(i32); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/closures/closure-last-use-move.rs b/tests/ui/closures/closure-last-use-move.rs new file mode 100644 index 00000000000..f5b99d87f09 --- /dev/null +++ b/tests/ui/closures/closure-last-use-move.rs @@ -0,0 +1,33 @@ +//! Regression test for issue #1818 +//! last-use analysis in closures should allow moves instead of requiring copies. +//! +//! The original issue was that the compiler incorrectly flagged certain return values +//! in anonymous functions/closures as requiring copies of non-copyable values, when +//! they should have been treated as moves (since they were the last use of the value). +//! +//! See: https://github.com/rust-lang/rust/issues/1818 + +//@ run-pass + +fn apply<T, F>(s: String, mut f: F) -> T +where + F: FnMut(String) -> T +{ + fn g<T, F>(s: String, mut f: F) -> T + where + F: FnMut(String) -> T + { + f(s) + } + + g(s, |v| { + let r = f(v); + r // This should be a move, not requiring copy + }) +} + +pub fn main() { + // Actually test the functionality + let result = apply(String::from("test"), |s| s.len()); + assert_eq!(result, 4); +} diff --git a/tests/ui/not-copy-closure.rs b/tests/ui/closures/closure-no-copy-mut-env.rs index f6530f9a410..890e99c1ac7 100644 --- a/tests/ui/not-copy-closure.rs +++ b/tests/ui/closures/closure-no-copy-mut-env.rs @@ -1,4 +1,4 @@ -// Check that closures do not implement `Copy` if their environment is not `Copy`. +//! Checks that closures do not implement `Copy` when they capture mutable references. fn main() { let mut a = 5; diff --git a/tests/ui/not-copy-closure.stderr b/tests/ui/closures/closure-no-copy-mut-env.stderr index 60cb1352313..1443366a477 100644 --- a/tests/ui/not-copy-closure.stderr +++ b/tests/ui/closures/closure-no-copy-mut-env.stderr @@ -1,5 +1,5 @@ error[E0382]: use of moved value: `hello` - --> $DIR/not-copy-closure.rs:10:13 + --> $DIR/closure-no-copy-mut-env.rs:10:13 | LL | let b = hello; | ----- value moved here @@ -7,7 +7,7 @@ LL | let c = hello; | ^^^^^ value used here after move | note: closure cannot be moved more than once as it is not `Copy` due to moving the variable `a` out of its environment - --> $DIR/not-copy-closure.rs:6:9 + --> $DIR/closure-no-copy-mut-env.rs:6:9 | LL | a += 1; | ^ diff --git a/tests/ui/closures/closure-upvar-last-use-analysis.rs b/tests/ui/closures/closure-upvar-last-use-analysis.rs new file mode 100644 index 00000000000..2c3e349437d --- /dev/null +++ b/tests/ui/closures/closure-upvar-last-use-analysis.rs @@ -0,0 +1,32 @@ +//! Regression test for issue #1399 +//! +//! This tests that the compiler's last-use analysis correctly handles variables +//! that are captured by closures (upvars). The original issue was that the analysis +//! would incorrectly optimize variable usage as "last use" and perform moves, even when +//! the variable was later needed by a closure that captured it. +//! +//! See: https://github.com/rust-lang/rust/issues/1399 + +//@ run-pass + +struct A { + _a: Box<isize>, +} + +fn foo() -> Box<dyn FnMut() -> isize + 'static> { + let k: Box<_> = Box::new(22); + + // This use of k.clone() should not be treated as a "last use" + // even though the closure below doesn't actually capture k + let _u = A { _a: k.clone() }; + + // The closure doesn't actually use k, but the analyzer needs to handle + // the potential capture scenario correctly + let result = || 22; + + Box::new(result) +} + +pub fn main() { + assert_eq!(foo()(), 22); +} diff --git a/tests/ui/once-cant-call-twice-on-heap.rs b/tests/ui/closures/fnonce-call-twice-error.rs index 3fd8c5cadca..1662b7bddaa 100644 --- a/tests/ui/once-cant-call-twice-on-heap.rs +++ b/tests/ui/closures/fnonce-call-twice-error.rs @@ -1,16 +1,15 @@ -// Testing guarantees provided by once functions. -// This program would segfault if it were legal. +//! Test that `FnOnce` closures cannot be called twice. use std::sync::Arc; -fn foo<F:FnOnce()>(blk: F) { +fn foo<F: FnOnce()>(blk: F) { blk(); blk(); //~ ERROR use of moved value } fn main() { let x = Arc::new(true); - foo(move|| { + foo(move || { assert!(*x); drop(x); }); diff --git a/tests/ui/once-cant-call-twice-on-heap.stderr b/tests/ui/closures/fnonce-call-twice-error.stderr index 42697374115..51d8a33dcd7 100644 --- a/tests/ui/once-cant-call-twice-on-heap.stderr +++ b/tests/ui/closures/fnonce-call-twice-error.stderr @@ -1,18 +1,18 @@ error[E0382]: use of moved value: `blk` - --> $DIR/once-cant-call-twice-on-heap.rs:8:5 + --> $DIR/fnonce-call-twice-error.rs:7:5 | -LL | fn foo<F:FnOnce()>(blk: F) { - | --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait +LL | fn foo<F: FnOnce()>(blk: F) { + | --- move occurs because `blk` has type `F`, which does not implement the `Copy` trait LL | blk(); | ----- `blk` moved due to this call LL | blk(); | ^^^ value used here after move | note: `FnOnce` closures can only be called once - --> $DIR/once-cant-call-twice-on-heap.rs:6:10 + --> $DIR/fnonce-call-twice-error.rs:5:11 | -LL | fn foo<F:FnOnce()>(blk: F) { - | ^^^^^^^^ `F` is made to be an `FnOnce` closure here +LL | fn foo<F: FnOnce()>(blk: F) { + | ^^^^^^^^ `F` is made to be an `FnOnce` closure here LL | blk(); | ----- this value implements `FnOnce`, which causes it to be moved when called diff --git a/tests/ui/closures/issue-111932.stderr b/tests/ui/closures/issue-111932.stderr index 93488ad2011..fc3b7b0c6e6 100644 --- a/tests/ui/closures/issue-111932.stderr +++ b/tests/ui/closures/issue-111932.stderr @@ -14,11 +14,9 @@ error[E0277]: the size for values of type `dyn Foo` cannot be known at compilati LL | println!("{:?}", foo); | ---- ^^^ doesn't have a size known at compile-time | | - | required by a bound introduced by this call + | required by this formatting parameter | = help: the trait `Sized` is not implemented for `dyn Foo` -note: required by an implicit `Sized` bound in `core::fmt::rt::Argument::<'_>::new_debug` - --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 2 previous errors diff --git a/tests/ui/closures/many-closures.rs b/tests/ui/closures/many-closures.rs new file mode 100644 index 00000000000..c96ef5544c2 --- /dev/null +++ b/tests/ui/closures/many-closures.rs @@ -0,0 +1,47 @@ +//! Test that the compiler can handle code bases with a high number of closures. +//! This is particularly important for the MinGW toolchain which has a limit of +//! 2^15 weak symbols per binary. This test creates 2^12 closures (256 functions +//! with 16 closures each) to check the compiler handles this correctly. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/34793>. +//! See also <https://github.com/rust-lang/rust/pull/34830>. + +//@ run-pass + +// Make sure we don't optimize anything away: +//@ compile-flags: -C no-prepopulate-passes -Cpasses=name-anon-globals + +/// Macro for exponential expansion - creates 2^n copies of the given macro call +macro_rules! go_bacterial { + ($mac:ident) => ($mac!()); + ($mac:ident 1 $($t:tt)*) => ( + go_bacterial!($mac $($t)*); + go_bacterial!($mac $($t)*); + ) +} + +/// Creates and immediately calls a closure +macro_rules! create_closure { + () => { + (move || {})() + }; +} + +/// Creates a function containing 16 closures (2^4) +macro_rules! create_function_with_closures { + () => { + { + fn function_with_closures() { + // Create 16 closures using exponential expansion: 2^4 = 16 + go_bacterial!(create_closure 1 1 1 1); + } + let _ = function_with_closures(); + } + } +} + +fn main() { + // Create 2^8 = 256 functions, each containing 16 closures, + // resulting in 2^12 = 4096 closures total. + go_bacterial!(create_function_with_closures 1 1 1 1 1 1 1 1); +} diff --git a/tests/ui/closures/missing-body.rs b/tests/ui/closures/missing-body.rs new file mode 100644 index 00000000000..461c2be3ccd --- /dev/null +++ b/tests/ui/closures/missing-body.rs @@ -0,0 +1,7 @@ +// Checks that the compiler complains about the missing closure body and does not +// crash. +// This is a regression test for <https://github.com/rust-lang/rust/issues/143128>. + +fn main() { |b: [str; _]| {}; } +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for closures +//~| ERROR the size for values of type `str` cannot be known at compilation time diff --git a/tests/ui/closures/missing-body.stderr b/tests/ui/closures/missing-body.stderr new file mode 100644 index 00000000000..33580fc2fbd --- /dev/null +++ b/tests/ui/closures/missing-body.stderr @@ -0,0 +1,19 @@ +error[E0121]: the placeholder `_` is not allowed within types on item signatures for closures + --> $DIR/missing-body.rs:5:23 + | +LL | fn main() { |b: [str; _]| {}; } + | ^ not allowed in type signatures + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/missing-body.rs:5:17 + | +LL | fn main() { |b: [str; _]| {}; } + | ^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: slice and array elements must have `Sized` type + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0121, E0277. +For more information about an error, try `rustc --explain E0121`. diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/callback-as-argument.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/callback-as-argument.rs index b25a81b858b..796c2634b62 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/callback-as-argument.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/callback-as-argument.rs @@ -2,15 +2,15 @@ //@ build-pass //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm -#![feature(abi_c_cmse_nonsecure_call, cmse_nonsecure_entry, no_core, lang_items, intrinsics)] +#![feature(abi_cmse_nonsecure_call, cmse_nonsecure_entry, no_core, lang_items, intrinsics)] #![no_core] extern crate minicore; use minicore::*; #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn test( - f: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32) -> u32, +pub extern "cmse-nonsecure-entry" fn test( + f: extern "cmse-nonsecure-call" fn(u32, u32, u32, u32) -> u32, a: u32, b: u32, c: u32, diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs index 2d0ed5d2a30..cb805309a02 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.rs @@ -1,9 +1,9 @@ -// gate-test-abi_c_cmse_nonsecure_call -#[allow(unsupported_fn_ptr_calling_conventions)] +// gate-test-abi_cmse_nonsecure_call fn main() { let non_secure_function = unsafe { - core::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(i32, i32, i32, i32) -> i32>( - //~^ ERROR [E0658] + core::mem::transmute::<usize, extern "cmse-nonsecure-call" fn(i32, i32, i32, i32) -> i32>( + //~^ ERROR: is not a supported ABI for the current target [E0570] + //~| ERROR: ABI is experimental and subject to change [E0658] 0x10000004, ) }; diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr index beb0ab70cc7..ecf70e890f4 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/gate_test.stderr @@ -1,23 +1,20 @@ -error[E0658]: the extern "C-cmse-nonsecure-call" ABI is experimental and subject to change - --> $DIR/gate_test.rs:5:46 +error[E0570]: "cmse-nonsecure-call" is not a supported ABI for the current target + --> $DIR/gate_test.rs:4:46 | -LL | core::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(i32, i32, i32, i32) -> i32>( - | ^^^^^^^^^^^^^^^^^^^^^^^ +LL | core::mem::transmute::<usize, extern "cmse-nonsecure-call" fn(i32, i32, i32, i32) -> i32>( + | ^^^^^^^^^^^^^^^^^^^^^ + +error[E0658]: the extern "cmse-nonsecure-call" ABI is experimental and subject to change + --> $DIR/gate_test.rs:4:46 + | +LL | core::mem::transmute::<usize, extern "cmse-nonsecure-call" fn(i32, i32, i32, i32) -> i32>( + | ^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #81391 <https://github.com/rust-lang/rust/issues/81391> for more information - = help: add `#![feature(abi_c_cmse_nonsecure_call)]` to the crate attributes to enable + = help: add `#![feature(abi_cmse_nonsecure_call)]` 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 1 previous error - -For more information about this error, try `rustc --explain E0658`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "C-cmse-nonsecure-call" is not supported on this target - --> $DIR/gate_test.rs:5:39 - | -LL | core::mem::transmute::<usize, extern "C-cmse-nonsecure-call" fn(i32, i32, i32, i32) -> i32>( - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> +error: aborting due to 2 previous errors +Some errors have detailed explanations: E0570, E0658. +For more information about an error, try `rustc --explain E0570`. diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.rs index 84080890e08..4ce5890a2da 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.rs @@ -1,7 +1,7 @@ //@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm -#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items)] +#![feature(abi_cmse_nonsecure_call, no_core, lang_items)] #![no_core] extern crate minicore; @@ -11,31 +11,31 @@ use minicore::*; struct Wrapper<T>(T); struct Test<T: Copy> { - f1: extern "C-cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64, + f1: extern "cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64, //~^ ERROR cannot find type `U` in this scope //~| ERROR function pointer types may not have generic parameters - f2: extern "C-cmse-nonsecure-call" fn(impl Copy, u32, u32, u32) -> u64, + f2: extern "cmse-nonsecure-call" fn(impl Copy, u32, u32, u32) -> u64, //~^ ERROR `impl Trait` is not allowed in `fn` pointer parameters - f3: extern "C-cmse-nonsecure-call" fn(T, u32, u32, u32) -> u64, //~ ERROR [E0798] - f4: extern "C-cmse-nonsecure-call" fn(Wrapper<T>, u32, u32, u32) -> u64, //~ ERROR [E0798] + f3: extern "cmse-nonsecure-call" fn(T, u32, u32, u32) -> u64, //~ ERROR [E0798] + f4: extern "cmse-nonsecure-call" fn(Wrapper<T>, u32, u32, u32) -> u64, //~ ERROR [E0798] } -type WithReference = extern "C-cmse-nonsecure-call" fn(&usize); +type WithReference = extern "cmse-nonsecure-call" fn(&usize); trait Trait {} -type WithTraitObject = extern "C-cmse-nonsecure-call" fn(&dyn Trait) -> &dyn Trait; -//~^ ERROR return value of `"C-cmse-nonsecure-call"` function too large to pass via registers [E0798] +type WithTraitObject = extern "cmse-nonsecure-call" fn(&dyn Trait) -> &dyn Trait; +//~^ ERROR return value of `"cmse-nonsecure-call"` function too large to pass via registers [E0798] type WithStaticTraitObject = - extern "C-cmse-nonsecure-call" fn(&'static dyn Trait) -> &'static dyn Trait; -//~^ ERROR return value of `"C-cmse-nonsecure-call"` function too large to pass via registers [E0798] + extern "cmse-nonsecure-call" fn(&'static dyn Trait) -> &'static dyn Trait; +//~^ ERROR return value of `"cmse-nonsecure-call"` function too large to pass via registers [E0798] #[repr(transparent)] struct WrapperTransparent<'a>(&'a dyn Trait); type WithTransparentTraitObject = - extern "C-cmse-nonsecure-call" fn(WrapperTransparent) -> WrapperTransparent; -//~^ ERROR return value of `"C-cmse-nonsecure-call"` function too large to pass via registers [E0798] + extern "cmse-nonsecure-call" fn(WrapperTransparent) -> WrapperTransparent; +//~^ ERROR return value of `"cmse-nonsecure-call"` function too large to pass via registers [E0798] -type WithVarArgs = extern "C-cmse-nonsecure-call" fn(u32, ...); -//~^ ERROR C-variadic functions with the "C-cmse-nonsecure-call" calling convention are not supported +type WithVarArgs = extern "cmse-nonsecure-call" fn(u32, ...); +//~^ ERROR C-variadic functions with the "cmse-nonsecure-call" calling convention are not supported diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.stderr index 2b51f48915b..15656853576 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/generics.stderr @@ -1,21 +1,21 @@ error: function pointer types may not have generic parameters - --> $DIR/generics.rs:14:42 + --> $DIR/generics.rs:14:40 | -LL | f1: extern "C-cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64, - | ^^^^^^^^^ +LL | f1: extern "cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64, + | ^^^^^^^^^ error[E0412]: cannot find type `U` in this scope - --> $DIR/generics.rs:14:52 + --> $DIR/generics.rs:14:50 | LL | struct Test<T: Copy> { | - similarly named type parameter `T` defined here -LL | f1: extern "C-cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64, - | ^ +LL | f1: extern "cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64, + | ^ | help: a type parameter with a similar name exists | -LL - f1: extern "C-cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64, -LL + f1: extern "C-cmse-nonsecure-call" fn<U: Copy>(T, u32, u32, u32) -> u64, +LL - f1: extern "cmse-nonsecure-call" fn<U: Copy>(U, u32, u32, u32) -> u64, +LL + f1: extern "cmse-nonsecure-call" fn<U: Copy>(T, u32, u32, u32) -> u64, | help: you might be missing a type parameter | @@ -23,57 +23,57 @@ LL | struct Test<T: Copy, U> { | +++ error[E0562]: `impl Trait` is not allowed in `fn` pointer parameters - --> $DIR/generics.rs:17:43 + --> $DIR/generics.rs:17:41 | -LL | f2: extern "C-cmse-nonsecure-call" fn(impl Copy, u32, u32, u32) -> u64, - | ^^^^^^^^^ +LL | f2: extern "cmse-nonsecure-call" fn(impl Copy, u32, u32, u32) -> u64, + | ^^^^^^^^^ | = note: `impl Trait` is only allowed in arguments and return types of functions and methods -error[E0798]: function pointers with the `"C-cmse-nonsecure-call"` ABI cannot contain generics in their type +error[E0798]: function pointers with the `"cmse-nonsecure-call"` ABI cannot contain generics in their type --> $DIR/generics.rs:19:9 | -LL | f3: extern "C-cmse-nonsecure-call" fn(T, u32, u32, u32) -> u64, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | f3: extern "cmse-nonsecure-call" fn(T, u32, u32, u32) -> u64, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0798]: function pointers with the `"C-cmse-nonsecure-call"` ABI cannot contain generics in their type +error[E0798]: function pointers with the `"cmse-nonsecure-call"` ABI cannot contain generics in their type --> $DIR/generics.rs:20:9 | -LL | f4: extern "C-cmse-nonsecure-call" fn(Wrapper<T>, u32, u32, u32) -> u64, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | f4: extern "cmse-nonsecure-call" fn(Wrapper<T>, u32, u32, u32) -> u64, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/generics.rs:26:73 +error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/generics.rs:26:71 | -LL | type WithTraitObject = extern "C-cmse-nonsecure-call" fn(&dyn Trait) -> &dyn Trait; - | ^^^^^^^^^^ this type doesn't fit in the available registers +LL | type WithTraitObject = extern "cmse-nonsecure-call" fn(&dyn Trait) -> &dyn Trait; + | ^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/generics.rs:30:62 +error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/generics.rs:30:60 | -LL | extern "C-cmse-nonsecure-call" fn(&'static dyn Trait) -> &'static dyn Trait; - | ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers +LL | extern "cmse-nonsecure-call" fn(&'static dyn Trait) -> &'static dyn Trait; + | ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/generics.rs:37:62 +error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/generics.rs:37:60 | -LL | extern "C-cmse-nonsecure-call" fn(WrapperTransparent) -> WrapperTransparent; - | ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers +LL | extern "cmse-nonsecure-call" fn(WrapperTransparent) -> WrapperTransparent; + | ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0045]: C-variadic functions with the "C-cmse-nonsecure-call" calling convention are not supported +error[E0045]: C-variadic functions with the "cmse-nonsecure-call" calling convention are not supported --> $DIR/generics.rs:40:20 | -LL | type WithVarArgs = extern "C-cmse-nonsecure-call" fn(u32, ...); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention +LL | type WithVarArgs = extern "cmse-nonsecure-call" fn(u32, ...); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ C-variadic function must have a compatible calling convention error: aborting due to 9 previous errors diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.rs index 8328f9b6dd5..7036cd367e4 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.rs @@ -1,7 +1,7 @@ //@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm -#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items)] +#![feature(abi_cmse_nonsecure_call, no_core, lang_items)] #![no_core] extern crate minicore; @@ -13,10 +13,10 @@ pub struct AlignRelevant(u32); #[no_mangle] pub fn test( - f1: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, x: u32, y: u32), //~ ERROR [E0798] - f2: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u16, u16), //~ ERROR [E0798] - f3: extern "C-cmse-nonsecure-call" fn(u32, u64, u32), //~ ERROR [E0798] - f4: extern "C-cmse-nonsecure-call" fn(AlignRelevant, u32), //~ ERROR [E0798] - f5: extern "C-cmse-nonsecure-call" fn([u32; 5]), //~ ERROR [E0798] + f1: extern "cmse-nonsecure-call" fn(u32, u32, u32, u32, x: u32, y: u32), //~ ERROR [E0798] + f2: extern "cmse-nonsecure-call" fn(u32, u32, u32, u16, u16), //~ ERROR [E0798] + f3: extern "cmse-nonsecure-call" fn(u32, u64, u32), //~ ERROR [E0798] + f4: extern "cmse-nonsecure-call" fn(AlignRelevant, u32), //~ ERROR [E0798] + f5: extern "cmse-nonsecure-call" fn([u32; 5]), //~ ERROR [E0798] ) { } diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.stderr index 10a5e856107..5d59405fbd1 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/params-via-stack.stderr @@ -1,42 +1,42 @@ -error[E0798]: arguments for `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/params-via-stack.rs:16:63 +error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/params-via-stack.rs:16:61 | -LL | f1: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32, x: u32, y: u32), - | ^^^^^^^^^^^^^^ these arguments don't fit in the available registers +LL | f1: extern "cmse-nonsecure-call" fn(u32, u32, u32, u32, x: u32, y: u32), + | ^^^^^^^^^^^^^^ these arguments don't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers -error[E0798]: arguments for `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/params-via-stack.rs:17:63 +error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/params-via-stack.rs:17:61 | -LL | f2: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u16, u16), - | ^^^ this argument doesn't fit in the available registers +LL | f2: extern "cmse-nonsecure-call" fn(u32, u32, u32, u16, u16), + | ^^^ this argument doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers -error[E0798]: arguments for `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/params-via-stack.rs:18:53 +error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/params-via-stack.rs:18:51 | -LL | f3: extern "C-cmse-nonsecure-call" fn(u32, u64, u32), - | ^^^ this argument doesn't fit in the available registers +LL | f3: extern "cmse-nonsecure-call" fn(u32, u64, u32), + | ^^^ this argument doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers -error[E0798]: arguments for `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/params-via-stack.rs:19:58 +error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/params-via-stack.rs:19:56 | -LL | f4: extern "C-cmse-nonsecure-call" fn(AlignRelevant, u32), - | ^^^ this argument doesn't fit in the available registers +LL | f4: extern "cmse-nonsecure-call" fn(AlignRelevant, u32), + | ^^^ this argument doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers -error[E0798]: arguments for `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/params-via-stack.rs:20:43 +error[E0798]: arguments for `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/params-via-stack.rs:20:41 | -LL | f5: extern "C-cmse-nonsecure-call" fn([u32; 5]), - | ^^^^^^^^ this argument doesn't fit in the available registers +LL | f5: extern "cmse-nonsecure-call" fn([u32; 5]), + | ^^^^^^^^ this argument doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass all their arguments via the 4 32-bit available argument registers error: aborting due to 5 previous errors diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs index 890ec4b00f6..77347b04ede 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.rs @@ -3,7 +3,7 @@ //@ needs-llvm-components: arm //@ add-core-stubs -#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items)] +#![feature(abi_cmse_nonsecure_call, no_core, lang_items)] #![no_core] extern crate minicore; @@ -23,18 +23,18 @@ pub struct ReprCAlign16(u16); #[no_mangle] pub fn test( - f1: extern "C-cmse-nonsecure-call" fn() -> ReprCU64, //~ ERROR [E0798] - f2: extern "C-cmse-nonsecure-call" fn() -> ReprCBytes, //~ ERROR [E0798] - f3: extern "C-cmse-nonsecure-call" fn() -> U64Compound, //~ ERROR [E0798] - f4: extern "C-cmse-nonsecure-call" fn() -> ReprCAlign16, //~ ERROR [E0798] - f5: extern "C-cmse-nonsecure-call" fn() -> [u8; 5], //~ ERROR [E0798] + f1: extern "cmse-nonsecure-call" fn() -> ReprCU64, //~ ERROR [E0798] + f2: extern "cmse-nonsecure-call" fn() -> ReprCBytes, //~ ERROR [E0798] + f3: extern "cmse-nonsecure-call" fn() -> U64Compound, //~ ERROR [E0798] + f4: extern "cmse-nonsecure-call" fn() -> ReprCAlign16, //~ ERROR [E0798] + f5: extern "cmse-nonsecure-call" fn() -> [u8; 5], //~ ERROR [E0798] ) { } #[allow(improper_ctypes_definitions)] struct Test { - u128: extern "C-cmse-nonsecure-call" fn() -> u128, //~ ERROR [E0798] - i128: extern "C-cmse-nonsecure-call" fn() -> i128, //~ ERROR [E0798] + u128: extern "cmse-nonsecure-call" fn() -> u128, //~ ERROR [E0798] + i128: extern "cmse-nonsecure-call" fn() -> i128, //~ ERROR [E0798] } #[repr(C)] @@ -49,7 +49,7 @@ pub union ReprRustUnionU64 { #[no_mangle] pub fn test_union( - f1: extern "C-cmse-nonsecure-call" fn() -> ReprRustUnionU64, //~ ERROR [E0798] - f2: extern "C-cmse-nonsecure-call" fn() -> ReprCUnionU64, //~ ERROR [E0798] + f1: extern "cmse-nonsecure-call" fn() -> ReprRustUnionU64, //~ ERROR [E0798] + f2: extern "cmse-nonsecure-call" fn() -> ReprCUnionU64, //~ ERROR [E0798] ) { } diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.stderr index d2077352900..ddf969c1bce 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/return-via-stack.stderr @@ -1,82 +1,82 @@ -error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:36:50 +error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/return-via-stack.rs:36:48 | -LL | u128: extern "C-cmse-nonsecure-call" fn() -> u128, - | ^^^^ this type doesn't fit in the available registers +LL | u128: extern "cmse-nonsecure-call" fn() -> u128, + | ^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:37:50 +error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/return-via-stack.rs:37:48 | -LL | i128: extern "C-cmse-nonsecure-call" fn() -> i128, - | ^^^^ this type doesn't fit in the available registers +LL | i128: extern "cmse-nonsecure-call" fn() -> i128, + | ^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:26:48 +error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/return-via-stack.rs:26:46 | -LL | f1: extern "C-cmse-nonsecure-call" fn() -> ReprCU64, - | ^^^^^^^^ this type doesn't fit in the available registers +LL | f1: extern "cmse-nonsecure-call" fn() -> ReprCU64, + | ^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:27:48 +error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/return-via-stack.rs:27:46 | -LL | f2: extern "C-cmse-nonsecure-call" fn() -> ReprCBytes, - | ^^^^^^^^^^ this type doesn't fit in the available registers +LL | f2: extern "cmse-nonsecure-call" fn() -> ReprCBytes, + | ^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:28:48 +error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/return-via-stack.rs:28:46 | -LL | f3: extern "C-cmse-nonsecure-call" fn() -> U64Compound, - | ^^^^^^^^^^^ this type doesn't fit in the available registers +LL | f3: extern "cmse-nonsecure-call" fn() -> U64Compound, + | ^^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:29:48 +error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/return-via-stack.rs:29:46 | -LL | f4: extern "C-cmse-nonsecure-call" fn() -> ReprCAlign16, - | ^^^^^^^^^^^^ this type doesn't fit in the available registers +LL | f4: extern "cmse-nonsecure-call" fn() -> ReprCAlign16, + | ^^^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:30:48 +error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/return-via-stack.rs:30:46 | -LL | f5: extern "C-cmse-nonsecure-call" fn() -> [u8; 5], - | ^^^^^^^ this type doesn't fit in the available registers +LL | f5: extern "cmse-nonsecure-call" fn() -> [u8; 5], + | ^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:52:48 +error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/return-via-stack.rs:52:46 | -LL | f1: extern "C-cmse-nonsecure-call" fn() -> ReprRustUnionU64, - | ^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers +LL | f1: extern "cmse-nonsecure-call" fn() -> ReprRustUnionU64, + | ^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-call"` function too large to pass via registers - --> $DIR/return-via-stack.rs:53:48 +error[E0798]: return value of `"cmse-nonsecure-call"` function too large to pass via registers + --> $DIR/return-via-stack.rs:53:46 | -LL | f2: extern "C-cmse-nonsecure-call" fn() -> ReprCUnionU64, - | ^^^^^^^^^^^^^ this type doesn't fit in the available registers +LL | f2: extern "cmse-nonsecure-call" fn() -> ReprCUnionU64, + | ^^^^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-call"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-call"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error: aborting due to 9 previous errors diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/via-registers.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/via-registers.rs index 7dfe6cf9672..419d26875bc 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/via-registers.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/via-registers.rs @@ -2,7 +2,7 @@ //@ build-pass //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm -#![feature(abi_c_cmse_nonsecure_call, no_core, lang_items, intrinsics)] +#![feature(abi_cmse_nonsecure_call, no_core, lang_items, intrinsics)] #![no_core] extern crate minicore; @@ -27,26 +27,26 @@ pub struct U32Compound(u16, u16); #[no_mangle] #[allow(improper_ctypes_definitions)] pub fn params( - f1: extern "C-cmse-nonsecure-call" fn(), - f2: extern "C-cmse-nonsecure-call" fn(u32, u32, u32, u32), - f3: extern "C-cmse-nonsecure-call" fn(u64, u64), - f4: extern "C-cmse-nonsecure-call" fn(u128), - f5: extern "C-cmse-nonsecure-call" fn(f64, f32, f32), - f6: extern "C-cmse-nonsecure-call" fn(ReprTransparentStruct<u64>, U32Compound), - f7: extern "C-cmse-nonsecure-call" fn([u32; 4]), + f1: extern "cmse-nonsecure-call" fn(), + f2: extern "cmse-nonsecure-call" fn(u32, u32, u32, u32), + f3: extern "cmse-nonsecure-call" fn(u64, u64), + f4: extern "cmse-nonsecure-call" fn(u128), + f5: extern "cmse-nonsecure-call" fn(f64, f32, f32), + f6: extern "cmse-nonsecure-call" fn(ReprTransparentStruct<u64>, U32Compound), + f7: extern "cmse-nonsecure-call" fn([u32; 4]), ) { } #[no_mangle] pub fn returns( - f1: extern "C-cmse-nonsecure-call" fn() -> u32, - f2: extern "C-cmse-nonsecure-call" fn() -> u64, - f3: extern "C-cmse-nonsecure-call" fn() -> i64, - f4: extern "C-cmse-nonsecure-call" fn() -> f64, - f5: extern "C-cmse-nonsecure-call" fn() -> [u8; 4], - f6: extern "C-cmse-nonsecure-call" fn() -> ReprTransparentStruct<u64>, - f7: extern "C-cmse-nonsecure-call" fn() -> ReprTransparentStruct<ReprTransparentStruct<u64>>, - f8: extern "C-cmse-nonsecure-call" fn() -> ReprTransparentEnumU64, - f9: extern "C-cmse-nonsecure-call" fn() -> U32Compound, + f1: extern "cmse-nonsecure-call" fn() -> u32, + f2: extern "cmse-nonsecure-call" fn() -> u64, + f3: extern "cmse-nonsecure-call" fn() -> i64, + f4: extern "cmse-nonsecure-call" fn() -> f64, + f5: extern "cmse-nonsecure-call" fn() -> [u8; 4], + f6: extern "cmse-nonsecure-call" fn() -> ReprTransparentStruct<u64>, + f7: extern "cmse-nonsecure-call" fn() -> ReprTransparentStruct<ReprTransparentStruct<u64>>, + f8: extern "cmse-nonsecure-call" fn() -> ReprTransparentEnumU64, + f9: extern "cmse-nonsecure-call" fn() -> U32Compound, ) { } diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs index 5a2d2db19c5..44a1e7d69a8 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.rs @@ -1,10 +1,10 @@ //@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm -#![feature(abi_c_cmse_nonsecure_call, lang_items, no_core)] +#![feature(abi_cmse_nonsecure_call, lang_items, no_core)] #![no_core] extern crate minicore; use minicore::*; -pub extern "C-cmse-nonsecure-call" fn test() {} //~ ERROR [E0781] +pub extern "cmse-nonsecure-call" fn test() {} //~ ERROR [E0781] diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr index f49fab043a4..b9cccecc64b 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-1.stderr @@ -1,8 +1,8 @@ -error[E0781]: the `"C-cmse-nonsecure-call"` ABI is only allowed on function pointers +error[E0781]: the `"cmse-nonsecure-call"` ABI is only allowed on function pointers --> $DIR/wrong-abi-location-1.rs:10:1 | -LL | pub extern "C-cmse-nonsecure-call" fn test() {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub extern "cmse-nonsecure-call" fn test() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs index e93b153949a..f23f45f786f 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.rs @@ -1,12 +1,12 @@ //@ add-core-stubs //@ compile-flags: --target thumbv8m.main-none-eabi --crate-type lib //@ needs-llvm-components: arm -#![feature(abi_c_cmse_nonsecure_call, lang_items, no_core)] +#![feature(abi_cmse_nonsecure_call, lang_items, no_core)] #![no_core] extern crate minicore; use minicore::*; -extern "C-cmse-nonsecure-call" { //~ ERROR [E0781] +extern "cmse-nonsecure-call" { //~ ERROR [E0781] fn test(); } diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr index bae8d20d81c..437d7b80b1f 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-call/wrong-abi-location-2.stderr @@ -1,7 +1,7 @@ -error[E0781]: the `"C-cmse-nonsecure-call"` ABI is only allowed on function pointers +error[E0781]: the `"cmse-nonsecure-call"` ABI is only allowed on function pointers --> $DIR/wrong-abi-location-2.rs:10:1 | -LL | / extern "C-cmse-nonsecure-call" { +LL | / extern "cmse-nonsecure-call" { LL | | fn test(); LL | | } | |_^ diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.rs index 6061451b2e9..8ec22033a3d 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.rs @@ -1,9 +1,9 @@ // gate-test-cmse_nonsecure_entry #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { - //~^ ERROR [E0570] - //~| ERROR [E0658] +pub extern "cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { + //~^ ERROR: is not a supported ABI for the current target [E0570] + //~| ERROR: ABI is experimental and subject to change [E0658] input + 6 } diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr index 0afbbe647af..e40862e74ee 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/gate_test.stderr @@ -1,19 +1,19 @@ -error[E0658]: the extern "C-cmse-nonsecure-entry" ABI is experimental and subject to change +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target --> $DIR/gate_test.rs:4:12 | -LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub extern "cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { + | ^^^^^^^^^^^^^^^^^^^^^^ + +error[E0658]: the extern "cmse-nonsecure-entry" ABI is experimental and subject to change + --> $DIR/gate_test.rs:4:12 + | +LL | pub extern "cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { + | ^^^^^^^^^^^^^^^^^^^^^^ | = note: see issue #75835 <https://github.com/rust-lang/rust/issues/75835> for more information = help: add `#![feature(cmse_nonsecure_entry)]` 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[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/gate_test.rs:4:1 - | -LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 2 previous errors Some errors have detailed explanations: E0570, E0658. diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs index 19b6179dde7..800dd580af2 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs @@ -11,12 +11,12 @@ use minicore::*; struct Wrapper<T>(T); impl<T: Copy> Wrapper<T> { - extern "C-cmse-nonsecure-entry" fn ambient_generic(_: T, _: u32, _: u32, _: u32) -> u64 { + extern "cmse-nonsecure-entry" fn ambient_generic(_: T, _: u32, _: u32, _: u32) -> u64 { //~^ ERROR [E0798] 0 } - extern "C-cmse-nonsecure-entry" fn ambient_generic_nested( + extern "cmse-nonsecure-entry" fn ambient_generic_nested( //~^ ERROR [E0798] _: Wrapper<T>, _: u32, @@ -27,7 +27,7 @@ impl<T: Copy> Wrapper<T> { } } -extern "C-cmse-nonsecure-entry" fn introduced_generic<U: Copy>( +extern "cmse-nonsecure-entry" fn introduced_generic<U: Copy>( //~^ ERROR [E0798] _: U, _: u32, @@ -37,40 +37,40 @@ extern "C-cmse-nonsecure-entry" fn introduced_generic<U: Copy>( 0 } -extern "C-cmse-nonsecure-entry" fn impl_trait(_: impl Copy, _: u32, _: u32, _: u32) -> u64 { +extern "cmse-nonsecure-entry" fn impl_trait(_: impl Copy, _: u32, _: u32, _: u32) -> u64 { //~^ ERROR [E0798] 0 } -extern "C-cmse-nonsecure-entry" fn reference(x: &usize) -> usize { +extern "cmse-nonsecure-entry" fn reference(x: &usize) -> usize { *x } trait Trait {} -extern "C-cmse-nonsecure-entry" fn trait_object(x: &dyn Trait) -> &dyn Trait { - //~^ ERROR return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers [E0798] +extern "cmse-nonsecure-entry" fn trait_object(x: &dyn Trait) -> &dyn Trait { + //~^ ERROR return value of `"cmse-nonsecure-entry"` function too large to pass via registers [E0798] x } -extern "C-cmse-nonsecure-entry" fn static_trait_object( +extern "cmse-nonsecure-entry" fn static_trait_object( x: &'static dyn Trait, ) -> &'static dyn Trait { - //~^ ERROR return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers [E0798] + //~^ ERROR return value of `"cmse-nonsecure-entry"` function too large to pass via registers [E0798] x } #[repr(transparent)] struct WrapperTransparent<'a>(&'a dyn Trait); -extern "C-cmse-nonsecure-entry" fn wrapped_trait_object( +extern "cmse-nonsecure-entry" fn wrapped_trait_object( x: WrapperTransparent, ) -> WrapperTransparent { - //~^ ERROR return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers [E0798] + //~^ ERROR return value of `"cmse-nonsecure-entry"` function too large to pass via registers [E0798] x } -extern "C-cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { +extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg //~| ERROR requires `va_list` lang_item } diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr index c314671dc29..f0190671b5a 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr @@ -1,13 +1,13 @@ error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg - --> $DIR/generics.rs:73:55 + --> $DIR/generics.rs:73:53 | -LL | extern "C-cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { - | ^^^^^^ +LL | extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { + | ^^^^^^ -error[E0798]: functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type +error[E0798]: functions with the `"cmse-nonsecure-entry"` ABI cannot contain generics in their type --> $DIR/generics.rs:30:1 | -LL | / extern "C-cmse-nonsecure-entry" fn introduced_generic<U: Copy>( +LL | / extern "cmse-nonsecure-entry" fn introduced_generic<U: Copy>( LL | | LL | | _: U, LL | | _: u32, @@ -16,22 +16,22 @@ LL | | _: u32, LL | | ) -> u64 { | |________^ -error[E0798]: functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type +error[E0798]: functions with the `"cmse-nonsecure-entry"` ABI cannot contain generics in their type --> $DIR/generics.rs:40:1 | -LL | extern "C-cmse-nonsecure-entry" fn impl_trait(_: impl Copy, _: u32, _: u32, _: u32) -> u64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cmse-nonsecure-entry" fn impl_trait(_: impl Copy, _: u32, _: u32, _: u32) -> u64 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0798]: functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type +error[E0798]: functions with the `"cmse-nonsecure-entry"` ABI cannot contain generics in their type --> $DIR/generics.rs:14:5 | -LL | extern "C-cmse-nonsecure-entry" fn ambient_generic(_: T, _: u32, _: u32, _: u32) -> u64 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | extern "cmse-nonsecure-entry" fn ambient_generic(_: T, _: u32, _: u32, _: u32) -> u64 { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0798]: functions with the `"C-cmse-nonsecure-entry"` ABI cannot contain generics in their type +error[E0798]: functions with the `"cmse-nonsecure-entry"` ABI cannot contain generics in their type --> $DIR/generics.rs:19:5 | -LL | / extern "C-cmse-nonsecure-entry" fn ambient_generic_nested( +LL | / extern "cmse-nonsecure-entry" fn ambient_generic_nested( LL | | LL | | _: Wrapper<T>, LL | | _: u32, @@ -40,38 +40,38 @@ LL | | _: u32, LL | | ) -> u64 { | |____________^ -error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/generics.rs:51:67 +error[E0798]: return value of `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/generics.rs:51:65 | -LL | extern "C-cmse-nonsecure-entry" fn trait_object(x: &dyn Trait) -> &dyn Trait { - | ^^^^^^^^^^ this type doesn't fit in the available registers +LL | extern "cmse-nonsecure-entry" fn trait_object(x: &dyn Trait) -> &dyn Trait { + | ^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers +error[E0798]: return value of `"cmse-nonsecure-entry"` function too large to pass via registers --> $DIR/generics.rs:58:6 | LL | ) -> &'static dyn Trait { | ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers +error[E0798]: return value of `"cmse-nonsecure-entry"` function too large to pass via registers --> $DIR/generics.rs:68:6 | LL | ) -> WrapperTransparent { | ^^^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error: requires `va_list` lang_item - --> $DIR/generics.rs:73:55 + --> $DIR/generics.rs:73:53 | -LL | extern "C-cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { - | ^^^^^^ +LL | extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { + | ^^^^^^ error: aborting due to 9 previous errors diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs index 4c53f9422da..d4f722fa193 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.rs @@ -12,14 +12,14 @@ use minicore::*; pub struct AlignRelevant(u32); #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn f1(_: u32, _: u32, _: u32, _: u32, _: u32, _: u32) {} //~ ERROR [E0798] +pub extern "cmse-nonsecure-entry" fn f1(_: u32, _: u32, _: u32, _: u32, _: u32, _: u32) {} //~ ERROR [E0798] #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn f2(_: u32, _: u32, _: u32, _: u16, _: u16) {} //~ ERROR [E0798] +pub extern "cmse-nonsecure-entry" fn f2(_: u32, _: u32, _: u32, _: u16, _: u16) {} //~ ERROR [E0798] #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn f3(_: u32, _: u64, _: u32) {} //~ ERROR [E0798] +pub extern "cmse-nonsecure-entry" fn f3(_: u32, _: u64, _: u32) {} //~ ERROR [E0798] #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn f4(_: AlignRelevant, _: u32) {} //~ ERROR [E0798] +pub extern "cmse-nonsecure-entry" fn f4(_: AlignRelevant, _: u32) {} //~ ERROR [E0798] #[no_mangle] #[allow(improper_ctypes_definitions)] -pub extern "C-cmse-nonsecure-entry" fn f5(_: [u32; 5]) {} //~ ERROR [E0798] +pub extern "cmse-nonsecure-entry" fn f5(_: [u32; 5]) {} //~ ERROR [E0798] diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.stderr index 24e9ddf32fe..f8b96bddc94 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/params-via-stack.stderr @@ -1,42 +1,42 @@ -error[E0798]: arguments for `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/params-via-stack.rs:15:78 +error[E0798]: arguments for `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/params-via-stack.rs:15:76 | -LL | pub extern "C-cmse-nonsecure-entry" fn f1(_: u32, _: u32, _: u32, _: u32, _: u32, _: u32) {} - | ^^^^^^^^^^^ these arguments don't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn f1(_: u32, _: u32, _: u32, _: u32, _: u32, _: u32) {} + | ^^^^^^^^^^^ these arguments don't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers -error[E0798]: arguments for `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/params-via-stack.rs:17:78 +error[E0798]: arguments for `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/params-via-stack.rs:17:76 | -LL | pub extern "C-cmse-nonsecure-entry" fn f2(_: u32, _: u32, _: u32, _: u16, _: u16) {} - | ^^^ this argument doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn f2(_: u32, _: u32, _: u32, _: u16, _: u16) {} + | ^^^ this argument doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers -error[E0798]: arguments for `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/params-via-stack.rs:19:62 +error[E0798]: arguments for `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/params-via-stack.rs:19:60 | -LL | pub extern "C-cmse-nonsecure-entry" fn f3(_: u32, _: u64, _: u32) {} - | ^^^ this argument doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn f3(_: u32, _: u64, _: u32) {} + | ^^^ this argument doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers -error[E0798]: arguments for `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/params-via-stack.rs:21:64 +error[E0798]: arguments for `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/params-via-stack.rs:21:62 | -LL | pub extern "C-cmse-nonsecure-entry" fn f4(_: AlignRelevant, _: u32) {} - | ^^^ this argument doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn f4(_: AlignRelevant, _: u32) {} + | ^^^ this argument doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers -error[E0798]: arguments for `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/params-via-stack.rs:25:46 +error[E0798]: arguments for `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/params-via-stack.rs:25:44 | -LL | pub extern "C-cmse-nonsecure-entry" fn f5(_: [u32; 5]) {} - | ^^^^^^^^ this argument doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn f5(_: [u32; 5]) {} + | ^^^^^^^^ this argument doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass all their arguments via the 4 32-bit available argument registers error: aborting due to 5 previous errors diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.rs index 735eab10fa1..0052a0977ed 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.rs @@ -22,41 +22,41 @@ pub struct U64Compound(u32, u32); pub struct ReprCAlign16(u16); #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn f1() -> ReprCU64 { +pub extern "cmse-nonsecure-entry" fn f1() -> ReprCU64 { //~^ ERROR [E0798] ReprCU64(0) } #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn f2() -> ReprCBytes { +pub extern "cmse-nonsecure-entry" fn f2() -> ReprCBytes { //~^ ERROR [E0798] ReprCBytes(0, 1, 2, 3, 4) } #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn f3() -> U64Compound { +pub extern "cmse-nonsecure-entry" fn f3() -> U64Compound { //~^ ERROR [E0798] U64Compound(2, 3) } #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn f4() -> ReprCAlign16 { +pub extern "cmse-nonsecure-entry" fn f4() -> ReprCAlign16 { //~^ ERROR [E0798] ReprCAlign16(4) } #[no_mangle] #[allow(improper_ctypes_definitions)] -pub extern "C-cmse-nonsecure-entry" fn f5() -> [u8; 5] { +pub extern "cmse-nonsecure-entry" fn f5() -> [u8; 5] { //~^ ERROR [E0798] [0xAA; 5] } #[no_mangle] #[allow(improper_ctypes_definitions)] -pub extern "C-cmse-nonsecure-entry" fn u128() -> u128 { +pub extern "cmse-nonsecure-entry" fn u128() -> u128 { //~^ ERROR [E0798] 123 } #[no_mangle] #[allow(improper_ctypes_definitions)] -pub extern "C-cmse-nonsecure-entry" fn i128() -> i128 { +pub extern "cmse-nonsecure-entry" fn i128() -> i128 { //~^ ERROR [E0798] 456 } @@ -73,12 +73,12 @@ pub union ReprCUnionU64 { #[no_mangle] #[allow(improper_ctypes_definitions)] -pub extern "C-cmse-nonsecure-entry" fn union_rust() -> ReprRustUnionU64 { +pub extern "cmse-nonsecure-entry" fn union_rust() -> ReprRustUnionU64 { //~^ ERROR [E0798] ReprRustUnionU64 { _unused: 1 } } #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn union_c() -> ReprCUnionU64 { +pub extern "cmse-nonsecure-entry" fn union_c() -> ReprCUnionU64 { //~^ ERROR [E0798] ReprCUnionU64 { _unused: 2 } } diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.stderr index 9c885d95318..c5effed92ae 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/return-via-stack.stderr @@ -1,82 +1,82 @@ -error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:25:48 +error[E0798]: return value of `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/return-via-stack.rs:25:46 | -LL | pub extern "C-cmse-nonsecure-entry" fn f1() -> ReprCU64 { - | ^^^^^^^^ this type doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn f1() -> ReprCU64 { + | ^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:30:48 +error[E0798]: return value of `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/return-via-stack.rs:30:46 | -LL | pub extern "C-cmse-nonsecure-entry" fn f2() -> ReprCBytes { - | ^^^^^^^^^^ this type doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn f2() -> ReprCBytes { + | ^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:35:48 +error[E0798]: return value of `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/return-via-stack.rs:35:46 | -LL | pub extern "C-cmse-nonsecure-entry" fn f3() -> U64Compound { - | ^^^^^^^^^^^ this type doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn f3() -> U64Compound { + | ^^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:40:48 +error[E0798]: return value of `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/return-via-stack.rs:40:46 | -LL | pub extern "C-cmse-nonsecure-entry" fn f4() -> ReprCAlign16 { - | ^^^^^^^^^^^^ this type doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn f4() -> ReprCAlign16 { + | ^^^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:47:48 +error[E0798]: return value of `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/return-via-stack.rs:47:46 | -LL | pub extern "C-cmse-nonsecure-entry" fn f5() -> [u8; 5] { - | ^^^^^^^ this type doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn f5() -> [u8; 5] { + | ^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:53:50 +error[E0798]: return value of `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/return-via-stack.rs:53:48 | -LL | pub extern "C-cmse-nonsecure-entry" fn u128() -> u128 { - | ^^^^ this type doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn u128() -> u128 { + | ^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:59:50 +error[E0798]: return value of `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/return-via-stack.rs:59:48 | -LL | pub extern "C-cmse-nonsecure-entry" fn i128() -> i128 { - | ^^^^ this type doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn i128() -> i128 { + | ^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:76:56 +error[E0798]: return value of `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/return-via-stack.rs:76:54 | -LL | pub extern "C-cmse-nonsecure-entry" fn union_rust() -> ReprRustUnionU64 { - | ^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn union_rust() -> ReprRustUnionU64 { + | ^^^^^^^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size -error[E0798]: return value of `"C-cmse-nonsecure-entry"` function too large to pass via registers - --> $DIR/return-via-stack.rs:81:53 +error[E0798]: return value of `"cmse-nonsecure-entry"` function too large to pass via registers + --> $DIR/return-via-stack.rs:81:51 | -LL | pub extern "C-cmse-nonsecure-entry" fn union_c() -> ReprCUnionU64 { - | ^^^^^^^^^^^^^ this type doesn't fit in the available registers +LL | pub extern "cmse-nonsecure-entry" fn union_c() -> ReprCUnionU64 { + | ^^^^^^^^^^^^^ this type doesn't fit in the available registers | - = note: functions with the `"C-cmse-nonsecure-entry"` ABI must pass their result via the available return registers + = note: functions with the `"cmse-nonsecure-entry"` ABI must pass their result via the available return registers = note: the result must either be a (transparently wrapped) i64, u64 or f64, or be at most 4 bytes in size error: aborting due to 9 previous errors diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.aarch64.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.aarch64.stderr index 6a90dc8d635..3949eac1542 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.aarch64.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.aarch64.stderr @@ -1,8 +1,8 @@ -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/trustzone-only.rs:17:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/trustzone-only.rs:17:12 | -LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub extern "cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs index 6d84dab2166..ff5d2ec0ab6 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.rs @@ -14,7 +14,7 @@ extern crate minicore; use minicore::*; #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { +pub extern "cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { //~^ ERROR [E0570] input } diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.thumb7.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.thumb7.stderr index 6a90dc8d635..3949eac1542 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.thumb7.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.thumb7.stderr @@ -1,8 +1,8 @@ -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/trustzone-only.rs:17:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/trustzone-only.rs:17:12 | -LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub extern "cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.x86.stderr b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.x86.stderr index 6a90dc8d635..3949eac1542 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.x86.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/trustzone-only.x86.stderr @@ -1,8 +1,8 @@ -error[E0570]: `"C-cmse-nonsecure-entry"` is not a supported ABI for the current target - --> $DIR/trustzone-only.rs:17:1 +error[E0570]: "cmse-nonsecure-entry" is not a supported ABI for the current target + --> $DIR/trustzone-only.rs:17:12 | -LL | pub extern "C-cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | pub extern "cmse-nonsecure-entry" fn entry_function(input: u32) -> u32 { + | ^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/via-registers.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/via-registers.rs index 912fc8b85eb..34373288125 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/via-registers.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/via-registers.rs @@ -26,49 +26,49 @@ pub enum ReprTransparentEnumU64 { pub struct U32Compound(u16, u16); #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn inputs1() {} +pub extern "cmse-nonsecure-entry" fn inputs1() {} #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn inputs2(_: u32, _: u32, _: u32, _: u32) {} +pub extern "cmse-nonsecure-entry" fn inputs2(_: u32, _: u32, _: u32, _: u32) {} #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn inputs3(_: u64, _: u64) {} +pub extern "cmse-nonsecure-entry" fn inputs3(_: u64, _: u64) {} #[no_mangle] #[allow(improper_ctypes_definitions)] -pub extern "C-cmse-nonsecure-entry" fn inputs4(_: u128) {} +pub extern "cmse-nonsecure-entry" fn inputs4(_: u128) {} #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn inputs5(_: f64, _: f32, _: f32) {} +pub extern "cmse-nonsecure-entry" fn inputs5(_: f64, _: f32, _: f32) {} #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn inputs6(_: ReprTransparentStruct<u64>, _: U32Compound) {} +pub extern "cmse-nonsecure-entry" fn inputs6(_: ReprTransparentStruct<u64>, _: U32Compound) {} #[no_mangle] #[allow(improper_ctypes_definitions)] -pub extern "C-cmse-nonsecure-entry" fn inputs7(_: [u32; 4]) {} +pub extern "cmse-nonsecure-entry" fn inputs7(_: [u32; 4]) {} #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn outputs1() -> u32 { +pub extern "cmse-nonsecure-entry" fn outputs1() -> u32 { 0 } #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn outputs2() -> u64 { +pub extern "cmse-nonsecure-entry" fn outputs2() -> u64 { 0 } #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn outputs3() -> i64 { +pub extern "cmse-nonsecure-entry" fn outputs3() -> i64 { 0 } #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn outputs4() -> f64 { +pub extern "cmse-nonsecure-entry" fn outputs4() -> f64 { 0.0 } #[no_mangle] #[allow(improper_ctypes_definitions)] -pub extern "C-cmse-nonsecure-entry" fn outputs5() -> [u8; 4] { +pub extern "cmse-nonsecure-entry" fn outputs5() -> [u8; 4] { [0xAA; 4] } #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn outputs6() -> ReprTransparentStruct<u64> { +pub extern "cmse-nonsecure-entry" fn outputs6() -> ReprTransparentStruct<u64> { ReprTransparentStruct { _marker1: (), _marker2: (), field: 0xAA, _marker3: () } } #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn outputs7( +pub extern "cmse-nonsecure-entry" fn outputs7( ) -> ReprTransparentStruct<ReprTransparentStruct<u64>> { ReprTransparentStruct { _marker1: (), @@ -78,10 +78,10 @@ pub extern "C-cmse-nonsecure-entry" fn outputs7( } } #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn outputs8() -> ReprTransparentEnumU64 { +pub extern "cmse-nonsecure-entry" fn outputs8() -> ReprTransparentEnumU64 { ReprTransparentEnumU64::A(0) } #[no_mangle] -pub extern "C-cmse-nonsecure-entry" fn outputs9() -> U32Compound { +pub extern "cmse-nonsecure-entry" fn outputs9() -> U32Compound { U32Compound(1, 2) } diff --git a/tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs b/tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs new file mode 100644 index 00000000000..64c31beba28 --- /dev/null +++ b/tests/ui/codegen/maximal-hir-to-mir-coverage-flag.rs @@ -0,0 +1,12 @@ +//! Test that -Z maximal-hir-to-mir-coverage flag is accepted. +//! +//! Original PR: https://github.com/rust-lang/rust/pull/105286 + +//@ compile-flags: -Zmaximal-hir-to-mir-coverage +//@ run-pass + +fn main() { + let x = 1; + let y = x + 1; + println!("{y}"); +} diff --git a/tests/ui/codegen/mono-respects-abi-alignment.rs b/tests/ui/codegen/mono-respects-abi-alignment.rs new file mode 100644 index 00000000000..045d82b761f --- /dev/null +++ b/tests/ui/codegen/mono-respects-abi-alignment.rs @@ -0,0 +1,37 @@ +//! Test that monomorphization correctly distinguishes types with different ABI alignment. +//! +//! On x86_64-linux-gnu and similar platforms, structs get 8-byte "preferred" +//! alignment, but their "ABI" alignment (what actually matters for data layout) +//! is the largest alignment of any field. If monomorphization incorrectly uses +//! "preferred" alignment instead of "ABI" alignment, it might unify types `A` +//! and `B` even though `S<A>` and `S<B>` have field `t` at different offsets, +//! leading to incorrect method dispatch for `unwrap()`. + +//@ run-pass + +#[derive(Copy, Clone)] +struct S<T> { + #[allow(dead_code)] + i: u8, + t: T, +} + +impl<T> S<T> { + fn unwrap(self) -> T { + self.t + } +} + +#[derive(Copy, Clone, PartialEq, Debug)] +struct A((u32, u32)); // Different ABI alignment than B + +#[derive(Copy, Clone, PartialEq, Debug)] +struct B(u64); // Different ABI alignment than A + +pub fn main() { + static CA: S<A> = S { i: 0, t: A((13, 104)) }; + static CB: S<B> = S { i: 0, t: B(31337) }; + + assert_eq!(CA.unwrap(), A((13, 104))); + assert_eq!(CB.unwrap(), B(31337)); +} diff --git a/tests/ui/codegen/msvc-opt-level-z-no-corruption.rs b/tests/ui/codegen/msvc-opt-level-z-no-corruption.rs new file mode 100644 index 00000000000..ba97acec822 --- /dev/null +++ b/tests/ui/codegen/msvc-opt-level-z-no-corruption.rs @@ -0,0 +1,37 @@ +//! Test that opt-level=z produces correct code on Windows MSVC targets. +//! +//! A previously outdated version of LLVM caused compilation failures and +//! generated invalid code on Windows specifically with optimization level `z`. +//! The bug manifested as corrupted base pointers due to incorrect register +//! usage in the generated assembly (e.g., `popl %esi` corrupting local variables). +//! After updating to a more recent LLVM version, this test ensures that +//! compilation and execution both succeed with opt-level=z. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/45034>. + +//@ ignore-cross-compile +// Reason: the compiled binary is executed +//@ only-windows +// Reason: the observed bug only occurred on Windows MSVC targets +//@ run-pass +//@ compile-flags: -C opt-level=z + +#![feature(test)] +extern crate test; + +fn foo(x: i32, y: i32) -> i64 { + (x + y) as i64 +} + +#[inline(never)] +fn bar() { + let _f = Box::new(0); + // This call used to trigger an LLVM bug in opt-level=z where the base + // pointer gets corrupted due to incorrect register allocation + let y: fn(i32, i32) -> i64 = test::black_box(foo); + test::black_box(y(1, 2)); +} + +fn main() { + bar(); +} diff --git a/tests/ui/coercion/basic-ptr-coercions.rs b/tests/ui/coercion/basic-ptr-coercions.rs new file mode 100644 index 00000000000..4229d1fb274 --- /dev/null +++ b/tests/ui/coercion/basic-ptr-coercions.rs @@ -0,0 +1,24 @@ +//! Tests basic pointer coercions + +//@ run-pass + +pub fn main() { + // &mut -> & + let x: &mut isize = &mut 42; + let _x: &isize = x; + let _x: &isize = &mut 42; + + // & -> *const + let x: &isize = &42; + let _x: *const isize = x; + let _x: *const isize = &42; + + // &mut -> *const + let x: &mut isize = &mut 42; + let _x: *const isize = x; + let _x: *const isize = &mut 42; + + // *mut -> *const + let _x: *mut isize = &mut 42; + let _x: *const isize = x; +} diff --git a/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.rs b/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.rs new file mode 100644 index 00000000000..a4fd7710718 --- /dev/null +++ b/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.rs @@ -0,0 +1,13 @@ +// Regression test minimized from #126982. +// We used to apply a coerce_unsized coercion to literally every argument since +// the blanket applied in literally all cases, even though it was incoherent. + +#![feature(coerce_unsized)] + +impl<A> std::ops::CoerceUnsized<A> for A {} +//~^ ERROR type parameter `A` must be used as the type parameter for some local type +//~| ERROR the trait `CoerceUnsized` may only be implemented for a coercion between structures + +const C: usize = 1; + +fn main() {} diff --git a/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.stderr b/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.stderr new file mode 100644 index 00000000000..377906ee334 --- /dev/null +++ b/tests/ui/coercion/invalid-blanket-coerce-unsized-impl.stderr @@ -0,0 +1,19 @@ +error[E0210]: type parameter `A` must be used as the type parameter for some local type (e.g., `MyStruct<A>`) + --> $DIR/invalid-blanket-coerce-unsized-impl.rs:7:6 + | +LL | impl<A> std::ops::CoerceUnsized<A> for A {} + | ^ type parameter `A` must be used as the type parameter for some local type + | + = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local + = note: only traits defined in the current crate can be implemented for a type parameter + +error[E0377]: the trait `CoerceUnsized` may only be implemented for a coercion between structures + --> $DIR/invalid-blanket-coerce-unsized-impl.rs:7:1 + | +LL | impl<A> std::ops::CoerceUnsized<A> for A {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0210, E0377. +For more information about an error, try `rustc --explain E0210`. diff --git a/tests/ui/ptr-coercion.rs b/tests/ui/coercion/ptr-mutability-errors.rs index 2549bd6f134..391eaf0b913 100644 --- a/tests/ui/ptr-coercion.rs +++ b/tests/ui/coercion/ptr-mutability-errors.rs @@ -1,5 +1,4 @@ -// Test coercions between pointers which don't do anything fancy like unsizing. -// These are testing that we don't lose mutability when converting to raw pointers. +//! Tests that pointer coercions preserving mutability are enforced: //@ dont-require-annotations: NOTE diff --git a/tests/ui/ptr-coercion.stderr b/tests/ui/coercion/ptr-mutability-errors.stderr index 8de41d2c382..b4ded821c79 100644 --- a/tests/ui/ptr-coercion.stderr +++ b/tests/ui/coercion/ptr-mutability-errors.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/ptr-coercion.rs:9:25 + --> $DIR/ptr-mutability-errors.rs:8:25 | LL | let x: *mut isize = x; | ---------- ^ types differ in mutability @@ -10,7 +10,7 @@ LL | let x: *mut isize = x; found raw pointer `*const isize` error[E0308]: mismatched types - --> $DIR/ptr-coercion.rs:15:25 + --> $DIR/ptr-mutability-errors.rs:14:25 | LL | let x: *mut isize = &42; | ---------- ^^^ types differ in mutability @@ -21,7 +21,7 @@ LL | let x: *mut isize = &42; found reference `&isize` error[E0308]: mismatched types - --> $DIR/ptr-coercion.rs:21:25 + --> $DIR/ptr-mutability-errors.rs:20:25 | LL | let x: *mut isize = x; | ---------- ^ types differ in mutability diff --git a/tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr b/tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr index 033bfee226f..aafedc30b17 100644 --- a/tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr +++ b/tests/ui/coherence/coherence-impl-trait-for-trait-dyn-compatible.stderr @@ -1,3 +1,11 @@ +error[E0046]: not all trait items implemented, missing: `eq` + --> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:7:1 + | +LL | trait DynIncompatible { fn eq(&self, other: Self); } + | -------------------------- `eq` from trait +LL | impl DynIncompatible for dyn DynIncompatible { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `eq` in implementation + error[E0038]: the trait `DynIncompatible` is not dyn compatible --> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:7:26 | @@ -14,14 +22,6 @@ LL | trait DynIncompatible { fn eq(&self, other: Self); } | this trait is not dyn compatible... = help: consider moving `eq` to another trait -error[E0046]: not all trait items implemented, missing: `eq` - --> $DIR/coherence-impl-trait-for-trait-dyn-compatible.rs:7:1 - | -LL | trait DynIncompatible { fn eq(&self, other: Self); } - | -------------------------- `eq` from trait -LL | impl DynIncompatible for dyn DynIncompatible { } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `eq` in implementation - error: aborting due to 2 previous errors Some errors have detailed explanations: E0038, E0046. diff --git a/tests/ui/coherence/fuzzing/best-obligation-ICE.stderr b/tests/ui/coherence/fuzzing/best-obligation-ICE.stderr index 01b6eaf422e..fe28f4ff136 100644 --- a/tests/ui/coherence/fuzzing/best-obligation-ICE.stderr +++ b/tests/ui/coherence/fuzzing/best-obligation-ICE.stderr @@ -1,3 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `Assoc` + --> $DIR/best-obligation-ICE.rs:10:1 + | +LL | type Assoc; + | ---------- `Assoc` from trait +... +LL | impl<T> Trait for W<W<W<T>>> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Assoc` in implementation + error[E0277]: the trait bound `W<W<T>>: Trait` is not satisfied --> $DIR/best-obligation-ICE.rs:10:19 | @@ -46,15 +55,6 @@ help: consider restricting type parameter `T` with trait `Trait` LL | impl<T: Trait> Trait for W<W<W<T>>> {} | +++++++ -error[E0046]: not all trait items implemented, missing: `Assoc` - --> $DIR/best-obligation-ICE.rs:10:1 - | -LL | type Assoc; - | ---------- `Assoc` from trait -... -LL | impl<T> Trait for W<W<W<T>>> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `Assoc` in implementation - error[E0119]: conflicting implementations of trait `NoOverlap` for type `W<W<W<W<_>>>>` --> $DIR/best-obligation-ICE.rs:18:1 | diff --git a/tests/ui/coherence/occurs-check/associated-type.next.stderr b/tests/ui/coherence/occurs-check/associated-type.next.stderr index 25f9523f4e4..52794b19945 100644 --- a/tests/ui/coherence/occurs-check/associated-type.next.stderr +++ b/tests/ui/coherence/occurs-check/associated-type.next.stderr @@ -1,5 +1,5 @@ - WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } - WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } + WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1))], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } + WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1))], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())` --> $DIR/associated-type.rs:32:1 | diff --git a/tests/ui/coherence/occurs-check/associated-type.old.stderr b/tests/ui/coherence/occurs-check/associated-type.old.stderr index e091ddcacb2..9fa443eefb3 100644 --- a/tests/ui/coherence/occurs-check/associated-type.old.stderr +++ b/tests/ui/coherence/occurs-check/associated-type.old.stderr @@ -1,5 +1,5 @@ - WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } - WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1), "'a")], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } + WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1))], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } + WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [*const ?1t, '^0.Named(DefId(0:27 ~ associated_type[f554]::{impl#3}::'a#1))], def_id: DefId(0:5 ~ associated_type[f554]::ToUnit::Unit), .. } error[E0119]: conflicting implementations of trait `Overlap<for<'a> fn(&'a (), ())>` for type `for<'a> fn(&'a (), ())` --> $DIR/associated-type.rs:32:1 | diff --git a/tests/ui/compiletest-self-test/line-annotation-mismatches.rs b/tests/ui/compiletest-self-test/line-annotation-mismatches.rs new file mode 100644 index 00000000000..d2a14374ed4 --- /dev/null +++ b/tests/ui/compiletest-self-test/line-annotation-mismatches.rs @@ -0,0 +1,42 @@ +//@ should-fail + +// The warning is reported with unknown line +//@ compile-flags: -D raw_pointer_derive +//~? WARN kind and unknown line match the reported warning, but we do not suggest it + +// The error is expected but not reported at all. +//~ ERROR this error does not exist + +// The error is reported but not expected at all. +// "`main` function not found in crate" (the main function is intentionally not added) + +// An "unimportant" diagnostic is expected on a wrong line. +//~ ERROR aborting due to + +// An "unimportant" diagnostic is expected with a wrong kind. +//~? ERROR For more information about an error + +fn wrong_line_or_kind() { + // A diagnostic expected on a wrong line. + unresolved1; + //~ ERROR cannot find value `unresolved1` in this scope + + // A diagnostic expected with a wrong kind. + unresolved2; //~ WARN cannot find value `unresolved2` in this scope + + // A diagnostic expected with a missing kind (treated as a wrong kind). + unresolved3; //~ cannot find value `unresolved3` in this scope + + // A diagnostic expected with a wrong line and kind. + unresolved4; + //~ WARN cannot find value `unresolved4` in this scope +} + +fn wrong_message() { + // A diagnostic expected with a wrong message, but the line is known and right. + unresolvedA; //~ ERROR stub message 1 + + // A diagnostic expected with a wrong message, but the line is known and right, + // even if the kind doesn't match. + unresolvedB; //~ WARN stub message 2 +} diff --git a/tests/ui/compiletest-self-test/line-annotation-mismatches.stderr b/tests/ui/compiletest-self-test/line-annotation-mismatches.stderr new file mode 100644 index 00000000000..7ca3bfaf396 --- /dev/null +++ b/tests/ui/compiletest-self-test/line-annotation-mismatches.stderr @@ -0,0 +1,61 @@ +warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok + | + = note: requested on the command line with `-D raw_pointer_derive` + = note: `#[warn(renamed_and_removed_lints)]` on by default + +error[E0425]: cannot find value `unresolved1` in this scope + --> $DIR/line-annotation-mismatches.rs:21:5 + | +LL | unresolved1; + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `unresolved2` in this scope + --> $DIR/line-annotation-mismatches.rs:25:5 + | +LL | unresolved2; + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `unresolved3` in this scope + --> $DIR/line-annotation-mismatches.rs:28:5 + | +LL | unresolved3; + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `unresolved4` in this scope + --> $DIR/line-annotation-mismatches.rs:31:5 + | +LL | unresolved4; + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `unresolvedA` in this scope + --> $DIR/line-annotation-mismatches.rs:37:5 + | +LL | unresolvedA; + | ^^^^^^^^^^^ not found in this scope + +error[E0425]: cannot find value `unresolvedB` in this scope + --> $DIR/line-annotation-mismatches.rs:41:5 + | +LL | unresolvedB; + | ^^^^^^^^^^^ not found in this scope + +warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok + | + = note: requested on the command line with `-D raw_pointer_derive` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0601]: `main` function not found in crate `line_annotation_mismatches` + --> $DIR/line-annotation-mismatches.rs:42:2 + | +LL | } + | ^ consider adding a `main` function to `$DIR/line-annotation-mismatches.rs` + +warning: lint `raw_pointer_derive` has been removed: using derive with raw pointers is ok + | + = note: requested on the command line with `-D raw_pointer_derive` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 7 previous errors; 3 warnings emitted + +Some errors have detailed explanations: E0425, E0601. +For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs b/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs new file mode 100644 index 00000000000..3a110bdad35 --- /dev/null +++ b/tests/ui/compiletest-self-test/ui-test-missing-annotations-detection.rs @@ -0,0 +1,9 @@ +//! Regression test checks UI tests without error annotations are detected as failing. +//! +//! This tests that when we forget to use any `//~ ERROR` comments whatsoever, +//! the test doesn't succeed +//! Originally created in https://github.com/rust-lang/rust/pull/56244 + +//@ should-fail + +fn main() {} diff --git a/tests/ui/const-generics/const_trait_fn-issue-88433.rs b/tests/ui/const-generics/const_trait_fn-issue-88433.rs index bc91fc1700e..2f92a528bf7 100644 --- a/tests/ui/const-generics/const_trait_fn-issue-88433.rs +++ b/tests/ui/const-generics/const_trait_fn-issue-88433.rs @@ -10,7 +10,6 @@ trait Func<T> { fn call_once(self, arg: T) -> Self::Output; } - struct Closure; impl const Func<&usize> for Closure { @@ -21,7 +20,7 @@ impl const Func<&usize> for Closure { } } -enum Bug<T = [(); Closure.call_once(&0) ]> { +enum Bug<T = [(); Closure.call_once(&0)]> { V(T), } diff --git a/tests/ui/const-generics/defaults/wfness.stderr b/tests/ui/const-generics/defaults/wfness.stderr index 4f42afed81d..7098850e978 100644 --- a/tests/ui/const-generics/defaults/wfness.stderr +++ b/tests/ui/const-generics/defaults/wfness.stderr @@ -12,6 +12,14 @@ LL | (): Trait<N>; | = help: the trait `Trait<2>` is not implemented for `()` but trait `Trait<3>` is implemented for it +note: required by a bound in `WhereClause` + --> $DIR/wfness.rs:8:9 + | +LL | struct WhereClause<const N: u8 = 2> + | ----------- required by a bound in this struct +LL | where +LL | (): Trait<N>; + | ^^^^^^^^ required by this bound in `WhereClause` error[E0277]: the trait bound `(): Trait<1>` is not satisfied --> $DIR/wfness.rs:18:13 diff --git a/tests/ui/const-generics/generic_arg_infer/in-signature.rs b/tests/ui/const-generics/generic_arg_infer/in-signature.rs index cd0235bf45a..1be8b564224 100644 --- a/tests/ui/const-generics/generic_arg_infer/in-signature.rs +++ b/tests/ui/const-generics/generic_arg_infer/in-signature.rs @@ -41,6 +41,7 @@ trait TyAssocConst { trait TyAssocConstMixed { const ARR: Bar<_, _>; //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated constants + //~| ERROR the placeholder `_` is not allowed within types on item signatures for associated constants } trait AssocTy { @@ -57,4 +58,5 @@ impl AssocTy for i16 { impl AssocTy for i32 { type Assoc = Bar<_, _>; //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types + //~| ERROR the placeholder `_` is not allowed within types on item signatures for associated types } diff --git a/tests/ui/const-generics/generic_arg_infer/in-signature.stderr b/tests/ui/const-generics/generic_arg_infer/in-signature.stderr index f964fc8d2f2..b6f2662a939 100644 --- a/tests/ui/const-generics/generic_arg_infer/in-signature.stderr +++ b/tests/ui/const-generics/generic_arg_infer/in-signature.stderr @@ -103,24 +103,28 @@ LL + static TY_STATIC_MIXED: Bar<i32, 3> = Bar::<i32, 3>(0); | error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types - --> $DIR/in-signature.rs:50:23 + --> $DIR/in-signature.rs:51:23 | LL | type Assoc = [u8; _]; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types - --> $DIR/in-signature.rs:54:27 + --> $DIR/in-signature.rs:55:27 | LL | type Assoc = Bar<i32, _>; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types - --> $DIR/in-signature.rs:58:22 + --> $DIR/in-signature.rs:59:22 | LL | type Assoc = Bar<_, _>; - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types + --> $DIR/in-signature.rs:59:25 + | +LL | type Assoc = Bar<_, _>; + | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants --> $DIR/in-signature.rs:34:21 @@ -138,10 +142,14 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/in-signature.rs:42:20 | LL | const ARR: Bar<_, _>; - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants + --> $DIR/in-signature.rs:42:23 + | +LL | const ARR: Bar<_, _>; + | ^ not allowed in type signatures -error: aborting due to 15 previous errors +error: aborting due to 17 previous errors For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/const-generics/generic_const_exprs/non-local-const.rs b/tests/ui/const-generics/generic_const_exprs/non-local-const.rs new file mode 100644 index 00000000000..0a30cc385ac --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/non-local-const.rs @@ -0,0 +1,10 @@ +// regression test for #133808. + +#![feature(generic_const_exprs)] +#![feature(min_generic_const_args)] +#![allow(incomplete_features)] +#![crate_type = "lib"] + +pub trait Foo {} +impl Foo for [u8; std::path::MAIN_SEPARATOR] {} +//~^ ERROR the constant `MAIN_SEPARATOR` is not of type `usize` diff --git a/tests/ui/const-generics/generic_const_exprs/non-local-const.stderr b/tests/ui/const-generics/generic_const_exprs/non-local-const.stderr new file mode 100644 index 00000000000..d8df3269a19 --- /dev/null +++ b/tests/ui/const-generics/generic_const_exprs/non-local-const.stderr @@ -0,0 +1,10 @@ +error: the constant `MAIN_SEPARATOR` is not of type `usize` + --> $DIR/non-local-const.rs:9:14 + | +LL | impl Foo for [u8; std::path::MAIN_SEPARATOR] {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `usize`, found `char` + | + = note: the length of array `[u8; MAIN_SEPARATOR]` must be type `usize` + +error: aborting due to 1 previous error + diff --git a/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.rs b/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.rs index e5af632da75..478fa3706e8 100644 --- a/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.rs +++ b/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.rs @@ -5,6 +5,7 @@ struct Foo; impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo //~^ ERROR the const parameter `NUM` is not constrained by the impl trait, self type, or predicates +//~| ERROR missing: `Output`, `add` where [(); 1 + 0]: Sized, { diff --git a/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.stderr b/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.stderr index ade18eb88b9..29bbd23a469 100644 --- a/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.stderr +++ b/tests/ui/const-generics/generic_const_exprs/post-analysis-user-facing-param-env.stderr @@ -1,5 +1,5 @@ error[E0407]: method `unimplemented` is not a member of trait `std::ops::Add` - --> $DIR/post-analysis-user-facing-param-env.rs:11:5 + --> $DIR/post-analysis-user-facing-param-env.rs:12:5 | LL | / fn unimplemented(self, _: &Foo) -> Self::Output { LL | | @@ -17,6 +17,19 @@ LL | #![feature(generic_const_exprs)] = note: see issue #76560 <https://github.com/rust-lang/rust/issues/76560> for more information = note: `#[warn(incomplete_features)]` on by default +error[E0046]: not all trait items implemented, missing: `Output`, `add` + --> $DIR/post-analysis-user-facing-param-env.rs:6:1 + | +LL | / impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo +LL | | +LL | | +LL | | where +LL | | [(); 1 + 0]: Sized, + | |_______________________^ missing `Output`, `add` in implementation + | + = help: implement the missing item: `type Output = /* Type */;` + = help: implement the missing item: `fn add(self, _: &'a Foo) -> <Self as Add<&'a Foo>>::Output { todo!() }` + error[E0207]: the const parameter `NUM` is not constrained by the impl trait, self type, or predicates --> $DIR/post-analysis-user-facing-param-env.rs:6:10 | @@ -27,7 +40,7 @@ LL | impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo = note: proving the result of expressions other than the parameter are unique is not supported error[E0284]: type annotations needed - --> $DIR/post-analysis-user-facing-param-env.rs:11:40 + --> $DIR/post-analysis-user-facing-param-env.rs:12:40 | LL | fn unimplemented(self, _: &Foo) -> Self::Output { | ^^^^^^^^^^^^ cannot infer the value of const parameter `NUM` @@ -40,7 +53,7 @@ LL | impl<'a, const NUM: usize> std::ops::Add<&'a Foo> for Foo | | | unsatisfied trait bound introduced here -error: aborting due to 3 previous errors; 1 warning emitted +error: aborting due to 4 previous errors; 1 warning emitted -Some errors have detailed explanations: E0207, E0284, E0407. -For more information about an error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0046, E0207, E0284, E0407. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr b/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr index 7cb67252da5..3b4b5798c80 100644 --- a/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr +++ b/tests/ui/const-generics/generic_const_exprs/type_mismatch.stderr @@ -1,11 +1,3 @@ -error: the constant `N` is not of type `usize` - --> $DIR/type_mismatch.rs:8:26 - | -LL | impl<const N: u64> Q for [u8; N] {} - | ^^^^^^^ expected `usize`, found `u64` - | - = note: the length of array `[u8; N]` must be type `usize` - error[E0046]: not all trait items implemented, missing: `ASSOC` --> $DIR/type_mismatch.rs:8:1 | @@ -15,6 +7,14 @@ LL | const ASSOC: usize; LL | impl<const N: u64> Q for [u8; N] {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `ASSOC` in implementation +error: the constant `N` is not of type `usize` + --> $DIR/type_mismatch.rs:8:26 + | +LL | impl<const N: u64> Q for [u8; N] {} + | ^^^^^^^ expected `usize`, found `u64` + | + = note: the length of array `[u8; N]` must be type `usize` + error: the constant `13` is not of type `u64` --> $DIR/type_mismatch.rs:12:26 | diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs index a55be99fc0b..02a95ed3e90 100644 --- a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.rs @@ -28,6 +28,10 @@ mod v20 { impl<const v10: usize> v17<v10, v2> { //~^ ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} //~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} + //~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} + //~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} + //~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} + //~| ERROR maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} pub const fn v21() -> v18 { //~^ ERROR cannot find type `v18` in this scope v18 { _p: () } diff --git a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr index b73611c79b2..cf0bdd0e9a1 100644 --- a/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unevaluated-const-ice-119731.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `v20::v13` - --> $DIR/unevaluated-const-ice-119731.rs:38:15 + --> $DIR/unevaluated-const-ice-119731.rs:42:15 | LL | pub use v20::{v13, v17}; | ^^^ @@ -23,7 +23,7 @@ LL | pub const fn v21() -> v18 {} | ^^^ help: a type alias with a similar name exists: `v11` error[E0412]: cannot find type `v18` in this scope - --> $DIR/unevaluated-const-ice-119731.rs:31:31 + --> $DIR/unevaluated-const-ice-119731.rs:35:31 | LL | pub type v11 = [[usize; v4]; v4]; | --------------------------------- similarly named type alias `v11` defined here @@ -32,7 +32,7 @@ LL | pub const fn v21() -> v18 { | ^^^ help: a type alias with a similar name exists: `v11` error[E0422]: cannot find struct, variant or union type `v18` in this scope - --> $DIR/unevaluated-const-ice-119731.rs:33:13 + --> $DIR/unevaluated-const-ice-119731.rs:37:13 | LL | pub type v11 = [[usize; v4]; v4]; | --------------------------------- similarly named type alias `v11` defined here @@ -86,6 +86,38 @@ LL | impl<const v10: usize> v17<v10, v2> { | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} + --> $DIR/unevaluated-const-ice-119731.rs:28:37 + | +LL | impl<const v10: usize> v17<v10, v2> { + | ^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} + --> $DIR/unevaluated-const-ice-119731.rs:28:37 + | +LL | impl<const v10: usize> v17<v10, v2> { + | ^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} + --> $DIR/unevaluated-const-ice-119731.rs:28:37 + | +LL | impl<const v10: usize> v17<v10, v2> { + | ^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: maximum number of nodes exceeded in constant v20::v17::<v10, v2>::{constant#0} + --> $DIR/unevaluated-const-ice-119731.rs:28:37 + | +LL | impl<const v10: usize> v17<v10, v2> { + | ^^ + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + error[E0592]: duplicate definitions with name `v21` --> $DIR/unevaluated-const-ice-119731.rs:23:9 | @@ -95,7 +127,7 @@ LL | pub const fn v21() -> v18 {} LL | pub const fn v21() -> v18 { | ------------------------- other definition for `v21` -error: aborting due to 10 previous errors; 2 warnings emitted +error: aborting due to 14 previous errors; 2 warnings emitted Some errors have detailed explanations: E0412, E0422, E0425, E0432, E0592. For more information about an error, try `rustc --explain E0412`. diff --git a/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.stderr b/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.stderr index 67eed46eadd..ae074373da2 100644 --- a/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.stderr +++ b/tests/ui/const-generics/generic_const_exprs/unresolved_lifetimes_error.stderr @@ -1,10 +1,13 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/unresolved_lifetimes_error.rs:5:13 | -LL | fn foo() -> [(); { - | - help: consider introducing lifetime `'a` here: `<'a>` LL | let a: &'a (); | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn foo<'a>() -> [(); { + | ++++ error: aborting due to 1 previous error diff --git a/tests/ui/const-generics/ice-unexpected-inference-var-122549.rs b/tests/ui/const-generics/ice-unexpected-inference-var-122549.rs index 126ea667290..34c7a252f11 100644 --- a/tests/ui/const-generics/ice-unexpected-inference-var-122549.rs +++ b/tests/ui/const-generics/ice-unexpected-inference-var-122549.rs @@ -15,6 +15,7 @@ struct ConstChunksExact<'rem, T: 'a, const N: usize> {} impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { //~^ ERROR the const parameter `N` is not constrained by the impl trait, self type, or predicates //~^^ ERROR mismatched types +//~| ERROR missing: `next` type Item = &'a [T; N]; } diff --git a/tests/ui/const-generics/ice-unexpected-inference-var-122549.stderr b/tests/ui/const-generics/ice-unexpected-inference-var-122549.stderr index afad3388145..311caaede09 100644 --- a/tests/ui/const-generics/ice-unexpected-inference-var-122549.stderr +++ b/tests/ui/const-generics/ice-unexpected-inference-var-122549.stderr @@ -17,9 +17,12 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/ice-unexpected-inference-var-122549.rs:11:34 | LL | struct ConstChunksExact<'rem, T: 'a, const N: usize> {} - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `'a,` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | struct ConstChunksExact<'a, 'rem, T: 'a, const N: usize> {} + | +++ error[E0046]: not all trait items implemented, missing: `const_chunks_exact` --> $DIR/ice-unexpected-inference-var-122549.rs:9:1 @@ -46,6 +49,20 @@ LL | struct ConstChunksExact<'rem, T: 'a, const N: usize> {} | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` +error[E0308]: mismatched types + --> $DIR/ice-unexpected-inference-var-122549.rs:15:66 + | +LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { + | ^^ expected `usize`, found `()` + +error[E0046]: not all trait items implemented, missing: `next` + --> $DIR/ice-unexpected-inference-var-122549.rs:15:1 + | +LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `next` in implementation + | + = help: implement the missing item: `fn next(&mut self) -> Option<<Self as Iterator>::Item> { todo!() }` + error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates --> $DIR/ice-unexpected-inference-var-122549.rs:15:13 | @@ -55,13 +72,7 @@ LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported -error[E0308]: mismatched types - --> $DIR/ice-unexpected-inference-var-122549.rs:15:66 - | -LL | impl<'a, T, const N: usize> Iterator for ConstChunksExact<'a, T, {}> { - | ^^ expected `usize`, found `()` - -error: aborting due to 7 previous errors +error: aborting due to 8 previous errors Some errors have detailed explanations: E0046, E0207, E0261, E0308, E0392. For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/const-generics/infer/issue-77092.stderr b/tests/ui/const-generics/infer/issue-77092.stderr index 4ab80cec58d..3763cd738a8 100644 --- a/tests/ui/const-generics/infer/issue-77092.stderr +++ b/tests/ui/const-generics/infer/issue-77092.stderr @@ -20,7 +20,7 @@ error[E0284]: type annotations needed LL | println!("{:?}", take_array_from_mut(&mut arr, i)); | ---- ^^^^^^^^^^^^^^^^^^^ cannot infer the value of the const parameter `N` declared on the function `take_array_from_mut` | | - | type must be known at this point + | required by this formatting parameter | = note: required for `[i32; _]` to implement `Debug` = note: 1 redundant requirement hidden diff --git a/tests/ui/const-generics/issues/issue-71202.stderr b/tests/ui/const-generics/issues/issue-71202.stderr index b7c3db494a5..dd0611a7223 100644 --- a/tests/ui/const-generics/issues/issue-71202.stderr +++ b/tests/ui/const-generics/issues/issue-71202.stderr @@ -7,7 +7,7 @@ LL | | const VALUE: bool = false; ... | LL | | <IsCopy<T>>::VALUE LL | | } as usize] = []; - | |_____________________^ + | |_______________^ | help: try adding a `where` bound | diff --git a/tests/ui/const-generics/issues/issue-88119.stderr b/tests/ui/const-generics/issues/issue-88119.stderr index 94f06bbbbc4..0aabf48011d 100644 --- a/tests/ui/const-generics/issues/issue-88119.stderr +++ b/tests/ui/const-generics/issues/issue-88119.stderr @@ -6,7 +6,7 @@ LL | #![feature(const_trait_impl, generic_const_exprs)] | = help: remove one of these features -error[E0275]: overflow evaluating the requirement `&T: ~const ConstName` +error[E0275]: overflow evaluating the requirement `&T: [const] ConstName` --> $DIR/issue-88119.rs:19:49 | LL | impl<T: ?Sized + ConstName> const ConstName for &T @@ -42,7 +42,7 @@ note: required by a bound in `<&T as ConstName>` LL | [(); name_len::<T>()]:, | ^^^^^^^^^^^^^^^^^^^^^ required by this bound in `<&T as ConstName>` -error[E0275]: overflow evaluating the requirement `&mut T: ~const ConstName` +error[E0275]: overflow evaluating the requirement `&mut T: [const] ConstName` --> $DIR/issue-88119.rs:26:49 | LL | impl<T: ?Sized + ConstName> const ConstName for &mut T diff --git a/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.rs b/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.rs index ba37087135f..9a39ab1ba02 100644 --- a/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.rs +++ b/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.rs @@ -14,5 +14,6 @@ impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T //~^ ERROR mismatched types [E0308] //~| ERROR the const parameter `N` is not constrained by the impl trait, self type, or predicates [E0207] type Item = &'a [T; N]; } + //~^ ERROR: `Item` specializes an item from a parent `impl`, but that item is not marked `default` fn main() {} diff --git a/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr b/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr index 1ee68647594..ad89705e1dc 100644 --- a/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr +++ b/tests/ui/const-generics/normalizing_with_unconstrained_impl_params.stderr @@ -34,6 +34,17 @@ LL | struct ConstChunksExact<'a, T: '_, const assert: usize> {} | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` +error[E0520]: `Item` specializes an item from a parent `impl`, but that item is not marked `default` + --> $DIR/normalizing_with_unconstrained_impl_params.rs:16:5 + | +LL | impl<'a, T: std::fmt::Debug, const N: usize> Iterator for ConstChunksExact<'a, T, { N }> { + | ---------------------------------------------------------------------------------------- parent `impl` is here +... +LL | type Item = &'a [T; N]; } + | ^^^^^^^^^ cannot specialize default item `Item` + | + = note: to specialize, `Item` in the parent `impl` must be marked `default` + error[E0207]: the const parameter `N` is not constrained by the impl trait, self type, or predicates --> $DIR/normalizing_with_unconstrained_impl_params.rs:13:30 | @@ -54,7 +65,7 @@ LL | fn next(&mut self) -> Option<Self::Item> {} = note: expected enum `Option<_>` found unit type `()` -error: aborting due to 7 previous errors +error: aborting due to 8 previous errors -Some errors have detailed explanations: E0046, E0207, E0308, E0392, E0637. +Some errors have detailed explanations: E0046, E0207, E0308, E0392, E0520, E0637. For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/const-generics/not_wf_param_in_rpitit.stderr b/tests/ui/const-generics/not_wf_param_in_rpitit.stderr index 42ae012fa55..3612cfad0d4 100644 --- a/tests/ui/const-generics/not_wf_param_in_rpitit.stderr +++ b/tests/ui/const-generics/not_wf_param_in_rpitit.stderr @@ -11,7 +11,7 @@ LL | trait Trait<const N: dyn Trait = bar> { | ^^^^^ | = note: ...which immediately requires computing type of `Trait::N` again -note: cycle used when computing explicit predicates of trait `Trait` +note: cycle used when checking that `Trait` is well-formed --> $DIR/not_wf_param_in_rpitit.rs:3:1 | LL | trait Trait<const N: dyn Trait = bar> { diff --git a/tests/ui/const-ptr/pointer-address-stability.rs b/tests/ui/const-ptr/pointer-address-stability.rs new file mode 100644 index 00000000000..84a36e1ddf5 --- /dev/null +++ b/tests/ui/const-ptr/pointer-address-stability.rs @@ -0,0 +1,11 @@ +//! Check that taking the address of a stack variable with `&` +//! yields a stable and comparable pointer. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/2040>. + +//@ run-pass + +pub fn main() { + let foo: isize = 1; + assert_eq!(&foo as *const isize, &foo as *const isize); +} diff --git a/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr b/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr index d95a8861230..586c96011e4 100644 --- a/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr +++ b/tests/ui/const_prop/ice-type-mismatch-when-copying-112824.stderr @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/ice-type-mismatch-when-copying-112824.rs:5:21 | LL | pub struct Opcode2(&'a S); - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `<'a>` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | pub struct Opcode2<'a>(&'a S); + | ++++ error[E0412]: cannot find type `S` in this scope --> $DIR/ice-type-mismatch-when-copying-112824.rs:5:24 diff --git a/tests/ui/consts/array-repeat-expr-not-const.rs b/tests/ui/consts/array-repeat-expr-not-const.rs new file mode 100644 index 00000000000..55aee7336da --- /dev/null +++ b/tests/ui/consts/array-repeat-expr-not-const.rs @@ -0,0 +1,10 @@ +//! Arrays created with `[value; length]` syntax need the length to be known at +//! compile time. This test makes sure the compiler rejects runtime values like +//! function parameters in the length position. + +fn main() { + fn create_array(n: usize) { + let _x = [0; n]; + //~^ ERROR attempt to use a non-constant value in a constant [E0435] + } +} diff --git a/tests/ui/non-constant-expr-for-arr-len.stderr b/tests/ui/consts/array-repeat-expr-not-const.stderr index c9f977fbaa4..f5761545259 100644 --- a/tests/ui/non-constant-expr-for-arr-len.stderr +++ b/tests/ui/consts/array-repeat-expr-not-const.stderr @@ -1,8 +1,8 @@ error[E0435]: attempt to use a non-constant value in a constant - --> $DIR/non-constant-expr-for-arr-len.rs:5:22 + --> $DIR/array-repeat-expr-not-const.rs:7:22 | -LL | fn bar(n: usize) { - | - this would need to be a `const` +LL | fn create_array(n: usize) { + | - this would need to be a `const` LL | let _x = [0; n]; | ^ diff --git a/tests/ui/consts/const-block-const-bound.rs b/tests/ui/consts/const-block-const-bound.rs index b4b89a93e75..1847c880a39 100644 --- a/tests/ui/consts/const-block-const-bound.rs +++ b/tests/ui/consts/const-block-const-bound.rs @@ -3,7 +3,7 @@ use std::marker::Destruct; -const fn f<T: ~const Destruct>(x: T) {} +const fn f<T: [const] Destruct>(x: T) {} struct UnconstDrop; diff --git a/tests/ui/consts/const-block-const-bound.stderr b/tests/ui/consts/const-block-const-bound.stderr index 624772f5aed..b6c8027918f 100644 --- a/tests/ui/consts/const-block-const-bound.stderr +++ b/tests/ui/consts/const-block-const-bound.stderr @@ -9,8 +9,8 @@ LL | f(UnconstDrop); note: required by a bound in `f` --> $DIR/const-block-const-bound.rs:6:15 | -LL | const fn f<T: ~const Destruct>(x: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `f` +LL | const fn f<T: [const] Destruct>(x: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `f` error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-eval/format.stderr b/tests/ui/consts/const-eval/format.stderr index 2f202705b7f..bd50ac0bf41 100644 --- a/tests/ui/consts/const-eval/format.stderr +++ b/tests/ui/consts/const-eval/format.stderr @@ -13,7 +13,7 @@ LL | println!("{:?}", 0); | ^^^^^^^^^^^^^^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0015]: cannot call non-const function `_print` in constant functions --> $DIR/format.rs:7:5 diff --git a/tests/ui/consts/const-fn-type-name.rs b/tests/ui/consts/const-fn-type-name.rs index 5403c26b979..733ab79b7cd 100644 --- a/tests/ui/consts/const-fn-type-name.rs +++ b/tests/ui/consts/const-fn-type-name.rs @@ -5,7 +5,7 @@ #![allow(dead_code)] const fn type_name_wrapper<T>(_: &T) -> &'static str { - core::intrinsics::type_name::<T>() + const { core::intrinsics::type_name::<T>() } } struct Struct<TA, TB, TC> { diff --git a/tests/ui/consts/const-mut-refs/issue-76510.rs b/tests/ui/consts/const-mut-refs/issue-76510.rs index 6ebbd4e50f6..a6f7540dd59 100644 --- a/tests/ui/consts/const-mut-refs/issue-76510.rs +++ b/tests/ui/consts/const-mut-refs/issue-76510.rs @@ -1,7 +1,7 @@ use std::mem::{transmute, ManuallyDrop}; const S: &'static mut str = &mut " hello "; -//~^ ERROR: mutable references are not allowed in the final value of constants +//~^ ERROR: mutable borrows of temporaries const fn trigger() -> [(); unsafe { let s = transmute::<(*const u8, usize), &ManuallyDrop<str>>((S.as_ptr(), 3)); diff --git a/tests/ui/consts/const-mut-refs/issue-76510.stderr b/tests/ui/consts/const-mut-refs/issue-76510.stderr index aff86e83578..3a6c95141e5 100644 --- a/tests/ui/consts/const-mut-refs/issue-76510.stderr +++ b/tests/ui/consts/const-mut-refs/issue-76510.stderr @@ -1,8 +1,12 @@ -error[E0764]: mutable references are not allowed in the final value of constants +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/issue-76510.rs:3:29 | LL | const S: &'static mut str = &mut " hello "; - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs b/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs index 28facc18886..9f9384adeb7 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.rs @@ -12,13 +12,13 @@ const A: *const i32 = &4; // It could be made sound to allow it to compile, // but we do not want to allow this to compile, // as that would be an enormous footgun in oli-obk's opinion. -const B: *mut i32 = &mut 4; //~ ERROR mutable references are not allowed +const B: *mut i32 = &mut 4; //~ ERROR mutable borrows of temporaries // Ok, no actual mutable allocation exists const B2: Option<&mut i32> = None; // Not ok, can't prove that no mutable allocation ends up in final value -const B3: Option<&mut i32> = Some(&mut 42); //~ ERROR mutable references are not allowed +const B3: Option<&mut i32> = Some(&mut 42); //~ ERROR mutable borrows of temporaries const fn helper(x: &mut i32) -> Option<&mut i32> { Some(x) } const B4: Option<&mut i32> = helper(&mut 42); //~ ERROR temporary value dropped while borrowed @@ -26,8 +26,10 @@ const B4: Option<&mut i32> = helper(&mut 42); //~ ERROR temporary value dropped // Not ok, since it points to read-only memory. const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) }; //~^ ERROR pointing to read-only memory +static IMMUT_MUT_REF_STATIC: &mut u16 = unsafe { mem::transmute(&13) }; +//~^ ERROR pointing to read-only memory -// Ok, because no references to mutable data exist here, since the `{}` moves +// Ok, because no borrows of mutable data exist here, since the `{}` moves // its value and then takes a reference to that. const C: *const i32 = &{ let mut x = 42; @@ -67,13 +69,13 @@ unsafe impl<T> Sync for SyncPtr<T> {} // (This relies on `SyncPtr` being a curly brace struct.) // However, we intern the inner memory as read-only, so this must be rejected. static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; -//~^ ERROR mutable references are not allowed +//~^ ERROR mutable borrows of temporaries static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 }; -//~^ ERROR mutable references are not allowed +//~^ ERROR mutable borrows of temporaries const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; -//~^ ERROR mutable references are not allowed +//~^ ERROR mutable borrows of temporaries const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 }; -//~^ ERROR mutable references are not allowed +//~^ ERROR mutable borrows of temporaries fn main() { println!("{}", unsafe { *A }); diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr index 122e5c1bdf0..16dee44d800 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final.stderr @@ -1,14 +1,22 @@ -error[E0764]: mutable references are not allowed in the final value of constants +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/mut_ref_in_final.rs:15:21 | LL | const B: *mut i32 = &mut 4; - | ^^^^^^ + | ^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` -error[E0764]: mutable references are not allowed in the final value of constants +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/mut_ref_in_final.rs:21:35 | LL | const B3: Option<&mut i32> = Some(&mut 42); - | ^^^^^^^ + | ^^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0716]: temporary value dropped while borrowed --> $DIR/mut_ref_in_final.rs:24:42 @@ -31,8 +39,19 @@ LL | const IMMUT_MUT_REF: &mut u16 = unsafe { mem::transmute(&13) }; HEX_DUMP } +error[E0080]: constructing invalid value: encountered mutable reference or box pointing to read-only memory + --> $DIR/mut_ref_in_final.rs:29:1 + | +LL | static IMMUT_MUT_REF_STATIC: &mut u16 = unsafe { mem::transmute(&13) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value + | + = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. + = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { + HEX_DUMP + } + error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:50:65 + --> $DIR/mut_ref_in_final.rs:52:65 | LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -42,7 +61,7 @@ LL | const FOO: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a constant requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:53:67 + --> $DIR/mut_ref_in_final.rs:55:67 | LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -52,7 +71,7 @@ LL | static FOO2: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | using this value as a static requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/mut_ref_in_final.rs:56:71 + --> $DIR/mut_ref_in_final.rs:58:71 | LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | -------------------------------^^-- @@ -61,31 +80,47 @@ LL | static mut FOO3: NotAMutex<&mut i32> = NotAMutex(UnsafeCell::new(&mut 42)); | | creates a temporary value which is freed while still in use | using this value as a static requires that borrow lasts for `'static` -error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/mut_ref_in_final.rs:69:53 +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed + --> $DIR/mut_ref_in_final.rs:71:53 | LL | static RAW_MUT_CAST_S: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; - | ^^^^^^^ + | ^^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` -error[E0764]: mutable references are not allowed in the final value of statics - --> $DIR/mut_ref_in_final.rs:71:54 +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed + --> $DIR/mut_ref_in_final.rs:73:54 | LL | static RAW_MUT_COERCE_S: SyncPtr<i32> = SyncPtr { x: &mut 0 }; - | ^^^^^^ + | ^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` -error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/mut_ref_in_final.rs:73:52 +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed + --> $DIR/mut_ref_in_final.rs:75:52 | LL | const RAW_MUT_CAST_C: SyncPtr<i32> = SyncPtr { x : &mut 42 as *mut _ as *const _ }; - | ^^^^^^^ + | ^^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` -error[E0764]: mutable references are not allowed in the final value of constants - --> $DIR/mut_ref_in_final.rs:75:53 +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed + --> $DIR/mut_ref_in_final.rs:77:53 | LL | const RAW_MUT_COERCE_C: SyncPtr<i32> = SyncPtr { x: &mut 0 }; - | ^^^^^^ + | ^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` -error: aborting due to 11 previous errors +error: aborting due to 12 previous errors Some errors have detailed explanations: E0080, E0716, E0764. For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs index 2707e8a14ec..1ae901f1653 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.rs @@ -16,7 +16,7 @@ static mut BUFFER: i32 = 42; const fn helper() -> Option<&'static mut i32> { unsafe { Some(&mut *std::ptr::addr_of_mut!(BUFFER)) } } -const MUT: Option<&mut i32> = helper(); //~ ERROR encountered reference to mutable +const MUT: Option<&mut i32> = helper(); //~ ERROR encountered mutable reference const fn helper_int2ptr() -> Option<&'static mut i32> { unsafe { // Undefined behaviour (integer as pointer), who doesn't love tests like this. diff --git a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr index 6456587b77a..302e342bce6 100644 --- a/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr +++ b/tests/ui/consts/const-mut-refs/mut_ref_in_final_dynamic_check.stderr @@ -1,4 +1,4 @@ -error[E0080]: constructing invalid value at .<enum-variant(Some)>.0: encountered reference to mutable memory in `const` +error[E0080]: constructing invalid value at .<enum-variant(Some)>.0: encountered mutable reference in `const` value --> $DIR/mut_ref_in_final_dynamic_check.rs:19:1 | LL | const MUT: Option<&mut i32> = helper(); diff --git a/tests/ui/consts/const-promoted-opaque.atomic.stderr b/tests/ui/consts/const-promoted-opaque.atomic.stderr index 9c0c969d586..64cc7b3a329 100644 --- a/tests/ui/consts/const-promoted-opaque.atomic.stderr +++ b/tests/ui/consts/const-promoted-opaque.atomic.stderr @@ -7,11 +7,15 @@ LL | LL | }; | - value is dropped here -error[E0492]: constants cannot refer to interior mutable data +error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/const-promoted-opaque.rs:36:19 | LL | const BAZ: &Foo = &FOO; - | ^^^^ this borrow of an interior mutable value may end up in the final value + | ^^^^ this borrow of an interior mutable value refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0716]: temporary value dropped while borrowed --> $DIR/const-promoted-opaque.rs:40:26 diff --git a/tests/ui/consts/const-promoted-opaque.rs b/tests/ui/consts/const-promoted-opaque.rs index 188dacd1003..270dddbb4a2 100644 --- a/tests/ui/consts/const-promoted-opaque.rs +++ b/tests/ui/consts/const-promoted-opaque.rs @@ -34,7 +34,7 @@ const BAR: () = { }; const BAZ: &Foo = &FOO; -//[atomic]~^ ERROR: constants cannot refer to interior mutable data +//[atomic]~^ ERROR: interior mutable shared borrows of temporaries fn main() { let _: &'static _ = &FOO; diff --git a/tests/ui/consts/const-size_of-cycle.stderr b/tests/ui/consts/const-size_of-cycle.stderr index bf17d76a092..b127f83d885 100644 --- a/tests/ui/consts/const-size_of-cycle.stderr +++ b/tests/ui/consts/const-size_of-cycle.stderr @@ -11,13 +11,17 @@ LL | bytes: [u8; std::mem::size_of::<Foo>()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which requires computing layout of `Foo`... = note: ...which requires computing layout of `[u8; std::mem::size_of::<Foo>()]`... - = note: ...which requires normalizing `[u8; std::mem::size_of::<Foo>()]`... +note: ...which requires normalizing `[u8; std::mem::size_of::<Foo>()]`... + --> $DIR/const-size_of-cycle.rs:2:17 + | +LL | bytes: [u8; std::mem::size_of::<Foo>()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires evaluating type-level constant, completing the cycle note: cycle used when checking that `Foo` is well-formed - --> $DIR/const-size_of-cycle.rs:1:1 + --> $DIR/const-size_of-cycle.rs:2:17 | -LL | struct Foo { - | ^^^^^^^^^^ +LL | bytes: [u8; std::mem::size_of::<Foo>()] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error diff --git a/tests/ui/consts/const-unsized.stderr b/tests/ui/consts/const-unsized.stderr index cee364b33f7..c92fbc17f9c 100644 --- a/tests/ui/consts/const-unsized.stderr +++ b/tests/ui/consts/const-unsized.stderr @@ -17,19 +17,19 @@ LL | const CONST_FOO: str = *"foo"; = note: statics and constants must have a statically known size error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time - --> $DIR/const-unsized.rs:11:18 + --> $DIR/const-unsized.rs:11:1 | LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); - | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)` = note: statics and constants must have a statically known size error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/const-unsized.rs:15:20 + --> $DIR/const-unsized.rs:15:1 | LL | static STATIC_BAR: str = *"bar"; - | ^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` = note: statics and constants must have a statically known size diff --git a/tests/ui/consts/const_cmp_type_id.rs b/tests/ui/consts/const_cmp_type_id.rs index e89b8d37787..dca0615083a 100644 --- a/tests/ui/consts/const_cmp_type_id.rs +++ b/tests/ui/consts/const_cmp_type_id.rs @@ -6,11 +6,10 @@ use std::any::TypeId; fn main() { const { assert!(TypeId::of::<u8>() == TypeId::of::<u8>()); - //~^ ERROR cannot call non-const operator in constants + //~^ ERROR the trait bound `TypeId: const PartialEq` is not satisfied assert!(TypeId::of::<()>() != TypeId::of::<u8>()); - //~^ ERROR cannot call non-const operator in constants + //~^ ERROR the trait bound `TypeId: const PartialEq` is not satisfied let _a = TypeId::of::<u8>() < TypeId::of::<u16>(); - //~^ ERROR cannot call non-const operator in constants // can't assert `_a` because it is not deterministic // FIXME(const_trait_impl) make it pass } diff --git a/tests/ui/consts/const_cmp_type_id.stderr b/tests/ui/consts/const_cmp_type_id.stderr index 62f8d42c0e6..a8242a200ef 100644 --- a/tests/ui/consts/const_cmp_type_id.stderr +++ b/tests/ui/consts/const_cmp_type_id.stderr @@ -1,33 +1,15 @@ -error[E0015]: cannot call non-const operator in constants +error[E0277]: the trait bound `TypeId: const PartialEq` is not satisfied --> $DIR/const_cmp_type_id.rs:8:17 | LL | assert!(TypeId::of::<u8>() == TypeId::of::<u8>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: impl defined here, but it is not `const` - --> $SRC_DIR/core/src/any.rs:LL:COL - = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const operator in constants +error[E0277]: the trait bound `TypeId: const PartialEq` is not satisfied --> $DIR/const_cmp_type_id.rs:10:17 | LL | assert!(TypeId::of::<()>() != TypeId::of::<u8>()); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: impl defined here, but it is not `const` - --> $SRC_DIR/core/src/any.rs:LL:COL - = note: calls in constants are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const operator in constants - --> $DIR/const_cmp_type_id.rs:12:18 - | -LL | let _a = TypeId::of::<u8>() < TypeId::of::<u16>(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: impl defined here, but it is not `const` - --> $SRC_DIR/core/src/any.rs:LL:COL - = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.stderr b/tests/ui/consts/const_refs_to_static-ice-121413.stderr index 3980a7e9b93..1263deebf76 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.stderr +++ b/tests/ui/consts/const_refs_to_static-ice-121413.stderr @@ -24,10 +24,10 @@ LL | static FOO: dyn Sync = AtomicUsize::new(0); | +++ error[E0277]: the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time - --> $DIR/const_refs_to_static-ice-121413.rs:8:17 + --> $DIR/const_refs_to_static-ice-121413.rs:8:5 | LL | static FOO: Sync = AtomicUsize::new(0); - | ^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Sync + 'static)` = note: statics and constants must have a statically known size diff --git a/tests/ui/consts/const_refs_to_static.rs b/tests/ui/consts/const_refs_to_static.rs index 3c59697e8ed..187fab86a89 100644 --- a/tests/ui/consts/const_refs_to_static.rs +++ b/tests/ui/consts/const_refs_to_static.rs @@ -1,4 +1,5 @@ //@ run-pass +use std::sync::atomic::AtomicU32; static S: i32 = 0; static mut S_MUT: i32 = 0; @@ -10,9 +11,13 @@ const C1_READ: () = { }; const C2: *const i32 = std::ptr::addr_of!(S_MUT); +static FOO: AtomicU32 = AtomicU32::new(0); +const NOT_VALID_AS_PATTERN: &'static AtomicU32 = &FOO; + fn main() { assert_eq!(*C1, 0); assert_eq!(unsafe { *C2 }, 0); // Computing this pattern will read from an immutable static. That's fine. assert!(matches!(&0, C1)); + let _val = NOT_VALID_AS_PATTERN; } diff --git a/tests/ui/consts/const_refs_to_static_fail.rs b/tests/ui/consts/const_refs_to_static_fail.rs index b8bab91e005..5bb9ca0a65e 100644 --- a/tests/ui/consts/const_refs_to_static_fail.rs +++ b/tests/ui/consts/const_refs_to_static_fail.rs @@ -9,13 +9,23 @@ use std::cell::SyncUnsafeCell; static S: SyncUnsafeCell<i32> = SyncUnsafeCell::new(0); static mut S_MUT: i32 = 0; -const C1: &SyncUnsafeCell<i32> = &S; //~ERROR encountered reference to mutable memory +const C1: &SyncUnsafeCell<i32> = &S; const C1_READ: () = unsafe { - assert!(*C1.get() == 0); + assert!(*C1.get() == 0); //~ERROR constant accesses mutable global memory }; const C2: *const i32 = unsafe { std::ptr::addr_of!(S_MUT) }; const C2_READ: () = unsafe { assert!(*C2 == 0); //~ERROR constant accesses mutable global memory }; -fn main() {} +const BAD_PATTERN: &i32 = { + static mut S: i32 = 0; + unsafe { &mut S } +}; + +fn main() { + match &0 { + BAD_PATTERN => {}, //~ ERROR cannot be used as pattern + _ => {}, + } +} diff --git a/tests/ui/consts/const_refs_to_static_fail.stderr b/tests/ui/consts/const_refs_to_static_fail.stderr index 86d6c11dc0c..c567b3e0ce1 100644 --- a/tests/ui/consts/const_refs_to_static_fail.stderr +++ b/tests/ui/consts/const_refs_to_static_fail.stderr @@ -1,19 +1,8 @@ -error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` - --> $DIR/const_refs_to_static_fail.rs:12:1 - | -LL | const C1: &SyncUnsafeCell<i32> = &S; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } - -note: erroneous constant encountered - --> $DIR/const_refs_to_static_fail.rs:14:14 +error[E0080]: constant accesses mutable global memory + --> $DIR/const_refs_to_static_fail.rs:14:13 | LL | assert!(*C1.get() == 0); - | ^^ + | ^^^^^^^^^ evaluation of `C1_READ` failed here error[E0080]: constant accesses mutable global memory --> $DIR/const_refs_to_static_fail.rs:18:13 @@ -21,6 +10,14 @@ error[E0080]: constant accesses mutable global memory LL | assert!(*C2 == 0); | ^^^ evaluation of `C2_READ` failed here -error: aborting due to 2 previous errors +error: constant BAD_PATTERN cannot be used as pattern + --> $DIR/const_refs_to_static_fail.rs:28:9 + | +LL | BAD_PATTERN => {}, + | ^^^^^^^^^^^ + | + = note: constants that reference mutable or external memory cannot be used as pattern + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.rs b/tests/ui/consts/const_refs_to_static_fail_invalid.rs index 34ed8540f3f..229b9fdcc60 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.rs +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.rs @@ -23,11 +23,10 @@ fn extern_() { } const C: &i8 = unsafe { &S }; - //~^ERROR: `extern` static // This must be rejected here (or earlier), since the pattern cannot be read. match &0 { - C => {} // ok, `const` already emitted an error + C => {} //~ ERROR cannot be used as pattern _ => {} } } @@ -36,12 +35,11 @@ fn mutable() { static mut S_MUT: i32 = 0; const C: &i32 = unsafe { &S_MUT }; - //~^ERROR: encountered reference to mutable memory // This *must not build*, the constant we are matching against // could change its value! match &42 { - C => {} // ok, `const` already emitted an error + C => {} //~ ERROR cannot be used as pattern _ => {} } } diff --git a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr index 8a034aa00bc..8be8b4bc50f 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr @@ -9,27 +9,21 @@ LL | const C: &bool = unsafe { std::mem::transmute(&S) }; HEX_DUMP } -error[E0080]: constructing invalid value: encountered reference to `extern` static in `const` - --> $DIR/const_refs_to_static_fail_invalid.rs:25:5 +error: constant extern_::C cannot be used as pattern + --> $DIR/const_refs_to_static_fail_invalid.rs:29:9 | -LL | const C: &i8 = unsafe { &S }; - | ^^^^^^^^^^^^ it is undefined behavior to use this value +LL | C => {} + | ^ | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } + = note: constants that reference mutable or external memory cannot be used as pattern -error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` - --> $DIR/const_refs_to_static_fail_invalid.rs:38:5 +error: constant mutable::C cannot be used as pattern + --> $DIR/const_refs_to_static_fail_invalid.rs:42:9 | -LL | const C: &i32 = unsafe { &S_MUT }; - | ^^^^^^^^^^^^^ it is undefined behavior to use this value +LL | C => {} + | ^ | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } + = note: constants that reference mutable or external memory cannot be used as pattern error: aborting due to 3 previous errors diff --git a/tests/ui/consts/constifconst-call-in-const-position.rs b/tests/ui/consts/constifconst-call-in-const-position.rs index 80e47c2230f..da29030dbc7 100644 --- a/tests/ui/consts/constifconst-call-in-const-position.rs +++ b/tests/ui/consts/constifconst-call-in-const-position.rs @@ -14,7 +14,7 @@ impl Tr for () { } } -const fn foo<T: ~const Tr>() -> [u8; T::a()] { +const fn foo<T: [const] Tr>() -> [u8; T::a()] { [0; T::a()] } diff --git a/tests/ui/consts/constifconst-call-in-const-position.stderr b/tests/ui/consts/constifconst-call-in-const-position.stderr index c778299560f..e84e686251a 100644 --- a/tests/ui/consts/constifconst-call-in-const-position.stderr +++ b/tests/ui/consts/constifconst-call-in-const-position.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `T: const Tr` is not satisfied - --> $DIR/constifconst-call-in-const-position.rs:17:38 + --> $DIR/constifconst-call-in-const-position.rs:17:39 | -LL | const fn foo<T: ~const Tr>() -> [u8; T::a()] { - | ^ +LL | const fn foo<T: [const] Tr>() -> [u8; T::a()] { + | ^ error[E0277]: the trait bound `T: const Tr` is not satisfied --> $DIR/constifconst-call-in-const-position.rs:18:9 diff --git a/tests/ui/consts/dont-ctfe-unsized-initializer.stderr b/tests/ui/consts/dont-ctfe-unsized-initializer.stderr index e69790fc182..5b0a0166f31 100644 --- a/tests/ui/consts/dont-ctfe-unsized-initializer.stderr +++ b/tests/ui/consts/dont-ctfe-unsized-initializer.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/dont-ctfe-unsized-initializer.rs:1:11 + --> $DIR/dont-ctfe-unsized-initializer.rs:1:1 | LL | static S: str = todo!(); - | ^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `str` = note: statics and constants must have a statically known size diff --git a/tests/ui/consts/fn_trait_refs.rs b/tests/ui/consts/fn_trait_refs.rs index af233efd738..e475c0a1b6f 100644 --- a/tests/ui/consts/fn_trait_refs.rs +++ b/tests/ui/consts/fn_trait_refs.rs @@ -11,47 +11,47 @@ use std::marker::Destruct; const fn tester_fn<T>(f: T) -> T::Output where - T: ~const Fn<()> + ~const Destruct, + T: [const] Fn<()> + [const] Destruct, { f() } const fn tester_fn_mut<T>(mut f: T) -> T::Output where - T: ~const FnMut<()> + ~const Destruct, + T: [const] FnMut<()> + [const] Destruct, { f() } const fn tester_fn_once<T>(f: T) -> T::Output where - T: ~const FnOnce<()>, + T: [const] FnOnce<()>, { f() } const fn test_fn<T>(mut f: T) -> (T::Output, T::Output, T::Output) where - T: ~const Fn<()> + ~const Destruct, + T: [const] Fn<()> + [const] Destruct, { ( - // impl<A: Tuple, F: ~const Fn + ?Sized> const Fn<A> for &F + // impl<A: Tuple, F: [const] Fn + ?Sized> const Fn<A> for &F tester_fn(&f), - // impl<A: Tuple, F: ~const Fn + ?Sized> const FnMut<A> for &F + // impl<A: Tuple, F: [const] Fn + ?Sized> const FnMut<A> for &F tester_fn_mut(&f), - // impl<A: Tuple, F: ~const Fn + ?Sized> const FnOnce<A> for &F + // impl<A: Tuple, F: [const] Fn + ?Sized> const FnOnce<A> for &F tester_fn_once(&f), ) } const fn test_fn_mut<T>(mut f: T) -> (T::Output, T::Output) where - T: ~const FnMut<()> + ~const Destruct, + T: [const] FnMut<()> + [const] Destruct, { ( - // impl<A: Tuple, F: ~const FnMut + ?Sized> const FnMut<A> for &mut F + // impl<A: Tuple, F: [const] FnMut + ?Sized> const FnMut<A> for &mut F tester_fn_mut(&mut f), - // impl<A: Tuple, F: ~const FnMut + ?Sized> const FnOnce<A> for &mut F + // impl<A: Tuple, F: [const] FnMut + ?Sized> const FnOnce<A> for &mut F tester_fn_once(&mut f), ) } diff --git a/tests/ui/consts/fn_trait_refs.stderr b/tests/ui/consts/fn_trait_refs.stderr index d688bfbde2b..445dd75f824 100644 --- a/tests/ui/consts/fn_trait_refs.stderr +++ b/tests/ui/consts/fn_trait_refs.stderr @@ -4,172 +4,162 @@ error[E0635]: unknown feature `const_fn_trait_ref_impls` LL | #![feature(const_fn_trait_ref_impls)] | ^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0635]: unknown feature `const_cmp` - --> $DIR/fn_trait_refs.rs:7:12 - | -LL | #![feature(const_cmp)] - | ^^^^^^^^^ - -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:14:8 | -LL | T: ~const Fn<()> + ~const Destruct, - | ^^^^^^ can't be applied to `Fn` +LL | T: [const] Fn<()> + [const] Destruct, + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:14:8 | -LL | T: ~const Fn<()> + ~const Destruct, - | ^^^^^^ can't be applied to `Fn` +LL | T: [const] Fn<()> + [const] Destruct, + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:14:8 | -LL | T: ~const Fn<()> + ~const Destruct, - | ^^^^^^ can't be applied to `Fn` +LL | T: [const] Fn<()> + [const] Destruct, + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:21:8 | -LL | T: ~const FnMut<()> + ~const Destruct, - | ^^^^^^ can't be applied to `FnMut` +LL | T: [const] FnMut<()> + [const] Destruct, + | ^^^^^^^ can't be applied to `FnMut` | -note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:21:8 | -LL | T: ~const FnMut<()> + ~const Destruct, - | ^^^^^^ can't be applied to `FnMut` +LL | T: [const] FnMut<()> + [const] Destruct, + | ^^^^^^^ can't be applied to `FnMut` | -note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:21:8 | -LL | T: ~const FnMut<()> + ~const Destruct, - | ^^^^^^ can't be applied to `FnMut` +LL | T: [const] FnMut<()> + [const] Destruct, + | ^^^^^^^ can't be applied to `FnMut` | -note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:28:8 | -LL | T: ~const FnOnce<()>, - | ^^^^^^ can't be applied to `FnOnce` +LL | T: [const] FnOnce<()>, + | ^^^^^^^ can't be applied to `FnOnce` | -note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:28:8 | -LL | T: ~const FnOnce<()>, - | ^^^^^^ can't be applied to `FnOnce` +LL | T: [const] FnOnce<()>, + | ^^^^^^^ can't be applied to `FnOnce` | -note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:28:8 | -LL | T: ~const FnOnce<()>, - | ^^^^^^ can't be applied to `FnOnce` +LL | T: [const] FnOnce<()>, + | ^^^^^^^ can't be applied to `FnOnce` | -note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:35:8 | -LL | T: ~const Fn<()> + ~const Destruct, - | ^^^^^^ can't be applied to `Fn` +LL | T: [const] Fn<()> + [const] Destruct, + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:35:8 | -LL | T: ~const Fn<()> + ~const Destruct, - | ^^^^^^ can't be applied to `Fn` +LL | T: [const] Fn<()> + [const] Destruct, + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:35:8 | -LL | T: ~const Fn<()> + ~const Destruct, - | ^^^^^^ can't be applied to `Fn` +LL | T: [const] Fn<()> + [const] Destruct, + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:49:8 | -LL | T: ~const FnMut<()> + ~const Destruct, - | ^^^^^^ can't be applied to `FnMut` +LL | T: [const] FnMut<()> + [const] Destruct, + | ^^^^^^^ can't be applied to `FnMut` | -note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:49:8 | -LL | T: ~const FnMut<()> + ~const Destruct, - | ^^^^^^ can't be applied to `FnMut` +LL | T: [const] FnMut<()> + [const] Destruct, + | ^^^^^^^ can't be applied to `FnMut` | -note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/fn_trait_refs.rs:49:8 | -LL | T: ~const FnMut<()> + ~const Destruct, - | ^^^^^^ can't be applied to `FnMut` +LL | T: [const] FnMut<()> + [const] Destruct, + | ^^^^^^^ can't be applied to `FnMut` | -note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0015]: cannot call non-const operator in constants +error[E0277]: the trait bound `(i32, i32, i32): const PartialEq` is not satisfied --> $DIR/fn_trait_refs.rs:71:17 | LL | assert!(test_one == (1, 1, 1)); | ^^^^^^^^^^^^^^^^^^^^^ - | - = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const operator in constants +error[E0277]: the trait bound `(i32, i32): const PartialEq` is not satisfied --> $DIR/fn_trait_refs.rs:74:17 | LL | assert!(test_two == (2, 2)); | ^^^^^^^^^^^^^^^^^^ - | - = note: calls in constants are limited to constant functions, tuple structs and tuple variants error[E0015]: cannot call non-const closure in constant functions --> $DIR/fn_trait_refs.rs:16:5 @@ -195,7 +185,7 @@ LL | f() | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error: aborting due to 22 previous errors +error: aborting due to 21 previous errors -Some errors have detailed explanations: E0015, E0635. +Some errors have detailed explanations: E0015, E0277, E0635. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/consts/issue-103790.stderr b/tests/ui/consts/issue-103790.stderr index 1515fa60a5c..adfac02bd0c 100644 --- a/tests/ui/consts/issue-103790.stderr +++ b/tests/ui/consts/issue-103790.stderr @@ -29,7 +29,7 @@ LL | struct S<const S: (), const S: S = { S }>; | ^ | = note: ...which immediately requires computing type of `S::S` again -note: cycle used when computing explicit predicates of `S` +note: cycle used when checking that `S` is well-formed --> $DIR/issue-103790.rs:4:1 | LL | struct S<const S: (), const S: S = { S }>; diff --git a/tests/ui/consts/issue-17718-const-bad-values.rs b/tests/ui/consts/issue-17718-const-bad-values.rs index 40fc02cf644..a447350e35b 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.rs +++ b/tests/ui/consts/issue-17718-const-bad-values.rs @@ -5,10 +5,10 @@ #![allow(static_mut_refs)] const C1: &'static mut [usize] = &mut []; -//~^ ERROR: mutable references are not allowed +//~^ ERROR: mutable borrows of temporaries static mut S: i32 = 3; const C2: &'static mut i32 = unsafe { &mut S }; -//~^ ERROR: reference to mutable memory +//~^ ERROR: encountered mutable reference fn main() {} diff --git a/tests/ui/consts/issue-17718-const-bad-values.stderr b/tests/ui/consts/issue-17718-const-bad-values.stderr index effb614b15b..68d1a72b71e 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.stderr +++ b/tests/ui/consts/issue-17718-const-bad-values.stderr @@ -1,10 +1,14 @@ -error[E0764]: mutable references are not allowed in the final value of constants +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/issue-17718-const-bad-values.rs:7:34 | LL | const C1: &'static mut [usize] = &mut []; - | ^^^^^^^ + | ^^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` -error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` +error[E0080]: constructing invalid value: encountered mutable reference in `const` value --> $DIR/issue-17718-const-bad-values.rs:11:1 | LL | const C2: &'static mut i32 = unsafe { &mut S }; diff --git a/tests/ui/consts/issue-17718-const-borrow.rs b/tests/ui/consts/issue-17718-const-borrow.rs index 89316dbd5c4..63733332591 100644 --- a/tests/ui/consts/issue-17718-const-borrow.rs +++ b/tests/ui/consts/issue-17718-const-borrow.rs @@ -2,13 +2,13 @@ use std::cell::UnsafeCell; const A: UnsafeCell<usize> = UnsafeCell::new(1); const B: &'static UnsafeCell<usize> = &A; -//~^ ERROR: cannot refer to interior mutable +//~^ ERROR: interior mutable shared borrows of temporaries struct C { a: UnsafeCell<usize> } const D: C = C { a: UnsafeCell::new(1) }; const E: &'static UnsafeCell<usize> = &D.a; -//~^ ERROR: cannot refer to interior mutable +//~^ ERROR: interior mutable shared borrows of temporaries const F: &'static C = &D; -//~^ ERROR: cannot refer to interior mutable +//~^ ERROR: interior mutable shared borrows of temporaries fn main() {} diff --git a/tests/ui/consts/issue-17718-const-borrow.stderr b/tests/ui/consts/issue-17718-const-borrow.stderr index e3ff6c923ad..420a2c378a2 100644 --- a/tests/ui/consts/issue-17718-const-borrow.stderr +++ b/tests/ui/consts/issue-17718-const-borrow.stderr @@ -1,20 +1,32 @@ -error[E0492]: constants cannot refer to interior mutable data +error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/issue-17718-const-borrow.rs:4:39 | LL | const B: &'static UnsafeCell<usize> = &A; - | ^^ this borrow of an interior mutable value may end up in the final value + | ^^ this borrow of an interior mutable value refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` -error[E0492]: constants cannot refer to interior mutable data +error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/issue-17718-const-borrow.rs:9:39 | LL | const E: &'static UnsafeCell<usize> = &D.a; - | ^^^^ this borrow of an interior mutable value may end up in the final value + | ^^^^ this borrow of an interior mutable value refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` -error[E0492]: constants cannot refer to interior mutable data +error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/issue-17718-const-borrow.rs:11:23 | LL | const F: &'static C = &D; - | ^^ this borrow of an interior mutable value may end up in the final value + | ^^ this borrow of an interior mutable value refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 3 previous errors diff --git a/tests/ui/consts/issue-44415.stderr b/tests/ui/consts/issue-44415.stderr index 641945fce9f..0e3f2e6199f 100644 --- a/tests/ui/consts/issue-44415.stderr +++ b/tests/ui/consts/issue-44415.stderr @@ -11,13 +11,17 @@ LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }], | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which requires computing layout of `Foo`... = note: ...which requires computing layout of `[u8; unsafe { intrinsics::size_of::<Foo>() }]`... - = note: ...which requires normalizing `[u8; unsafe { intrinsics::size_of::<Foo>() }]`... +note: ...which requires normalizing `[u8; unsafe { intrinsics::size_of::<Foo>() }]`... + --> $DIR/issue-44415.rs:6:17 + | +LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }], + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires evaluating type-level constant, completing the cycle note: cycle used when checking that `Foo` is well-formed - --> $DIR/issue-44415.rs:5:1 + --> $DIR/issue-44415.rs:6:17 | -LL | struct Foo { - | ^^^^^^^^^^ +LL | bytes: [u8; unsafe { intrinsics::size_of::<Foo>() }], + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error diff --git a/tests/ui/consts/issue-73976-monomorphic.stderr b/tests/ui/consts/issue-73976-monomorphic.stderr index ef754b23ff0..367d5be09da 100644 --- a/tests/ui/consts/issue-73976-monomorphic.stderr +++ b/tests/ui/consts/issue-73976-monomorphic.stderr @@ -1,13 +1,9 @@ -error[E0015]: cannot call non-const operator in constant functions +error[E0277]: the trait bound `TypeId: [const] PartialEq` is not satisfied --> $DIR/issue-73976-monomorphic.rs:21:5 | LL | GetTypeId::<T>::VALUE == GetTypeId::<usize>::VALUE | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: impl defined here, but it is not `const` - --> $SRC_DIR/core/src/any.rs:LL:COL - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/consts/issue-90870.rs b/tests/ui/consts/issue-90870.rs index b62769a33f8..f807ae75ee5 100644 --- a/tests/ui/consts/issue-90870.rs +++ b/tests/ui/consts/issue-90870.rs @@ -3,22 +3,31 @@ #![allow(dead_code)] const fn f(a: &u8, b: &u8) -> bool { + //~^ HELP: add `#![feature(const_trait_impl)]` to the crate attributes to enable + //~| HELP: add `#![feature(const_trait_impl)]` to the crate attributes to enable + //~| HELP: add `#![feature(const_trait_impl)]` to the crate attributes to enable a == b - //~^ ERROR: cannot call non-const operator in constant functions [E0015] + //~^ ERROR: cannot call conditionally-const operator in constant functions + //~| ERROR: `PartialEq` is not yet stable as a const trait //~| HELP: consider dereferencing here + //~| HELP: add `#![feature(const_trait_impl)]` to the crate attributes to enable } const fn g(a: &&&&i64, b: &&&&i64) -> bool { a == b - //~^ ERROR: cannot call non-const operator in constant functions [E0015] + //~^ ERROR: cannot call conditionally-const operator in constant functions + //~| ERROR: `PartialEq` is not yet stable as a const trait //~| HELP: consider dereferencing here + //~| HELP: add `#![feature(const_trait_impl)]` to the crate attributes to enable } const fn h(mut a: &[u8], mut b: &[u8]) -> bool { while let ([l, at @ ..], [r, bt @ ..]) = (a, b) { if l == r { - //~^ ERROR: cannot call non-const operator in constant functions [E0015] + //~^ ERROR: cannot call conditionally-const operator in constant functions + //~| ERROR: `PartialEq` is not yet stable as a const trait //~| HELP: consider dereferencing here + //~| HELP: add `#![feature(const_trait_impl)]` to the crate attributes to enable a = at; b = bt; } else { diff --git a/tests/ui/consts/issue-90870.stderr b/tests/ui/consts/issue-90870.stderr index ea987920d7d..8d6f21fd82f 100644 --- a/tests/ui/consts/issue-90870.stderr +++ b/tests/ui/consts/issue-90870.stderr @@ -1,39 +1,81 @@ -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/issue-90870.rs:6:5 +error[E0658]: cannot call conditionally-const operator in constant functions + --> $DIR/issue-90870.rs:9:5 | LL | a == b | ^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date help: consider dereferencing here | LL | *a == *b | + + -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/issue-90870.rs:12:5 +error: `PartialEq` is not yet stable as a const trait + --> $DIR/issue-90870.rs:9:5 + | +LL | a == b + | ^^^^^^ + | +help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + | +LL + #![feature(const_trait_impl)] + | + +error[E0658]: cannot call conditionally-const operator in constant functions + --> $DIR/issue-90870.rs:17:5 | LL | a == b | ^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date help: consider dereferencing here | LL | ****a == ****b | ++++ ++++ -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/issue-90870.rs:19:12 +error: `PartialEq` is not yet stable as a const trait + --> $DIR/issue-90870.rs:17:5 + | +LL | a == b + | ^^^^^^ + | +help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + | +LL + #![feature(const_trait_impl)] + | + +error[E0658]: cannot call conditionally-const operator in constant functions + --> $DIR/issue-90870.rs:26:12 | LL | if l == r { | ^^^^^^ | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants + = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information + = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date help: consider dereferencing here | LL | if *l == *r { | + + -error: aborting due to 3 previous errors +error: `PartialEq` is not yet stable as a const trait + --> $DIR/issue-90870.rs:26:12 + | +LL | if l == r { + | ^^^^^^ + | +help: add `#![feature(const_trait_impl)]` to the crate attributes to enable + | +LL + #![feature(const_trait_impl)] + | + +error: aborting due to 6 previous errors -For more information about this error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs index 6cc67094346..eb78b5335cb 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.rs @@ -20,7 +20,7 @@ static mut MUTABLE: u32 = 0; const READ_MUT: u32 = unsafe { MUTABLE }; //~ERROR constant accesses mutable global memory // Evaluating this does not read anything mutable, but validation does, so this should error. -const REF_INTERIOR_MUT: &usize = { //~ ERROR encountered reference to mutable memory +const REF_INTERIOR_MUT: &usize = { static FOO: AtomicUsize = AtomicUsize::new(0); unsafe { &*(&FOO as *const _ as *const usize) } }; @@ -30,6 +30,13 @@ static MY_STATIC: u8 = 4; const REF_IMMUT: &u8 = &MY_STATIC; const READ_IMMUT: u8 = *REF_IMMUT; +fn foo() { + match &0 { + REF_INTERIOR_MUT => {}, //~ ERROR cannot be used as pattern + _ => {}, + } +} + fn main() {} //~? WARN skipping const checks diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr index eed3b4d9065..6b70a211a72 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static.stderr @@ -16,16 +16,13 @@ error[E0080]: constant accesses mutable global memory LL | const READ_MUT: u32 = unsafe { MUTABLE }; | ^^^^^^^ evaluation of `READ_MUT` failed here -error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` - --> $DIR/const_refers_to_static.rs:23:1 +error: constant REF_INTERIOR_MUT cannot be used as pattern + --> $DIR/const_refers_to_static.rs:35:9 | -LL | const REF_INTERIOR_MUT: &usize = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value +LL | REF_INTERIOR_MUT => {}, + | ^^^^^^^^^^^^^^^^ | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } + = note: constants that reference mutable or external memory cannot be used as pattern warning: skipping const checks | diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs index 6c7e7835661..cb093305429 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.rs @@ -11,18 +11,15 @@ extern crate static_cross_crate; // Sneaky: reference to a mutable static. // Allowing this would be a disaster for pattern matching, we could violate exhaustiveness checking! const SLICE_MUT: &[u8; 1] = { - //~^ ERROR encountered reference to mutable memory unsafe { &static_cross_crate::ZERO } }; const U8_MUT: &u8 = { - //~^ ERROR encountered reference to mutable memory unsafe { &static_cross_crate::ZERO[0] } }; // Also test indirection that reads from other static. const U8_MUT2: &u8 = { - //~^ ERROR encountered reference to mutable memory unsafe { &(*static_cross_crate::ZERO_REF)[0] } }; const U8_MUT3: &u8 = { @@ -37,14 +34,14 @@ const U8_MUT3: &u8 = { pub fn test(x: &[u8; 1]) -> bool { match x { - SLICE_MUT => true, // ok, `const` error already emitted + SLICE_MUT => true, //~ ERROR cannot be used as pattern &[1..] => false, } } pub fn test2(x: &u8) -> bool { match x { - U8_MUT => true, // ok, `const` error already emitted + U8_MUT => true, //~ ERROR cannot be used as pattern &(1..) => false, } } @@ -53,7 +50,7 @@ pub fn test2(x: &u8) -> bool { // the errors above otherwise stop compilation too early? pub fn test3(x: &u8) -> bool { match x { - U8_MUT2 => true, // ok, `const` error already emitted + U8_MUT2 => true, //~ ERROR cannot be used as pattern &(1..) => false, } } diff --git a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr index 8af3a1948f0..d753506cc94 100644 --- a/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr +++ b/tests/ui/consts/miri_unleashed/const_refers_to_static_cross_crate.stderr @@ -1,41 +1,32 @@ -error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` - --> $DIR/const_refers_to_static_cross_crate.rs:13:1 - | -LL | const SLICE_MUT: &[u8; 1] = { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value +error[E0080]: constant accesses mutable global memory + --> $DIR/const_refers_to_static_cross_crate.rs:27:15 | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } +LL | match static_cross_crate::OPT_ZERO { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `U8_MUT3` failed here -error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` - --> $DIR/const_refers_to_static_cross_crate.rs:18:1 +error: constant SLICE_MUT cannot be used as pattern + --> $DIR/const_refers_to_static_cross_crate.rs:37:9 | -LL | const U8_MUT: &u8 = { - | ^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value +LL | SLICE_MUT => true, + | ^^^^^^^^^ | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } + = note: constants that reference mutable or external memory cannot be used as pattern -error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` - --> $DIR/const_refers_to_static_cross_crate.rs:24:1 +error: constant U8_MUT cannot be used as pattern + --> $DIR/const_refers_to_static_cross_crate.rs:44:9 | -LL | const U8_MUT2: &u8 = { - | ^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value +LL | U8_MUT => true, + | ^^^^^^ | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } + = note: constants that reference mutable or external memory cannot be used as pattern -error[E0080]: constant accesses mutable global memory - --> $DIR/const_refers_to_static_cross_crate.rs:30:15 +error: constant U8_MUT2 cannot be used as pattern + --> $DIR/const_refers_to_static_cross_crate.rs:53:9 | -LL | match static_cross_crate::OPT_ZERO { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `U8_MUT3` failed here +LL | U8_MUT2 => true, + | ^^^^^^^ + | + = note: constants that reference mutable or external memory cannot be used as pattern error: aborting due to 4 previous errors diff --git a/tests/ui/consts/miri_unleashed/mutable_references.rs b/tests/ui/consts/miri_unleashed/mutable_references.rs index 63d243f892c..2e95393ccbf 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.rs +++ b/tests/ui/consts/miri_unleashed/mutable_references.rs @@ -26,7 +26,7 @@ const BLUNT: &mut i32 = &mut 42; //~^ ERROR: pointing to read-only memory const SUBTLE: &mut i32 = unsafe { - //~^ ERROR: constructing invalid value: encountered reference to mutable memory in `const` + //~^ ERROR: encountered mutable reference static mut STATIC: i32 = 0; &mut STATIC }; @@ -65,7 +65,10 @@ static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as // # Check for consts pointing to mutable memory static mut MUTABLE: i32 = 42; -const POINTS_TO_MUTABLE: &i32 = unsafe { &MUTABLE }; //~ ERROR encountered reference to mutable memory +const POINTS_TO_MUTABLE: &i32 = unsafe { &MUTABLE }; // OK, as long as it is not used as a pattern. + +// This fails since `&*MUTABLE_REF` is basically a copy of `MUTABLE_REF`, but we +// can't read from that static as it is mutable. static mut MUTABLE_REF: &mut i32 = &mut 42; const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; //~^ ERROR accesses mutable global memory diff --git a/tests/ui/consts/miri_unleashed/mutable_references.stderr b/tests/ui/consts/miri_unleashed/mutable_references.stderr index 22860e4f6d9..137efde44b3 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references.stderr @@ -43,7 +43,7 @@ LL | const BLUNT: &mut i32 = &mut 42; HEX_DUMP } -error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` +error[E0080]: constructing invalid value: encountered mutable reference in `const` value --> $DIR/mutable_references.rs:28:1 | LL | const SUBTLE: &mut i32 = unsafe { @@ -98,49 +98,38 @@ LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const HEX_DUMP } -error[E0080]: constructing invalid value: encountered reference to mutable memory in `const` - --> $DIR/mutable_references.rs:68:1 - | -LL | const POINTS_TO_MUTABLE: &i32 = unsafe { &MUTABLE }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ it is undefined behavior to use this value - | - = note: The rules on what exactly is undefined behavior aren't clear, so this check might be overzealous. Please open an issue on the rustc repository if you believe it should not be considered undefined behavior. - = note: the raw bytes of the constant (size: $SIZE, align: $ALIGN) { - HEX_DUMP - } - error[E0080]: constant accesses mutable global memory - --> $DIR/mutable_references.rs:70:43 + --> $DIR/mutable_references.rs:73:43 | LL | const POINTS_TO_MUTABLE2: &i32 = unsafe { &*MUTABLE_REF }; | ^^^^^^^^^^^^^ evaluation of `POINTS_TO_MUTABLE2` failed here error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:73:1 + --> $DIR/mutable_references.rs:76:1 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:76:1 + --> $DIR/mutable_references.rs:79:1 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:96:1 + --> $DIR/mutable_references.rs:99:1 | LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: encountered mutable pointer in final value of constant - --> $DIR/mutable_references.rs:99:1 + --> $DIR/mutable_references.rs:102:1 | LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0594]: cannot assign to `*OH_YES`, as `OH_YES` is an immutable static item - --> $DIR/mutable_references.rs:106:5 + --> $DIR/mutable_references.rs:109:5 | LL | *OH_YES = 99; | ^^^^^^^^^^^^ cannot assign @@ -188,37 +177,37 @@ help: skipping check that does not even have a feature gate LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:73:45 + --> $DIR/mutable_references.rs:76:45 | LL | const POINTS_TO_MUTABLE_INNER: *const i32 = &mut 42 as *mut _ as *const _; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:76:46 + --> $DIR/mutable_references.rs:79:46 | LL | const POINTS_TO_MUTABLE_INNER2: *const i32 = &mut 42 as *const _; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:81:47 + --> $DIR/mutable_references.rs:84:47 | LL | const INTERIOR_MUTABLE_BEHIND_RAW: *mut i32 = &UnsafeCell::new(42) as *const _ as *mut _; | ^^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:93:51 + --> $DIR/mutable_references.rs:96:51 | LL | const RAW_SYNC: SyncPtr<AtomicI32> = SyncPtr { x: &AtomicI32::new(42) }; | ^^^^^^^^^^^^^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:96:49 + --> $DIR/mutable_references.rs:99:49 | LL | const RAW_MUT_CAST: SyncPtr<i32> = SyncPtr { x: &mut 42 as *mut _ as *const _ }; | ^^^^^^^ help: skipping check that does not even have a feature gate - --> $DIR/mutable_references.rs:99:51 + --> $DIR/mutable_references.rs:102:51 | LL | const RAW_MUT_COERCE: SyncPtr<i32> = SyncPtr { x: &mut 0 }; | ^^^^^^ -error: aborting due to 17 previous errors; 1 warning emitted +error: aborting due to 16 previous errors; 1 warning emitted Some errors have detailed explanations: E0080, E0594. For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/normalize-before-const-arg-has-type-goal.rs b/tests/ui/consts/normalize-before-const-arg-has-type-goal.rs new file mode 100644 index 00000000000..9caa3c9e214 --- /dev/null +++ b/tests/ui/consts/normalize-before-const-arg-has-type-goal.rs @@ -0,0 +1,19 @@ +trait A<const B: bool> {} + +// vv- Let's call this const "UNEVALUATED" for the comment below. +impl A<{}> for () {} +//~^ ERROR mismatched types + +// During overlap check, we end up trying to prove `(): A<?0c>`. Inference guides +// `?0c = UNEVALUATED` (which is the `{}` const in the erroneous impl). We then +// fail to prove `ConstArgHasType<UNEVALUATED, u8>` since `UNEVALUATED` has the +// type `bool` from the type_of query. We then deeply normalize the predicate for +// error reporting, which ends up normalizing `UNEVALUATED` to a ConstKind::Error. +// This ended up ICEing when trying to report an error for the `ConstArgHasType` +// predicate, since we don't expect `ConstArgHasType(ERROR, Ty)` to ever fail. + +trait C<const D: u8> {} +impl<const D: u8> C<D> for () where (): A<D> {} +impl<const D: u8> C<D> for () {} + +fn main() {} diff --git a/tests/ui/consts/normalize-before-const-arg-has-type-goal.stderr b/tests/ui/consts/normalize-before-const-arg-has-type-goal.stderr new file mode 100644 index 00000000000..a53231846b7 --- /dev/null +++ b/tests/ui/consts/normalize-before-const-arg-has-type-goal.stderr @@ -0,0 +1,9 @@ +error[E0308]: mismatched types + --> $DIR/normalize-before-const-arg-has-type-goal.rs:4:8 + | +LL | impl A<{}> for () {} + | ^^ expected `bool`, found `()` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/consts/partial_qualif.rs b/tests/ui/consts/partial_qualif.rs index 7c28b8b8a62..18438cc576b 100644 --- a/tests/ui/consts/partial_qualif.rs +++ b/tests/ui/consts/partial_qualif.rs @@ -3,7 +3,7 @@ use std::cell::Cell; const FOO: &(Cell<usize>, bool) = { let mut a = (Cell::new(0), false); a.1 = true; // sets `qualif(a)` to `qualif(a) | qualif(true)` - &{a} //~ ERROR cannot refer to interior mutable + &{a} //~ ERROR interior mutable shared borrows of temporaries }; fn main() {} diff --git a/tests/ui/consts/partial_qualif.stderr b/tests/ui/consts/partial_qualif.stderr index 05e0eeee133..b7632eb868a 100644 --- a/tests/ui/consts/partial_qualif.stderr +++ b/tests/ui/consts/partial_qualif.stderr @@ -1,8 +1,12 @@ -error[E0492]: constants cannot refer to interior mutable data +error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/partial_qualif.rs:6:5 | LL | &{a} - | ^^^^ this borrow of an interior mutable value may end up in the final value + | ^^^^ this borrow of an interior mutable value refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 1 previous error diff --git a/tests/ui/consts/qualif_overwrite.rs b/tests/ui/consts/qualif_overwrite.rs index aae4e41ffd7..93310b3f2a6 100644 --- a/tests/ui/consts/qualif_overwrite.rs +++ b/tests/ui/consts/qualif_overwrite.rs @@ -7,7 +7,7 @@ use std::cell::Cell; const FOO: &Option<Cell<usize>> = { let mut a = Some(Cell::new(0)); a = None; // sets `qualif(a)` to `qualif(a) | qualif(None)` - &{a} //~ ERROR cannot refer to interior mutable + &{a} //~ ERROR interior mutable shared borrows of temporaries }; fn main() {} diff --git a/tests/ui/consts/qualif_overwrite.stderr b/tests/ui/consts/qualif_overwrite.stderr index 976cf7bd79e..4aaaa4b2ca9 100644 --- a/tests/ui/consts/qualif_overwrite.stderr +++ b/tests/ui/consts/qualif_overwrite.stderr @@ -1,8 +1,12 @@ -error[E0492]: constants cannot refer to interior mutable data +error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/qualif_overwrite.rs:10:5 | LL | &{a} - | ^^^^ this borrow of an interior mutable value may end up in the final value + | ^^^^ this borrow of an interior mutable value refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 1 previous error diff --git a/tests/ui/consts/qualif_overwrite_2.rs b/tests/ui/consts/qualif_overwrite_2.rs index 1819d9a6d20..e739790b566 100644 --- a/tests/ui/consts/qualif_overwrite_2.rs +++ b/tests/ui/consts/qualif_overwrite_2.rs @@ -5,7 +5,7 @@ use std::cell::Cell; const FOO: &Option<Cell<usize>> = { let mut a = (Some(Cell::new(0)),); a.0 = None; // sets `qualif(a)` to `qualif(a) | qualif(None)` - &{a.0} //~ ERROR cannot refer to interior mutable + &{a.0} //~ ERROR interior mutable shared borrows of temporaries }; fn main() {} diff --git a/tests/ui/consts/qualif_overwrite_2.stderr b/tests/ui/consts/qualif_overwrite_2.stderr index a107c4a5c6d..bc168141876 100644 --- a/tests/ui/consts/qualif_overwrite_2.stderr +++ b/tests/ui/consts/qualif_overwrite_2.stderr @@ -1,8 +1,12 @@ -error[E0492]: constants cannot refer to interior mutable data +error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/qualif_overwrite_2.rs:8:5 | LL | &{a.0} - | ^^^^^^ this borrow of an interior mutable value may end up in the final value + | ^^^^^^ this borrow of an interior mutable value refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 1 previous error diff --git a/tests/ui/consts/recursive-static-write.rs b/tests/ui/consts/recursive-static-write.rs new file mode 100644 index 00000000000..dc5813d8c78 --- /dev/null +++ b/tests/ui/consts/recursive-static-write.rs @@ -0,0 +1,24 @@ +//! Ensure that writing to `S` while initializing `S` errors. +//! Regression test for <https://github.com/rust-lang/rust/issues/142404>. +#![allow(dead_code)] + +struct Foo { + x: i32, + y: (), +} + +static S: Foo = Foo { + x: 0, + y: unsafe { + (&raw const S.x).cast_mut().write(1); //~ERROR access itself during initialization + }, +}; + +static mut S2: Foo = Foo { + x: 0, + y: unsafe { + S2.x = 1; //~ERROR access itself during initialization + }, +}; + +fn main() {} diff --git a/tests/ui/consts/recursive-static-write.stderr b/tests/ui/consts/recursive-static-write.stderr new file mode 100644 index 00000000000..f5b5c49317c --- /dev/null +++ b/tests/ui/consts/recursive-static-write.stderr @@ -0,0 +1,15 @@ +error[E0080]: encountered static that tried to access itself during initialization + --> $DIR/recursive-static-write.rs:13:9 + | +LL | (&raw const S.x).cast_mut().write(1); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ evaluation of `S` failed here + +error[E0080]: encountered static that tried to access itself during initialization + --> $DIR/recursive-static-write.rs:20:9 + | +LL | S2.x = 1; + | ^^^^^^^^ evaluation of `S2` failed here + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/recursive-zst-static.default.stderr b/tests/ui/consts/recursive-zst-static.default.stderr index fee33a892d0..c814576dfd5 100644 --- a/tests/ui/consts/recursive-zst-static.default.stderr +++ b/tests/ui/consts/recursive-zst-static.default.stderr @@ -1,20 +1,20 @@ -error[E0080]: encountered static that tried to initialize itself with itself +error[E0080]: encountered static that tried to access itself during initialization --> $DIR/recursive-zst-static.rs:10:18 | LL | static FOO: () = FOO; | ^^^ evaluation of `FOO` failed here error[E0391]: cycle detected when evaluating initializer of static `A` - --> $DIR/recursive-zst-static.rs:13:16 + --> $DIR/recursive-zst-static.rs:13:1 | LL | static A: () = B; - | ^ + | ^^^^^^^^^^^^ | note: ...which requires evaluating initializer of static `B`... - --> $DIR/recursive-zst-static.rs:14:16 + --> $DIR/recursive-zst-static.rs:14:1 | LL | static B: () = A; - | ^ + | ^^^^^^^^^^^^ = note: ...which again requires evaluating initializer of static `A`, completing the cycle = note: cycle used when running analysis passes on this crate = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information diff --git a/tests/ui/consts/recursive-zst-static.rs b/tests/ui/consts/recursive-zst-static.rs index 852caae9493..853af6d70eb 100644 --- a/tests/ui/consts/recursive-zst-static.rs +++ b/tests/ui/consts/recursive-zst-static.rs @@ -8,7 +8,7 @@ // See https://github.com/rust-lang/rust/issues/71078 for more details. static FOO: () = FOO; -//~^ ERROR encountered static that tried to initialize itself with itself +//~^ ERROR encountered static that tried to access itself during initialization static A: () = B; //~ ERROR cycle detected when evaluating initializer of static `A` static B: () = A; diff --git a/tests/ui/consts/recursive-zst-static.unleash.stderr b/tests/ui/consts/recursive-zst-static.unleash.stderr index fee33a892d0..c814576dfd5 100644 --- a/tests/ui/consts/recursive-zst-static.unleash.stderr +++ b/tests/ui/consts/recursive-zst-static.unleash.stderr @@ -1,20 +1,20 @@ -error[E0080]: encountered static that tried to initialize itself with itself +error[E0080]: encountered static that tried to access itself during initialization --> $DIR/recursive-zst-static.rs:10:18 | LL | static FOO: () = FOO; | ^^^ evaluation of `FOO` failed here error[E0391]: cycle detected when evaluating initializer of static `A` - --> $DIR/recursive-zst-static.rs:13:16 + --> $DIR/recursive-zst-static.rs:13:1 | LL | static A: () = B; - | ^ + | ^^^^^^^^^^^^ | note: ...which requires evaluating initializer of static `B`... - --> $DIR/recursive-zst-static.rs:14:16 + --> $DIR/recursive-zst-static.rs:14:1 | LL | static B: () = A; - | ^ + | ^^^^^^^^^^^^ = note: ...which again requires evaluating initializer of static `A`, completing the cycle = note: cycle used when running analysis passes on this crate = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information diff --git a/tests/ui/consts/refs-to-cell-in-final.rs b/tests/ui/consts/refs-to-cell-in-final.rs index 844b140cff2..2bd0623d94b 100644 --- a/tests/ui/consts/refs-to-cell-in-final.rs +++ b/tests/ui/consts/refs-to-cell-in-final.rs @@ -11,9 +11,9 @@ unsafe impl<T> Sync for SyncPtr<T> {} // The resulting constant would pass all validation checks, so it is crucial that this gets rejected // by static const checks! static RAW_SYNC_S: SyncPtr<Cell<i32>> = SyncPtr { x: &Cell::new(42) }; -//~^ ERROR: cannot refer to interior mutable data +//~^ ERROR: interior mutable shared borrows of temporaries const RAW_SYNC_C: SyncPtr<Cell<i32>> = SyncPtr { x: &Cell::new(42) }; -//~^ ERROR: cannot refer to interior mutable data +//~^ ERROR: interior mutable shared borrows of temporaries // This one does not get promoted because of `Drop`, and then enters interesting codepaths because // as a value it has no interior mutability, but as a type it does. See @@ -39,7 +39,7 @@ const NONE_EXPLICIT_PROMOTED: &'static Option<Cell<i32>> = { // Not okay, since we are borrowing something with interior mutability. const INTERIOR_MUT_VARIANT: &Option<UnsafeCell<bool>> = &{ - //~^ERROR: cannot refer to interior mutable data + //~^ERROR: interior mutable shared borrows of temporaries let mut x = None; assert!(x.is_none()); x = Some(UnsafeCell::new(false)); diff --git a/tests/ui/consts/refs-to-cell-in-final.stderr b/tests/ui/consts/refs-to-cell-in-final.stderr index 8d82d94f412..ac866dbe721 100644 --- a/tests/ui/consts/refs-to-cell-in-final.stderr +++ b/tests/ui/consts/refs-to-cell-in-final.stderr @@ -1,18 +1,24 @@ -error[E0492]: statics cannot refer to interior mutable data +error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/refs-to-cell-in-final.rs:13:54 | LL | static RAW_SYNC_S: SyncPtr<Cell<i32>> = SyncPtr { x: &Cell::new(42) }; - | ^^^^^^^^^^^^^^ this borrow of an interior mutable value may end up in the final value + | ^^^^^^^^^^^^^^ this borrow of an interior mutable value refers to such a temporary | - = help: to fix this, the value can be extracted to a separate `static` item and then referenced + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` -error[E0492]: constants cannot refer to interior mutable data +error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/refs-to-cell-in-final.rs:15:53 | LL | const RAW_SYNC_C: SyncPtr<Cell<i32>> = SyncPtr { x: &Cell::new(42) }; - | ^^^^^^^^^^^^^^ this borrow of an interior mutable value may end up in the final value + | ^^^^^^^^^^^^^^ this borrow of an interior mutable value refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` -error[E0492]: constants cannot refer to interior mutable data +error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/refs-to-cell-in-final.rs:41:57 | LL | const INTERIOR_MUT_VARIANT: &Option<UnsafeCell<bool>> = &{ @@ -23,7 +29,11 @@ LL | | assert!(x.is_none()); LL | | x = Some(UnsafeCell::new(false)); LL | | x LL | | }; - | |_^ this borrow of an interior mutable value may end up in the final value + | |_^ this borrow of an interior mutable value refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 3 previous errors diff --git a/tests/ui/consts/unsafe_cell_in_const.rs b/tests/ui/consts/unsafe_cell_in_const.rs new file mode 100644 index 00000000000..b867ae1ba9f --- /dev/null +++ b/tests/ui/consts/unsafe_cell_in_const.rs @@ -0,0 +1,15 @@ +//! Ensure we do not complain about zero-sized `UnsafeCell` in a const in any form. +//! See <https://github.com/rust-lang/rust/issues/142948>. + +//@ check-pass +use std::cell::UnsafeCell; + +const X1: &mut UnsafeCell<[i32; 0]> = UnsafeCell::from_mut(&mut []); + +const X2: &mut UnsafeCell<[i32]> = UnsafeCell::from_mut(&mut []); + +trait Trait {} +impl Trait for [i32; 0] {} +const X3: &mut UnsafeCell<dyn Trait> = UnsafeCell::from_mut(&mut []); + +fn main() {} diff --git a/tests/ui/consts/unstable-const-fn-in-libcore.rs b/tests/ui/consts/unstable-const-fn-in-libcore.rs index baeece40a52..f4b4c687bd2 100644 --- a/tests/ui/consts/unstable-const-fn-in-libcore.rs +++ b/tests/ui/consts/unstable-const-fn-in-libcore.rs @@ -16,7 +16,7 @@ enum Opt<T> { impl<T> Opt<T> { #[rustc_const_unstable(feature = "foo", issue = "none")] #[stable(feature = "rust1", since = "1.0.0")] - const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { + const fn unwrap_or_else<F: [const] FnOnce() -> T>(self, f: F) -> T { //FIXME ~^ ERROR destructor of //FIXME ~| ERROR destructor of match self { diff --git a/tests/ui/consts/unstable-const-fn-in-libcore.stderr b/tests/ui/consts/unstable-const-fn-in-libcore.stderr index 32693edbfcb..95e48b7b7c8 100644 --- a/tests/ui/consts/unstable-const-fn-in-libcore.stderr +++ b/tests/ui/consts/unstable-const-fn-in-libcore.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/unstable-const-fn-in-libcore.rs:19:32 | -LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { - | ^^^^^^ can't be applied to `FnOnce` +LL | const fn unwrap_or_else<F: [const] FnOnce() -> T>(self, f: F) -> T { + | ^^^^^^^ can't be applied to `FnOnce` | -note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/unstable-const-fn-in-libcore.rs:19:32 | -LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { - | ^^^^^^ can't be applied to `FnOnce` +LL | const fn unwrap_or_else<F: [const] FnOnce() -> T>(self, f: F) -> T { + | ^^^^^^^ can't be applied to `FnOnce` | -note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` @@ -26,19 +26,19 @@ LL | Opt::None => f(), = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error[E0493]: destructor of `F` cannot be evaluated at compile-time - --> $DIR/unstable-const-fn-in-libcore.rs:19:60 + --> $DIR/unstable-const-fn-in-libcore.rs:19:61 | -LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { - | ^ the destructor for this type cannot be evaluated in constant functions +LL | const fn unwrap_or_else<F: [const] FnOnce() -> T>(self, f: F) -> T { + | ^ the destructor for this type cannot be evaluated in constant functions ... LL | } | - value is dropped here error[E0493]: destructor of `Opt<T>` cannot be evaluated at compile-time - --> $DIR/unstable-const-fn-in-libcore.rs:19:54 + --> $DIR/unstable-const-fn-in-libcore.rs:19:55 | -LL | const fn unwrap_or_else<F: ~const FnOnce() -> T>(self, f: F) -> T { - | ^^^^ the destructor for this type cannot be evaluated in constant functions +LL | const fn unwrap_or_else<F: [const] FnOnce() -> T>(self, f: F) -> T { + | ^^^^ the destructor for this type cannot be evaluated in constant functions ... LL | } | - value is dropped here diff --git a/tests/ui/consts/write-to-static-mut-in-static.rs b/tests/ui/consts/write-to-static-mut-in-static.rs index ce15d9e912b..016bfb06ccf 100644 --- a/tests/ui/consts/write-to-static-mut-in-static.rs +++ b/tests/ui/consts/write-to-static-mut-in-static.rs @@ -3,8 +3,9 @@ pub static mut B: () = unsafe { A = 1; }; //~^ ERROR modifying a static's initial value pub static mut C: u32 = unsafe { C = 1; 0 }; +//~^ ERROR static that tried to access itself during initialization pub static D: u32 = D; -//~^ ERROR static that tried to initialize itself with itself +//~^ ERROR static that tried to access itself during initialization fn main() {} diff --git a/tests/ui/consts/write-to-static-mut-in-static.stderr b/tests/ui/consts/write-to-static-mut-in-static.stderr index bb5e217afb9..4180bb49339 100644 --- a/tests/ui/consts/write-to-static-mut-in-static.stderr +++ b/tests/ui/consts/write-to-static-mut-in-static.stderr @@ -4,12 +4,18 @@ error[E0080]: modifying a static's initial value from another static's initializ LL | pub static mut B: () = unsafe { A = 1; }; | ^^^^^ evaluation of `B` failed here -error[E0080]: encountered static that tried to initialize itself with itself - --> $DIR/write-to-static-mut-in-static.rs:7:21 +error[E0080]: encountered static that tried to access itself during initialization + --> $DIR/write-to-static-mut-in-static.rs:5:34 + | +LL | pub static mut C: u32 = unsafe { C = 1; 0 }; + | ^^^^^ evaluation of `C` failed here + +error[E0080]: encountered static that tried to access itself during initialization + --> $DIR/write-to-static-mut-in-static.rs:8:21 | LL | pub static D: u32 = D; | ^ evaluation of `D` failed here -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/consts/write_to_static_via_mut_ref.rs b/tests/ui/consts/write_to_static_via_mut_ref.rs index 82ac85bd250..dc8a7eed13d 100644 --- a/tests/ui/consts/write_to_static_via_mut_ref.rs +++ b/tests/ui/consts/write_to_static_via_mut_ref.rs @@ -1,4 +1,4 @@ -static OH_NO: &mut i32 = &mut 42; //~ ERROR mutable references are not allowed +static OH_NO: &mut i32 = &mut 42; //~ ERROR mutable borrows of temporaries fn main() { assert_eq!(*OH_NO, 42); *OH_NO = 43; //~ ERROR cannot assign to `*OH_NO`, as `OH_NO` is an immutable static diff --git a/tests/ui/consts/write_to_static_via_mut_ref.stderr b/tests/ui/consts/write_to_static_via_mut_ref.stderr index 63ef788032f..1bcd7b81fe0 100644 --- a/tests/ui/consts/write_to_static_via_mut_ref.stderr +++ b/tests/ui/consts/write_to_static_via_mut_ref.stderr @@ -1,8 +1,12 @@ -error[E0764]: mutable references are not allowed in the final value of statics +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/write_to_static_via_mut_ref.rs:1:26 | LL | static OH_NO: &mut i32 = &mut 42; - | ^^^^^^^ + | ^^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0594]: cannot assign to `*OH_NO`, as `OH_NO` is an immutable static item --> $DIR/write_to_static_via_mut_ref.rs:4:5 diff --git a/tests/ui/coroutine/auto-trait-regions.rs b/tests/ui/coroutine/auto-trait-regions.rs index f115896a473..736555b31bb 100644 --- a/tests/ui/coroutine/auto-trait-regions.rs +++ b/tests/ui/coroutine/auto-trait-regions.rs @@ -23,31 +23,31 @@ fn assert_foo<T: Foo>(f: T) {} fn main() { // Make sure 'static is erased for coroutine interiors so we can't match it in trait selection let x: &'static _ = &OnlyFooIfStaticRef(No); - let gen = #[coroutine] move || { + let generator = #[coroutine] move || { let x = x; yield; assert_foo(x); }; - assert_foo(gen); + assert_foo(generator); //~^ ERROR implementation of `Foo` is not general enough // Allow impls which matches any lifetime let x = &OnlyFooIfRef(No); - let gen = #[coroutine] move || { + let generator = #[coroutine] move || { let x = x; yield; assert_foo(x); }; - assert_foo(gen); // ok + assert_foo(generator); // ok // Disallow impls which relates lifetimes in the coroutine interior - let gen = #[coroutine] move || { + let generator = #[coroutine] move || { let a = A(&mut true, &mut true, No); //~^ ERROR borrow may still be in use when coroutine yields //~| ERROR borrow may still be in use when coroutine yields yield; assert_foo(a); }; - assert_foo(gen); + assert_foo(generator); //~^ ERROR not general enough } diff --git a/tests/ui/coroutine/auto-trait-regions.stderr b/tests/ui/coroutine/auto-trait-regions.stderr index 77b5f3ce57c..beb689d868d 100644 --- a/tests/ui/coroutine/auto-trait-regions.stderr +++ b/tests/ui/coroutine/auto-trait-regions.stderr @@ -1,8 +1,8 @@ error[E0626]: borrow may still be in use when coroutine yields --> $DIR/auto-trait-regions.rs:45:19 | -LL | let gen = #[coroutine] move || { - | ------- within this coroutine +LL | let generator = #[coroutine] move || { + | ------- within this coroutine LL | let a = A(&mut true, &mut true, No); | ^^^^^^^^^ ... @@ -11,14 +11,14 @@ LL | yield; | help: add `static` to mark this coroutine as unmovable | -LL | let gen = #[coroutine] static move || { - | ++++++ +LL | let generator = #[coroutine] static move || { + | ++++++ error[E0626]: borrow may still be in use when coroutine yields --> $DIR/auto-trait-regions.rs:45:30 | -LL | let gen = #[coroutine] move || { - | ------- within this coroutine +LL | let generator = #[coroutine] move || { + | ------- within this coroutine LL | let a = A(&mut true, &mut true, No); | ^^^^^^^^^ ... @@ -27,14 +27,14 @@ LL | yield; | help: add `static` to mark this coroutine as unmovable | -LL | let gen = #[coroutine] static move || { - | ++++++ +LL | let generator = #[coroutine] static move || { + | ++++++ error: implementation of `Foo` is not general enough --> $DIR/auto-trait-regions.rs:31:5 | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough +LL | assert_foo(generator); + | ^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `&'0 OnlyFooIfStaticRef` must implement `Foo`, for any lifetime `'0`... = note: ...but `Foo` is actually implemented for the type `&'static OnlyFooIfStaticRef` @@ -42,8 +42,8 @@ LL | assert_foo(gen); error: implementation of `Foo` is not general enough --> $DIR/auto-trait-regions.rs:51:5 | -LL | assert_foo(gen); - | ^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough +LL | assert_foo(generator); + | ^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `Foo` would have to be implemented for the type `A<'0, '1>`, for any two lifetimes `'0` and `'1`... = note: ...but `Foo` is actually implemented for the type `A<'_, '2>`, for some specific lifetime `'2` diff --git a/tests/ui/coroutine/clone-impl-static.rs b/tests/ui/coroutine/clone-impl-static.rs index f6fadff7faf..2f941d65591 100644 --- a/tests/ui/coroutine/clone-impl-static.rs +++ b/tests/ui/coroutine/clone-impl-static.rs @@ -7,13 +7,13 @@ #![feature(coroutines, coroutine_clone, stmt_expr_attributes)] fn main() { - let gen = #[coroutine] + let generator = #[coroutine] static move || { yield; }; - check_copy(&gen); + check_copy(&generator); //~^ ERROR Copy` is not satisfied - check_clone(&gen); + check_clone(&generator); //~^ ERROR Clone` is not satisfied } diff --git a/tests/ui/coroutine/clone-impl-static.stderr b/tests/ui/coroutine/clone-impl-static.stderr index db1d2770346..9fb71fd5fd0 100644 --- a/tests/ui/coroutine/clone-impl-static.stderr +++ b/tests/ui/coroutine/clone-impl-static.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `{static coroutine@$DIR/clone-impl-static.rs:11:5: 11:19}: Copy` is not satisfied --> $DIR/clone-impl-static.rs:14:16 | -LL | check_copy(&gen); - | ---------- ^^^^ the trait `Copy` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:11:5: 11:19}` +LL | check_copy(&generator); + | ---------- ^^^^^^^^^^ the trait `Copy` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:11:5: 11:19}` | | | required by a bound introduced by this call | @@ -15,8 +15,8 @@ LL | fn check_copy<T: Copy>(_x: &T) {} error[E0277]: the trait bound `{static coroutine@$DIR/clone-impl-static.rs:11:5: 11:19}: Clone` is not satisfied --> $DIR/clone-impl-static.rs:16:17 | -LL | check_clone(&gen); - | ----------- ^^^^ the trait `Clone` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:11:5: 11:19}` +LL | check_clone(&generator); + | ----------- ^^^^^^^^^^ the trait `Clone` is not implemented for `{static coroutine@$DIR/clone-impl-static.rs:11:5: 11:19}` | | | required by a bound introduced by this call | diff --git a/tests/ui/auxiliary/issue-16822.rs b/tests/ui/cross-crate/auxiliary/cross-crate-refcell-match.rs index 9042dd39117..9042dd39117 100644 --- a/tests/ui/auxiliary/issue-16822.rs +++ b/tests/ui/cross-crate/auxiliary/cross-crate-refcell-match.rs diff --git a/tests/ui/auxiliary/kinds_in_metadata.rs b/tests/ui/cross-crate/auxiliary/kinds_in_metadata.rs index 2a2106ff70a..2a2106ff70a 100644 --- a/tests/ui/auxiliary/kinds_in_metadata.rs +++ b/tests/ui/cross-crate/auxiliary/kinds_in_metadata.rs diff --git a/tests/ui/auxiliary/noexporttypelib.rs b/tests/ui/cross-crate/auxiliary/unexported-type-error-message.rs index 67889cc5f65..67889cc5f65 100644 --- a/tests/ui/auxiliary/noexporttypelib.rs +++ b/tests/ui/cross-crate/auxiliary/unexported-type-error-message.rs diff --git a/tests/ui/cross-crate/cross-crate-refcell-match.rs b/tests/ui/cross-crate/cross-crate-refcell-match.rs new file mode 100644 index 00000000000..7e46425612f --- /dev/null +++ b/tests/ui/cross-crate/cross-crate-refcell-match.rs @@ -0,0 +1,36 @@ +//! Regression test for https://github.com/rust-lang/rust/issues/16822 +// +//! ICE when using RefCell::borrow_mut() +//! inside match statement with cross-crate generics. +//! +//! The bug occurred when: +//! - A library defines a generic struct with RefCell<T> and uses borrow_mut() in match +//! - Main crate implements the library trait for its own type +//! - Cross-crate generic constraint causes type inference issues +//! +//! The problematic match statement is in the auxiliary file, this file triggers it. + +//@ run-pass +//@ aux-build:cross-crate-refcell-match.rs + +extern crate cross_crate_refcell_match as lib; + +use std::cell::RefCell; + +struct App { + i: isize, +} + +impl lib::Update for App { + fn update(&mut self) { + self.i += 1; + } +} + +fn main() { + let app = App { i: 5 }; + let window = lib::Window { data: RefCell::new(app) }; + // This specific pattern (RefCell::borrow_mut in match with cross-crate generics) + // caused the ICE in the original issue + window.update(1); +} diff --git a/tests/ui/kinds-in-metadata.rs b/tests/ui/cross-crate/metadata-trait-serialization.rs index 58dffba861d..a6645018da4 100644 --- a/tests/ui/kinds-in-metadata.rs +++ b/tests/ui/cross-crate/metadata-trait-serialization.rs @@ -1,12 +1,11 @@ +//! Test that trait information (like Copy) is correctly serialized in crate metadata + //@ run-pass //@ aux-build:kinds_in_metadata.rs - /* Any copyright is dedicated to the Public Domain. * http://creativecommons.org/publicdomain/zero/1.0/ */ -// Tests that metadata serialization works for the `Copy` kind. - extern crate kinds_in_metadata; use kinds_in_metadata::f; diff --git a/tests/ui/noexporttypeexe.rs b/tests/ui/cross-crate/unexported-type-error-message.rs index 35257b20ccd..5998f0dc6e2 100644 --- a/tests/ui/noexporttypeexe.rs +++ b/tests/ui/cross-crate/unexported-type-error-message.rs @@ -1,13 +1,13 @@ -//@ aux-build:noexporttypelib.rs +//@ aux-build:unexported-type-error-message.rs -extern crate noexporttypelib; +extern crate unexported_type_error_message; fn main() { // Here, the type returned by foo() is not exported. // This used to cause internal errors when serializing // because the def_id associated with the type was // not convertible to a path. - let x: isize = noexporttypelib::foo(); + let x: isize = unexported_type_error_message::foo(); //~^ ERROR mismatched types //~| NOTE expected type `isize` //~| NOTE found enum `Option<isize>` diff --git a/tests/ui/cross-crate/unexported-type-error-message.stderr b/tests/ui/cross-crate/unexported-type-error-message.stderr new file mode 100644 index 00000000000..b468d9839e1 --- /dev/null +++ b/tests/ui/cross-crate/unexported-type-error-message.stderr @@ -0,0 +1,18 @@ +error[E0308]: mismatched types + --> $DIR/unexported-type-error-message.rs:10:20 + | +LL | let x: isize = unexported_type_error_message::foo(); + | ----- ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `Option<isize>` + | | + | expected due to this + | + = note: expected type `isize` + found enum `Option<isize>` +help: consider using `Option::expect` to unwrap the `Option<isize>` value, panicking if the value is an `Option::None` + | +LL | let x: isize = unexported_type_error_message::foo().expect("REASON"); + | +++++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr index 2e11a59c3a4..3e5579d2e4a 100644 --- a/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr +++ b/tests/ui/cycle-trait/cycle-trait-supertrait-direct.stderr @@ -8,10 +8,8 @@ LL | trait Chromosome: Chromosome { note: cycle used when checking that `Chromosome` is well-formed --> $DIR/cycle-trait-supertrait-direct.rs:3:1 | -LL | / trait Chromosome: Chromosome { -LL | | -LL | | } - | |_^ +LL | trait Chromosome: Chromosome { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error diff --git a/tests/ui/cycle-trait/issue-12511.stderr b/tests/ui/cycle-trait/issue-12511.stderr index 0246bf21983..45fc86a7413 100644 --- a/tests/ui/cycle-trait/issue-12511.stderr +++ b/tests/ui/cycle-trait/issue-12511.stderr @@ -13,10 +13,8 @@ LL | trait T2 : T1 { note: cycle used when checking that `T1` is well-formed --> $DIR/issue-12511.rs:1:1 | -LL | / trait T1 : T2 { -LL | | -LL | | } - | |_^ +LL | trait T1 : T2 { + | ^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error diff --git a/tests/ui/darwin-ld64.rs b/tests/ui/darwin-ld64.rs new file mode 100644 index 00000000000..75acc07a002 --- /dev/null +++ b/tests/ui/darwin-ld64.rs @@ -0,0 +1,24 @@ +//@ compile-flags: -Copt-level=3 -Ccodegen-units=256 -Clink-arg=-ld_classic +//@ run-pass +//@ only-x86_64-apple-darwin + +// This is a regression test for https://github.com/rust-lang/rust/issues/140686. +// Although this is a ld64(ld-classic) bug, we still need to support it +// due to cross-compilation and support for older Xcode. + +fn main() { + let dst: Vec<u8> = Vec::new(); + let len = broken_func(std::hint::black_box(2), dst); + assert_eq!(len, 8); +} + +#[inline(never)] +pub fn broken_func(version: usize, mut dst: Vec<u8>) -> usize { + match version { + 1 => dst.extend_from_slice(b"aaaaaaaa"), + 2 => dst.extend_from_slice(b"bbbbbbbb"), + 3 => dst.extend_from_slice(b"bbbbbbbb"), + _ => panic!(), + } + dst.len() +} diff --git a/tests/ui/defaults-well-formedness.rs b/tests/ui/defaults-well-formedness.rs deleted file mode 100644 index e5e48edad88..00000000000 --- a/tests/ui/defaults-well-formedness.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -trait Trait<T> {} -struct Foo<U, V=i32>(U, V) where U: Trait<V>; - -trait Marker {} -struct TwoParams<T, U>(T, U); -impl Marker for TwoParams<i32, i32> {} - -// Clauses with more than 1 param are not checked. -struct IndividuallyBogus<T = i32, U = i32>(TwoParams<T, U>) where TwoParams<T, U>: Marker; -struct BogusTogether<T = u32, U = i32>(T, U) where TwoParams<T, U>: Marker; -// Clauses with non-defaulted params are not checked. -struct NonDefaultedInClause<T, U = i32>(TwoParams<T, U>) where TwoParams<T, U>: Marker; -struct DefaultedLhs<U, V=i32>(U, V) where V: Trait<U>; -// Dependent defaults are not checked. -struct Dependent<T, U = T>(T, U) where U: Copy; -trait SelfBound<T: Copy=Self> {} -// Not even for well-formedness. -struct WellFormedProjection<A, T=<A as Iterator>::Item>(A, T); - -// Issue #49344, predicates with lifetimes should not be checked. -trait Scope<'a> {} -struct Request<'a, S: Scope<'a> = i32>(S, &'a ()); - -fn main() {} diff --git a/tests/ui/delegation/unsupported.stderr b/tests/ui/delegation/unsupported.stderr index 53d05c3db8c..f69be60133e 100644 --- a/tests/ui/delegation/unsupported.stderr +++ b/tests/ui/delegation/unsupported.stderr @@ -10,11 +10,11 @@ note: ...which requires comparing an impl and trait method signature, inferring LL | reuse to_reuse::opaque_ret; | ^^^^^^^^^^ = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::opaque_ret::{anon_assoc#0}`, completing the cycle -note: cycle used when checking that `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>` is well-formed - --> $DIR/unsupported.rs:21:5 +note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:21:5: 21:24>::opaque_ret` is compatible with trait definition + --> $DIR/unsupported.rs:22:25 | -LL | impl ToReuse for u8 { - | ^^^^^^^^^^^^^^^^^^^ +LL | reuse to_reuse::opaque_ret; + | ^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::opaque_ret::{anon_assoc#0}` @@ -29,11 +29,11 @@ note: ...which requires comparing an impl and trait method signature, inferring LL | reuse ToReuse::opaque_ret; | ^^^^^^^^^^ = note: ...which again requires computing type of `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::opaque_ret::{anon_assoc#0}`, completing the cycle -note: cycle used when checking that `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>` is well-formed - --> $DIR/unsupported.rs:24:5 +note: cycle used when checking assoc item `opaque::<impl at $DIR/unsupported.rs:24:5: 24:25>::opaque_ret` is compatible with trait definition + --> $DIR/unsupported.rs:25:24 | -LL | impl ToReuse for u16 { - | ^^^^^^^^^^^^^^^^^^^^ +LL | reuse ToReuse::opaque_ret; + | ^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: recursive delegation is not supported yet diff --git a/tests/ui/deprecation/deprecated-expr-precedence.rs b/tests/ui/deprecation/deprecated-expr-precedence.rs new file mode 100644 index 00000000000..9636b46df20 --- /dev/null +++ b/tests/ui/deprecation/deprecated-expr-precedence.rs @@ -0,0 +1,8 @@ +//@ check-fail +//@ compile-flags: --crate-type=lib + +// Regression test for issue 142649 +pub fn public() { + #[deprecated] 0 + //~^ ERROR mismatched types +} diff --git a/tests/ui/deprecation/deprecated-expr-precedence.stderr b/tests/ui/deprecation/deprecated-expr-precedence.stderr new file mode 100644 index 00000000000..3275f2e790a --- /dev/null +++ b/tests/ui/deprecation/deprecated-expr-precedence.stderr @@ -0,0 +1,11 @@ +error[E0308]: mismatched types + --> $DIR/deprecated-expr-precedence.rs:6:19 + | +LL | pub fn public() { + | - help: try adding a return type: `-> i32` +LL | #[deprecated] 0 + | ^ expected `()`, found integer + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/deprecation-in-force-unstable.rs b/tests/ui/deprecation/deprecated_main_function.rs index 6aaf29b069a..398046637d8 100644 --- a/tests/ui/deprecation-in-force-unstable.rs +++ b/tests/ui/deprecation/deprecated_main_function.rs @@ -2,4 +2,4 @@ //@ compile-flags:-Zforce-unstable-if-unmarked #[deprecated] // should work even with -Zforce-unstable-if-unmarked -fn main() { } +fn main() {} diff --git a/tests/ui/deprecation/deprecated_no_stack_check.rs b/tests/ui/deprecation/deprecated_no_stack_check.rs index ef482098634..8e1f5bbf045 100644 --- a/tests/ui/deprecation/deprecated_no_stack_check.rs +++ b/tests/ui/deprecation/deprecated_no_stack_check.rs @@ -1,5 +1,3 @@ -//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION" - #![deny(warnings)] #![feature(no_stack_check)] //~^ ERROR: feature has been removed [E0557] diff --git a/tests/ui/deprecation/deprecated_no_stack_check.stderr b/tests/ui/deprecation/deprecated_no_stack_check.stderr index 2d08b1b8db5..33788661d73 100644 --- a/tests/ui/deprecation/deprecated_no_stack_check.stderr +++ b/tests/ui/deprecation/deprecated_no_stack_check.stderr @@ -1,10 +1,10 @@ error[E0557]: feature has been removed - --> $DIR/deprecated_no_stack_check.rs:4:12 + --> $DIR/deprecated_no_stack_check.rs:2:12 | LL | #![feature(no_stack_check)] | ^^^^^^^^^^^^^^ feature has been removed | - = note: removed in 1.0.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/40110> for more information + = note: removed in 1.0.0; see <https://github.com/rust-lang/rust/pull/40110> for more information error: aborting due to 1 previous error diff --git a/tests/ui/deref-rc.rs b/tests/ui/deref-rc.rs deleted file mode 100644 index 92fdd900359..00000000000 --- a/tests/ui/deref-rc.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass - -use std::rc::Rc; - -fn main() { - let x = Rc::new([1, 2, 3, 4]); - assert_eq!(*x, [1, 2, 3, 4]); -} diff --git a/tests/ui/deref.rs b/tests/ui/deref.rs deleted file mode 100644 index 0a6f3cc81f6..00000000000 --- a/tests/ui/deref.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-pass - -pub fn main() { - let x: Box<isize> = Box::new(10); - let _y: isize = *x; -} diff --git a/tests/ui/derive-uninhabited-enum-38885.rs b/tests/ui/derive-uninhabited-enum-38885.rs deleted file mode 100644 index 2259a542706..00000000000 --- a/tests/ui/derive-uninhabited-enum-38885.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ check-pass -//@ compile-flags: -Wunused - -// ensure there are no special warnings about uninhabited types -// when deriving Debug on an empty enum - -#[derive(Debug)] -enum Void {} - -#[derive(Debug)] -enum Foo { - Bar(#[allow(dead_code)] u8), - Void(Void), //~ WARN variant `Void` is never constructed -} - -fn main() { - let x = Foo::Bar(42); - println!("{:?}", x); -} diff --git a/tests/ui/derives/derive-Debug-enum-variants.rs b/tests/ui/derives/derive-Debug-enum-variants.rs new file mode 100644 index 00000000000..26f527f7664 --- /dev/null +++ b/tests/ui/derives/derive-Debug-enum-variants.rs @@ -0,0 +1,30 @@ +//! Test that `#[derive(Debug)]` for enums correctly formats variant names. + +//@ run-pass + +#[derive(Debug)] +enum Foo { + A(usize), + C, +} + +#[derive(Debug)] +enum Bar { + D, +} + +pub fn main() { + // Test variant with data + let foo_a = Foo::A(22); + assert_eq!("A(22)".to_string(), format!("{:?}", foo_a)); + + if let Foo::A(value) = foo_a { + println!("Value: {}", value); // This needs to remove #[allow(dead_code)] + } + + // Test unit variant + assert_eq!("C".to_string(), format!("{:?}", Foo::C)); + + // Test unit variant from different enum + assert_eq!("D".to_string(), format!("{:?}", Bar::D)); +} diff --git a/tests/ui/derives/derive-debug-uninhabited-enum.rs b/tests/ui/derives/derive-debug-uninhabited-enum.rs new file mode 100644 index 00000000000..be7b3ab348d --- /dev/null +++ b/tests/ui/derives/derive-debug-uninhabited-enum.rs @@ -0,0 +1,23 @@ +//! Regression test for `#[derive(Debug)]` on enums with uninhabited variants. +//! +//! Ensures there are no special warnings about uninhabited types when deriving +//! Debug on an enum with uninhabited variants, only standard unused warnings. +//! +//! Issue: https://github.com/rust-lang/rust/issues/38885 + +//@ check-pass +//@ compile-flags: -Wunused + +#[derive(Debug)] +enum Void {} + +#[derive(Debug)] +enum Foo { + Bar(#[allow(dead_code)] u8), + Void(Void), //~ WARN variant `Void` is never constructed +} + +fn main() { + let x = Foo::Bar(42); + println!("{:?}", x); +} diff --git a/tests/ui/derive-uninhabited-enum-38885.stderr b/tests/ui/derives/derive-debug-uninhabited-enum.stderr index bcd8f6b7b53..4911b6b6cde 100644 --- a/tests/ui/derive-uninhabited-enum-38885.stderr +++ b/tests/ui/derives/derive-debug-uninhabited-enum.stderr @@ -1,5 +1,5 @@ warning: variant `Void` is never constructed - --> $DIR/derive-uninhabited-enum-38885.rs:13:5 + --> $DIR/derive-debug-uninhabited-enum.rs:17:5 | LL | enum Foo { | --- variant in this enum diff --git a/tests/ui/derives/derives-span-Debug-enum-struct-variant.stderr b/tests/ui/derives/derives-span-Debug-enum-struct-variant.stderr index a7f6d094681..147910b715f 100644 --- a/tests/ui/derives/derives-span-Debug-enum-struct-variant.stderr +++ b/tests/ui/derives/derives-span-Debug-enum-struct-variant.stderr @@ -5,9 +5,8 @@ LL | #[derive(Debug)] | ----- in this derive macro expansion ... LL | x: Error - | ^^^^^^^^ `Error` cannot be formatted using `{:?}` + | ^^^^^^^^ the trait `Debug` is not implemented for `Error` | - = help: the trait `Debug` is not implemented for `Error` = note: add `#[derive(Debug)]` to `Error` or manually `impl Debug for Error` help: consider annotating `Error` with `#[derive(Debug)]` | diff --git a/tests/ui/derives/derives-span-Debug-enum.stderr b/tests/ui/derives/derives-span-Debug-enum.stderr index b3a58478159..6f97ceb02d3 100644 --- a/tests/ui/derives/derives-span-Debug-enum.stderr +++ b/tests/ui/derives/derives-span-Debug-enum.stderr @@ -5,9 +5,8 @@ LL | #[derive(Debug)] | ----- in this derive macro expansion ... LL | Error - | ^^^^^ `Error` cannot be formatted using `{:?}` + | ^^^^^ the trait `Debug` is not implemented for `Error` | - = help: the trait `Debug` is not implemented for `Error` = note: add `#[derive(Debug)]` to `Error` or manually `impl Debug for Error` help: consider annotating `Error` with `#[derive(Debug)]` | diff --git a/tests/ui/derives/derives-span-Debug-struct.stderr b/tests/ui/derives/derives-span-Debug-struct.stderr index c8ad652716c..46d69a892f2 100644 --- a/tests/ui/derives/derives-span-Debug-struct.stderr +++ b/tests/ui/derives/derives-span-Debug-struct.stderr @@ -5,9 +5,8 @@ LL | #[derive(Debug)] | ----- in this derive macro expansion LL | struct Struct { LL | x: Error - | ^^^^^^^^ `Error` cannot be formatted using `{:?}` + | ^^^^^^^^ the trait `Debug` is not implemented for `Error` | - = help: the trait `Debug` is not implemented for `Error` = note: add `#[derive(Debug)]` to `Error` or manually `impl Debug for Error` help: consider annotating `Error` with `#[derive(Debug)]` | diff --git a/tests/ui/derives/derives-span-Debug-tuple-struct.stderr b/tests/ui/derives/derives-span-Debug-tuple-struct.stderr index dbece4d2091..a3feeff6df3 100644 --- a/tests/ui/derives/derives-span-Debug-tuple-struct.stderr +++ b/tests/ui/derives/derives-span-Debug-tuple-struct.stderr @@ -5,9 +5,8 @@ LL | #[derive(Debug)] | ----- in this derive macro expansion LL | struct Struct( LL | Error - | ^^^^^ `Error` cannot be formatted using `{:?}` + | ^^^^^ the trait `Debug` is not implemented for `Error` | - = help: the trait `Debug` is not implemented for `Error` = note: add `#[derive(Debug)]` to `Error` or manually `impl Debug for Error` help: consider annotating `Error` with `#[derive(Debug)]` | diff --git a/tests/ui/derives/nonsense-input-to-debug.rs b/tests/ui/derives/nonsense-input-to-debug.rs new file mode 100644 index 00000000000..7dfa3cd616a --- /dev/null +++ b/tests/ui/derives/nonsense-input-to-debug.rs @@ -0,0 +1,12 @@ +// Issue: #32950 +// Ensure that using macros rather than a type doesn't break `derive`. + +#[derive(Debug)] +struct Nonsense<T> { + //~^ ERROR type parameter `T` is never used + should_be_vec_t: vec![T], + //~^ ERROR `derive` cannot be used on items with type macros + //~| ERROR expected type, found `expr` metavariable +} + +fn main() {} diff --git a/tests/ui/derives/nonsense-input-to-debug.stderr b/tests/ui/derives/nonsense-input-to-debug.stderr new file mode 100644 index 00000000000..7c97ca93cfc --- /dev/null +++ b/tests/ui/derives/nonsense-input-to-debug.stderr @@ -0,0 +1,30 @@ +error: `derive` cannot be used on items with type macros + --> $DIR/nonsense-input-to-debug.rs:7:22 + | +LL | should_be_vec_t: vec![T], + | ^^^^^^^ + +error: expected type, found `expr` metavariable + --> $DIR/nonsense-input-to-debug.rs:7:22 + | +LL | should_be_vec_t: vec![T], + | ^^^^^^^ + | | + | expected type + | in this macro invocation + | this macro call doesn't expand to a type + | + = note: this error originates in the macro `vec` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0392]: type parameter `T` is never used + --> $DIR/nonsense-input-to-debug.rs:5:17 + | +LL | struct Nonsense<T> { + | ^ unused type parameter + | + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` + = help: if you intended `T` to be a const parameter, use `const T: /* Type */` instead + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0392`. diff --git a/tests/ui/destructure-trait-ref.rs b/tests/ui/destructure-trait-ref.rs deleted file mode 100644 index daa0ca30d68..00000000000 --- a/tests/ui/destructure-trait-ref.rs +++ /dev/null @@ -1,46 +0,0 @@ -// The regression test for #15031 to make sure destructuring trait -// reference work properly. - -//@ dont-require-annotations: NOTE - -#![feature(box_patterns)] - -trait T { fn foo(&self) {} } -impl T for isize {} - - -fn main() { - // For an expression of the form: - // - // let &...&x = &..&SomeTrait; - // - // Say we have n `&` at the left hand and m `&` right hand, then: - // if n < m, we are golden; - // if n == m, it's a derefing non-derefable type error; - // if n > m, it's a type mismatch error. - - // n < m - let &x = &(&1isize as &dyn T); - let &x = &&(&1isize as &dyn T); - let &&x = &&(&1isize as &dyn T); - - // n == m - let &x = &1isize as &dyn T; //~ ERROR type `&dyn T` cannot be dereferenced - let &&x = &(&1isize as &dyn T); //~ ERROR type `&dyn T` cannot be dereferenced - let box x = Box::new(1isize) as Box<dyn T>; - //~^ ERROR type `Box<dyn T>` cannot be dereferenced - - // n > m - let &&x = &1isize as &dyn T; - //~^ ERROR mismatched types - //~| NOTE expected trait object `dyn T` - //~| NOTE found reference `&_` - let &&&x = &(&1isize as &dyn T); - //~^ ERROR mismatched types - //~| NOTE expected trait object `dyn T` - //~| NOTE found reference `&_` - let box box x = Box::new(1isize) as Box<dyn T>; - //~^ ERROR mismatched types - //~| NOTE expected trait object `dyn T` - //~| NOTE found struct `Box<_>` -} diff --git a/tests/ui/short-error-format.rs b/tests/ui/diagnostic-flags/error-format-short.rs index 719870a04fb..4c793cd1b18 100644 --- a/tests/ui/short-error-format.rs +++ b/tests/ui/diagnostic-flags/error-format-short.rs @@ -1,3 +1,6 @@ +//! Check that compile errors are formatted in the "short" style +//! when `--error-format=short` is used. + //@ compile-flags: --error-format=short fn foo(_: u32) {} diff --git a/tests/ui/diagnostic-flags/error-format-short.stderr b/tests/ui/diagnostic-flags/error-format-short.stderr new file mode 100644 index 00000000000..0a097e2f623 --- /dev/null +++ b/tests/ui/diagnostic-flags/error-format-short.stderr @@ -0,0 +1,3 @@ +$DIR/error-format-short.rs:9:9: error[E0308]: mismatched types: expected `u32`, found `String` +$DIR/error-format-short.rs:11:7: error[E0599]: no method named `salut` found for type `u32` in the current scope: method not found in `u32` +error: aborting due to 2 previous errors diff --git a/tests/ui/did_you_mean/bad-assoc-ty.stderr b/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr index 7e34f4d35b4..ed6e5c3e0c0 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.stderr +++ b/tests/ui/did_you_mean/bad-assoc-ty.edition2015.stderr @@ -1,5 +1,5 @@ error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:1:10 + --> $DIR/bad-assoc-ty.rs:5:10 | LL | type A = [u8; 4]::AssocTy; | ^^^^^^^ @@ -10,7 +10,7 @@ LL | type A = <[u8; 4]>::AssocTy; | + + error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:5:10 + --> $DIR/bad-assoc-ty.rs:9:10 | LL | type B = [u8]::AssocTy; | ^^^^ @@ -21,7 +21,7 @@ LL | type B = <[u8]>::AssocTy; | + + error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:9:10 + --> $DIR/bad-assoc-ty.rs:13:10 | LL | type C = (u8)::AssocTy; | ^^^^ @@ -32,7 +32,7 @@ LL | type C = <(u8)>::AssocTy; | + + error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:13:10 + --> $DIR/bad-assoc-ty.rs:17:10 | LL | type D = (u8, u8)::AssocTy; | ^^^^^^^^ @@ -43,7 +43,7 @@ LL | type D = <(u8, u8)>::AssocTy; | + + error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:17:10 + --> $DIR/bad-assoc-ty.rs:21:10 | LL | type E = _::AssocTy; | ^ @@ -54,7 +54,7 @@ LL | type E = <_>::AssocTy; | + + error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:21:19 + --> $DIR/bad-assoc-ty.rs:25:19 | LL | type F = &'static (u8)::AssocTy; | ^^^^ @@ -65,7 +65,7 @@ LL | type F = &'static <(u8)>::AssocTy; | + + error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:27:10 + --> $DIR/bad-assoc-ty.rs:31:10 | LL | type G = dyn 'static + (Send)::AssocTy; | ^^^^^^^^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | type G = <dyn 'static + (Send)>::AssocTy; | + + error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:46:10 + --> $DIR/bad-assoc-ty.rs:51:10 | LL | type I = ty!()::AssocTy; | ^^^^^ @@ -87,7 +87,7 @@ LL | type I = <ty!()>::AssocTy; | + + error: missing angle brackets in associated item path - --> $DIR/bad-assoc-ty.rs:39:19 + --> $DIR/bad-assoc-ty.rs:44:19 | LL | ($ty: ty) => ($ty::AssocTy); | ^^^ @@ -102,7 +102,7 @@ LL | ($ty: ty) => (<$ty>::AssocTy); | + + error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:1:10 + --> $DIR/bad-assoc-ty.rs:5:10 | LL | type A = [u8; 4]::AssocTy; | ^^^^^^^^^^^^^^^^ @@ -114,7 +114,7 @@ LL + type A = <[u8; 4] as Example>::AssocTy; | error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:5:10 + --> $DIR/bad-assoc-ty.rs:9:10 | LL | type B = [u8]::AssocTy; | ^^^^^^^^^^^^^ @@ -126,7 +126,7 @@ LL + type B = <[u8] as Example>::AssocTy; | error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:9:10 + --> $DIR/bad-assoc-ty.rs:13:10 | LL | type C = (u8)::AssocTy; | ^^^^^^^^^^^^^ @@ -138,7 +138,7 @@ LL + type C = <u8 as Example>::AssocTy; | error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:13:10 + --> $DIR/bad-assoc-ty.rs:17:10 | LL | type D = (u8, u8)::AssocTy; | ^^^^^^^^^^^^^^^^^ @@ -150,13 +150,13 @@ LL + type D = <(u8, u8) as Example>::AssocTy; | error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases - --> $DIR/bad-assoc-ty.rs:17:10 + --> $DIR/bad-assoc-ty.rs:21:10 | LL | type E = _::AssocTy; | ^ not allowed in type signatures error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:21:19 + --> $DIR/bad-assoc-ty.rs:25:19 | LL | type F = &'static (u8)::AssocTy; | ^^^^^^^^^^^^^ @@ -168,7 +168,7 @@ LL + type F = &'static <u8 as Example>::AssocTy; | error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:27:10 + --> $DIR/bad-assoc-ty.rs:31:10 | LL | type G = dyn 'static + (Send)::AssocTy; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -180,7 +180,7 @@ LL + type G = <(dyn Send + 'static) as Example>::AssocTy; | warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/bad-assoc-ty.rs:33:10 + --> $DIR/bad-assoc-ty.rs:37:10 | LL | type H = Fn(u8) -> (u8)::Output; | ^^^^^^^^^^^^^^ @@ -194,7 +194,7 @@ LL | type H = <dyn Fn(u8) -> (u8)>::Output; | ++++ + error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:33:10 + --> $DIR/bad-assoc-ty.rs:37:10 | LL | type H = Fn(u8) -> (u8)::Output; | ^^^^^^^^^^^^^^^^^^^^^^ @@ -209,7 +209,7 @@ LL + type H = <(dyn Fn(u8) -> u8 + 'static) as IntoFuture>::Output; | error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:39:19 + --> $DIR/bad-assoc-ty.rs:44:19 | LL | ($ty: ty) => ($ty::AssocTy); | ^^^^^^^^^^^^ @@ -225,7 +225,7 @@ LL + ($ty: ty) => (<u8 as Example>::AssocTy); | error[E0223]: ambiguous associated type - --> $DIR/bad-assoc-ty.rs:46:10 + --> $DIR/bad-assoc-ty.rs:51:10 | LL | type I = ty!()::AssocTy; | ^^^^^^^^^^^^^^ @@ -237,99 +237,55 @@ LL + type I = <u8 as Example>::AssocTy; | error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/bad-assoc-ty.rs:51:13 + --> $DIR/bad-assoc-ty.rs:56:13 | LL | fn foo<X: K<_, _>>(x: X) {} - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures + | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/bad-assoc-ty.rs:54:34 + --> $DIR/bad-assoc-ty.rs:56:16 + | +LL | fn foo<X: K<_, _>>(x: X) {} + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/bad-assoc-ty.rs:60:34 | LL | fn bar<F>(_: F) where F: Fn() -> _ {} | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn bar<F>(_: F) where F: Fn() -> _ {} -LL + fn bar<F, T>(_: F) where F: Fn() -> T {} - | error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/bad-assoc-ty.rs:57:19 + --> $DIR/bad-assoc-ty.rs:63:19 | LL | fn baz<F: Fn() -> _>(_: F) {} | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn baz<F: Fn() -> _>(_: F) {} -LL + fn baz<F: Fn() -> T, T>(_: F) {} - | error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs - --> $DIR/bad-assoc-ty.rs:60:33 + --> $DIR/bad-assoc-ty.rs:66:33 | LL | struct L<F>(F) where F: Fn() -> _; | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - struct L<F>(F) where F: Fn() -> _; -LL + struct L<F, T>(F) where F: Fn() -> T; - | - -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/bad-assoc-ty.rs:82:38 - | -LL | fn foo<F>(_: F) where F: Fn() -> _ {} - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn foo<F>(_: F) where F: Fn() -> _ {} -LL + fn foo<F, T>(_: F) where F: Fn() -> T {} - | error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs - --> $DIR/bad-assoc-ty.rs:62:30 + --> $DIR/bad-assoc-ty.rs:68:30 | LL | struct M<F> where F: Fn() -> _ { | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - struct M<F> where F: Fn() -> _ { -LL + struct M<F, T> where F: Fn() -> T { - | error[E0121]: the placeholder `_` is not allowed within types on item signatures for enums - --> $DIR/bad-assoc-ty.rs:66:28 + --> $DIR/bad-assoc-ty.rs:72:28 | LL | enum N<F> where F: Fn() -> _ { | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - enum N<F> where F: Fn() -> _ { -LL + enum N<F, T> where F: Fn() -> T { - | error[E0121]: the placeholder `_` is not allowed within types on item signatures for unions - --> $DIR/bad-assoc-ty.rs:71:29 + --> $DIR/bad-assoc-ty.rs:77:29 | LL | union O<F> where F: Fn() -> _ { | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - union O<F> where F: Fn() -> _ { -LL + union O<F, T> where F: Fn() -> T { - | error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/bad-assoc-ty.rs:73:5 + --> $DIR/bad-assoc-ty.rs:79:5 | LL | foo: F, | ^^^^^^ @@ -341,18 +297,18 @@ LL | foo: std::mem::ManuallyDrop<F>, | +++++++++++++++++++++++ + error[E0121]: the placeholder `_` is not allowed within types on item signatures for traits - --> $DIR/bad-assoc-ty.rs:77:29 + --> $DIR/bad-assoc-ty.rs:83:29 | LL | trait P<F> where F: Fn() -> _ { | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions + --> $DIR/bad-assoc-ty.rs:88:38 | -help: use type parameters instead - | -LL - trait P<F> where F: Fn() -> _ { -LL + trait P<F, T> where F: Fn() -> T { - | +LL | fn foo<F>(_: F) where F: Fn() -> _ {} + | ^ not allowed in type signatures -error: aborting due to 29 previous errors; 1 warning emitted +error: aborting due to 30 previous errors; 1 warning emitted Some errors have detailed explanations: E0121, E0223, E0740. For more information about an error, try `rustc --explain E0121`. diff --git a/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr b/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr new file mode 100644 index 00000000000..2ee8ab2760a --- /dev/null +++ b/tests/ui/did_you_mean/bad-assoc-ty.edition2021.stderr @@ -0,0 +1,296 @@ +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-ty.rs:5:10 + | +LL | type A = [u8; 4]::AssocTy; + | ^^^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type A = <[u8; 4]>::AssocTy; + | + + + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-ty.rs:9:10 + | +LL | type B = [u8]::AssocTy; + | ^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type B = <[u8]>::AssocTy; + | + + + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-ty.rs:13:10 + | +LL | type C = (u8)::AssocTy; + | ^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type C = <(u8)>::AssocTy; + | + + + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-ty.rs:17:10 + | +LL | type D = (u8, u8)::AssocTy; + | ^^^^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type D = <(u8, u8)>::AssocTy; + | + + + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-ty.rs:21:10 + | +LL | type E = _::AssocTy; + | ^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type E = <_>::AssocTy; + | + + + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-ty.rs:25:19 + | +LL | type F = &'static (u8)::AssocTy; + | ^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type F = &'static <(u8)>::AssocTy; + | + + + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-ty.rs:31:10 + | +LL | type G = dyn 'static + (Send)::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type G = <dyn 'static + (Send)>::AssocTy; + | + + + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-ty.rs:51:10 + | +LL | type I = ty!()::AssocTy; + | ^^^^^ + | +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | type I = <ty!()>::AssocTy; + | + + + +error: missing angle brackets in associated item path + --> $DIR/bad-assoc-ty.rs:44:19 + | +LL | ($ty: ty) => ($ty::AssocTy); + | ^^^ +... +LL | type J = ty!(u8); + | ------- in this macro invocation + | + = note: this error originates in the macro `ty` (in Nightly builds, run with -Z macro-backtrace for more info) +help: types that don't start with an identifier need to be surrounded with angle brackets in qualified paths + | +LL | ($ty: ty) => (<$ty>::AssocTy); + | + + + +error[E0223]: ambiguous associated type + --> $DIR/bad-assoc-ty.rs:5:10 + | +LL | type A = [u8; 4]::AssocTy; + | ^^^^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated type `AssocTy` implemented for `[u8; 4]`, you could use the fully-qualified path + | +LL - type A = [u8; 4]::AssocTy; +LL + type A = <[u8; 4] as Example>::AssocTy; + | + +error[E0223]: ambiguous associated type + --> $DIR/bad-assoc-ty.rs:9:10 + | +LL | type B = [u8]::AssocTy; + | ^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated type `AssocTy` implemented for `[u8]`, you could use the fully-qualified path + | +LL - type B = [u8]::AssocTy; +LL + type B = <[u8] as Example>::AssocTy; + | + +error[E0223]: ambiguous associated type + --> $DIR/bad-assoc-ty.rs:13:10 + | +LL | type C = (u8)::AssocTy; + | ^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated type `AssocTy` implemented for `u8`, you could use the fully-qualified path + | +LL - type C = (u8)::AssocTy; +LL + type C = <u8 as Example>::AssocTy; + | + +error[E0223]: ambiguous associated type + --> $DIR/bad-assoc-ty.rs:17:10 + | +LL | type D = (u8, u8)::AssocTy; + | ^^^^^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated type `AssocTy` implemented for `(u8, u8)`, you could use the fully-qualified path + | +LL - type D = (u8, u8)::AssocTy; +LL + type D = <(u8, u8) as Example>::AssocTy; + | + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases + --> $DIR/bad-assoc-ty.rs:21:10 + | +LL | type E = _::AssocTy; + | ^ not allowed in type signatures + +error[E0223]: ambiguous associated type + --> $DIR/bad-assoc-ty.rs:25:19 + | +LL | type F = &'static (u8)::AssocTy; + | ^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated type `AssocTy` implemented for `u8`, you could use the fully-qualified path + | +LL - type F = &'static (u8)::AssocTy; +LL + type F = &'static <u8 as Example>::AssocTy; + | + +error[E0223]: ambiguous associated type + --> $DIR/bad-assoc-ty.rs:31:10 + | +LL | type G = dyn 'static + (Send)::AssocTy; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated type `AssocTy` implemented for `(dyn Send + 'static)`, you could use the fully-qualified path + | +LL - type G = dyn 'static + (Send)::AssocTy; +LL + type G = <(dyn Send + 'static) as Example>::AssocTy; + | + +error[E0782]: expected a type, found a trait + --> $DIR/bad-assoc-ty.rs:37:10 + | +LL | type H = Fn(u8) -> (u8)::Output; + | ^^^^^^^^^^^^^^ + | +help: you can add the `dyn` keyword if you want a trait object + | +LL | type H = <dyn Fn(u8) -> (u8)>::Output; + | ++++ + + +error[E0223]: ambiguous associated type + --> $DIR/bad-assoc-ty.rs:44:19 + | +LL | ($ty: ty) => ($ty::AssocTy); + | ^^^^^^^^^^^^ +... +LL | type J = ty!(u8); + | ------- in this macro invocation + | + = note: this error originates in the macro `ty` (in Nightly builds, run with -Z macro-backtrace for more info) +help: if there were a trait named `Example` with associated type `AssocTy` implemented for `u8`, you could use the fully-qualified path + | +LL - ($ty: ty) => ($ty::AssocTy); +LL + ($ty: ty) => (<u8 as Example>::AssocTy); + | + +error[E0223]: ambiguous associated type + --> $DIR/bad-assoc-ty.rs:51:10 + | +LL | type I = ty!()::AssocTy; + | ^^^^^^^^^^^^^^ + | +help: if there were a trait named `Example` with associated type `AssocTy` implemented for `u8`, you could use the fully-qualified path + | +LL - type I = ty!()::AssocTy; +LL + type I = <u8 as Example>::AssocTy; + | + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/bad-assoc-ty.rs:56:13 + | +LL | fn foo<X: K<_, _>>(x: X) {} + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/bad-assoc-ty.rs:56:16 + | +LL | fn foo<X: K<_, _>>(x: X) {} + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/bad-assoc-ty.rs:60:34 + | +LL | fn bar<F>(_: F) where F: Fn() -> _ {} + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/bad-assoc-ty.rs:63:19 + | +LL | fn baz<F: Fn() -> _>(_: F) {} + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/bad-assoc-ty.rs:66:33 + | +LL | struct L<F>(F) where F: Fn() -> _; + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/bad-assoc-ty.rs:68:30 + | +LL | struct M<F> where F: Fn() -> _ { + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for enums + --> $DIR/bad-assoc-ty.rs:72:28 + | +LL | enum N<F> where F: Fn() -> _ { + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for unions + --> $DIR/bad-assoc-ty.rs:77:29 + | +LL | union O<F> where F: Fn() -> _ { + | ^ not allowed in type signatures + +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/bad-assoc-ty.rs:79:5 + | +LL | foo: F, + | ^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | foo: std::mem::ManuallyDrop<F>, + | +++++++++++++++++++++++ + + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for traits + --> $DIR/bad-assoc-ty.rs:83:29 + | +LL | trait P<F> where F: Fn() -> _ { + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions + --> $DIR/bad-assoc-ty.rs:88:38 + | +LL | fn foo<F>(_: F) where F: Fn() -> _ {} + | ^ not allowed in type signatures + +error: aborting due to 30 previous errors + +Some errors have detailed explanations: E0121, E0223, E0740, E0782. +For more information about an error, try `rustc --explain E0121`. diff --git a/tests/ui/did_you_mean/bad-assoc-ty.rs b/tests/ui/did_you_mean/bad-assoc-ty.rs index 5a559b01ea2..39f0a84855a 100644 --- a/tests/ui/did_you_mean/bad-assoc-ty.rs +++ b/tests/ui/did_you_mean/bad-assoc-ty.rs @@ -1,3 +1,7 @@ +//@revisions: edition2015 edition2021 +//@[edition2015] edition:2015 +//@[edition2021] edition:2021 + type A = [u8; 4]::AssocTy; //~^ ERROR missing angle brackets in associated item path //~| ERROR ambiguous associated type @@ -31,9 +35,10 @@ type G = dyn 'static + (Send)::AssocTy; // This is actually a legal path with fn-like generic arguments in the middle! // Recovery should not apply in this context. type H = Fn(u8) -> (u8)::Output; -//~^ ERROR ambiguous associated type -//~| WARN trait objects without an explicit `dyn` are deprecated -//~| WARN this is accepted in the current edition +//[edition2015]~^ ERROR ambiguous associated type +//[edition2015]~| WARN trait objects without an explicit `dyn` are deprecated +//[edition2015]~| WARN this is accepted in the current edition +//[edition2021]~^^^^ ERROR expected a type, found a trait macro_rules! ty { ($ty: ty) => ($ty::AssocTy); @@ -50,6 +55,7 @@ type I = ty!()::AssocTy; trait K<A, B> {} fn foo<X: K<_, _>>(x: X) {} //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions +//~| ERROR the placeholder `_` is not allowed within types on item signatures for functions fn bar<F>(_: F) where F: Fn() -> _ {} //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions @@ -80,7 +86,7 @@ trait P<F> where F: Fn() -> _ { trait Q { fn foo<F>(_: F) where F: Fn() -> _ {} - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions } fn main() {} diff --git a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed index db18cf2ad96..0096d3eaea4 100644 --- a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed +++ b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.fixed @@ -7,7 +7,7 @@ trait Foo<T>: Sized { impl Foo<usize> for () { fn bar(i: i32, t: usize, s: &()) -> (usize, i32) { - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions //~| ERROR type annotations needed (1, 2) } diff --git a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs index 1217a96112d..9ebc565b8fd 100644 --- a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs +++ b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.rs @@ -7,7 +7,7 @@ trait Foo<T>: Sized { impl Foo<usize> for () { fn bar(i: _, t: _, s: _) -> _ { - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions //~| ERROR type annotations needed (1, 2) } diff --git a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr index 6c24a5899ea..3c11ad0cf29 100644 --- a/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr +++ b/tests/ui/did_you_mean/replace-impl-infer-ty-from-trait.stderr @@ -1,4 +1,4 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/replace-impl-infer-ty-from-trait.rs:9:15 | LL | fn bar(i: _, t: _, s: _) -> _ { diff --git a/tests/ui/diverging-fallback-method-chain.rs b/tests/ui/diverging-fallback-method-chain.rs deleted file mode 100644 index aa8eba1191b..00000000000 --- a/tests/ui/diverging-fallback-method-chain.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ run-pass - -#![allow(unused_imports)] -// Test a regression found when building compiler. The `produce()` -// error type `T` winds up getting unified with result of `x.parse()`; -// the type of the closure given to `unwrap_or_else` needs to be -// inferred to `usize`. - -use std::num::ParseIntError; - -fn produce<T>() -> Result<&'static str, T> { - Ok("22") -} - -fn main() { - let x: usize = produce() - .and_then(|x| x.parse()) - .unwrap_or_else(|_| panic!()); - println!("{}", x); -} diff --git a/tests/ui/diverging-fallback-option.rs b/tests/ui/diverging-fallback-option.rs deleted file mode 100644 index aa793ebd017..00000000000 --- a/tests/ui/diverging-fallback-option.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ run-pass - -#![allow(warnings)] - -// Here the type of `c` is `Option<?T>`, where `?T` is unconstrained. -// Because there is data-flow from the `{ return; }` block, which -// diverges and hence has type `!`, into `c`, we will default `?T` to -// `!`, and hence this code compiles rather than failing and requiring -// a type annotation. - -fn main() { - let c = Some({ return; }); - c.unwrap(); -} diff --git a/tests/ui/diverging-fn-tail-35849.rs b/tests/ui/diverging-fn-tail-35849.rs deleted file mode 100644 index f21ce2973e9..00000000000 --- a/tests/ui/diverging-fn-tail-35849.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn assert_sizeof() -> ! { - unsafe { - ::std::mem::transmute::<f64, [u8; 8]>(panic!()) - //~^ ERROR mismatched types - } -} - -fn main() { } diff --git a/tests/ui/resource-assign-is-not-copy.rs b/tests/ui/drop/drop-once-on-move.rs index ab426016901..da018058076 100644 --- a/tests/ui/resource-assign-is-not-copy.rs +++ b/tests/ui/drop/drop-once-on-move.rs @@ -1,3 +1,7 @@ +//! Check that types not implementing `Copy` are moved, not copied, during assignment +//! operations, and their `Drop` implementation is called exactly once when the +//! value goes out of scope. + //@ run-pass #![allow(non_camel_case_types)] @@ -15,9 +19,7 @@ impl<'a> Drop for r<'a> { } fn r(i: &Cell<isize>) -> r<'_> { - r { - i: i - } + r { i } } pub fn main() { diff --git a/tests/ui/drop/drop-order-comparisons-let-chains.rs b/tests/ui/drop/drop-order-comparisons-let-chains.rs new file mode 100644 index 00000000000..5dea5e1a580 --- /dev/null +++ b/tests/ui/drop/drop-order-comparisons-let-chains.rs @@ -0,0 +1,145 @@ +// See drop-order-comparisons.rs + +//@ edition: 2024 +//@ run-pass + +#![feature(if_let_guard)] + +fn t_if_let_chains_then() { + let e = Events::new(); + _ = if e.ok(1).is_ok() + && let true = e.ok(9).is_ok() + && let Ok(_v) = e.ok(8) + && let Ok(_) = e.ok(7) + && let Ok(_) = e.ok(6).as_ref() + && e.ok(2).is_ok() + && let Ok(_v) = e.ok(5) + && let Ok(_) = e.ok(4).as_ref() { + e.mark(3); + }; + e.assert(9); +} + +fn t_guard_if_let_chains_then() { + let e = Events::new(); + _ = match () { + () if e.ok(1).is_ok() + && let true = e.ok(9).is_ok() + && let Ok(_v) = e.ok(8) + && let Ok(_) = e.ok(7) + && let Ok(_) = e.ok(6).as_ref() + && e.ok(2).is_ok() + && let Ok(_v) = e.ok(5) + && let Ok(_) = e.ok(4).as_ref() => { + e.mark(3); + } + _ => {} + }; + e.assert(9); +} + +fn t_if_let_chains_then_else() { + let e = Events::new(); + _ = if e.ok(1).is_ok() + && let true = e.ok(8).is_ok() + && let Ok(_v) = e.ok(7) + && let Ok(_) = e.ok(6) + && let Ok(_) = e.ok(5).as_ref() + && e.ok(2).is_ok() + && let Ok(_v) = e.ok(4) + && let Ok(_) = e.err(3) {} else { + e.mark(9); + }; + e.assert(9); +} + +fn t_guard_if_let_chains_then_else() { + let e = Events::new(); + _ = match () { + () if e.ok(1).is_ok() + && let true = e.ok(8).is_ok() + && let Ok(_v) = e.ok(7) + && let Ok(_) = e.ok(6) + && let Ok(_) = e.ok(5).as_ref() + && e.ok(2).is_ok() + && let Ok(_v) = e.ok(4) + && let Ok(_) = e.err(3) => {} + _ => { + e.mark(9); + } + }; + e.assert(9); +} + +fn main() { + t_if_let_chains_then(); + t_guard_if_let_chains_then(); + t_if_let_chains_then_else(); + t_guard_if_let_chains_then_else(); +} + +// # Test scaffolding + +use core::cell::RefCell; +use std::collections::HashSet; + +/// A buffer to track the order of events. +/// +/// First, numbered events are logged into this buffer. +/// +/// Then, `assert` is called to verify that the correct number of +/// events were logged, and that they were logged in the expected +/// order. +struct Events(RefCell<Option<Vec<u64>>>); + +impl Events { + const fn new() -> Self { + Self(RefCell::new(Some(Vec::new()))) + } + #[track_caller] + fn assert(&self, max: u64) { + let buf = &self.0; + let v1 = buf.borrow().as_ref().unwrap().clone(); + let mut v2 = buf.borrow().as_ref().unwrap().clone(); + *buf.borrow_mut() = None; + v2.sort(); + let uniq_len = v2.iter().collect::<HashSet<_>>().len(); + // Check that the sequence is sorted. + assert_eq!(v1, v2); + // Check that there are no duplicates. + assert_eq!(v2.len(), uniq_len); + // Check that the length is the expected one. + assert_eq!(max, uniq_len as u64); + // Check that the last marker is the expected one. + assert_eq!(v2.last().unwrap(), &max); + } + /// Return an `Ok` value that logs its drop. + fn ok(&self, m: u64) -> Result<LogDrop<'_>, LogDrop<'_>> { + Ok(LogDrop(self, m)) + } + /// Return an `Err` value that logs its drop. + fn err(&self, m: u64) -> Result<LogDrop<'_>, LogDrop<'_>> { + Err(LogDrop(self, m)) + } + /// Log an event. + fn mark(&self, m: u64) { + self.0.borrow_mut().as_mut().unwrap().push(m); + } +} + +impl Drop for Events { + fn drop(&mut self) { + if self.0.borrow().is_some() { + panic!("failed to call `Events::assert()`"); + } + } +} + +/// A type that logs its drop events. +struct LogDrop<'b>(&'b Events, u64); + +impl<'b> Drop for LogDrop<'b> { + fn drop(&mut self) { + self.0.mark(self.1); + } +} diff --git a/tests/ui/drop/drop-order-comparisons.e2021.fixed b/tests/ui/drop/drop-order-comparisons.e2021.fixed index 42f805923ec..b0f6eb93f70 100644 --- a/tests/ui/drop/drop-order-comparisons.e2021.fixed +++ b/tests/ui/drop/drop-order-comparisons.e2021.fixed @@ -1,3 +1,6 @@ +// N.B. drop-order-comparisons-let-chains.rs is part of this test. +// It is separate because let chains cannot be parsed before Rust 2024. +// // This tests various aspects of the drop order with a focus on: // // - The lifetime of temporaries with the `if let` construct (and with @@ -25,7 +28,6 @@ //@ run-pass #![feature(if_let_guard)] -#![cfg_attr(e2021, feature(let_chains))] #![cfg_attr(e2021, warn(rust_2024_compatibility))] fn t_bindings() { @@ -313,59 +315,6 @@ fn t_let_else_chained_then() { #[cfg(e2021)] #[rustfmt::skip] -fn t_if_let_chains_then() { - let e = Events::new(); - _ = if e.ok(1).is_ok() - && let true = e.ok(9).is_ok() - && let Ok(_v) = e.ok(5) - && let Ok(_) = e.ok(8) - && let Ok(_) = e.ok(7).as_ref() - && e.ok(2).is_ok() - && let Ok(_v) = e.ok(4) - && let Ok(_) = e.ok(6).as_ref() { - e.mark(3); - }; - e.assert(9); -} - -#[cfg(e2024)] -#[rustfmt::skip] -fn t_if_let_chains_then() { - let e = Events::new(); - _ = if e.ok(1).is_ok() - && let true = e.ok(9).is_ok() - && let Ok(_v) = e.ok(8) - && let Ok(_) = e.ok(7) - && let Ok(_) = e.ok(6).as_ref() - && e.ok(2).is_ok() - && let Ok(_v) = e.ok(5) - && let Ok(_) = e.ok(4).as_ref() { - e.mark(3); - }; - e.assert(9); -} - -#[rustfmt::skip] -fn t_guard_if_let_chains_then() { - let e = Events::new(); - _ = match () { - () if e.ok(1).is_ok() - && let true = e.ok(9).is_ok() - && let Ok(_v) = e.ok(8) - && let Ok(_) = e.ok(7) - && let Ok(_) = e.ok(6).as_ref() - && e.ok(2).is_ok() - && let Ok(_v) = e.ok(5) - && let Ok(_) = e.ok(4).as_ref() => { - e.mark(3); - } - _ => {} - }; - e.assert(9); -} - -#[cfg(e2021)] -#[rustfmt::skip] fn t_if_let_nested_else() { let e = Events::new(); _ = if e.err(1).is_ok() {} else { @@ -470,59 +419,6 @@ fn t_let_else_chained_then_else() { e.assert(9); } -#[cfg(e2021)] -#[rustfmt::skip] -fn t_if_let_chains_then_else() { - let e = Events::new(); - _ = if e.ok(1).is_ok() - && let true = e.ok(9).is_ok() - && let Ok(_v) = e.ok(4) - && let Ok(_) = e.ok(8) - && let Ok(_) = e.ok(7).as_ref() - && e.ok(2).is_ok() - && let Ok(_v) = e.ok(3) - && let Ok(_) = e.err(6) {} else { - e.mark(5); - }; - e.assert(9); -} - -#[cfg(e2024)] -#[rustfmt::skip] -fn t_if_let_chains_then_else() { - let e = Events::new(); - _ = if e.ok(1).is_ok() - && let true = e.ok(8).is_ok() - && let Ok(_v) = e.ok(7) - && let Ok(_) = e.ok(6) - && let Ok(_) = e.ok(5).as_ref() - && e.ok(2).is_ok() - && let Ok(_v) = e.ok(4) - && let Ok(_) = e.err(3) {} else { - e.mark(9); - }; - e.assert(9); -} - -#[rustfmt::skip] -fn t_guard_if_let_chains_then_else() { - let e = Events::new(); - _ = match () { - () if e.ok(1).is_ok() - && let true = e.ok(8).is_ok() - && let Ok(_v) = e.ok(7) - && let Ok(_) = e.ok(6) - && let Ok(_) = e.ok(5).as_ref() - && e.ok(2).is_ok() - && let Ok(_v) = e.ok(4) - && let Ok(_) = e.err(3) => {} - _ => { - e.mark(9); - } - }; - e.assert(9); -} - fn main() { t_bindings(); t_tuples(); @@ -540,13 +436,9 @@ fn main() { t_if_let_else_tailexpr(); t_if_let_nested_then(); t_let_else_chained_then(); - t_if_let_chains_then(); - t_guard_if_let_chains_then(); t_if_let_nested_else(); t_if_let_nested_then_else(); t_let_else_chained_then_else(); - t_if_let_chains_then_else(); - t_guard_if_let_chains_then_else(); } // # Test scaffolding diff --git a/tests/ui/drop/drop-order-comparisons.e2021.stderr b/tests/ui/drop/drop-order-comparisons.e2021.stderr index 8b93376cc0d..15a3f274514 100644 --- a/tests/ui/drop/drop-order-comparisons.e2021.stderr +++ b/tests/ui/drop/drop-order-comparisons.e2021.stderr @@ -1,5 +1,5 @@ warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:77:9 + --> $DIR/drop-order-comparisons.rs:79:9 | LL | _ = ({ | _________- @@ -29,35 +29,35 @@ LL | | }, e.mark(3), e.ok(4)); = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> note: `#3` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `_v` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages note: the lint level is defined here - --> $DIR/drop-order-comparisons.rs:29:25 + --> $DIR/drop-order-comparisons.rs:31:25 | LL | #![cfg_attr(e2021, warn(rust_2024_compatibility))] | ^^^^^^^^^^^^^^^^^^^^^^^ = note: `#[warn(tail_expr_drop_order)]` implied by `#[warn(rust_2024_compatibility)]` warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:101:45 + --> $DIR/drop-order-comparisons.rs:103:45 | LL | _ = ({ | _________- @@ -77,19 +77,19 @@ LL | | }, e.mark(1), e.ok(4)); = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:101:19 + --> $DIR/drop-order-comparisons.rs:103:19 | LL | _ = ({ | _________- @@ -109,19 +109,19 @@ LL | | }, e.mark(1), e.ok(4)); = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:222:24 + --> $DIR/drop-order-comparisons.rs:224:24 | LL | _ = ({ | _________- @@ -141,19 +141,19 @@ LL | | }, e.mark(2), e.ok(3)); = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages warning: relative drop order changing in Rust 2024 - --> $DIR/drop-order-comparisons.rs:248:24 + --> $DIR/drop-order-comparisons.rs:250:24 | LL | _ = ({ | _________- @@ -173,19 +173,19 @@ LL | | }, e.mark(2), e.ok(3)); = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-tail-expr-scope.html> note: `#2` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: `#1` invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: most of the time, changing drop order is harmless; inspect the `impl Drop`s for side effects like releasing locks or sending messages warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:124:13 + --> $DIR/drop-order-comparisons.rs:126:13 | LL | _ = (if let Ok(_) = e.ok(4).as_ref() { | ^^^^^^^^^^^^-------^^^^^^^^^ @@ -195,12 +195,12 @@ LL | _ = (if let Ok(_) = e.ok(4).as_ref() { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:128:5 + --> $DIR/drop-order-comparisons.rs:130:5 | LL | }, e.mark(2), e.ok(3)); | ^ @@ -215,7 +215,7 @@ LL ~ } _ => {}}, e.mark(2), e.ok(3)); | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:146:13 + --> $DIR/drop-order-comparisons.rs:148:13 | LL | _ = (if let Ok(_) = e.err(4).as_ref() {} else { | ^^^^^^^^^^^^--------^^^^^^^^^ @@ -225,12 +225,12 @@ LL | _ = (if let Ok(_) = e.err(4).as_ref() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:146:44 + --> $DIR/drop-order-comparisons.rs:148:44 | LL | _ = (if let Ok(_) = e.err(4).as_ref() {} else { | ^ @@ -244,7 +244,7 @@ LL ~ }}, e.mark(2), e.ok(3)); | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:248:12 + --> $DIR/drop-order-comparisons.rs:250:12 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^^^^^^^^^^^^--------^^^^^^^^^ @@ -254,12 +254,12 @@ LL | if let Ok(_) = e.err(4).as_ref() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:248:43 + --> $DIR/drop-order-comparisons.rs:250:43 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^ @@ -273,7 +273,7 @@ LL ~ }} | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:372:12 + --> $DIR/drop-order-comparisons.rs:321:12 | LL | if let true = e.err(9).is_ok() {} else { | ^^^^^^^^^^^--------^^^^^^^^ @@ -283,12 +283,12 @@ LL | if let true = e.err(9).is_ok() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:372:41 + --> $DIR/drop-order-comparisons.rs:321:41 | LL | if let true = e.err(9).is_ok() {} else { | ^ @@ -302,7 +302,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:375:12 + --> $DIR/drop-order-comparisons.rs:324:12 | LL | if let Ok(_v) = e.err(8) {} else { | ^^^^^^^^^^^^^-------- @@ -312,12 +312,12 @@ LL | if let Ok(_v) = e.err(8) {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:375:35 + --> $DIR/drop-order-comparisons.rs:324:35 | LL | if let Ok(_v) = e.err(8) {} else { | ^ @@ -331,7 +331,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:378:12 + --> $DIR/drop-order-comparisons.rs:327:12 | LL | if let Ok(_) = e.err(7) {} else { | ^^^^^^^^^^^^-------- @@ -341,12 +341,12 @@ LL | if let Ok(_) = e.err(7) {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:378:34 + --> $DIR/drop-order-comparisons.rs:327:34 | LL | if let Ok(_) = e.err(7) {} else { | ^ @@ -360,7 +360,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:381:12 + --> $DIR/drop-order-comparisons.rs:330:12 | LL | if let Ok(_) = e.err(6).as_ref() {} else { | ^^^^^^^^^^^^--------^^^^^^^^^ @@ -370,12 +370,12 @@ LL | if let Ok(_) = e.err(6).as_ref() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:381:43 + --> $DIR/drop-order-comparisons.rs:330:43 | LL | if let Ok(_) = e.err(6).as_ref() {} else { | ^ @@ -389,7 +389,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:385:12 + --> $DIR/drop-order-comparisons.rs:334:12 | LL | if let Ok(_v) = e.err(5) {} else { | ^^^^^^^^^^^^^-------- @@ -399,12 +399,12 @@ LL | if let Ok(_v) = e.err(5) {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:385:35 + --> $DIR/drop-order-comparisons.rs:334:35 | LL | if let Ok(_v) = e.err(5) {} else { | ^ @@ -418,7 +418,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:388:12 + --> $DIR/drop-order-comparisons.rs:337:12 | LL | if let Ok(_) = e.err(4) {} else { | ^^^^^^^^^^^^-------- @@ -428,12 +428,12 @@ LL | if let Ok(_) = e.err(4) {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:388:34 + --> $DIR/drop-order-comparisons.rs:337:34 | LL | if let Ok(_) = e.err(4) {} else { | ^ @@ -447,7 +447,7 @@ LL ~ }}}}}}}}}; | warning: `if let` assigns a shorter lifetime since Edition 2024 - --> $DIR/drop-order-comparisons.rs:424:12 + --> $DIR/drop-order-comparisons.rs:373:12 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^^^^^^^^^^^^--------^^^^^^^^^ @@ -457,12 +457,12 @@ LL | if let Ok(_) = e.err(4).as_ref() {} else { = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/temporary-if-let-scope.html> note: value invokes this custom destructor - --> $DIR/drop-order-comparisons.rs:612:1 + --> $DIR/drop-order-comparisons.rs:504:1 | LL | impl<'b> Drop for LogDrop<'b> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: the value is now dropped here in Edition 2024 - --> $DIR/drop-order-comparisons.rs:424:43 + --> $DIR/drop-order-comparisons.rs:373:43 | LL | if let Ok(_) = e.err(4).as_ref() {} else { | ^ diff --git a/tests/ui/drop/drop-order-comparisons.rs b/tests/ui/drop/drop-order-comparisons.rs index e7425159aa2..257c0c14ecf 100644 --- a/tests/ui/drop/drop-order-comparisons.rs +++ b/tests/ui/drop/drop-order-comparisons.rs @@ -1,3 +1,6 @@ +// N.B. drop-order-comparisons-let-chains.rs is part of this test. +// It is separate because let chains cannot be parsed before Rust 2024. +// // This tests various aspects of the drop order with a focus on: // // - The lifetime of temporaries with the `if let` construct (and with @@ -25,7 +28,6 @@ //@ run-pass #![feature(if_let_guard)] -#![cfg_attr(e2021, feature(let_chains))] #![cfg_attr(e2021, warn(rust_2024_compatibility))] fn t_bindings() { @@ -313,59 +315,6 @@ fn t_let_else_chained_then() { #[cfg(e2021)] #[rustfmt::skip] -fn t_if_let_chains_then() { - let e = Events::new(); - _ = if e.ok(1).is_ok() - && let true = e.ok(9).is_ok() - && let Ok(_v) = e.ok(5) - && let Ok(_) = e.ok(8) - && let Ok(_) = e.ok(7).as_ref() - && e.ok(2).is_ok() - && let Ok(_v) = e.ok(4) - && let Ok(_) = e.ok(6).as_ref() { - e.mark(3); - }; - e.assert(9); -} - -#[cfg(e2024)] -#[rustfmt::skip] -fn t_if_let_chains_then() { - let e = Events::new(); - _ = if e.ok(1).is_ok() - && let true = e.ok(9).is_ok() - && let Ok(_v) = e.ok(8) - && let Ok(_) = e.ok(7) - && let Ok(_) = e.ok(6).as_ref() - && e.ok(2).is_ok() - && let Ok(_v) = e.ok(5) - && let Ok(_) = e.ok(4).as_ref() { - e.mark(3); - }; - e.assert(9); -} - -#[rustfmt::skip] -fn t_guard_if_let_chains_then() { - let e = Events::new(); - _ = match () { - () if e.ok(1).is_ok() - && let true = e.ok(9).is_ok() - && let Ok(_v) = e.ok(8) - && let Ok(_) = e.ok(7) - && let Ok(_) = e.ok(6).as_ref() - && e.ok(2).is_ok() - && let Ok(_v) = e.ok(5) - && let Ok(_) = e.ok(4).as_ref() => { - e.mark(3); - } - _ => {} - }; - e.assert(9); -} - -#[cfg(e2021)] -#[rustfmt::skip] fn t_if_let_nested_else() { let e = Events::new(); _ = if e.err(1).is_ok() {} else { @@ -470,59 +419,6 @@ fn t_let_else_chained_then_else() { e.assert(9); } -#[cfg(e2021)] -#[rustfmt::skip] -fn t_if_let_chains_then_else() { - let e = Events::new(); - _ = if e.ok(1).is_ok() - && let true = e.ok(9).is_ok() - && let Ok(_v) = e.ok(4) - && let Ok(_) = e.ok(8) - && let Ok(_) = e.ok(7).as_ref() - && e.ok(2).is_ok() - && let Ok(_v) = e.ok(3) - && let Ok(_) = e.err(6) {} else { - e.mark(5); - }; - e.assert(9); -} - -#[cfg(e2024)] -#[rustfmt::skip] -fn t_if_let_chains_then_else() { - let e = Events::new(); - _ = if e.ok(1).is_ok() - && let true = e.ok(8).is_ok() - && let Ok(_v) = e.ok(7) - && let Ok(_) = e.ok(6) - && let Ok(_) = e.ok(5).as_ref() - && e.ok(2).is_ok() - && let Ok(_v) = e.ok(4) - && let Ok(_) = e.err(3) {} else { - e.mark(9); - }; - e.assert(9); -} - -#[rustfmt::skip] -fn t_guard_if_let_chains_then_else() { - let e = Events::new(); - _ = match () { - () if e.ok(1).is_ok() - && let true = e.ok(8).is_ok() - && let Ok(_v) = e.ok(7) - && let Ok(_) = e.ok(6) - && let Ok(_) = e.ok(5).as_ref() - && e.ok(2).is_ok() - && let Ok(_v) = e.ok(4) - && let Ok(_) = e.err(3) => {} - _ => { - e.mark(9); - } - }; - e.assert(9); -} - fn main() { t_bindings(); t_tuples(); @@ -540,13 +436,9 @@ fn main() { t_if_let_else_tailexpr(); t_if_let_nested_then(); t_let_else_chained_then(); - t_if_let_chains_then(); - t_guard_if_let_chains_then(); t_if_let_nested_else(); t_if_let_nested_then_else(); t_let_else_chained_then_else(); - t_if_let_chains_then_else(); - t_guard_if_let_chains_then_else(); } // # Test scaffolding diff --git a/tests/ui/resource-destruct.rs b/tests/ui/drop/drop-scope-exit.rs index 480cbe091a7..4d003fec712 100644 --- a/tests/ui/resource-destruct.rs +++ b/tests/ui/drop/drop-scope-exit.rs @@ -1,31 +1,37 @@ +//! Check that the `Drop` implementation is called when a value goes out of scope. + //@ run-pass #![allow(non_camel_case_types)] use std::cell::Cell; struct shrinky_pointer<'a> { - i: &'a Cell<isize>, + i: &'a Cell<isize>, } impl<'a> Drop for shrinky_pointer<'a> { fn drop(&mut self) { - println!("Hello!"); self.i.set(self.i.get() - 1); + println!("Hello!"); + self.i.set(self.i.get() - 1); } } impl<'a> shrinky_pointer<'a> { - pub fn look_at(&self) -> isize { return self.i.get(); } + pub fn look_at(&self) -> isize { + return self.i.get(); + } } fn shrinky_pointer(i: &Cell<isize>) -> shrinky_pointer<'_> { - shrinky_pointer { - i: i - } + shrinky_pointer { i } } pub fn main() { let my_total = &Cell::new(10); - { let pt = shrinky_pointer(my_total); assert_eq!(pt.look_at(), 10); } + { + let pt = shrinky_pointer(my_total); + assert_eq!(pt.look_at(), 10); + } println!("my_total = {}", my_total.get()); assert_eq!(my_total.get(), 9); } diff --git a/tests/ui/drop/drop_order.rs b/tests/ui/drop/drop_order.rs index 34b1a0e8f75..ead498a21c3 100644 --- a/tests/ui/drop/drop_order.rs +++ b/tests/ui/drop/drop_order.rs @@ -5,8 +5,6 @@ //@ [edition2024] compile-flags: -Z lint-mir //@ [edition2024] edition: 2024 -#![cfg_attr(edition2021, feature(let_chains))] - use std::cell::RefCell; use std::convert::TryInto; @@ -210,68 +208,6 @@ impl DropOrderCollector { } } - fn let_chain(&self) { - // take the "then" branch - if self.option_loud_drop(1).is_some() // 1 - && self.option_loud_drop(2).is_some() // 2 - && let Some(_d) = self.option_loud_drop(4) { // 4 - self.print(3); // 3 - } - - #[cfg(edition2021)] - // take the "else" branch - if self.option_loud_drop(5).is_some() // 1 - && self.option_loud_drop(6).is_some() // 2 - && let None = self.option_loud_drop(8) { // 4 - unreachable!(); - } else { - self.print(7); // 3 - } - #[cfg(edition2024)] - // take the "else" branch - if self.option_loud_drop(5).is_some() // 1 - && self.option_loud_drop(6).is_some() // 2 - && let None = self.option_loud_drop(7) { // 4 - unreachable!(); - } else { - self.print(8); // 3 - } - - // let exprs interspersed - if self.option_loud_drop(9).is_some() // 1 - && let Some(_d) = self.option_loud_drop(13) // 5 - && self.option_loud_drop(10).is_some() // 2 - && let Some(_e) = self.option_loud_drop(12) { // 4 - self.print(11); // 3 - } - - // let exprs first - if let Some(_d) = self.option_loud_drop(18) // 5 - && let Some(_e) = self.option_loud_drop(17) // 4 - && self.option_loud_drop(14).is_some() // 1 - && self.option_loud_drop(15).is_some() { // 2 - self.print(16); // 3 - } - - // let exprs last - if self.option_loud_drop(19).is_some() // 1 - && self.option_loud_drop(20).is_some() // 2 - && let Some(_d) = self.option_loud_drop(23) // 5 - && let Some(_e) = self.option_loud_drop(22) { // 4 - self.print(21); // 3 - } - } - - fn while_(&self) { - let mut v = self.option_loud_drop(4); - while let Some(_d) = v - && self.option_loud_drop(1).is_some() - && self.option_loud_drop(2).is_some() { - self.print(3); - v = None; - } - } - fn assert_sorted(self) { assert!( self.0 @@ -313,14 +249,4 @@ fn main() { let collector = DropOrderCollector::default(); collector.match_(); collector.assert_sorted(); - - println!("-- let chain --"); - let collector = DropOrderCollector::default(); - collector.let_chain(); - collector.assert_sorted(); - - println!("-- while --"); - let collector = DropOrderCollector::default(); - collector.while_(); - collector.assert_sorted(); } diff --git a/tests/ui/drop/drop_order_let_chain.rs b/tests/ui/drop/drop_order_let_chain.rs new file mode 100644 index 00000000000..8d1b71c4dab --- /dev/null +++ b/tests/ui/drop/drop_order_let_chain.rs @@ -0,0 +1,103 @@ +//@ run-pass +//@ compile-flags: -Z validate-mir +//@ edition: 2024 + +use std::cell::RefCell; +use std::convert::TryInto; + +#[derive(Default)] +struct DropOrderCollector(RefCell<Vec<u32>>); + +struct LoudDrop<'a>(&'a DropOrderCollector, u32); + +impl Drop for LoudDrop<'_> { + fn drop(&mut self) { + println!("{}", self.1); + self.0.0.borrow_mut().push(self.1); + } +} + +impl DropOrderCollector { + fn option_loud_drop(&self, n: u32) -> Option<LoudDrop<'_>> { + Some(LoudDrop(self, n)) + } + + fn print(&self, n: u32) { + println!("{}", n); + self.0.borrow_mut().push(n) + } + + fn let_chain(&self) { + // take the "then" branch + if self.option_loud_drop(1).is_some() // 1 + && self.option_loud_drop(2).is_some() // 2 + && let Some(_d) = self.option_loud_drop(4) { // 4 + self.print(3); // 3 + } + + // take the "else" branch + if self.option_loud_drop(5).is_some() // 1 + && self.option_loud_drop(6).is_some() // 2 + && let None = self.option_loud_drop(7) { // 4 + unreachable!(); + } else { + self.print(8); // 3 + } + + // let exprs interspersed + if self.option_loud_drop(9).is_some() // 1 + && let Some(_d) = self.option_loud_drop(13) // 5 + && self.option_loud_drop(10).is_some() // 2 + && let Some(_e) = self.option_loud_drop(12) { // 4 + self.print(11); // 3 + } + + // let exprs first + if let Some(_d) = self.option_loud_drop(18) // 5 + && let Some(_e) = self.option_loud_drop(17) // 4 + && self.option_loud_drop(14).is_some() // 1 + && self.option_loud_drop(15).is_some() { // 2 + self.print(16); // 3 + } + + // let exprs last + if self.option_loud_drop(19).is_some() // 1 + && self.option_loud_drop(20).is_some() // 2 + && let Some(_d) = self.option_loud_drop(23) // 5 + && let Some(_e) = self.option_loud_drop(22) { // 4 + self.print(21); // 3 + } + } + + fn while_(&self) { + let mut v = self.option_loud_drop(4); + while let Some(_d) = v + && self.option_loud_drop(1).is_some() + && self.option_loud_drop(2).is_some() { + self.print(3); + v = None; + } + } + + fn assert_sorted(self) { + assert!( + self.0 + .into_inner() + .into_iter() + .enumerate() + .all(|(idx, item)| idx + 1 == item.try_into().unwrap()) + ); + } +} + +fn main() { + println!("-- let chain --"); + let collector = DropOrderCollector::default(); + collector.let_chain(); + collector.assert_sorted(); + + println!("-- while --"); + let collector = DropOrderCollector::default(); + collector.while_(); + collector.assert_sorted(); +} diff --git a/tests/ui/drop/field-replace-in-struct-with-drop.rs b/tests/ui/drop/field-replace-in-struct-with-drop.rs new file mode 100644 index 00000000000..8c65a4b3ad1 --- /dev/null +++ b/tests/ui/drop/field-replace-in-struct-with-drop.rs @@ -0,0 +1,40 @@ +//! Circa 2016-06-05, `fn inline` below issued an +//! erroneous warning from the elaborate_drops pass about moving out of +//! a field in `Foo`, which has a destructor (and thus cannot have +//! content moved out of it). The reason that the warning is erroneous +//! in this case is that we are doing a *replace*, not a move, of the +//! content in question, and it is okay to replace fields within `Foo`. +//! +//! Another more subtle problem was that the elaborate_drops was +//! creating a separate drop flag for that internally replaced content, +//! even though the compiler should enforce an invariant that any drop +//! flag for such subcontent of `Foo` will always have the same value +//! as the drop flag for `Foo` itself. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/34101>. + +//@ check-pass + +struct Foo(String); + +impl Drop for Foo { + fn drop(&mut self) {} +} + +fn test_inline_replacement() { + // dummy variable so `f` gets assigned `var1` in MIR for both functions + let _s = (); + let mut f = Foo(String::from("foo")); + f.0 = String::from("bar"); // This should not warn +} + +fn test_outline_replacement() { + let _s = String::from("foo"); + let mut f = Foo(_s); + f.0 = String::from("bar"); // This should not warn either +} + +fn main() { + test_inline_replacement(); + test_outline_replacement(); +} diff --git a/tests/ui/drop/issue-100276.rs b/tests/ui/drop/issue-100276.rs index 5d212b3a0a9..c8e25e48b15 100644 --- a/tests/ui/drop/issue-100276.rs +++ b/tests/ui/drop/issue-100276.rs @@ -1,11 +1,6 @@ //@ check-pass -//@ compile-flags: -Z validate-mir -//@ revisions: edition2021 edition2024 -//@ [edition2021] edition: 2021 -//@ [edition2024] compile-flags: -Z lint-mir -//@ [edition2024] edition: 2024 - -#![cfg_attr(edition2021, feature(let_chains))] +//@ compile-flags: -Z lint-mir -Z validate-mir +//@ edition: 2024 fn let_chains(entry: std::io::Result<std::fs::DirEntry>) { if let Ok(entry) = entry diff --git a/tests/ui/dropck/explicit-drop-bounds.bad1.stderr b/tests/ui/dropck/explicit-drop-bounds.bad1.stderr index 28d7546d0c9..d898f2f9761 100644 --- a/tests/ui/dropck/explicit-drop-bounds.bad1.stderr +++ b/tests/ui/dropck/explicit-drop-bounds.bad1.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/explicit-drop-bounds.rs:27:18 + --> $DIR/explicit-drop-bounds.rs:32:5 | -LL | impl<T> Drop for DropMe<T> - | ^^^^^^^^^ the trait `Copy` is not implemented for `T` +LL | fn drop(&mut self) {} + | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` | note: required by a bound in `DropMe` --> $DIR/explicit-drop-bounds.rs:7:18 @@ -15,10 +15,10 @@ LL | [T; 1]: Copy, T: std::marker::Copy // But `[T; 1]: Copy` does not imply | ++++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/explicit-drop-bounds.rs:32:5 + --> $DIR/explicit-drop-bounds.rs:27:18 | -LL | fn drop(&mut self) {} - | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` +LL | impl<T> Drop for DropMe<T> + | ^^^^^^^^^ the trait `Copy` is not implemented for `T` | note: required by a bound in `DropMe` --> $DIR/explicit-drop-bounds.rs:7:18 diff --git a/tests/ui/dropck/explicit-drop-bounds.bad2.stderr b/tests/ui/dropck/explicit-drop-bounds.bad2.stderr index c363676edea..8155bd4134d 100644 --- a/tests/ui/dropck/explicit-drop-bounds.bad2.stderr +++ b/tests/ui/dropck/explicit-drop-bounds.bad2.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/explicit-drop-bounds.rs:38:18 + --> $DIR/explicit-drop-bounds.rs:41:5 | -LL | impl<T> Drop for DropMe<T> - | ^^^^^^^^^ the trait `Copy` is not implemented for `T` +LL | fn drop(&mut self) {} + | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` | note: required by a bound in `DropMe` --> $DIR/explicit-drop-bounds.rs:7:18 @@ -15,10 +15,10 @@ LL | impl<T: std::marker::Copy> Drop for DropMe<T> | +++++++++++++++++++ error[E0277]: the trait bound `T: Copy` is not satisfied - --> $DIR/explicit-drop-bounds.rs:41:5 + --> $DIR/explicit-drop-bounds.rs:38:18 | -LL | fn drop(&mut self) {} - | ^^^^^^^^^^^^^^^^^^ the trait `Copy` is not implemented for `T` +LL | impl<T> Drop for DropMe<T> + | ^^^^^^^^^ the trait `Copy` is not implemented for `T` | note: required by a bound in `DropMe` --> $DIR/explicit-drop-bounds.rs:7:18 diff --git a/tests/ui/dropck/unconstrained_const_param_on_drop.rs b/tests/ui/dropck/unconstrained_const_param_on_drop.rs index de77fa55fb2..839aca07a6a 100644 --- a/tests/ui/dropck/unconstrained_const_param_on_drop.rs +++ b/tests/ui/dropck/unconstrained_const_param_on_drop.rs @@ -3,5 +3,6 @@ struct Foo {} impl<const UNUSED: usize> Drop for Foo {} //~^ ERROR: `Drop` impl requires `the constant `_` has type `usize`` //~| ERROR: the const parameter `UNUSED` is not constrained by the impl trait, self type, or predicates +//~| ERROR: missing: `drop` fn main() {} diff --git a/tests/ui/dropck/unconstrained_const_param_on_drop.stderr b/tests/ui/dropck/unconstrained_const_param_on_drop.stderr index 851888534ee..515637dd47f 100644 --- a/tests/ui/dropck/unconstrained_const_param_on_drop.stderr +++ b/tests/ui/dropck/unconstrained_const_param_on_drop.stderr @@ -10,6 +10,14 @@ note: the implementor must specify the same requirement LL | struct Foo {} | ^^^^^^^^^^ +error[E0046]: not all trait items implemented, missing: `drop` + --> $DIR/unconstrained_const_param_on_drop.rs:3:1 + | +LL | impl<const UNUSED: usize> Drop for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `drop` in implementation + | + = help: implement the missing item: `fn drop(&mut self) { todo!() }` + error[E0207]: the const parameter `UNUSED` is not constrained by the impl trait, self type, or predicates --> $DIR/unconstrained_const_param_on_drop.rs:3:6 | @@ -19,7 +27,7 @@ LL | impl<const UNUSED: usize> Drop for Foo {} = note: expressions using a const parameter must map each value to a distinct output value = note: proving the result of expressions other than the parameter are unique is not supported -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0207, E0367. -For more information about an error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0046, E0207, E0367. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.old.stderr b/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.old.stderr index d8935be5609..8b4f3f52ee9 100644 --- a/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.old.stderr +++ b/tests/ui/dyn-compatibility/avoid-ice-on-warning-3.old.stderr @@ -87,6 +87,11 @@ help: alternatively, consider constraining `g` so it does not apply to trait obj | LL | trait A { fn g(b: B) -> B where Self: Sized; } | +++++++++++++++++ +help: you might have meant to use `Self` to refer to the implementing type + | +LL - trait B { fn f(a: A) -> A; } +LL + trait B { fn f(a: Self) -> A; } + | warning: trait objects without an explicit `dyn` are deprecated --> $DIR/avoid-ice-on-warning-3.rs:14:19 @@ -124,6 +129,11 @@ help: alternatively, consider constraining `f` so it does not apply to trait obj | LL | trait B { fn f(a: A) -> A where Self: Sized; } | +++++++++++++++++ +help: you might have meant to use `Self` to refer to the implementing type + | +LL - trait A { fn g(b: B) -> B; } +LL + trait A { fn g(b: Self) -> B; } + | error: aborting due to 2 previous errors; 6 warnings emitted diff --git a/tests/ui/dyn-compatibility/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.stderr b/tests/ui/dyn-compatibility/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.stderr index 2cf244185e6..83a0a77d842 100644 --- a/tests/ui/dyn-compatibility/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.stderr +++ b/tests/ui/dyn-compatibility/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.stderr @@ -139,9 +139,12 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:96:12 | LL | fn bar(_: &'a Trait) {} - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `<'a>` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn bar<'a>(_: &'a Trait) {} + | ++++ error[E0106]: missing lifetime specifier --> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:110:13 @@ -171,9 +174,12 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:122:17 | LL | fn kitten() -> &'a Trait { - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `<'a>` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn kitten<'a>() -> &'a Trait { + | ++++ error[E0106]: missing lifetime specifier --> $DIR/reference-to-bare-trait-in-fn-inputs-and-outputs-issue-125139.rs:133:16 diff --git a/tests/ui/dyn-compatibility/supertrait-mentions-GAT.rs b/tests/ui/dyn-compatibility/supertrait-mentions-GAT.rs index 9e5c1bfe416..b866dab9dba 100644 --- a/tests/ui/dyn-compatibility/supertrait-mentions-GAT.rs +++ b/tests/ui/dyn-compatibility/supertrait-mentions-GAT.rs @@ -8,8 +8,7 @@ trait GatTrait { trait SuperTrait<T>: for<'a> GatTrait<Gat<'a> = T> { fn c(&self) -> dyn SuperTrait<T>; - //~^ ERROR associated item referring to unboxed trait object for its own trait - //~| ERROR the trait `SuperTrait` is not dyn compatible + //~^ ERROR the trait `SuperTrait` is not dyn compatible } fn main() {} diff --git a/tests/ui/dyn-compatibility/supertrait-mentions-GAT.stderr b/tests/ui/dyn-compatibility/supertrait-mentions-GAT.stderr index 582cf1af054..ba4ce475399 100644 --- a/tests/ui/dyn-compatibility/supertrait-mentions-GAT.stderr +++ b/tests/ui/dyn-compatibility/supertrait-mentions-GAT.stderr @@ -7,20 +7,6 @@ LL | Self: 'a; | ^^ = help: consider adding an explicit lifetime bound `Self: 'a`... -error: associated item referring to unboxed trait object for its own trait - --> $DIR/supertrait-mentions-GAT.rs:10:20 - | -LL | trait SuperTrait<T>: for<'a> GatTrait<Gat<'a> = T> { - | ---------- in this trait -LL | fn c(&self) -> dyn SuperTrait<T>; - | ^^^^^^^^^^^^^^^^^ - | -help: you might have meant to use `Self` to refer to the implementing type - | -LL - fn c(&self) -> dyn SuperTrait<T>; -LL + fn c(&self) -> Self; - | - error[E0038]: the trait `SuperTrait` is not dyn compatible --> $DIR/supertrait-mentions-GAT.rs:10:20 | @@ -37,8 +23,13 @@ LL | type Gat<'a> LL | trait SuperTrait<T>: for<'a> GatTrait<Gat<'a> = T> { | ---------- this trait is not dyn compatible... = help: consider moving `Gat` to another trait +help: you might have meant to use `Self` to refer to the implementing type + | +LL - fn c(&self) -> dyn SuperTrait<T>; +LL + fn c(&self) -> Self; + | -error: aborting due to 3 previous errors +error: aborting due to 2 previous errors Some errors have detailed explanations: E0038, E0311. For more information about an error, try `rustc --explain E0038`. diff --git a/tests/ui/dyn-star/align.normal.stderr b/tests/ui/dyn-star/align.normal.stderr deleted file mode 100644 index d3ee0d3e550..00000000000 --- a/tests/ui/dyn-star/align.normal.stderr +++ /dev/null @@ -1,20 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/align.rs:3:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: `AlignedUsize` needs to have the same ABI as a pointer - --> $DIR/align.rs:14:13 - | -LL | let x = AlignedUsize(12) as dyn* Debug; - | ^^^^^^^^^^^^^^^^ `AlignedUsize` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `AlignedUsize` - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/align.over_aligned.stderr b/tests/ui/dyn-star/align.over_aligned.stderr deleted file mode 100644 index d3ee0d3e550..00000000000 --- a/tests/ui/dyn-star/align.over_aligned.stderr +++ /dev/null @@ -1,20 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/align.rs:3:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: `AlignedUsize` needs to have the same ABI as a pointer - --> $DIR/align.rs:14:13 - | -LL | let x = AlignedUsize(12) as dyn* Debug; - | ^^^^^^^^^^^^^^^^ `AlignedUsize` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `AlignedUsize` - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/align.rs b/tests/ui/dyn-star/align.rs deleted file mode 100644 index f9ef7063231..00000000000 --- a/tests/ui/dyn-star/align.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ revisions: normal over_aligned - -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -use std::fmt::Debug; - -#[cfg_attr(over_aligned, repr(C, align(1024)))] -#[cfg_attr(not(over_aligned), repr(C))] -#[derive(Debug)] -struct AlignedUsize(usize); - -fn main() { - let x = AlignedUsize(12) as dyn* Debug; - //~^ ERROR `AlignedUsize` needs to have the same ABI as a pointer -} diff --git a/tests/ui/dyn-star/async-block-dyn-star.rs b/tests/ui/dyn-star/async-block-dyn-star.rs deleted file mode 100644 index db133d94c91..00000000000 --- a/tests/ui/dyn-star/async-block-dyn-star.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ edition:2018 - -#![feature(dyn_star, const_async_blocks)] -//~^ WARN the feature `dyn_star` is incomplete - -static S: dyn* Send + Sync = async { 42 }; -//~^ ERROR needs to have the same ABI as a pointer - -pub fn main() {} diff --git a/tests/ui/dyn-star/async-block-dyn-star.stderr b/tests/ui/dyn-star/async-block-dyn-star.stderr deleted file mode 100644 index f62c85c0ad2..00000000000 --- a/tests/ui/dyn-star/async-block-dyn-star.stderr +++ /dev/null @@ -1,20 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/async-block-dyn-star.rs:3:12 - | -LL | #![feature(dyn_star, const_async_blocks)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: `{async block@$DIR/async-block-dyn-star.rs:6:30: 6:35}` needs to have the same ABI as a pointer - --> $DIR/async-block-dyn-star.rs:6:30 - | -LL | static S: dyn* Send + Sync = async { 42 }; - | ^^^^^^^^^^^^ `{async block@$DIR/async-block-dyn-star.rs:6:30: 6:35}` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `{async block@$DIR/async-block-dyn-star.rs:6:30: 6:35}` - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/auxiliary/dyn-star-foreign.rs b/tests/ui/dyn-star/auxiliary/dyn-star-foreign.rs deleted file mode 100644 index ce892088f50..00000000000 --- a/tests/ui/dyn-star/auxiliary/dyn-star-foreign.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(dyn_star)] - -use std::fmt::Display; - -pub fn require_dyn_star_display(_: dyn* Display) {} - -fn works_locally() { - require_dyn_star_display(1usize); -} diff --git a/tests/ui/dyn-star/box.rs b/tests/ui/dyn-star/box.rs deleted file mode 100644 index f1c9fd1a01e..00000000000 --- a/tests/ui/dyn-star/box.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ run-pass -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[current] compile-flags: -C opt-level=0 -//@[next] compile-flags: -Znext-solver -C opt-level=0 - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Display; - -fn make_dyn_star() -> dyn* Display { - Box::new(42) as dyn* Display -} - -fn main() { - let x = make_dyn_star(); - - println!("{x}"); -} diff --git a/tests/ui/dyn-star/cell.rs b/tests/ui/dyn-star/cell.rs deleted file mode 100644 index f4c7927a39d..00000000000 --- a/tests/ui/dyn-star/cell.rs +++ /dev/null @@ -1,34 +0,0 @@ -// This test with Cell also indirectly exercises UnsafeCell in dyn*. -// -//@ run-pass - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::cell::Cell; - -trait Rw<T> { - fn read(&self) -> T; - fn write(&self, v: T); -} - -impl<T: Copy> Rw<T> for Cell<T> { - fn read(&self) -> T { - self.get() - } - fn write(&self, v: T) { - self.set(v) - } -} - -fn make_dyn_star() -> dyn* Rw<usize> { - Cell::new(42usize) as dyn* Rw<usize> -} - -fn main() { - let x = make_dyn_star(); - - assert_eq!(x.read(), 42); - x.write(24); - assert_eq!(x.read(), 24); -} diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr deleted file mode 100644 index a0aff69f396..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.current.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `&T` needs to have the same ABI as a pointer - --> $DIR/check-size-at-cast-polymorphic-bad.rs:15:15 - | -LL | fn polymorphic<T: Debug + ?Sized>(t: &T) { - | - this type parameter needs to be `Sized` -LL | dyn_debug(t); - | ^ `&T` needs to be a pointer-like type - | - = note: required for `&T` to implement `PointerLike` -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - fn polymorphic<T: Debug + ?Sized>(t: &T) { -LL + fn polymorphic<T: Debug>(t: &T) { - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr deleted file mode 100644 index a0aff69f396..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.next.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `&T` needs to have the same ABI as a pointer - --> $DIR/check-size-at-cast-polymorphic-bad.rs:15:15 - | -LL | fn polymorphic<T: Debug + ?Sized>(t: &T) { - | - this type parameter needs to be `Sized` -LL | dyn_debug(t); - | ^ `&T` needs to be a pointer-like type - | - = note: required for `&T` to implement `PointerLike` -help: consider removing the `?Sized` bound to make the type parameter `Sized` - | -LL - fn polymorphic<T: Debug + ?Sized>(t: &T) { -LL + fn polymorphic<T: Debug>(t: &T) { - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs b/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs deleted file mode 100644 index acc293a5956..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic-bad.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ revisions: current next -//@ ignore-compare-mode-next-solver (explicit revisions) -//@[next] compile-flags: -Znext-solver - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Debug; - -fn dyn_debug(_: (dyn* Debug + '_)) { - -} - -fn polymorphic<T: Debug + ?Sized>(t: &T) { - dyn_debug(t); - //~^ ERROR `&T` needs to have the same ABI as a pointer -} - -fn main() {} diff --git a/tests/ui/dyn-star/check-size-at-cast-polymorphic.rs b/tests/ui/dyn-star/check-size-at-cast-polymorphic.rs deleted file mode 100644 index ceedbafd86b..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast-polymorphic.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ check-pass - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Debug; - -fn dyn_debug(_: (dyn* Debug + '_)) { - -} - -fn polymorphic<T: Debug>(t: &T) { - dyn_debug(t); -} - -fn main() {} diff --git a/tests/ui/dyn-star/check-size-at-cast.rs b/tests/ui/dyn-star/check-size-at-cast.rs deleted file mode 100644 index e15e090b529..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Debug; - -fn main() { - let i = [1, 2, 3, 4] as dyn* Debug; - //~^ ERROR `[i32; 4]` needs to have the same ABI as a pointer - dbg!(i); -} diff --git a/tests/ui/dyn-star/check-size-at-cast.stderr b/tests/ui/dyn-star/check-size-at-cast.stderr deleted file mode 100644 index b402403ee6f..00000000000 --- a/tests/ui/dyn-star/check-size-at-cast.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0277]: `[i32; 4]` needs to have the same ABI as a pointer - --> $DIR/check-size-at-cast.rs:7:13 - | -LL | let i = [1, 2, 3, 4] as dyn* Debug; - | ^^^^^^^^^^^^ `[i32; 4]` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `[i32; 4]` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/const-and-static.rs b/tests/ui/dyn-star/const-and-static.rs deleted file mode 100644 index cbb64261a66..00000000000 --- a/tests/ui/dyn-star/const-and-static.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ check-pass - -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete - -const C: dyn* Send + Sync = &(); - -static S: dyn* Send + Sync = &(); - -fn main() {} diff --git a/tests/ui/dyn-star/const-and-static.stderr b/tests/ui/dyn-star/const-and-static.stderr deleted file mode 100644 index df8f42fb0f5..00000000000 --- a/tests/ui/dyn-star/const-and-static.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/const-and-static.rs:3:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/const.rs b/tests/ui/dyn-star/const.rs deleted file mode 100644 index 036d678dc02..00000000000 --- a/tests/ui/dyn-star/const.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ run-pass -#![feature(dyn_star)] -#![allow(unused, incomplete_features)] - -use std::fmt::Debug; - -fn make_dyn_star() { - let i = 42usize; - let dyn_i: dyn* Debug = i; -} - -fn main() { - make_dyn_star(); -} diff --git a/tests/ui/dyn-star/dispatch-on-pin-mut.rs b/tests/ui/dyn-star/dispatch-on-pin-mut.rs deleted file mode 100644 index be40fa30f0d..00000000000 --- a/tests/ui/dyn-star/dispatch-on-pin-mut.rs +++ /dev/null @@ -1,36 +0,0 @@ -//@ run-pass -//@ edition:2021 -//@ check-run-results - -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -use std::future::Future; - -async fn foo(f: dyn* Future<Output = i32>) { - println!("value: {}", f.await); -} - -async fn async_main() { - foo(Box::pin(async { 1 })).await -} - -// ------------------------------------------------------------------------- // -// Implementation Details Below... - -use std::pin::pin; -use std::task::*; - -fn main() { - let mut fut = pin!(async_main()); - - // Poll loop, just to test the future... - let ctx = &mut Context::from_waker(Waker::noop()); - - loop { - match fut.as_mut().poll(ctx) { - Poll::Pending => {} - Poll::Ready(()) => break, - } - } -} diff --git a/tests/ui/dyn-star/dispatch-on-pin-mut.run.stdout b/tests/ui/dyn-star/dispatch-on-pin-mut.run.stdout deleted file mode 100644 index 96c5ca6985f..00000000000 --- a/tests/ui/dyn-star/dispatch-on-pin-mut.run.stdout +++ /dev/null @@ -1 +0,0 @@ -value: 1 diff --git a/tests/ui/dyn-star/dispatch-on-pin-mut.stderr b/tests/ui/dyn-star/dispatch-on-pin-mut.stderr deleted file mode 100644 index cb9c7815814..00000000000 --- a/tests/ui/dyn-star/dispatch-on-pin-mut.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dispatch-on-pin-mut.rs:5:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.rs b/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.rs deleted file mode 100644 index abc66df8b36..00000000000 --- a/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ run-pass -//@ check-run-results - -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -trait AddOne { - fn add1(&mut self) -> usize; -} - -impl AddOne for usize { - fn add1(&mut self) -> usize { - *self += 1; - *self - } -} - -fn add_one(i: &mut (dyn* AddOne + '_)) -> usize { - i.add1() -} - -fn main() { - let mut x = 42usize as dyn* AddOne; - - println!("{}", add_one(&mut x)); - println!("{}", add_one(&mut x)); -} diff --git a/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.run.stdout b/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.run.stdout deleted file mode 100644 index b4db3ed707d..00000000000 --- a/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.run.stdout +++ /dev/null @@ -1,2 +0,0 @@ -43 -44 diff --git a/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.stderr b/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.stderr deleted file mode 100644 index bcd014f8dc3..00000000000 --- a/tests/ui/dyn-star/dont-unsize-coerce-dyn-star.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dont-unsize-coerce-dyn-star.rs:4:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/drop.rs b/tests/ui/dyn-star/drop.rs deleted file mode 100644 index bc746331527..00000000000 --- a/tests/ui/dyn-star/drop.rs +++ /dev/null @@ -1,28 +0,0 @@ -//@ run-pass -//@ check-run-results -#![feature(dyn_star, pointer_like_trait)] -#![allow(incomplete_features)] - -use std::fmt::Debug; -use std::marker::PointerLike; - -#[derive(Debug)] -#[repr(transparent)] -struct Foo(#[allow(dead_code)] usize); - -// FIXME(dyn_star): Make this into a derive. -impl PointerLike for Foo {} - -impl Drop for Foo { - fn drop(&mut self) { - println!("destructor called"); - } -} - -fn make_dyn_star(i: Foo) { - let _dyn_i: dyn* Debug = i; -} - -fn main() { - make_dyn_star(Foo(42)); -} diff --git a/tests/ui/dyn-star/drop.run.stdout b/tests/ui/dyn-star/drop.run.stdout deleted file mode 100644 index dadb33ccf3a..00000000000 --- a/tests/ui/dyn-star/drop.run.stdout +++ /dev/null @@ -1 +0,0 @@ -destructor called diff --git a/tests/ui/dyn-star/dyn-async-trait.rs b/tests/ui/dyn-star/dyn-async-trait.rs deleted file mode 100644 index a673b269910..00000000000 --- a/tests/ui/dyn-star/dyn-async-trait.rs +++ /dev/null @@ -1,36 +0,0 @@ -//@ check-pass -//@ edition: 2021 - -// This test case is meant to demonstrate how close we can get to async -// functions in dyn traits with the current level of dyn* support. - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::future::Future; - -trait DynAsyncCounter { - fn increment<'a>(&'a mut self) -> dyn* Future<Output = usize> + 'a; -} - -struct MyCounter { - count: usize, -} - -impl DynAsyncCounter for MyCounter { - fn increment<'a>(&'a mut self) -> dyn* Future<Output = usize> + 'a { - Box::pin(async { - self.count += 1; - self.count - }) - } -} - -async fn do_counter(counter: &mut dyn DynAsyncCounter) -> usize { - counter.increment().await -} - -fn main() { - let mut counter = MyCounter { count: 0 }; - let _ = do_counter(&mut counter); -} diff --git a/tests/ui/dyn-star/dyn-pointer-like.rs b/tests/ui/dyn-star/dyn-pointer-like.rs deleted file mode 100644 index f26fa90505c..00000000000 --- a/tests/ui/dyn-star/dyn-pointer-like.rs +++ /dev/null @@ -1,23 +0,0 @@ -// Test that `dyn PointerLike` and `dyn* PointerLike` do not implement `PointerLike`. -// This used to ICE during codegen. - -#![crate_type = "lib"] - -#![feature(pointer_like_trait, dyn_star)] -#![feature(unsized_fn_params)] -#![expect(incomplete_features)] -#![expect(internal_features)] - -use std::marker::PointerLike; - -pub fn lol(x: dyn* PointerLike) { - foo(x); //~ ERROR `dyn* PointerLike` needs to have the same ABI as a pointer -} - -pub fn uwu(x: dyn PointerLike) { - foo(x); //~ ERROR `dyn PointerLike` needs to have the same ABI as a pointer -} - -fn foo<T: PointerLike + ?Sized>(x: T) { - let _: dyn* PointerLike = x; -} diff --git a/tests/ui/dyn-star/dyn-pointer-like.stderr b/tests/ui/dyn-star/dyn-pointer-like.stderr deleted file mode 100644 index 4c558e92d3f..00000000000 --- a/tests/ui/dyn-star/dyn-pointer-like.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error[E0277]: `dyn* PointerLike` needs to have the same ABI as a pointer - --> $DIR/dyn-pointer-like.rs:14:9 - | -LL | foo(x); - | --- ^ the trait `PointerLike` is not implemented for `dyn* PointerLike` - | | - | required by a bound introduced by this call - | - = note: the trait bound `dyn* PointerLike: PointerLike` is not satisfied -note: required by a bound in `foo` - --> $DIR/dyn-pointer-like.rs:21:11 - | -LL | fn foo<T: PointerLike + ?Sized>(x: T) { - | ^^^^^^^^^^^ required by this bound in `foo` -help: consider borrowing here - | -LL | foo(&x); - | + -LL | foo(&mut x); - | ++++ - -error[E0277]: `dyn PointerLike` needs to have the same ABI as a pointer - --> $DIR/dyn-pointer-like.rs:18:9 - | -LL | foo(x); - | --- ^ `dyn PointerLike` needs to be a pointer-like type - | | - | required by a bound introduced by this call - | - = help: the trait `PointerLike` is not implemented for `dyn PointerLike` -note: required by a bound in `foo` - --> $DIR/dyn-pointer-like.rs:21:11 - | -LL | fn foo<T: PointerLike + ?Sized>(x: T) { - | ^^^^^^^^^^^ required by this bound in `foo` - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/dyn-star-to-dyn.rs b/tests/ui/dyn-star/dyn-star-to-dyn.rs deleted file mode 100644 index 99f673df868..00000000000 --- a/tests/ui/dyn-star/dyn-star-to-dyn.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass - -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -use std::fmt::Debug; - -fn main() { - let x: dyn* Debug = &42; - let x = Box::new(x) as Box<dyn Debug>; - assert_eq!("42", format!("{x:?}")); - - // Also test opposite direction. - let x: Box<dyn Debug> = Box::new(42); - let x = &x as dyn* Debug; - assert_eq!("42", format!("{x:?}")); -} diff --git a/tests/ui/dyn-star/dyn-star-to-dyn.stderr b/tests/ui/dyn-star/dyn-star-to-dyn.stderr deleted file mode 100644 index 03aedf5f797..00000000000 --- a/tests/ui/dyn-star/dyn-star-to-dyn.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/dyn-star-to-dyn.rs:3:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/dyn-to-rigid.rs b/tests/ui/dyn-star/dyn-to-rigid.rs deleted file mode 100644 index dc33e288f24..00000000000 --- a/tests/ui/dyn-star/dyn-to-rigid.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![feature(dyn_star)] -#![allow(incomplete_features)] - -trait Tr {} - -fn f(x: dyn* Tr) -> usize { - x as usize - //~^ ERROR non-primitive cast: `(dyn* Tr + 'static)` as `usize` -} - -fn main() {} diff --git a/tests/ui/dyn-star/dyn-to-rigid.stderr b/tests/ui/dyn-star/dyn-to-rigid.stderr deleted file mode 100644 index 49b8f268aa4..00000000000 --- a/tests/ui/dyn-star/dyn-to-rigid.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0605]: non-primitive cast: `(dyn* Tr + 'static)` as `usize` - --> $DIR/dyn-to-rigid.rs:7:5 - | -LL | x as usize - | ^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/dyn-star/enum-cast.rs b/tests/ui/dyn-star/enum-cast.rs deleted file mode 100644 index 3cc7390eb12..00000000000 --- a/tests/ui/dyn-star/enum-cast.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ check-pass - -// This used to ICE, because the compiler confused a pointer-like to dyn* coercion -// with a c-like enum to integer cast. - -#![feature(dyn_star, pointer_like_trait)] -#![expect(incomplete_features)] - -use std::marker::PointerLike; - -#[repr(transparent)] -enum E { - Num(usize), -} - -impl PointerLike for E {} - -trait Trait {} -impl Trait for E {} - -fn main() { - let _ = E::Num(42) as dyn* Trait; -} diff --git a/tests/ui/dyn-star/error.rs b/tests/ui/dyn-star/error.rs deleted file mode 100644 index 1d252d2ce42..00000000000 --- a/tests/ui/dyn-star/error.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Debug; - -trait Foo {} - -fn make_dyn_star() { - let i = 42usize; - let dyn_i: dyn* Foo = i; //~ ERROR trait bound `usize: Foo` is not satisfied -} - -fn main() {} diff --git a/tests/ui/dyn-star/error.stderr b/tests/ui/dyn-star/error.stderr deleted file mode 100644 index 55981c03bac..00000000000 --- a/tests/ui/dyn-star/error.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0277]: the trait bound `usize: Foo` is not satisfied - --> $DIR/error.rs:10:27 - | -LL | let dyn_i: dyn* Foo = i; - | ^ the trait `Foo` is not implemented for `usize` - | -help: this trait has no implementations, consider adding one - --> $DIR/error.rs:6:1 - | -LL | trait Foo {} - | ^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/feature-gate-dyn_star.rs b/tests/ui/dyn-star/feature-gate-dyn_star.rs deleted file mode 100644 index b12fd7755be..00000000000 --- a/tests/ui/dyn-star/feature-gate-dyn_star.rs +++ /dev/null @@ -1,9 +0,0 @@ -// Feature gate test for dyn_star - -/// dyn* is not necessarily the final surface syntax (if we have one at all), -/// but for now we will support it to aid in writing tests independently. -pub fn dyn_star_parameter(_: &dyn* Send) { - //~^ ERROR `dyn*` trait objects are experimental -} - -fn main() {} diff --git a/tests/ui/dyn-star/feature-gate-dyn_star.stderr b/tests/ui/dyn-star/feature-gate-dyn_star.stderr deleted file mode 100644 index c3e99b20d06..00000000000 --- a/tests/ui/dyn-star/feature-gate-dyn_star.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: `dyn*` trait objects are experimental - --> $DIR/feature-gate-dyn_star.rs:5:31 - | -LL | pub fn dyn_star_parameter(_: &dyn* Send) { - | ^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = help: add `#![feature(dyn_star)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/dyn-star/float-as-dyn-star.rs b/tests/ui/dyn-star/float-as-dyn-star.rs deleted file mode 100644 index 1b629c64c25..00000000000 --- a/tests/ui/dyn-star/float-as-dyn-star.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ only-x86_64 - -#![feature(dyn_star, pointer_like_trait)] -//~^ WARN the feature `dyn_star` is incomplete - -use std::fmt::Debug; -use std::marker::PointerLike; - -fn make_dyn_star() -> dyn* Debug + 'static { - f32::from_bits(0x1) as f64 - //~^ ERROR `f64` needs to have the same ABI as a pointer -} - -fn main() { - println!("{:?}", make_dyn_star()); -} diff --git a/tests/ui/dyn-star/float-as-dyn-star.stderr b/tests/ui/dyn-star/float-as-dyn-star.stderr deleted file mode 100644 index 06071a27afc..00000000000 --- a/tests/ui/dyn-star/float-as-dyn-star.stderr +++ /dev/null @@ -1,23 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/float-as-dyn-star.rs:3:12 - | -LL | #![feature(dyn_star, pointer_like_trait)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: `f64` needs to have the same ABI as a pointer - --> $DIR/float-as-dyn-star.rs:10:5 - | -LL | f32::from_bits(0x1) as f64 - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `f64` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `f64` - = help: the following other types implement trait `PointerLike`: - isize - usize - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/gated-span.rs b/tests/ui/dyn-star/gated-span.rs deleted file mode 100644 index a747987bd24..00000000000 --- a/tests/ui/dyn-star/gated-span.rs +++ /dev/null @@ -1,8 +0,0 @@ -macro_rules! t { - ($t:ty) => {} -} - -t!(dyn* Send); -//~^ ERROR `dyn*` trait objects are experimental - -fn main() {} diff --git a/tests/ui/dyn-star/gated-span.stderr b/tests/ui/dyn-star/gated-span.stderr deleted file mode 100644 index 8ba6d7969fc..00000000000 --- a/tests/ui/dyn-star/gated-span.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0658]: `dyn*` trait objects are experimental - --> $DIR/gated-span.rs:5:4 - | -LL | t!(dyn* Send); - | ^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = help: add `#![feature(dyn_star)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/dyn-star/illegal.rs b/tests/ui/dyn-star/illegal.rs deleted file mode 100644 index ce0d784fcd2..00000000000 --- a/tests/ui/dyn-star/illegal.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete - -trait Foo {} - -pub fn lol(x: dyn* Foo + Send) { - x as dyn* Foo; - //~^ ERROR casting `(dyn* Foo + Send + 'static)` as `dyn* Foo` is invalid -} - -fn lol2(x: &dyn Foo) { - *x as dyn* Foo; - //~^ ERROR `dyn Foo` needs to have the same ABI as a pointer -} - -fn main() {} diff --git a/tests/ui/dyn-star/illegal.stderr b/tests/ui/dyn-star/illegal.stderr deleted file mode 100644 index fdf3c813a23..00000000000 --- a/tests/ui/dyn-star/illegal.stderr +++ /dev/null @@ -1,27 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/illegal.rs:1:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0606]: casting `(dyn* Foo + Send + 'static)` as `dyn* Foo` is invalid - --> $DIR/illegal.rs:7:5 - | -LL | x as dyn* Foo; - | ^^^^^^^^^^^^^ - -error[E0277]: `dyn Foo` needs to have the same ABI as a pointer - --> $DIR/illegal.rs:12:5 - | -LL | *x as dyn* Foo; - | ^^ `dyn Foo` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `dyn Foo` - -error: aborting due to 2 previous errors; 1 warning emitted - -Some errors have detailed explanations: E0277, E0606. -For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/issue-102430.rs b/tests/ui/dyn-star/issue-102430.rs deleted file mode 100644 index 4e48d5e2f5d..00000000000 --- a/tests/ui/dyn-star/issue-102430.rs +++ /dev/null @@ -1,32 +0,0 @@ -//@ check-pass - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -trait AddOne { - fn add1(&mut self) -> usize; -} - -impl AddOne for usize { - fn add1(&mut self) -> usize { - *self += 1; - *self - } -} - -impl AddOne for &mut usize { - fn add1(&mut self) -> usize { - (*self).add1() - } -} - -fn add_one(mut i: dyn* AddOne + '_) -> usize { - i.add1() -} - -fn main() { - let mut x = 42usize; - let y = &mut x as (dyn* AddOne + '_); - - println!("{}", add_one(y)); -} diff --git a/tests/ui/dyn-star/make-dyn-star.rs b/tests/ui/dyn-star/make-dyn-star.rs deleted file mode 100644 index 24004335f06..00000000000 --- a/tests/ui/dyn-star/make-dyn-star.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ run-pass -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Debug; - -fn make_dyn_star(i: usize) { - let _dyn_i: dyn* Debug = i; -} - -fn make_dyn_star_explicit(i: usize) { - let _dyn_i: dyn* Debug = i as dyn* Debug; -} - -fn main() { - make_dyn_star(42); - make_dyn_star_explicit(42); -} diff --git a/tests/ui/dyn-star/method.rs b/tests/ui/dyn-star/method.rs deleted file mode 100644 index 0d0855eec7f..00000000000 --- a/tests/ui/dyn-star/method.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ run-pass - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -trait Foo { - fn get(&self) -> usize; -} - -impl Foo for usize { - fn get(&self) -> usize { - *self - } -} - -fn invoke_dyn_star(i: dyn* Foo) -> usize { - i.get() -} - -fn make_and_invoke_dyn_star(i: usize) -> usize { - let dyn_i: dyn* Foo = i; - invoke_dyn_star(dyn_i) -} - -fn main() { - println!("{}", make_and_invoke_dyn_star(42)); -} diff --git a/tests/ui/dyn-star/no-explicit-dyn-star-cast.rs b/tests/ui/dyn-star/no-explicit-dyn-star-cast.rs deleted file mode 100644 index 2d28f516ab5..00000000000 --- a/tests/ui/dyn-star/no-explicit-dyn-star-cast.rs +++ /dev/null @@ -1,13 +0,0 @@ -use std::fmt::Debug; - -fn make_dyn_star() { - let i = 42usize; - let dyn_i: dyn* Debug = i as dyn* Debug; - //~^ ERROR casting `usize` as `dyn* Debug` is invalid - //~| ERROR `dyn*` trait objects are experimental - //~| ERROR `dyn*` trait objects are experimental -} - -fn main() { - make_dyn_star(); -} diff --git a/tests/ui/dyn-star/no-explicit-dyn-star-cast.stderr b/tests/ui/dyn-star/no-explicit-dyn-star-cast.stderr deleted file mode 100644 index bb4c612cedd..00000000000 --- a/tests/ui/dyn-star/no-explicit-dyn-star-cast.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error[E0658]: `dyn*` trait objects are experimental - --> $DIR/no-explicit-dyn-star-cast.rs:5:16 - | -LL | let dyn_i: dyn* Debug = i as dyn* Debug; - | ^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = help: add `#![feature(dyn_star)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0658]: `dyn*` trait objects are experimental - --> $DIR/no-explicit-dyn-star-cast.rs:5:34 - | -LL | let dyn_i: dyn* Debug = i as dyn* Debug; - | ^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = help: add `#![feature(dyn_star)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error[E0606]: casting `usize` as `dyn* Debug` is invalid - --> $DIR/no-explicit-dyn-star-cast.rs:5:29 - | -LL | let dyn_i: dyn* Debug = i as dyn* Debug; - | ^^^^^^^^^^^^^^^ - -error: aborting due to 3 previous errors - -Some errors have detailed explanations: E0606, E0658. -For more information about an error, try `rustc --explain E0606`. diff --git a/tests/ui/dyn-star/no-explicit-dyn-star.rs b/tests/ui/dyn-star/no-explicit-dyn-star.rs deleted file mode 100644 index 0847597450e..00000000000 --- a/tests/ui/dyn-star/no-explicit-dyn-star.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ aux-build:dyn-star-foreign.rs - -extern crate dyn_star_foreign; - -fn main() { - dyn_star_foreign::require_dyn_star_display(1usize as _); - //~^ ERROR casting `usize` as `dyn* std::fmt::Display` is invalid -} diff --git a/tests/ui/dyn-star/no-explicit-dyn-star.stderr b/tests/ui/dyn-star/no-explicit-dyn-star.stderr deleted file mode 100644 index 641404aa09e..00000000000 --- a/tests/ui/dyn-star/no-explicit-dyn-star.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0606]: casting `usize` as `dyn* std::fmt::Display` is invalid - --> $DIR/no-explicit-dyn-star.rs:6:48 - | -LL | dyn_star_foreign::require_dyn_star_display(1usize as _); - | ^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0606`. diff --git a/tests/ui/dyn-star/no-implicit-dyn-star.rs b/tests/ui/dyn-star/no-implicit-dyn-star.rs deleted file mode 100644 index 7af3f9a734b..00000000000 --- a/tests/ui/dyn-star/no-implicit-dyn-star.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ aux-build:dyn-star-foreign.rs - -extern crate dyn_star_foreign; - -fn main() { - dyn_star_foreign::require_dyn_star_display(1usize); - //~^ ERROR mismatched types -} diff --git a/tests/ui/dyn-star/no-implicit-dyn-star.stderr b/tests/ui/dyn-star/no-implicit-dyn-star.stderr deleted file mode 100644 index d1d3da9ca70..00000000000 --- a/tests/ui/dyn-star/no-implicit-dyn-star.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/no-implicit-dyn-star.rs:6:48 - | -LL | dyn_star_foreign::require_dyn_star_display(1usize); - | ------------------------------------------ ^^^^^^ expected `dyn Display`, found `usize` - | | - | arguments to this function are incorrect - | - = note: expected trait object `(dyn* std::fmt::Display + 'static)` - found type `usize` - = help: `usize` implements `Display`, `#[feature(dyn_star)]` is likely not enabled; that feature it is currently incomplete -note: function defined here - --> $DIR/auxiliary/dyn-star-foreign.rs:5:8 - | -LL | pub fn require_dyn_star_display(_: dyn* Display) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.rs b/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.rs deleted file mode 100644 index 1702fc1ed49..00000000000 --- a/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.rs +++ /dev/null @@ -1,13 +0,0 @@ -#![expect(incomplete_features)] -#![feature(dyn_star)] - -trait A: B {} -trait B {} -impl A for usize {} -impl B for usize {} - -fn main() { - let x: Box<dyn* A> = Box::new(1usize as dyn* A); - let y: Box<dyn* B> = x; - //~^ ERROR mismatched types -} diff --git a/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr b/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr deleted file mode 100644 index 289d85072e6..00000000000 --- a/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/no-unsize-coerce-dyn-trait.rs:11:26 - | -LL | let y: Box<dyn* B> = x; - | ----------- ^ expected trait `B`, found trait `A` - | | - | expected due to this - | - = note: expected struct `Box<dyn* B>` - found struct `Box<dyn* A>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/dyn-star/param-env-region-infer.current.stderr b/tests/ui/dyn-star/param-env-region-infer.current.stderr deleted file mode 100644 index 6e464c17014..00000000000 --- a/tests/ui/dyn-star/param-env-region-infer.current.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0282]: type annotations needed - --> $DIR/param-env-region-infer.rs:20:10 - | -LL | t as _ - | ^ cannot infer type - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/dyn-star/param-env-region-infer.rs b/tests/ui/dyn-star/param-env-region-infer.rs deleted file mode 100644 index 842964ad284..00000000000 --- a/tests/ui/dyn-star/param-env-region-infer.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ revisions: current -//@ incremental - -// FIXME(-Znext-solver): This currently results in unstable query results: -// `normalizes-to(opaque, opaque)` changes from `Maybe(Ambiguous)` to `Maybe(Overflow)` -// once the hidden type of the opaque is already defined to be itself. -//@ unused-revision-names: next - -// checks that we don't ICE if there are region inference variables in the environment -// when computing `PointerLike` builtin candidates. - -#![feature(dyn_star, pointer_like_trait)] -#![allow(incomplete_features)] - -use std::fmt::Debug; -use std::marker::PointerLike; - -fn make_dyn_star<'a, T: PointerLike + Debug + 'a>(t: T) -> impl PointerLike + Debug + 'a { - //[next]~^ ERROR cycle detected when computing - t as _ - //[current]~^ ERROR type annotations needed -} - -fn main() {} diff --git a/tests/ui/dyn-star/pointer-like-impl-rules.rs b/tests/ui/dyn-star/pointer-like-impl-rules.rs deleted file mode 100644 index c234e86e09a..00000000000 --- a/tests/ui/dyn-star/pointer-like-impl-rules.rs +++ /dev/null @@ -1,82 +0,0 @@ -//@ check-fail - -#![feature(extern_types)] -#![feature(pointer_like_trait)] - -use std::marker::PointerLike; - -struct NotReprTransparent; -impl PointerLike for NotReprTransparent {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: the struct `NotReprTransparent` is not `repr(transparent)` - -#[repr(transparent)] -struct FieldIsPl(usize); -impl PointerLike for FieldIsPl {} - -#[repr(transparent)] -struct FieldIsPlAndHasOtherField(usize, ()); -impl PointerLike for FieldIsPlAndHasOtherField {} - -#[repr(transparent)] -struct FieldIsNotPl(u8); -impl PointerLike for FieldIsNotPl {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: the field `0` of struct `FieldIsNotPl` does not implement `PointerLike` - -#[repr(transparent)] -struct GenericFieldIsNotPl<T>(T); -impl<T> PointerLike for GenericFieldIsNotPl<T> {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: the field `0` of struct `GenericFieldIsNotPl<T>` does not implement `PointerLike` - -#[repr(transparent)] -struct GenericFieldIsPl<T>(T); -impl<T: PointerLike> PointerLike for GenericFieldIsPl<T> {} - -#[repr(transparent)] -struct IsZeroSized(()); -impl PointerLike for IsZeroSized {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: the struct `IsZeroSized` is `repr(transparent)`, but does not have a non-trivial field - -trait SomeTrait {} -impl PointerLike for dyn SomeTrait {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: types of dynamic or unknown size - -extern "C" { - type ExternType; -} -impl PointerLike for ExternType {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: types of dynamic or unknown size - -struct LocalSizedType(&'static str); -struct LocalUnsizedType(str); - -// This is not a special error but a normal coherence error, -// which should still happen. -impl PointerLike for &LocalSizedType {} -//~^ ERROR: conflicting implementations of trait `PointerLike` -//~| NOTE: conflicting implementation in crate `core` - -impl PointerLike for &LocalUnsizedType {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: references to dynamically-sized types are too large to be `PointerLike` - -impl PointerLike for Box<LocalSizedType> {} -//~^ ERROR: conflicting implementations of trait `PointerLike` -//~| NOTE: conflicting implementation in crate `alloc` - -impl PointerLike for Box<LocalUnsizedType> {} -//~^ ERROR: implementation must be applied to type that -//~| NOTE: boxes of dynamically-sized types are too large to be `PointerLike` - -fn expects_pointer_like(x: impl PointerLike) {} - -fn main() { - expects_pointer_like(FieldIsPl(1usize)); - expects_pointer_like(FieldIsPlAndHasOtherField(1usize, ())); - expects_pointer_like(GenericFieldIsPl(1usize)); -} diff --git a/tests/ui/dyn-star/pointer-like-impl-rules.stderr b/tests/ui/dyn-star/pointer-like-impl-rules.stderr deleted file mode 100644 index 39f08f442c4..00000000000 --- a/tests/ui/dyn-star/pointer-like-impl-rules.stderr +++ /dev/null @@ -1,85 +0,0 @@ -error[E0119]: conflicting implementations of trait `PointerLike` for type `&LocalSizedType` - --> $DIR/pointer-like-impl-rules.rs:60:1 - | -LL | impl PointerLike for &LocalSizedType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: conflicting implementation in crate `core`: - - impl<T> PointerLike for &T; - -error[E0119]: conflicting implementations of trait `PointerLike` for type `Box<LocalSizedType>` - --> $DIR/pointer-like-impl-rules.rs:68:1 - | -LL | impl PointerLike for Box<LocalSizedType> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: conflicting implementation in crate `alloc`: - - impl<T> PointerLike for Box<T>; - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:9:1 - | -LL | impl PointerLike for NotReprTransparent {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the struct `NotReprTransparent` is not `repr(transparent)` - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:23:1 - | -LL | impl PointerLike for FieldIsNotPl {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the field `0` of struct `FieldIsNotPl` does not implement `PointerLike` - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:29:1 - | -LL | impl<T> PointerLike for GenericFieldIsNotPl<T> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the field `0` of struct `GenericFieldIsNotPl<T>` does not implement `PointerLike` - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:39:1 - | -LL | impl PointerLike for IsZeroSized {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: the struct `IsZeroSized` is `repr(transparent)`, but does not have a non-trivial field (it is zero-sized) - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:44:1 - | -LL | impl PointerLike for dyn SomeTrait {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: types of dynamic or unknown size may not implement `PointerLike` - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:51:1 - | -LL | impl PointerLike for ExternType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: types of dynamic or unknown size may not implement `PointerLike` - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:64:1 - | -LL | impl PointerLike for &LocalUnsizedType {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: references to dynamically-sized types are too large to be `PointerLike` - -error: implementation must be applied to type that has the same ABI as a pointer, or is `repr(transparent)` and whose field is `PointerLike` - --> $DIR/pointer-like-impl-rules.rs:72:1 - | -LL | impl PointerLike for Box<LocalUnsizedType> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: boxes of dynamically-sized types are too large to be `PointerLike` - -error: aborting due to 10 previous errors - -For more information about this error, try `rustc --explain E0119`. diff --git a/tests/ui/dyn-star/return.rs b/tests/ui/dyn-star/return.rs deleted file mode 100644 index 47d95d1d643..00000000000 --- a/tests/ui/dyn-star/return.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ check-pass - -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -fn _foo() -> dyn* Unpin { - 4usize -} - -fn main() {} diff --git a/tests/ui/dyn-star/return.stderr b/tests/ui/dyn-star/return.stderr deleted file mode 100644 index 9c265682904..00000000000 --- a/tests/ui/dyn-star/return.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/return.rs:3:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/syntax.rs b/tests/ui/dyn-star/syntax.rs deleted file mode 100644 index d4983404de2..00000000000 --- a/tests/ui/dyn-star/syntax.rs +++ /dev/null @@ -1,11 +0,0 @@ -// Make sure we can parse the `dyn* Trait` syntax -// -//@ check-pass - -#![feature(dyn_star)] -#![allow(incomplete_features)] - -pub fn dyn_star_parameter(_: dyn* Send) { -} - -fn main() {} diff --git a/tests/ui/dyn-star/thin.next.stderr b/tests/ui/dyn-star/thin.next.stderr deleted file mode 100644 index ef251062afc..00000000000 --- a/tests/ui/dyn-star/thin.next.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/thin.rs:6:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/thin.old.stderr b/tests/ui/dyn-star/thin.old.stderr deleted file mode 100644 index ef251062afc..00000000000 --- a/tests/ui/dyn-star/thin.old.stderr +++ /dev/null @@ -1,11 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/thin.rs:6:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -warning: 1 warning emitted - diff --git a/tests/ui/dyn-star/thin.rs b/tests/ui/dyn-star/thin.rs deleted file mode 100644 index 6df70f560de..00000000000 --- a/tests/ui/dyn-star/thin.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@check-pass -//@revisions: old next -//@[next] compile-flags: -Znext-solver - -#![feature(ptr_metadata)] -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -use std::fmt::Debug; -use std::ptr::Thin; - -fn check_thin<T: ?Sized + Thin>() {} - -fn main() { - check_thin::<dyn* Debug>(); -} diff --git a/tests/ui/dyn-star/union.rs b/tests/ui/dyn-star/union.rs deleted file mode 100644 index ad3a85a937a..00000000000 --- a/tests/ui/dyn-star/union.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(dyn_star)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - -union Union { - x: usize, -} - -trait Trait {} -impl Trait for Union {} - -fn bar(_: dyn* Trait) {} - -fn main() { - bar(Union { x: 0usize }); - //~^ ERROR `Union` needs to have the same ABI as a pointer -} diff --git a/tests/ui/dyn-star/union.stderr b/tests/ui/dyn-star/union.stderr deleted file mode 100644 index 906eb4f5163..00000000000 --- a/tests/ui/dyn-star/union.stderr +++ /dev/null @@ -1,20 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/union.rs:1:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: `Union` needs to have the same ABI as a pointer - --> $DIR/union.rs:14:9 - | -LL | bar(Union { x: 0usize }); - | ^^^^^^^^^^^^^^^^^^^ `Union` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `Union` - -error: aborting due to 1 previous error; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/dyn-star/unsize-into-ref-dyn-star.rs b/tests/ui/dyn-star/unsize-into-ref-dyn-star.rs deleted file mode 100644 index 1e8cafe1561..00000000000 --- a/tests/ui/dyn-star/unsize-into-ref-dyn-star.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(dyn_star)] -#![allow(incomplete_features)] - -use std::fmt::Debug; - -fn main() { - let i = 42 as &dyn* Debug; - //~^ ERROR non-primitive cast: `i32` as `&dyn* Debug` -} diff --git a/tests/ui/dyn-star/unsize-into-ref-dyn-star.stderr b/tests/ui/dyn-star/unsize-into-ref-dyn-star.stderr deleted file mode 100644 index b3274580afe..00000000000 --- a/tests/ui/dyn-star/unsize-into-ref-dyn-star.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0605]: non-primitive cast: `i32` as `&dyn* Debug` - --> $DIR/unsize-into-ref-dyn-star.rs:7:13 - | -LL | let i = 42 as &dyn* Debug; - | ^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/dyn-star/upcast.rs b/tests/ui/dyn-star/upcast.rs deleted file mode 100644 index 01e1b94f87e..00000000000 --- a/tests/ui/dyn-star/upcast.rs +++ /dev/null @@ -1,32 +0,0 @@ -//@ known-bug: #104800 - -#![feature(dyn_star)] - -trait Foo: Bar { - fn hello(&self); -} - -trait Bar { - fn world(&self); -} - -struct W(usize); - -impl Foo for W { - fn hello(&self) { - println!("hello!"); - } -} - -impl Bar for W { - fn world(&self) { - println!("world!"); - } -} - -fn main() { - let w: dyn* Foo = W(0); - w.hello(); - let w: dyn* Bar = w; - w.world(); -} diff --git a/tests/ui/dyn-star/upcast.stderr b/tests/ui/dyn-star/upcast.stderr deleted file mode 100644 index 3f244d4b6ae..00000000000 --- a/tests/ui/dyn-star/upcast.stderr +++ /dev/null @@ -1,28 +0,0 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/upcast.rs:3:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - -error[E0277]: `W` needs to have the same ABI as a pointer - --> $DIR/upcast.rs:28:23 - | -LL | let w: dyn* Foo = W(0); - | ^^^^ `W` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `W` - -error[E0277]: `dyn* Foo` needs to have the same ABI as a pointer - --> $DIR/upcast.rs:30:23 - | -LL | let w: dyn* Bar = w; - | ^ `dyn* Foo` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `dyn* Foo` - -error: aborting due to 2 previous errors; 1 warning emitted - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/early-ret-binop-add.rs b/tests/ui/early-ret-binop-add.rs deleted file mode 100644 index 3fec66f35fb..00000000000 --- a/tests/ui/early-ret-binop-add.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -#![allow(unreachable_code)] - -use std::ops::Add; - -fn wsucc<T:Add<Output=T> + Copy>(n: T) -> T { n + { return n } } - -pub fn main() { } diff --git a/tests/ui/elide-errors-on-mismatched-tuple.rs b/tests/ui/elide-errors-on-mismatched-tuple.rs deleted file mode 100644 index 7d87b0a7756..00000000000 --- a/tests/ui/elide-errors-on-mismatched-tuple.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Hide irrelevant E0277 errors (#50333) - -trait T {} - -struct A; -impl T for A {} -impl A { - fn new() -> Self { - Self {} - } -} - -fn main() { - let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three - //~^ ERROR mismatched types - let ts: Vec<&dyn T> = vec![&a, &b, &c]; - // There is no E0277 error above, as `a`, `b` and `c` are `TyErr` -} diff --git a/tests/ui/elided-test.rs b/tests/ui/elided-test.rs deleted file mode 100644 index 2bedc25e17b..00000000000 --- a/tests/ui/elided-test.rs +++ /dev/null @@ -1,5 +0,0 @@ -// Since we're not compiling a test runner this function should be elided -// and the build will fail because main doesn't exist -#[test] -fn main() { -} //~ ERROR `main` function not found in crate `elided_test` diff --git a/tests/ui/elided-test.stderr b/tests/ui/elided-test.stderr deleted file mode 100644 index 7aebe5d8264..00000000000 --- a/tests/ui/elided-test.stderr +++ /dev/null @@ -1,9 +0,0 @@ -error[E0601]: `main` function not found in crate `elided_test` - --> $DIR/elided-test.rs:5:2 - | -LL | } - | ^ consider adding a `main` function to `$DIR/elided-test.rs` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0601`. diff --git a/tests/ui/else-if.rs b/tests/ui/else-if.rs deleted file mode 100644 index 2161b28c58c..00000000000 --- a/tests/ui/else-if.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ run-pass - -pub fn main() { - if 1 == 2 { - assert!((false)); - } else if 2 == 3 { - assert!((false)); - } else if 3 == 4 { assert!((false)); } else { assert!((true)); } - if 1 == 2 { assert!((false)); } else if 2 == 2 { assert!((true)); } - if 1 == 2 { - assert!((false)); - } else if 2 == 2 { - if 1 == 1 { - assert!((true)); - } else { if 2 == 1 { assert!((false)); } else { assert!((false)); } } - } - if 1 == 2 { - assert!((false)); - } else { if 1 == 2 { assert!((false)); } else { assert!((true)); } } -} diff --git a/tests/ui/empty/empty-attributes.stderr b/tests/ui/empty/empty-attributes.stderr index e86dea10c70..f0be56ddc6a 100644 --- a/tests/ui/empty/empty-attributes.stderr +++ b/tests/ui/empty/empty-attributes.stderr @@ -1,10 +1,10 @@ error: unused attribute - --> $DIR/empty-attributes.rs:9:1 + --> $DIR/empty-attributes.rs:2:1 | -LL | #[repr()] - | ^^^^^^^^^ help: remove this attribute +LL | #![allow()] + | ^^^^^^^^^^^ help: remove this attribute | - = note: attribute `repr` with an empty list has no effect + = note: attribute `allow` with an empty list has no effect note: the lint level is defined here --> $DIR/empty-attributes.rs:1:9 | @@ -12,22 +12,6 @@ LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ error: unused attribute - --> $DIR/empty-attributes.rs:12:1 - | -LL | #[target_feature()] - | ^^^^^^^^^^^^^^^^^^^ help: remove this attribute - | - = note: attribute `target_feature` with an empty list has no effect - -error: unused attribute - --> $DIR/empty-attributes.rs:2:1 - | -LL | #![allow()] - | ^^^^^^^^^^^ help: remove this attribute - | - = note: attribute `allow` with an empty list has no effect - -error: unused attribute --> $DIR/empty-attributes.rs:3:1 | LL | #![expect()] @@ -67,5 +51,17 @@ LL | #![feature()] | = note: attribute `feature` with an empty list has no effect +error: unused attribute + --> $DIR/empty-attributes.rs:9:1 + | +LL | #[repr()] + | ^^^^^^^^^ help: remove this attribute + +error: unused attribute + --> $DIR/empty-attributes.rs:12:1 + | +LL | #[target_feature()] + | ^^^^^^^^^^^^^^^^^^^ help: remove this attribute + error: aborting due to 8 previous errors diff --git a/tests/ui/enum-discriminant/eval-error.stderr b/tests/ui/enum-discriminant/eval-error.stderr index c29d258a90b..77449656ea6 100644 --- a/tests/ui/enum-discriminant/eval-error.stderr +++ b/tests/ui/enum-discriminant/eval-error.stderr @@ -15,6 +15,18 @@ LL | | A LL | | } | |_- not a struct or union +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/eval-error.rs:2:5 + | +LL | a: str, + | ^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | a: std::mem::ManuallyDrop<str>, + | +++++++++++++++++++++++ + + error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/eval-error.rs:2:8 | @@ -33,18 +45,6 @@ help: the `Box` type always has a statically known size and allocates its conten LL | a: Box<str>, | ++++ + -error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/eval-error.rs:2:5 - | -LL | a: str, - | ^^^^^^ - | - = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` -help: wrap the field type in `ManuallyDrop<...>` - | -LL | a: std::mem::ManuallyDrop<str>, - | +++++++++++++++++++++++ + - error[E0080]: the type `Foo` has an unknown layout --> $DIR/eval-error.rs:9:30 | diff --git a/tests/ui/error-codes/E0017.rs b/tests/ui/error-codes/E0017.rs index 8c685aad030..0f00ddac579 100644 --- a/tests/ui/error-codes/E0017.rs +++ b/tests/ui/error-codes/E0017.rs @@ -5,12 +5,12 @@ static X: i32 = 1; const C: i32 = 2; static mut M: i32 = 3; -const CR: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed +const CR: &'static mut i32 = &mut C; //~ ERROR mutable borrows of temporaries //~| WARN taking a mutable static STATIC_REF: &'static mut i32 = &mut X; //~ ERROR cannot borrow immutable static item `X` as mutable -static CONST_REF: &'static mut i32 = &mut C; //~ ERROR mutable references are not allowed +static CONST_REF: &'static mut i32 = &mut C; //~ ERROR mutable borrows of temporaries //~| WARN taking a mutable fn main() {} diff --git a/tests/ui/error-codes/E0017.stderr b/tests/ui/error-codes/E0017.stderr index 285d363592f..2039e556470 100644 --- a/tests/ui/error-codes/E0017.stderr +++ b/tests/ui/error-codes/E0017.stderr @@ -13,11 +13,15 @@ LL | const C: i32 = 2; | ^^^^^^^^^^^^ = note: `#[warn(const_item_mutation)]` on by default -error[E0764]: mutable references are not allowed in the final value of constants +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/E0017.rs:8:30 | LL | const CR: &'static mut i32 = &mut C; - | ^^^^^^ + | ^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0596]: cannot borrow immutable static item `X` as mutable --> $DIR/E0017.rs:11:39 @@ -39,11 +43,15 @@ note: `const` item defined here LL | const C: i32 = 2; | ^^^^^^^^^^^^ -error[E0764]: mutable references are not allowed in the final value of statics +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/E0017.rs:13:38 | LL | static CONST_REF: &'static mut i32 = &mut C; - | ^^^^^^ + | ^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 3 previous errors; 2 warnings emitted diff --git a/tests/ui/error-codes/E0261.stderr b/tests/ui/error-codes/E0261.stderr index 0eab2dc0ee0..9ca26dc8459 100644 --- a/tests/ui/error-codes/E0261.stderr +++ b/tests/ui/error-codes/E0261.stderr @@ -2,17 +2,23 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/E0261.rs:1:12 | LL | fn foo(x: &'a str) { } - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `<'a>` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn foo<'a>(x: &'a str) { } + | ++++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/E0261.rs:5:9 | -LL | struct Foo { - | - help: consider introducing lifetime `'a` here: `<'a>` LL | x: &'a str, | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | struct Foo<'a> { + | ++++ error: aborting due to 2 previous errors diff --git a/tests/ui/error-codes/E0492.stderr b/tests/ui/error-codes/E0492.stderr index 557c977e87d..43a3a872e4e 100644 --- a/tests/ui/error-codes/E0492.stderr +++ b/tests/ui/error-codes/E0492.stderr @@ -1,16 +1,22 @@ -error[E0492]: constants cannot refer to interior mutable data +error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/E0492.rs:4:33 | LL | const B: &'static AtomicUsize = &A; - | ^^ this borrow of an interior mutable value may end up in the final value + | ^^ this borrow of an interior mutable value refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` -error[E0492]: statics cannot refer to interior mutable data +error[E0492]: interior mutable shared borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/E0492.rs:5:34 | LL | static C: &'static AtomicUsize = &A; - | ^^ this borrow of an interior mutable value may end up in the final value + | ^^ this borrow of an interior mutable value refers to such a temporary | - = help: to fix this, the value can be extracted to a separate `static` item and then referenced + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 2 previous errors diff --git a/tests/ui/error-codes/E0637.stderr b/tests/ui/error-codes/E0637.stderr index 95a5a58ab85..88c08cb94ba 100644 --- a/tests/ui/error-codes/E0637.stderr +++ b/tests/ui/error-codes/E0637.stderr @@ -3,6 +3,8 @@ error[E0637]: `'_` cannot be used here | LL | fn underscore_lifetime<'_>(str1: &'_ str, str2: &'_ str) -> &'_ str { | ^^ `'_` is a reserved lifetime name + | + = help: use another lifetime specifier error[E0106]: missing lifetime specifier --> $DIR/E0637.rs:1:62 diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr index 3ddff11798d..229bfbe59e5 100644 --- a/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr +++ b/tests/ui/errors/remap-path-prefix-diagnostics.not-diag-in-deps.stderr @@ -2,10 +2,8 @@ error[E0277]: `A` doesn't implement `std::fmt::Display` --> remapped/errors/remap-path-prefix-diagnostics.rs:LL:COL | LL | impl r#trait::Trait for A {} - | ^ `A` cannot be formatted with the default formatter + | ^ the trait `std::fmt::Display` is not implemented for `A` | - = help: the trait `std::fmt::Display` is not implemented for `A` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `Trait` --> $DIR/auxiliary/trait.rs:LL:COL | diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.only-debuginfo-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.only-debuginfo-in-deps.stderr index 85c781425b1..a59af3b6a82 100644 --- a/tests/ui/errors/remap-path-prefix-diagnostics.only-debuginfo-in-deps.stderr +++ b/tests/ui/errors/remap-path-prefix-diagnostics.only-debuginfo-in-deps.stderr @@ -2,10 +2,8 @@ error[E0277]: `A` doesn't implement `std::fmt::Display` --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL | LL | impl r#trait::Trait for A {} - | ^ `A` cannot be formatted with the default formatter + | ^ the trait `std::fmt::Display` is not implemented for `A` | - = help: the trait `std::fmt::Display` is not implemented for `A` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `Trait` --> $DIR/auxiliary/trait-debuginfo.rs:LL:COL | diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr index 792ea7925ad..18fb9afcf39 100644 --- a/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr +++ b/tests/ui/errors/remap-path-prefix-diagnostics.only-diag-in-deps.stderr @@ -2,10 +2,8 @@ error[E0277]: `A` doesn't implement `std::fmt::Display` --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL | LL | impl r#trait::Trait for A {} - | ^ `A` cannot be formatted with the default formatter + | ^ the trait `std::fmt::Display` is not implemented for `A` | - = help: the trait `std::fmt::Display` is not implemented for `A` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `Trait` --> $DIR/auxiliary/trait-diag.rs:LL:COL | diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.only-macro-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.only-macro-in-deps.stderr index d13333d2e48..9e770f07fba 100644 --- a/tests/ui/errors/remap-path-prefix-diagnostics.only-macro-in-deps.stderr +++ b/tests/ui/errors/remap-path-prefix-diagnostics.only-macro-in-deps.stderr @@ -2,10 +2,8 @@ error[E0277]: `A` doesn't implement `std::fmt::Display` --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL | LL | impl r#trait::Trait for A {} - | ^ `A` cannot be formatted with the default formatter + | ^ the trait `std::fmt::Display` is not implemented for `A` | - = help: the trait `std::fmt::Display` is not implemented for `A` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `Trait` --> $DIR/auxiliary/trait-macro.rs:LL:COL | diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.with-debuginfo-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.with-debuginfo-in-deps.stderr index 85c781425b1..a59af3b6a82 100644 --- a/tests/ui/errors/remap-path-prefix-diagnostics.with-debuginfo-in-deps.stderr +++ b/tests/ui/errors/remap-path-prefix-diagnostics.with-debuginfo-in-deps.stderr @@ -2,10 +2,8 @@ error[E0277]: `A` doesn't implement `std::fmt::Display` --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL | LL | impl r#trait::Trait for A {} - | ^ `A` cannot be formatted with the default formatter + | ^ the trait `std::fmt::Display` is not implemented for `A` | - = help: the trait `std::fmt::Display` is not implemented for `A` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `Trait` --> $DIR/auxiliary/trait-debuginfo.rs:LL:COL | diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr index 08f7fb2c736..ca6f2b1697a 100644 --- a/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr +++ b/tests/ui/errors/remap-path-prefix-diagnostics.with-diag-in-deps.stderr @@ -2,10 +2,8 @@ error[E0277]: `A` doesn't implement `std::fmt::Display` --> remapped/errors/remap-path-prefix-diagnostics.rs:LL:COL | LL | impl r#trait::Trait for A {} - | ^ `A` cannot be formatted with the default formatter + | ^ the trait `std::fmt::Display` is not implemented for `A` | - = help: the trait `std::fmt::Display` is not implemented for `A` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `Trait` --> remapped/errors/auxiliary/trait-diag.rs:LL:COL | diff --git a/tests/ui/errors/remap-path-prefix-diagnostics.with-macro-in-deps.stderr b/tests/ui/errors/remap-path-prefix-diagnostics.with-macro-in-deps.stderr index d13333d2e48..9e770f07fba 100644 --- a/tests/ui/errors/remap-path-prefix-diagnostics.with-macro-in-deps.stderr +++ b/tests/ui/errors/remap-path-prefix-diagnostics.with-macro-in-deps.stderr @@ -2,10 +2,8 @@ error[E0277]: `A` doesn't implement `std::fmt::Display` --> $DIR/remap-path-prefix-diagnostics.rs:LL:COL | LL | impl r#trait::Trait for A {} - | ^ `A` cannot be formatted with the default formatter + | ^ the trait `std::fmt::Display` is not implemented for `A` | - = help: the trait `std::fmt::Display` is not implemented for `A` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `Trait` --> $DIR/auxiliary/trait-macro.rs:LL:COL | diff --git a/tests/ui/expr/early-return-in-binop.rs b/tests/ui/expr/early-return-in-binop.rs new file mode 100644 index 00000000000..389d25210f7 --- /dev/null +++ b/tests/ui/expr/early-return-in-binop.rs @@ -0,0 +1,19 @@ +//! Test early return within binary operation expressions + +//@ run-pass + +#![allow(dead_code)] +#![allow(unreachable_code)] + +use std::ops::Add; + +/// Function that performs addition with an early return in the right operand +fn add_with_early_return<T: Add<Output = T> + Copy>(n: T) -> T { + n + { return n } +} + +pub fn main() { + // Test with different numeric types to ensure generic behavior works + let _result1 = add_with_early_return(42i32); + let _result2 = add_with_early_return(3.14f64); +} diff --git a/tests/ui/expr/if/if-else-chain-missing-else.stderr b/tests/ui/expr/if/if-else-chain-missing-else.stderr index 374c4927e30..6c437120d39 100644 --- a/tests/ui/expr/if/if-else-chain-missing-else.stderr +++ b/tests/ui/expr/if/if-else-chain-missing-else.stderr @@ -1,18 +1,15 @@ error[E0308]: `if` and `else` have incompatible types --> $DIR/if-else-chain-missing-else.rs:12:12 | -LL | let x = if let Ok(x) = res { - | ______________- -LL | | x - | | - expected because of this -LL | | } else if let Err(e) = res { - | | ____________^ -LL | || return Err(e); -LL | || }; - | || ^ - | ||_____| - | |_____`if` and `else` have incompatible types - | expected `i32`, found `()` +LL | let x = if let Ok(x) = res { + | ------------------ `if` and `else` have incompatible types +LL | x + | - expected because of this +LL | } else if let Err(e) = res { + | ____________^ +LL | | return Err(e); +LL | | }; + | |_____^ expected `i32`, found `()` | = note: `if` expressions without `else` evaluate to `()` = note: consider adding an `else` block that evaluates to the expected type diff --git a/tests/ui/expr/if/if-else-type-mismatch.stderr b/tests/ui/expr/if/if-else-type-mismatch.stderr index 1cf94c98800..56181267a31 100644 --- a/tests/ui/expr/if/if-else-type-mismatch.stderr +++ b/tests/ui/expr/if/if-else-type-mismatch.stderr @@ -92,13 +92,16 @@ LL | | }; error[E0308]: `if` and `else` have incompatible types --> $DIR/if-else-type-mismatch.rs:37:9 | -LL | let _ = if true { - | _____________________- -LL | | -LL | | } else { - | |_____- expected because of this -LL | 11u32 - | ^^^^^ expected `()`, found `u32` +LL | let _ = if true { + | ______________- - + | | _____________________| +LL | || +LL | || } else { + | ||_____- expected because of this +LL | | 11u32 + | | ^^^^^ expected `()`, found `u32` +LL | | }; + | |______- `if` and `else` have incompatible types error[E0308]: `if` and `else` have incompatible types --> $DIR/if-else-type-mismatch.rs:42:12 diff --git a/tests/ui/extern-flag/auxiliary/panic_handler.rs b/tests/ui/extern-flag/auxiliary/panic_handler.rs index 9140ceed229..9607f0ed013 100644 --- a/tests/ui/extern-flag/auxiliary/panic_handler.rs +++ b/tests/ui/extern-flag/auxiliary/panic_handler.rs @@ -12,4 +12,12 @@ pub fn begin_panic_handler(_info: &core::panic::PanicInfo<'_>) -> ! { } #[lang = "eh_personality"] -extern "C" fn eh_personality() {} +extern "C" fn eh_personality( + _version: i32, + _actions: i32, + _exception_class: u64, + _exception_object: *mut (), + _context: *mut (), +) -> i32 { + loop {} +} diff --git a/tests/ui/extern/issue-36122-accessing-externed-dst.stderr b/tests/ui/extern/issue-36122-accessing-externed-dst.stderr index 6f805aec1df..8007c3f13e5 100644 --- a/tests/ui/extern/issue-36122-accessing-externed-dst.stderr +++ b/tests/ui/extern/issue-36122-accessing-externed-dst.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `[usize]` cannot be known at compilation time - --> $DIR/issue-36122-accessing-externed-dst.rs:3:24 + --> $DIR/issue-36122-accessing-externed-dst.rs:3:9 | LL | static symbol: [usize]; - | ^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[usize]` = note: statics and constants must have a statically known size diff --git a/tests/ui/extern/issue-47725.rs b/tests/ui/extern/issue-47725.rs index 9ec55be5872..60d0cd62347 100644 --- a/tests/ui/extern/issue-47725.rs +++ b/tests/ui/extern/issue-47725.rs @@ -17,12 +17,8 @@ extern "C" { #[link_name] //~^ ERROR malformed `link_name` attribute input //~| HELP must be of the form -//~| WARN attribute should be applied to a foreign function or static [unused_attributes] -//~| WARN this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -//~| HELP try `#[link(name = "...")]` instead extern "C" { fn bar() -> u32; } -//~^^^ NOTE not a foreign function or static fn main() {} diff --git a/tests/ui/extern/issue-47725.stderr b/tests/ui/extern/issue-47725.stderr index 0d3b77b4608..4fd02a1778b 100644 --- a/tests/ui/extern/issue-47725.stderr +++ b/tests/ui/extern/issue-47725.stderr @@ -1,4 +1,4 @@ -error: malformed `link_name` attribute input +error[E0539]: malformed `link_name` attribute input --> $DIR/issue-47725.rs:17:1 | LL | #[link_name] @@ -38,23 +38,6 @@ help: try `#[link(name = "foobar")]` instead LL | #[link_name = "foobar"] | ^^^^^^^^^^^^^^^^^^^^^^^ -warning: attribute should be applied to a foreign function or static - --> $DIR/issue-47725.rs:17:1 - | -LL | #[link_name] - | ^^^^^^^^^^^^ -... -LL | / extern "C" { -LL | | fn bar() -> u32; -LL | | } - | |_- not a foreign function or static - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -help: try `#[link(name = "...")]` instead - --> $DIR/issue-47725.rs:17:1 - | -LL | #[link_name] - | ^^^^^^^^^^^^ - -error: aborting due to 1 previous error; 3 warnings emitted +error: aborting due to 1 previous error; 2 warnings emitted +For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/feature-gates/feature-gate-abi-custom.rs b/tests/ui/feature-gates/feature-gate-abi-custom.rs index 3ddce974dd7..312b6230b74 100644 --- a/tests/ui/feature-gates/feature-gate-abi-custom.rs +++ b/tests/ui/feature-gates/feature-gate-abi-custom.rs @@ -15,11 +15,11 @@ unsafe extern "custom" fn f7() { trait Tr { extern "custom" fn m7(); //~^ ERROR "custom" ABI is experimental - //~| ERROR functions with the `"custom"` ABI must be unsafe + //~| ERROR functions with the "custom" ABI must be unsafe #[unsafe(naked)] extern "custom" fn dm7() { //~^ ERROR "custom" ABI is experimental - //~| ERROR functions with the `"custom"` ABI must be unsafe + //~| ERROR functions with the "custom" ABI must be unsafe naked_asm!("") } } @@ -31,7 +31,7 @@ impl Tr for S { #[unsafe(naked)] extern "custom" fn m7() { //~^ ERROR "custom" ABI is experimental - //~| ERROR functions with the `"custom"` ABI must be unsafe + //~| ERROR functions with the "custom" ABI must be unsafe naked_asm!("") } } @@ -41,7 +41,7 @@ impl S { #[unsafe(naked)] extern "custom" fn im7() { //~^ ERROR "custom" ABI is experimental - //~| ERROR functions with the `"custom"` ABI must be unsafe + //~| ERROR functions with the "custom" ABI must be unsafe naked_asm!("") } } diff --git a/tests/ui/feature-gates/feature-gate-abi-custom.stderr b/tests/ui/feature-gates/feature-gate-abi-custom.stderr index e6dce0126d6..e359dbb5ebe 100644 --- a/tests/ui/feature-gates/feature-gate-abi-custom.stderr +++ b/tests/ui/feature-gates/feature-gate-abi-custom.stderr @@ -1,4 +1,4 @@ -error: functions with the `"custom"` ABI must be unsafe +error: functions with the "custom" ABI must be unsafe --> $DIR/feature-gate-abi-custom.rs:16:5 | LL | extern "custom" fn m7(); @@ -9,7 +9,7 @@ help: add the `unsafe` keyword to this definition LL | unsafe extern "custom" fn m7(); | ++++++ -error: functions with the `"custom"` ABI must be unsafe +error: functions with the "custom" ABI must be unsafe --> $DIR/feature-gate-abi-custom.rs:20:5 | LL | extern "custom" fn dm7() { @@ -20,7 +20,7 @@ help: add the `unsafe` keyword to this definition LL | unsafe extern "custom" fn dm7() { | ++++++ -error: functions with the `"custom"` ABI must be unsafe +error: functions with the "custom" ABI must be unsafe --> $DIR/feature-gate-abi-custom.rs:32:5 | LL | extern "custom" fn m7() { @@ -31,7 +31,7 @@ help: add the `unsafe` keyword to this definition LL | unsafe extern "custom" fn m7() { | ++++++ -error: functions with the `"custom"` ABI must be unsafe +error: functions with the "custom" ABI must be unsafe --> $DIR/feature-gate-abi-custom.rs:42:5 | LL | extern "custom" fn im7() { diff --git a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.AMDGPU.stderr b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.AMDGPU.stderr index fca32c5c1e6..4fa3fee942e 100644 --- a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.AMDGPU.stderr +++ b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.AMDGPU.stderr @@ -19,7 +19,7 @@ LL | extern "gpu-kernel" fn m1(_: ()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:23:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:24:12 | LL | extern "gpu-kernel" fn dm1(_: ()) {} | ^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | extern "gpu-kernel" fn dm1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:31:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:32:12 | LL | extern "gpu-kernel" fn m1(_: ()) {} | ^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | extern "gpu-kernel" fn m1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:37:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:38:12 | LL | extern "gpu-kernel" fn im1(_: ()) {} | ^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | extern "gpu-kernel" fn im1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:42:18 + --> $DIR/feature-gate-abi_gpu_kernel.rs:43:18 | LL | type A1 = extern "gpu-kernel" fn(_: ()); | ^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.HOST.stderr b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.HOST.stderr index cc81289f6b7..88734bc9d22 100644 --- a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.HOST.stderr +++ b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.HOST.stderr @@ -1,3 +1,9 @@ +error[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/feature-gate-abi_gpu_kernel.rs:16:8 + | +LL | extern "gpu-kernel" fn f1(_: ()) {} + | ^^^^^^^^^^^^ + error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_gpu_kernel.rs:16:8 | @@ -8,6 +14,12 @@ LL | extern "gpu-kernel" fn f1(_: ()) {} = help: add `#![feature(abi_gpu_kernel)]` 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[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/feature-gate-abi_gpu_kernel.rs:21:12 + | +LL | extern "gpu-kernel" fn m1(_: ()); + | ^^^^^^^^^^^^ + error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_gpu_kernel.rs:21:12 | @@ -18,8 +30,14 @@ LL | extern "gpu-kernel" fn m1(_: ()); = help: add `#![feature(abi_gpu_kernel)]` 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[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/feature-gate-abi_gpu_kernel.rs:24:12 + | +LL | extern "gpu-kernel" fn dm1(_: ()) {} + | ^^^^^^^^^^^^ + error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:23:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:24:12 | LL | extern "gpu-kernel" fn dm1(_: ()) {} | ^^^^^^^^^^^^ @@ -28,8 +46,14 @@ LL | extern "gpu-kernel" fn dm1(_: ()) {} = help: add `#![feature(abi_gpu_kernel)]` 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[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/feature-gate-abi_gpu_kernel.rs:32:12 + | +LL | extern "gpu-kernel" fn m1(_: ()) {} + | ^^^^^^^^^^^^ + error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:31:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:32:12 | LL | extern "gpu-kernel" fn m1(_: ()) {} | ^^^^^^^^^^^^ @@ -38,8 +62,14 @@ LL | extern "gpu-kernel" fn m1(_: ()) {} = help: add `#![feature(abi_gpu_kernel)]` 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[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/feature-gate-abi_gpu_kernel.rs:38:12 + | +LL | extern "gpu-kernel" fn im1(_: ()) {} + | ^^^^^^^^^^^^ + error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:37:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:38:12 | LL | extern "gpu-kernel" fn im1(_: ()) {} | ^^^^^^^^^^^^ @@ -48,8 +78,14 @@ LL | extern "gpu-kernel" fn im1(_: ()) {} = help: add `#![feature(abi_gpu_kernel)]` 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[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/feature-gate-abi_gpu_kernel.rs:43:18 + | +LL | type A1 = extern "gpu-kernel" fn(_: ()); + | ^^^^^^^^^^^^ + error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:42:18 + --> $DIR/feature-gate-abi_gpu_kernel.rs:43:18 | LL | type A1 = extern "gpu-kernel" fn(_: ()); | ^^^^^^^^^^^^ @@ -58,6 +94,12 @@ LL | type A1 = extern "gpu-kernel" fn(_: ()); = help: add `#![feature(abi_gpu_kernel)]` 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[E0570]: "gpu-kernel" is not a supported ABI for the current target + --> $DIR/feature-gate-abi_gpu_kernel.rs:47:8 + | +LL | extern "gpu-kernel" {} + | ^^^^^^^^^^^^ + error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change --> $DIR/feature-gate-abi_gpu_kernel.rs:47:8 | @@ -68,58 +110,7 @@ LL | extern "gpu-kernel" {} = help: add `#![feature(abi_gpu_kernel)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -warning: the calling convention "gpu-kernel" is not supported on this target - --> $DIR/feature-gate-abi_gpu_kernel.rs:42:11 - | -LL | type A1 = extern "gpu-kernel" fn(_: ()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - -error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:47:1 - | -LL | extern "gpu-kernel" {} - | ^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:16:1 - | -LL | extern "gpu-kernel" fn f1(_: ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:23:5 - | -LL | extern "gpu-kernel" fn dm1(_: ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:31:5 - | -LL | extern "gpu-kernel" fn m1(_: ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0570]: `"gpu-kernel"` is not a supported ABI for the current target - --> $DIR/feature-gate-abi_gpu_kernel.rs:37:5 - | -LL | extern "gpu-kernel" fn im1(_: ()) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 12 previous errors; 1 warning emitted +error: aborting due to 14 previous errors Some errors have detailed explanations: E0570, E0658. For more information about an error, try `rustc --explain E0570`. -Future incompatibility report: Future breakage diagnostic: -warning: the calling convention "gpu-kernel" is not supported on this target - --> $DIR/feature-gate-abi_gpu_kernel.rs:42:11 - | -LL | type A1 = extern "gpu-kernel" fn(_: ()); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #130260 <https://github.com/rust-lang/rust/issues/130260> - = note: `#[warn(unsupported_fn_ptr_calling_conventions)]` on by default - diff --git a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.NVPTX.stderr b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.NVPTX.stderr index fca32c5c1e6..4fa3fee942e 100644 --- a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.NVPTX.stderr +++ b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.NVPTX.stderr @@ -19,7 +19,7 @@ LL | extern "gpu-kernel" fn m1(_: ()); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:23:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:24:12 | LL | extern "gpu-kernel" fn dm1(_: ()) {} | ^^^^^^^^^^^^ @@ -29,7 +29,7 @@ LL | extern "gpu-kernel" fn dm1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:31:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:32:12 | LL | extern "gpu-kernel" fn m1(_: ()) {} | ^^^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | extern "gpu-kernel" fn m1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:37:12 + --> $DIR/feature-gate-abi_gpu_kernel.rs:38:12 | LL | extern "gpu-kernel" fn im1(_: ()) {} | ^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | extern "gpu-kernel" fn im1(_: ()) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: the extern "gpu-kernel" ABI is experimental and subject to change - --> $DIR/feature-gate-abi_gpu_kernel.rs:42:18 + --> $DIR/feature-gate-abi_gpu_kernel.rs:43:18 | LL | type A1 = extern "gpu-kernel" fn(_: ()); | ^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs index 7b1ee681dd7..988fbd83afc 100644 --- a/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs +++ b/tests/ui/feature-gates/feature-gate-abi_gpu_kernel.rs @@ -19,6 +19,7 @@ extern "gpu-kernel" fn f1(_: ()) {} //~ ERROR "gpu-kernel" ABI is experimental a // Methods in trait definition trait Tr { extern "gpu-kernel" fn m1(_: ()); //~ ERROR "gpu-kernel" ABI is experimental and subject to change + //[HOST]~^ ERROR is not a supported ABI extern "gpu-kernel" fn dm1(_: ()) {} //~ ERROR "gpu-kernel" ABI is experimental and subject to change //[HOST]~^ ERROR is not a supported ABI @@ -40,8 +41,7 @@ impl S { // Function pointer types type A1 = extern "gpu-kernel" fn(_: ()); //~ ERROR "gpu-kernel" ABI is experimental and subject to change -//[HOST]~^ WARNING the calling convention "gpu-kernel" is not supported on this target [unsupported_fn_ptr_calling_conventions] -//[HOST]~| WARNING this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +//[HOST]~^ ERROR is not a supported ABI // Foreign modules extern "gpu-kernel" {} //~ ERROR "gpu-kernel" ABI is experimental and subject to change diff --git a/tests/ui/feature-gates/feature-gate-cfi_encoding.rs b/tests/ui/feature-gates/feature-gate-cfi_encoding.rs index 3cef8156014..b6312dd7817 100644 --- a/tests/ui/feature-gates/feature-gate-cfi_encoding.rs +++ b/tests/ui/feature-gates/feature-gate-cfi_encoding.rs @@ -1,4 +1,4 @@ #![crate_type = "lib"] -#[cfi_encoding = "3Bar"] //~ERROR 3:1: 3:25: the `#[cfi_encoding]` attribute is an experimental feature [E0658] +#[cfi_encoding = "3Bar"] //~ ERROR the `#[cfi_encoding]` attribute is an experimental feature [E0658] pub struct Foo(i32); diff --git a/tests/ui/feature-gates/feature-gate-concat_idents.rs b/tests/ui/feature-gates/feature-gate-concat_idents.rs deleted file mode 100644 index 4fc3b691597..00000000000 --- a/tests/ui/feature-gates/feature-gate-concat_idents.rs +++ /dev/null @@ -1,11 +0,0 @@ -#![expect(deprecated)] // concat_idents is deprecated - -const XY_1: i32 = 10; - -fn main() { - const XY_2: i32 = 20; - let a = concat_idents!(X, Y_1); //~ ERROR `concat_idents` is not stable - let b = concat_idents!(X, Y_2); //~ ERROR `concat_idents` is not stable - assert_eq!(a, 10); - assert_eq!(b, 20); -} diff --git a/tests/ui/feature-gates/feature-gate-concat_idents.stderr b/tests/ui/feature-gates/feature-gate-concat_idents.stderr deleted file mode 100644 index 6399424eecd..00000000000 --- a/tests/ui/feature-gates/feature-gate-concat_idents.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change - --> $DIR/feature-gate-concat_idents.rs:7:13 - | -LL | let a = concat_idents!(X, Y_1); - | ^^^^^^^^^^^^^ - | - = note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information - = help: add `#![feature(concat_idents)]` 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]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change - --> $DIR/feature-gate-concat_idents.rs:8:13 - | -LL | let b = concat_idents!(X, Y_2); - | ^^^^^^^^^^^^^ - | - = note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information - = help: add `#![feature(concat_idents)]` 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`. diff --git a/tests/ui/feature-gates/feature-gate-concat_idents2.rs b/tests/ui/feature-gates/feature-gate-concat_idents2.rs deleted file mode 100644 index bc2b4f7cddf..00000000000 --- a/tests/ui/feature-gates/feature-gate-concat_idents2.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![expect(deprecated)] // concat_idents is deprecated - -fn main() { - concat_idents!(a, b); //~ ERROR `concat_idents` is not stable enough - //~| ERROR cannot find value `ab` in this scope -} diff --git a/tests/ui/feature-gates/feature-gate-concat_idents2.stderr b/tests/ui/feature-gates/feature-gate-concat_idents2.stderr deleted file mode 100644 index a770c1a348b..00000000000 --- a/tests/ui/feature-gates/feature-gate-concat_idents2.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change - --> $DIR/feature-gate-concat_idents2.rs:4:5 - | -LL | concat_idents!(a, b); - | ^^^^^^^^^^^^^ - | - = note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information - = help: add `#![feature(concat_idents)]` 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[E0425]: cannot find value `ab` in this scope - --> $DIR/feature-gate-concat_idents2.rs:4:5 - | -LL | concat_idents!(a, b); - | ^^^^^^^^^^^^^^^^^^^^ not found in this scope - -error: aborting due to 2 previous errors - -Some errors have detailed explanations: E0425, E0658. -For more information about an error, try `rustc --explain E0425`. diff --git a/tests/ui/feature-gates/feature-gate-concat_idents3.rs b/tests/ui/feature-gates/feature-gate-concat_idents3.rs deleted file mode 100644 index d4a0d2e6bb0..00000000000 --- a/tests/ui/feature-gates/feature-gate-concat_idents3.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![expect(deprecated)] // concat_idents is deprecated - -const XY_1: i32 = 10; - -fn main() { - const XY_2: i32 = 20; - assert_eq!(10, concat_idents!(X, Y_1)); //~ ERROR `concat_idents` is not stable - assert_eq!(20, concat_idents!(X, Y_2)); //~ ERROR `concat_idents` is not stable -} diff --git a/tests/ui/feature-gates/feature-gate-concat_idents3.stderr b/tests/ui/feature-gates/feature-gate-concat_idents3.stderr deleted file mode 100644 index 7d929322bc0..00000000000 --- a/tests/ui/feature-gates/feature-gate-concat_idents3.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0658]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change - --> $DIR/feature-gate-concat_idents3.rs:7:20 - | -LL | assert_eq!(10, concat_idents!(X, Y_1)); - | ^^^^^^^^^^^^^ - | - = note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information - = help: add `#![feature(concat_idents)]` 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]: use of unstable library feature `concat_idents`: `concat_idents` is not stable enough for use and is subject to change - --> $DIR/feature-gate-concat_idents3.rs:8:20 - | -LL | assert_eq!(20, concat_idents!(X, Y_2)); - | ^^^^^^^^^^^^^ - | - = note: see issue #29599 <https://github.com/rust-lang/rust/issues/29599> for more information - = help: add `#![feature(concat_idents)]` 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`. diff --git a/tests/ui/feature-gates/feature-gate-coverage-attribute.rs b/tests/ui/feature-gates/feature-gate-coverage-attribute.rs index 2cf4b76180e..0a463755f13 100644 --- a/tests/ui/feature-gates/feature-gate-coverage-attribute.rs +++ b/tests/ui/feature-gates/feature-gate-coverage-attribute.rs @@ -1,5 +1,3 @@ -//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION" - #![crate_type = "lib"] #![feature(no_coverage)] //~ ERROR feature has been removed [E0557] diff --git a/tests/ui/feature-gates/feature-gate-coverage-attribute.stderr b/tests/ui/feature-gates/feature-gate-coverage-attribute.stderr index 8c23544698d..68d0d9bc3c3 100644 --- a/tests/ui/feature-gates/feature-gate-coverage-attribute.stderr +++ b/tests/ui/feature-gates/feature-gate-coverage-attribute.stderr @@ -1,14 +1,14 @@ error[E0557]: feature has been removed - --> $DIR/feature-gate-coverage-attribute.rs:4:12 + --> $DIR/feature-gate-coverage-attribute.rs:2:12 | LL | #![feature(no_coverage)] | ^^^^^^^^^^^ feature has been removed | - = note: removed in 1.74.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/114656> for more information + = note: removed in 1.74.0; see <https://github.com/rust-lang/rust/pull/114656> for more information = note: renamed to `coverage_attribute` error[E0658]: the `#[coverage]` attribute is an experimental feature - --> $DIR/feature-gate-coverage-attribute.rs:12:1 + --> $DIR/feature-gate-coverage-attribute.rs:10:1 | LL | #[coverage(off)] | ^^^^^^^^^^^^^^^^ diff --git a/tests/ui/feature-gates/feature-gate-loop-match.rs b/tests/ui/feature-gates/feature-gate-loop-match.rs new file mode 100644 index 00000000000..399b20234f3 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-loop-match.rs @@ -0,0 +1,30 @@ +// Test that `#[loop_match]` and `#[const_continue]` cannot be used without +// `#![feature(loop_match)]`. + +enum State { + A, + B, + C, +} + +fn main() { + let mut state = State::A; + #[loop_match] //~ ERROR the `#[loop_match]` attribute is an experimental feature + 'a: loop { + state = 'blk: { + match state { + State::A => { + #[const_continue] + //~^ ERROR the `#[const_continue]` attribute is an experimental feature + break 'blk State::B; + } + State::B => { + #[const_continue] + //~^ ERROR the `#[const_continue]` attribute is an experimental feature + break 'blk State::C; + } + State::C => break 'a, + } + }; + } +} diff --git a/tests/ui/feature-gates/feature-gate-loop-match.stderr b/tests/ui/feature-gates/feature-gate-loop-match.stderr new file mode 100644 index 00000000000..9b12047cf4d --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-loop-match.stderr @@ -0,0 +1,33 @@ +error[E0658]: the `#[loop_match]` attribute is an experimental feature + --> $DIR/feature-gate-loop-match.rs:12:5 + | +LL | #[loop_match] + | ^^^^^^^^^^^^^ + | + = note: see issue #132306 <https://github.com/rust-lang/rust/issues/132306> for more information + = help: add `#![feature(loop_match)]` 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]: the `#[const_continue]` attribute is an experimental feature + --> $DIR/feature-gate-loop-match.rs:17:21 + | +LL | #[const_continue] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #132306 <https://github.com/rust-lang/rust/issues/132306> for more information + = help: add `#![feature(loop_match)]` 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]: the `#[const_continue]` attribute is an experimental feature + --> $DIR/feature-gate-loop-match.rs:22:21 + | +LL | #[const_continue] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #132306 <https://github.com/rust-lang/rust/issues/132306> for more information + = help: add `#![feature(loop_match)]` 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 3 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-naked_functions_target_feature.stderr b/tests/ui/feature-gates/feature-gate-naked_functions_target_feature.stderr index 8e601a14753..e57ec9cc59b 100644 --- a/tests/ui/feature-gates/feature-gate-naked_functions_target_feature.stderr +++ b/tests/ui/feature-gates/feature-gate-naked_functions_target_feature.stderr @@ -1,8 +1,8 @@ error[E0658]: `#[target_feature(/* ... */)]` is currently unstable on `#[naked]` functions - --> $DIR/feature-gate-naked_functions_target_feature.rs:7:1 + --> $DIR/feature-gate-naked_functions_target_feature.rs:7:3 | LL | #[target_feature(enable = "avx2")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ | = note: see issue #138568 <https://github.com/rust-lang/rust/issues/138568> for more information = help: add `#![feature(naked_functions_target_feature)]` to the crate attributes to enable diff --git a/tests/ui/feature-gates/feature-gate-pin_ergonomics.rs b/tests/ui/feature-gates/feature-gate-pin_ergonomics.rs index 663a83a665c..7746654555d 100644 --- a/tests/ui/feature-gates/feature-gate-pin_ergonomics.rs +++ b/tests/ui/feature-gates/feature-gate-pin_ergonomics.rs @@ -17,6 +17,10 @@ fn foo(mut x: Pin<&mut Foo>) { let _y: &pin mut Foo = x; //~ ERROR pinned reference syntax is experimental } +fn foo_const(x: Pin<&Foo>) { + let _y: &pin const Foo = x; //~ ERROR pinned reference syntax is experimental +} + fn foo_sugar(_: &pin mut Foo) {} //~ ERROR pinned reference syntax is experimental fn bar(x: Pin<&mut Foo>) { @@ -31,6 +35,18 @@ fn baz(mut x: Pin<&mut Foo>) { fn baz_sugar(_: &pin const Foo) {} //~ ERROR pinned reference syntax is experimental +fn borrows() { + let mut x: Pin<&mut _> = &pin mut Foo; //~ ERROR pinned reference syntax is experimental + foo(x.as_mut()); + foo(x.as_mut()); + foo_const(x.as_ref()); + + let x: Pin<&_> = &pin const Foo; //~ ERROR pinned reference syntax is experimental + + foo_const(x); + foo_const(x); +} + #[cfg(any())] mod not_compiled { use std::pin::Pin; @@ -63,6 +79,18 @@ mod not_compiled { } fn baz_sugar(_: &pin const Foo) {} //~ ERROR pinned reference syntax is experimental + + fn borrows() { + let mut x: Pin<&mut _> = &pin mut Foo; //~ ERROR pinned reference syntax is experimental + foo(x.as_mut()); + foo(x.as_mut()); + foo_const(x.as_ref()); + + let x: Pin<&_> = &pin const Foo; //~ ERROR pinned reference syntax is experimental + + foo_const(x); + foo_const(x); + } } fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr b/tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr index 8ed7543d86e..a8890254fac 100644 --- a/tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr +++ b/tests/ui/feature-gates/feature-gate-pin_ergonomics.stderr @@ -29,7 +29,17 @@ LL | let _y: &pin mut Foo = x; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: pinned reference syntax is experimental - --> $DIR/feature-gate-pin_ergonomics.rs:20:18 + --> $DIR/feature-gate-pin_ergonomics.rs:21:14 + | +LL | let _y: &pin const Foo = x; + | ^^^ + | + = note: see issue #130494 <https://github.com/rust-lang/rust/issues/130494> for more information + = help: add `#![feature(pin_ergonomics)]` 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]: pinned reference syntax is experimental + --> $DIR/feature-gate-pin_ergonomics.rs:24:18 | LL | fn foo_sugar(_: &pin mut Foo) {} | ^^^ @@ -39,7 +49,7 @@ LL | fn foo_sugar(_: &pin mut Foo) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: pinned reference syntax is experimental - --> $DIR/feature-gate-pin_ergonomics.rs:32:18 + --> $DIR/feature-gate-pin_ergonomics.rs:36:18 | LL | fn baz_sugar(_: &pin const Foo) {} | ^^^ @@ -49,7 +59,27 @@ LL | fn baz_sugar(_: &pin const Foo) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: pinned reference syntax is experimental - --> $DIR/feature-gate-pin_ergonomics.rs:43:23 + --> $DIR/feature-gate-pin_ergonomics.rs:39:31 + | +LL | let mut x: Pin<&mut _> = &pin mut Foo; + | ^^^ + | + = note: see issue #130494 <https://github.com/rust-lang/rust/issues/130494> for more information + = help: add `#![feature(pin_ergonomics)]` 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]: pinned reference syntax is experimental + --> $DIR/feature-gate-pin_ergonomics.rs:44:23 + | +LL | let x: Pin<&_> = &pin const Foo; + | ^^^ + | + = note: see issue #130494 <https://github.com/rust-lang/rust/issues/130494> for more information + = help: add `#![feature(pin_ergonomics)]` 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]: pinned reference syntax is experimental + --> $DIR/feature-gate-pin_ergonomics.rs:59:23 | LL | fn foo_sugar(&pin mut self) {} | ^^^ @@ -59,7 +89,7 @@ LL | fn foo_sugar(&pin mut self) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: pinned reference syntax is experimental - --> $DIR/feature-gate-pin_ergonomics.rs:44:29 + --> $DIR/feature-gate-pin_ergonomics.rs:60:29 | LL | fn foo_sugar_const(&pin const self) {} | ^^^ @@ -69,7 +99,7 @@ LL | fn foo_sugar_const(&pin const self) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: pinned reference syntax is experimental - --> $DIR/feature-gate-pin_ergonomics.rs:50:18 + --> $DIR/feature-gate-pin_ergonomics.rs:66:18 | LL | let _y: &pin mut Foo = x; | ^^^ @@ -79,7 +109,7 @@ LL | let _y: &pin mut Foo = x; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: pinned reference syntax is experimental - --> $DIR/feature-gate-pin_ergonomics.rs:53:22 + --> $DIR/feature-gate-pin_ergonomics.rs:69:22 | LL | fn foo_sugar(_: &pin mut Foo) {} | ^^^ @@ -89,7 +119,7 @@ LL | fn foo_sugar(_: &pin mut Foo) {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: pinned reference syntax is experimental - --> $DIR/feature-gate-pin_ergonomics.rs:65:22 + --> $DIR/feature-gate-pin_ergonomics.rs:81:22 | LL | fn baz_sugar(_: &pin const Foo) {} | ^^^ @@ -98,8 +128,28 @@ LL | fn baz_sugar(_: &pin const Foo) {} = help: add `#![feature(pin_ergonomics)]` 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]: pinned reference syntax is experimental + --> $DIR/feature-gate-pin_ergonomics.rs:84:35 + | +LL | let mut x: Pin<&mut _> = &pin mut Foo; + | ^^^ + | + = note: see issue #130494 <https://github.com/rust-lang/rust/issues/130494> for more information + = help: add `#![feature(pin_ergonomics)]` 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]: pinned reference syntax is experimental + --> $DIR/feature-gate-pin_ergonomics.rs:89:27 + | +LL | let x: Pin<&_> = &pin const Foo; + | ^^^ + | + = note: see issue #130494 <https://github.com/rust-lang/rust/issues/130494> for more information + = help: add `#![feature(pin_ergonomics)]` 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[E0382]: use of moved value: `x` - --> $DIR/feature-gate-pin_ergonomics.rs:24:9 + --> $DIR/feature-gate-pin_ergonomics.rs:28:9 | LL | fn bar(x: Pin<&mut Foo>) { | - move occurs because `x` has type `Pin<&mut Foo>`, which does not implement the `Copy` trait @@ -117,7 +167,7 @@ LL | fn foo(mut x: Pin<&mut Foo>) { | in this function error[E0382]: use of moved value: `x` - --> $DIR/feature-gate-pin_ergonomics.rs:29:5 + --> $DIR/feature-gate-pin_ergonomics.rs:33:5 | LL | fn baz(mut x: Pin<&mut Foo>) { | ----- move occurs because `x` has type `Pin<&mut Foo>`, which does not implement the `Copy` trait @@ -136,7 +186,7 @@ help: consider reborrowing the `Pin` instead of moving it LL | x.as_mut().foo(); | +++++++++ -error: aborting due to 12 previous errors +error: aborting due to 17 previous errors Some errors have detailed explanations: E0382, E0658. For more information about an error, try `rustc --explain E0382`. diff --git a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr index 7768c25bd2c..334bc63b7ee 100644 --- a/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr +++ b/tests/ui/feature-gates/feature-gate-unboxed-closures-manual-impls.stderr @@ -56,6 +56,19 @@ LL | impl Fn<()> for Foo { | = help: add `#![feature(unboxed_closures)]` to the crate attributes to enable +error[E0053]: method `call` has an incompatible type for trait + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:13:32 + | +LL | extern "rust-call" fn call(self, args: ()) -> () {} + | ^^^^ expected `&Foo`, found `Foo` + | + = note: expected signature `extern "rust-call" fn(&Foo, ()) -> _` + found signature `extern "rust-call" fn(Foo, ()) -> ()` +help: change the self-receiver type to match the trait + | +LL | extern "rust-call" fn call(&self, args: ()) -> () {} + | + + error[E0658]: the precise format of `Fn`-family traits' type parameters is subject to change --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:26:6 | @@ -85,19 +98,6 @@ LL | impl Fn<()> for Foo { note: required by a bound in `Fn` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error[E0053]: method `call` has an incompatible type for trait - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:13:32 - | -LL | extern "rust-call" fn call(self, args: ()) -> () {} - | ^^^^ expected `&Foo`, found `Foo` - | - = note: expected signature `extern "rust-call" fn(&Foo, ()) -> _` - found signature `extern "rust-call" fn(Foo, ()) -> ()` -help: change the self-receiver type to match the trait - | -LL | extern "rust-call" fn call(&self, args: ()) -> () {} - | + - error[E0183]: manual implementations of `FnOnce` are experimental --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:18:6 | @@ -144,17 +144,6 @@ LL | impl FnOnce() for Foo1 { | = help: implement the missing item: `type Output = /* Type */;` -error[E0277]: expected a `FnOnce()` closure, found `Bar` - --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:26:20 - | -LL | impl FnMut<()> for Bar { - | ^^^ expected an `FnOnce()` closure, found `Bar` - | - = help: the trait `FnOnce()` is not implemented for `Bar` - = note: wrap the `Bar` in a closure with no arguments: `|| { /* code */ }` -note: required by a bound in `FnMut` - --> $SRC_DIR/core/src/ops/function.rs:LL:COL - error[E0053]: method `call_mut` has an incompatible type for trait --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:30:36 | @@ -168,6 +157,17 @@ help: change the self-receiver type to match the trait LL | extern "rust-call" fn call_mut(&mut self, args: ()) -> () {} | +++ +error[E0277]: expected a `FnOnce()` closure, found `Bar` + --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:26:20 + | +LL | impl FnMut<()> for Bar { + | ^^^ expected an `FnOnce()` closure, found `Bar` + | + = help: the trait `FnOnce()` is not implemented for `Bar` + = note: wrap the `Bar` in a closure with no arguments: `|| { /* code */ }` +note: required by a bound in `FnMut` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL + error[E0046]: not all trait items implemented, missing: `Output` --> $DIR/feature-gate-unboxed-closures-manual-impls.rs:35:1 | diff --git a/tests/ui/feature-gates/feature-gate-unsized_fn_params.stderr b/tests/ui/feature-gates/feature-gate-unsized_fn_params.edition2015.stderr index 30f95851768..ac2d1ffa868 100644 --- a/tests/ui/feature-gates/feature-gate-unsized_fn_params.stderr +++ b/tests/ui/feature-gates/feature-gate-unsized_fn_params.edition2015.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time - --> $DIR/feature-gate-unsized_fn_params.rs:17:11 + --> $DIR/feature-gate-unsized_fn_params.rs:20:11 | LL | fn foo(x: dyn Foo) { | ^^^^^^^ doesn't have a size known at compile-time @@ -17,7 +17,7 @@ LL | fn foo(x: &dyn Foo) { | + error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time - --> $DIR/feature-gate-unsized_fn_params.rs:21:11 + --> $DIR/feature-gate-unsized_fn_params.rs:24:11 | LL | fn bar(x: Foo) { | ^^^ doesn't have a size known at compile-time @@ -34,7 +34,7 @@ LL | fn bar(x: &dyn Foo) { | ++++ error[E0277]: the size for values of type `[()]` cannot be known at compilation time - --> $DIR/feature-gate-unsized_fn_params.rs:25:11 + --> $DIR/feature-gate-unsized_fn_params.rs:30:11 | LL | fn qux(_: [()]) {} | ^^^^ doesn't have a size known at compile-time @@ -47,7 +47,7 @@ LL | fn qux(_: &[()]) {} | + error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time - --> $DIR/feature-gate-unsized_fn_params.rs:29:9 + --> $DIR/feature-gate-unsized_fn_params.rs:34:9 | LL | foo(*x); | ^^ doesn't have a size known at compile-time diff --git a/tests/ui/feature-gates/feature-gate-unsized_fn_params.edition2021.stderr b/tests/ui/feature-gates/feature-gate-unsized_fn_params.edition2021.stderr new file mode 100644 index 00000000000..12411f695f4 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-unsized_fn_params.edition2021.stderr @@ -0,0 +1,65 @@ +error[E0782]: expected a type, found a trait + --> $DIR/feature-gate-unsized_fn_params.rs:24:11 + | +LL | fn bar(x: Foo) { + | ^^^ + | +help: use a new generic type parameter, constrained by `Foo` + | +LL - fn bar(x: Foo) { +LL + fn bar<T: Foo>(x: T) { + | +help: you can also use an opaque type, but users won't be able to specify the type parameter when calling the `fn`, having to rely exclusively on type inference + | +LL | fn bar(x: impl Foo) { + | ++++ +help: alternatively, use a trait object to accept any type that implements `Foo`, accessing its methods at runtime using dynamic dispatch + | +LL | fn bar(x: &dyn Foo) { + | ++++ + +error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time + --> $DIR/feature-gate-unsized_fn_params.rs:20:11 + | +LL | fn foo(x: dyn Foo) { + | ^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Foo + 'static)` + = help: unsized fn params are gated as an unstable feature +help: you can use `impl Trait` as the argument type + | +LL - fn foo(x: dyn Foo) { +LL + fn foo(x: impl Foo) { + | +help: function arguments must have a statically known size, borrowed types always have a known size + | +LL | fn foo(x: &dyn Foo) { + | + + +error[E0277]: the size for values of type `[()]` cannot be known at compilation time + --> $DIR/feature-gate-unsized_fn_params.rs:30:11 + | +LL | fn qux(_: [()]) {} + | ^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `[()]` + = help: unsized fn params are gated as an unstable feature +help: function arguments must have a statically known size, borrowed slices always have a known size + | +LL | fn qux(_: &[()]) {} + | + + +error[E0277]: the size for values of type `(dyn Foo + 'static)` cannot be known at compilation time + --> $DIR/feature-gate-unsized_fn_params.rs:34:9 + | +LL | foo(*x); + | ^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `(dyn Foo + 'static)` + = note: all function arguments must have a statically known size + = help: unsized fn params are gated as an unstable feature + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0277, E0782. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/feature-gates/feature-gate-unsized_fn_params.rs b/tests/ui/feature-gates/feature-gate-unsized_fn_params.rs index c04e57843d4..3c5f932e891 100644 --- a/tests/ui/feature-gates/feature-gate-unsized_fn_params.rs +++ b/tests/ui/feature-gates/feature-gate-unsized_fn_params.rs @@ -1,3 +1,6 @@ +//@revisions: edition2015 edition2021 +//@[edition2015] edition:2015 +//@[edition2021] edition:2021 #![allow(unused, bare_trait_objects)] #[repr(align(256))] struct A { @@ -18,7 +21,9 @@ fn foo(x: dyn Foo) { //~ ERROR [E0277] x.foo() } -fn bar(x: Foo) { //~ ERROR [E0277] +fn bar(x: Foo) { +//[edition2015]~^ ERROR [E0277] +//[edition2021]~^^ ERROR expected a type, found a trait x.foo() } diff --git a/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs b/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs index b5fbcc9ccf8..c1469863792 100644 --- a/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs +++ b/tests/ui/feature-gates/feature-gate-unsized_tuple_coercion.rs @@ -1,4 +1,4 @@ fn main() { let _ : &(dyn Send,) = &((),); - //~^ ERROR 2:28: 2:34: mismatched types [E0308] + //~^ ERROR mismatched types [E0308] } diff --git a/tests/ui/feature-gates/gated-bad-feature.rs b/tests/ui/feature-gates/gated-bad-feature.rs index 3114f661dc5..51f2db5556e 100644 --- a/tests/ui/feature-gates/gated-bad-feature.rs +++ b/tests/ui/feature-gates/gated-bad-feature.rs @@ -1,4 +1,3 @@ -//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION" #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)] //~^ ERROR malformed `feature` //~| ERROR malformed `feature` diff --git a/tests/ui/feature-gates/gated-bad-feature.stderr b/tests/ui/feature-gates/gated-bad-feature.stderr index 0e75dff14f8..e0e84d84235 100644 --- a/tests/ui/feature-gates/gated-bad-feature.stderr +++ b/tests/ui/feature-gates/gated-bad-feature.stderr @@ -1,43 +1,43 @@ error[E0556]: malformed `feature` attribute input - --> $DIR/gated-bad-feature.rs:2:25 + --> $DIR/gated-bad-feature.rs:1:25 | LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)] | ^^^^^^^^ help: expected just one word: `foo` error[E0556]: malformed `feature` attribute input - --> $DIR/gated-bad-feature.rs:2:35 + --> $DIR/gated-bad-feature.rs:1:35 | LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)] | ^^^^^^^^^^^ help: expected just one word: `foo` error[E0557]: feature has been removed - --> $DIR/gated-bad-feature.rs:9:12 + --> $DIR/gated-bad-feature.rs:8:12 | LL | #![feature(test_removed_feature)] | ^^^^^^^^^^^^^^^^^^^^ feature has been removed | - = note: removed in 1.0.0 (you are using $RUSTC_VERSION) + = note: removed in 1.0.0 error: malformed `feature` attribute input - --> $DIR/gated-bad-feature.rs:7:1 + --> $DIR/gated-bad-feature.rs:6:1 | LL | #![feature] | ^^^^^^^^^^^ help: must be of the form: `#![feature(name1, name2, ...)]` error: malformed `feature` attribute input - --> $DIR/gated-bad-feature.rs:8:1 + --> $DIR/gated-bad-feature.rs:7:1 | LL | #![feature = "foo"] | ^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#![feature(name1, name2, ...)]` error[E0635]: unknown feature `foo_bar_baz` - --> $DIR/gated-bad-feature.rs:2:12 + --> $DIR/gated-bad-feature.rs:1:12 | LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)] | ^^^^^^^^^^^ error[E0635]: unknown feature `foo` - --> $DIR/gated-bad-feature.rs:2:48 + --> $DIR/gated-bad-feature.rs:1:48 | LL | #![feature(foo_bar_baz, foo(bar), foo = "baz", foo)] | ^^^ 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 1620bf72922..49c666f498f 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 @@ -121,21 +121,6 @@ LL - #![rustc_main] LL + #[rustc_main] | -error: `path` attribute cannot be used at crate level - --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:21:1 - | -LL | #![path = "3800"] - | ^^^^^^^^^^^^^^^^^ -... -LL | mod inline { - | ------ the inner attribute doesn't annotate this module - | -help: perhaps you meant to use an outer attribute - | -LL - #![path = "3800"] -LL + #[path = "3800"] - | - error: `automatically_derived` attribute cannot be used at crate level --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:23:1 | @@ -166,6 +151,21 @@ LL - #![repr()] LL + #[repr()] | +error: `path` attribute cannot be used at crate level + --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:21:1 + | +LL | #![path = "3800"] + | ^^^^^^^^^^^^^^^^^ +... +LL | mod inline { + | ------ the inner attribute doesn't annotate this module + | +help: perhaps you meant to use an outer attribute + | +LL - #![path = "3800"] +LL + #[path = "3800"] + | + error[E0518]: attribute should be applied to function or closure --> $DIR/issue-43106-gating-of-builtin-attrs-error.rs:42:17 | diff --git a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr index 9280dfdf92e..5d7d1caeeab 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.stderr @@ -367,12 +367,6 @@ warning: `#[should_panic]` only has an effect on functions LL | #![should_panic] | ^^^^^^^^^^^^^^^^ -warning: `#[ignore]` only has an effect on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:54:1 - | -LL | #![ignore] - | ^^^^^^^^^^ - warning: `#[proc_macro_derive]` only has an effect on functions --> $DIR/issue-43106-gating-of-builtin-attrs.rs:60:1 | @@ -387,6 +381,12 @@ LL | #![link()] | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! +warning: `#[ignore]` only has an effect on functions + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:54:1 + | +LL | #![ignore] + | ^^^^^^^^^^ + warning: attribute should be applied to a foreign function or static --> $DIR/issue-43106-gating-of-builtin-attrs.rs:66:1 | diff --git a/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.rs b/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.rs index ec6adb471ba..d8c5f48f9fd 100644 --- a/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.rs +++ b/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.rs @@ -1,5 +1,3 @@ -//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION" - #![feature(external_doc)] //~ ERROR feature has been removed #![doc(include("README.md"))] //~ ERROR unknown `doc` attribute `include` diff --git a/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.stderr b/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.stderr index 43205c7360b..bd8c56c61c3 100644 --- a/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.stderr +++ b/tests/ui/feature-gates/removed-features-note-version-and-pr-issue-141619.stderr @@ -1,14 +1,14 @@ error[E0557]: feature has been removed - --> $DIR/removed-features-note-version-and-pr-issue-141619.rs:3:12 + --> $DIR/removed-features-note-version-and-pr-issue-141619.rs:1:12 | LL | #![feature(external_doc)] | ^^^^^^^^^^^^ feature has been removed | - = note: removed in 1.54.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/85457> for more information + = note: removed in 1.54.0; see <https://github.com/rust-lang/rust/pull/85457> for more information = note: use #[doc = include_str!("filename")] instead, which handles macro invocations error: unknown `doc` attribute `include` - --> $DIR/removed-features-note-version-and-pr-issue-141619.rs:4:8 + --> $DIR/removed-features-note-version-and-pr-issue-141619.rs:2:8 | LL | #![doc(include("README.md"))] | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/logging-only-prints-once.rs b/tests/ui/fmt/debug-single-call.rs index bb8c29694b5..b59a766c71a 100644 --- a/tests/ui/logging-only-prints-once.rs +++ b/tests/ui/fmt/debug-single-call.rs @@ -1,9 +1,12 @@ +//! Test that Debug::fmt is called exactly once during formatting. +//! +//! This is a regression test for PR https://github.com/rust-lang/rust/pull/10715 + //@ run-pass //@ needs-threads use std::cell::Cell; -use std::fmt; -use std::thread; +use std::{fmt, thread}; struct Foo(Cell<isize>); diff --git a/tests/ui/fmt/format-args-argument-span.stderr b/tests/ui/fmt/format-args-argument-span.stderr index 4e2702383d6..d46cfb438cf 100644 --- a/tests/ui/fmt/format-args-argument-span.stderr +++ b/tests/ui/fmt/format-args-argument-span.stderr @@ -12,7 +12,9 @@ error[E0277]: `Option<{integer}>` doesn't implement `std::fmt::Display` --> $DIR/format-args-argument-span.rs:15:37 | LL | println!("{x:?} {x} {x:?}", x = Some(1)); - | ^^^^^^^ `Option<{integer}>` cannot be formatted with the default formatter + | --- ^^^^^^^ `Option<{integer}>` cannot be formatted with the default formatter + | | + | required by this formatting parameter | = help: the trait `std::fmt::Display` is not implemented for `Option<{integer}>` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead @@ -22,7 +24,7 @@ error[E0277]: `DisplayOnly` doesn't implement `Debug` --> $DIR/format-args-argument-span.rs:18:19 | LL | println!("{x} {x:?} {x}"); - | ^^^^^ `DisplayOnly` cannot be formatted using `{:?}` + | ^^^^^ `DisplayOnly` cannot be formatted using `{:?}` because it doesn't implement `Debug` | = help: the trait `Debug` is not implemented for `DisplayOnly` = note: add `#[derive(Debug)]` to `DisplayOnly` or manually `impl Debug for DisplayOnly` @@ -37,7 +39,9 @@ error[E0277]: `DisplayOnly` doesn't implement `Debug` --> $DIR/format-args-argument-span.rs:20:35 | LL | println!("{x} {x:?} {x}", x = DisplayOnly); - | ^^^^^^^^^^^ `DisplayOnly` cannot be formatted using `{:?}` + | ----- ^^^^^^^^^^^ `DisplayOnly` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | | + | required by this formatting parameter | = help: the trait `Debug` is not implemented for `DisplayOnly` = note: add `#[derive(Debug)]` to `DisplayOnly` or manually `impl Debug for DisplayOnly` diff --git a/tests/ui/fmt/ifmt-unimpl.stderr b/tests/ui/fmt/ifmt-unimpl.stderr index b8d4425a4a7..5e80f892dcb 100644 --- a/tests/ui/fmt/ifmt-unimpl.stderr +++ b/tests/ui/fmt/ifmt-unimpl.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `str: UpperHex` is not satisfied LL | format!("{:X}", "3"); | ---- ^^^ the trait `UpperHex` is not implemented for `str` | | - | required by a bound introduced by this call + | required by this formatting parameter | = help: the following other types implement trait `UpperHex`: &T @@ -17,8 +17,6 @@ LL | format!("{:X}", "3"); i32 and 9 others = note: required for `&str` to implement `UpperHex` -note: required by a bound in `core::fmt::rt::Argument::<'_>::new_upper_hex` - --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL = note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/fmt/non-source-literals.rs b/tests/ui/fmt/non-source-literals.rs new file mode 100644 index 00000000000..e3ffdb40a6b --- /dev/null +++ b/tests/ui/fmt/non-source-literals.rs @@ -0,0 +1,13 @@ +/// Do not point at the format string if it wasn't written in the source. +//@ forbid-output: required by this formatting parameter + +#[derive(Debug)] +pub struct NonDisplay; +pub struct NonDebug; + +fn main() { + let _ = format!(concat!("{", "}"), NonDisplay); //~ ERROR + let _ = format!(concat!("{", "0", "}"), NonDisplay); //~ ERROR + let _ = format!(concat!("{:", "?}"), NonDebug); //~ ERROR + let _ = format!(concat!("{", "0", ":?}"), NonDebug); //~ ERROR +} diff --git a/tests/ui/fmt/non-source-literals.stderr b/tests/ui/fmt/non-source-literals.stderr new file mode 100644 index 00000000000..5f8a6200dab --- /dev/null +++ b/tests/ui/fmt/non-source-literals.stderr @@ -0,0 +1,53 @@ +error[E0277]: `NonDisplay` doesn't implement `std::fmt::Display` + --> $DIR/non-source-literals.rs:9:40 + | +LL | let _ = format!(concat!("{", "}"), NonDisplay); + | ^^^^^^^^^^ `NonDisplay` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `NonDisplay` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `NonDisplay` doesn't implement `std::fmt::Display` + --> $DIR/non-source-literals.rs:10:45 + | +LL | let _ = format!(concat!("{", "0", "}"), NonDisplay); + | ^^^^^^^^^^ `NonDisplay` cannot be formatted with the default formatter + | + = help: the trait `std::fmt::Display` is not implemented for `NonDisplay` + = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + = note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0277]: `NonDebug` doesn't implement `Debug` + --> $DIR/non-source-literals.rs:11:42 + | +LL | let _ = format!(concat!("{:", "?}"), NonDebug); + | ^^^^^^^^ `NonDebug` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | + = help: the trait `Debug` is not implemented for `NonDebug` + = note: add `#[derive(Debug)]` to `NonDebug` or manually `impl Debug for NonDebug` + = note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `NonDebug` with `#[derive(Debug)]` + | +LL + #[derive(Debug)] +LL | pub struct NonDebug; + | + +error[E0277]: `NonDebug` doesn't implement `Debug` + --> $DIR/non-source-literals.rs:12:47 + | +LL | let _ = format!(concat!("{", "0", ":?}"), NonDebug); + | ^^^^^^^^ `NonDebug` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | + = help: the trait `Debug` is not implemented for `NonDebug` + = note: add `#[derive(Debug)]` to `NonDebug` or manually `impl Debug for NonDebug` + = note: this error originates in the macro `$crate::__export::format_args` which comes from the expansion of the macro `format` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider annotating `NonDebug` with `#[derive(Debug)]` + | +LL + #[derive(Debug)] +LL | pub struct NonDebug; + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/auxiliary/delegate_macro.rs b/tests/ui/fn/auxiliary/delegate_macro.rs index 0d752e12039..0d752e12039 100644 --- a/tests/ui/auxiliary/delegate_macro.rs +++ b/tests/ui/fn/auxiliary/delegate_macro.rs diff --git a/tests/ui/fn/error-recovery-mismatch.stderr b/tests/ui/fn/error-recovery-mismatch.stderr index f281e77f13b..10dab3052be 100644 --- a/tests/ui/fn/error-recovery-mismatch.stderr +++ b/tests/ui/fn/error-recovery-mismatch.stderr @@ -29,17 +29,11 @@ LL | fn fold<T>(&self, _: T, &self._) {} = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686> = note: `#[warn(anonymous_parameters)]` on by default -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/error-recovery-mismatch.rs:11:35 | LL | fn fold<T>(&self, _: T, &self._) {} | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn fold<T>(&self, _: T, &self._) {} -LL + fn fold<T, U>(&self, _: T, &self.U) {} - | error: aborting due to 4 previous errors; 1 warning emitted diff --git a/tests/ui/not-enough-arguments.rs b/tests/ui/fn/fn-arg-count-mismatch-diagnostics.rs index ec660a1de81..b2f80ba1bf6 100644 --- a/tests/ui/not-enough-arguments.rs +++ b/tests/ui/fn/fn-arg-count-mismatch-diagnostics.rs @@ -1,15 +1,15 @@ +//! Checks clean diagnostics for argument count mismatches without unrelated errors. +//! +//! `delegate!` part related: <https://github.com/rust-lang/rust/pull/140591> + //@ aux-build: delegate_macro.rs extern crate delegate_macro; use delegate_macro::delegate; -// Check that the only error msg we report is the -// mismatch between the # of params, and not other -// unrelated errors. fn foo(a: isize, b: isize, c: isize, d: isize) { panic!(); } -// Check that all arguments are shown in the error message, even if they're across multiple lines. fn bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) { println!("{}", a); println!("{}", b); @@ -37,6 +37,7 @@ struct Bar; impl Bar { fn foo(a: u8, b: u8) {} + fn bar() { delegate_local!(foo); delegate!(foo); diff --git a/tests/ui/not-enough-arguments.stderr b/tests/ui/fn/fn-arg-count-mismatch-diagnostics.stderr index 908d0273bbe..6af7671af03 100644 --- a/tests/ui/not-enough-arguments.stderr +++ b/tests/ui/fn/fn-arg-count-mismatch-diagnostics.stderr @@ -1,5 +1,5 @@ error[E0061]: this function takes 2 arguments but 1 argument was supplied - --> $DIR/not-enough-arguments.rs:24:9 + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:24:9 | LL | <Self>::$method(8) | ^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing @@ -8,7 +8,7 @@ LL | delegate_local!(foo); | -------------------- in this macro invocation | note: associated function defined here - --> $DIR/not-enough-arguments.rs:39:8 + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:39:8 | LL | fn foo(a: u8, b: u8) {} | ^^^ ----- @@ -19,20 +19,20 @@ LL | <Self>::$method(8, /* u8 */) | ++++++++++ error[E0061]: this function takes 2 arguments but 1 argument was supplied - --> $DIR/not-enough-arguments.rs:42:9 + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:43:9 | LL | delegate!(foo); | ^^^^^^^^^^^^^^ argument #2 of type `u8` is missing | note: associated function defined here - --> $DIR/not-enough-arguments.rs:39:8 + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:39:8 | LL | fn foo(a: u8, b: u8) {} | ^^^ ----- = note: this error originates in the macro `delegate` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0061]: this function takes 2 arguments but 1 argument was supplied - --> $DIR/not-enough-arguments.rs:31:9 + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:31:9 | LL | <$from>::$method(8) | ^^^^^^^^^^^^^^^^--- argument #2 of type `u8` is missing @@ -41,7 +41,7 @@ LL | delegate_from!(Bar, foo); | ------------------------ in this macro invocation | note: associated function defined here - --> $DIR/not-enough-arguments.rs:39:8 + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:39:8 | LL | fn foo(a: u8, b: u8) {} | ^^^ ----- @@ -52,13 +52,13 @@ LL | <$from>::$method(8, /* u8 */) | ++++++++++ error[E0061]: this function takes 4 arguments but 3 arguments were supplied - --> $DIR/not-enough-arguments.rs:49:5 + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:50:5 | LL | foo(1, 2, 3); | ^^^--------- argument #4 of type `isize` is missing | note: function defined here - --> $DIR/not-enough-arguments.rs:8:4 + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:9:4 | LL | fn foo(a: isize, b: isize, c: isize, d: isize) { | ^^^ -------- @@ -68,13 +68,13 @@ LL | foo(1, 2, 3, /* isize */); | +++++++++++++ error[E0061]: this function takes 6 arguments but 3 arguments were supplied - --> $DIR/not-enough-arguments.rs:51:5 + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:52:5 | LL | bar(1, 2, 3); | ^^^--------- three arguments of type `i32`, `i32`, and `i32` are missing | note: function defined here - --> $DIR/not-enough-arguments.rs:13:4 + --> $DIR/fn-arg-count-mismatch-diagnostics.rs:13:4 | LL | fn bar(a: i32, b: i32, c: i32, d: i32, e: i32, f: i32) { | ^^^ ------ ------ ------ diff --git a/tests/ui/fn/issue-39259.stderr b/tests/ui/fn/issue-39259.stderr index a923d7b26ef..90e305ca17a 100644 --- a/tests/ui/fn/issue-39259.stderr +++ b/tests/ui/fn/issue-39259.stderr @@ -10,6 +10,14 @@ help: parenthesized trait syntax expands to `Fn<(u32,), Output=u32>` LL | impl Fn(u32) -> u32 for S { | ^^^^^^^^^^^^^^ +error[E0050]: method `call` has 1 parameter but the declaration in trait `call` has 2 + --> $DIR/issue-39259.rs:9:13 + | +LL | fn call(&self) -> u32 { + | ^^^^^ expected 2 parameters, found 1 + | + = note: `call` from trait: `extern "rust-call" fn(&Self, Args) -> <Self as FnOnce<Args>>::Output` + error[E0277]: expected a `FnMut(u32)` closure, found `S` --> $DIR/issue-39259.rs:6:25 | @@ -20,14 +28,6 @@ LL | impl Fn(u32) -> u32 for S { note: required by a bound in `Fn` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error[E0050]: method `call` has 1 parameter but the declaration in trait `call` has 2 - --> $DIR/issue-39259.rs:9:13 - | -LL | fn call(&self) -> u32 { - | ^^^^^ expected 2 parameters, found 1 - | - = note: `call` from trait: `extern "rust-call" fn(&Self, Args) -> <Self as FnOnce<Args>>::Output` - error: aborting due to 3 previous errors Some errors have detailed explanations: E0050, E0229, E0277. diff --git a/tests/ui/fn/mutable-function-parameters.rs b/tests/ui/fn/mutable-function-parameters.rs new file mode 100644 index 00000000000..5045a783f04 --- /dev/null +++ b/tests/ui/fn/mutable-function-parameters.rs @@ -0,0 +1,24 @@ +//! Test that function and closure parameters marked as `mut` can be mutated +//! within the function body. + +//@ run-pass + +fn f(mut y: Box<isize>) { + *y = 5; + assert_eq!(*y, 5); +} + +fn g() { + let frob = |mut q: Box<isize>| { + *q = 2; + assert_eq!(*q, 2); + }; + let w = Box::new(37); + frob(w); +} + +pub fn main() { + let z = Box::new(17); + f(z); + g(); +} diff --git a/tests/ui/generic-associated-types/bugs/issue-87735.stderr b/tests/ui/generic-associated-types/bugs/issue-87735.stderr index 1b955431363..c3f4f7a73f3 100644 --- a/tests/ui/generic-associated-types/bugs/issue-87735.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-87735.stderr @@ -5,12 +5,13 @@ LL | impl<'b, T, U> AsRef2 for Foo<T> | ^ unconstrained type parameter error[E0309]: the parameter type `U` may not live long enough - --> $DIR/issue-87735.rs:34:21 + --> $DIR/issue-87735.rs:34:3 | LL | type Output<'a> = FooRef<'a, U> where Self: 'a; - | -- ^^^^^^^^^^^^^ ...so that the type `U` will meet its required lifetime bounds... - | | - | the parameter type `U` must be valid for the lifetime `'a` as defined here... + | ^^^^^^^^^^^^--^ + | | | + | | the parameter type `U` must be valid for the lifetime `'a` as defined here... + | ...so that the type `U` will meet its required lifetime bounds... | note: ...that is required by this bound --> $DIR/issue-87735.rs:23:22 diff --git a/tests/ui/generic-associated-types/bugs/issue-88526.stderr b/tests/ui/generic-associated-types/bugs/issue-88526.stderr index 5da3e3ff64a..5e39eb7a6b9 100644 --- a/tests/ui/generic-associated-types/bugs/issue-88526.stderr +++ b/tests/ui/generic-associated-types/bugs/issue-88526.stderr @@ -5,12 +5,13 @@ LL | impl<'q, Q, I, F> A for TestB<Q, F> | ^ unconstrained type parameter error[E0309]: the parameter type `F` may not live long enough - --> $DIR/issue-88526.rs:16:18 + --> $DIR/issue-88526.rs:16:5 | LL | type I<'a> = &'a F; - | -- ^^^^^ ...so that the reference type `&'a F` does not outlive the data it points at - | | - | the parameter type `F` must be valid for the lifetime `'a` as defined here... + | ^^^^^^^--^ + | | | + | | the parameter type `F` must be valid for the lifetime `'a` as defined here... + | ...so that the reference type `&'a F` does not outlive the data it points at | help: consider adding an explicit lifetime bound | diff --git a/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs b/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs index d00c036fbd5..81e2db182bc 100644 --- a/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs +++ b/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.rs @@ -9,6 +9,7 @@ impl <T, T1> Foo for T { type F<T1> = &[u8]; //~^ ERROR: the name `T1` is already used for //~| ERROR: `&` without an explicit lifetime name cannot be used here + //~| ERROR: has 1 type parameter but its trait declaration has 0 type parameters } fn main() {} diff --git a/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr b/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr index cb2b9f32bfe..42aa83c8f43 100644 --- a/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr +++ b/tests/ui/generic-associated-types/gat-trait-path-generic-type-arg.stderr @@ -13,13 +13,22 @@ error[E0637]: `&` without an explicit lifetime name cannot be used here LL | type F<T1> = &[u8]; | ^ explicit lifetime name needed here +error[E0049]: associated type `F` has 1 type parameter but its trait declaration has 0 type parameters + --> $DIR/gat-trait-path-generic-type-arg.rs:9:12 + | +LL | type F<'a>; + | -- expected 0 type parameters +... +LL | type F<T1> = &[u8]; + | ^^ found 1 type parameter + error[E0207]: the type parameter `T1` is not constrained by the impl trait, self type, or predicates --> $DIR/gat-trait-path-generic-type-arg.rs:7:10 | LL | impl <T, T1> Foo for T { | ^^ unconstrained type parameter -error: aborting due to 3 previous errors +error: aborting due to 4 previous errors -Some errors have detailed explanations: E0207, E0403, E0637. -For more information about an error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0049, E0207, E0403, E0637. +For more information about an error, try `rustc --explain E0049`. diff --git a/tests/ui/generic-associated-types/generic-associated-types-where.stderr b/tests/ui/generic-associated-types/generic-associated-types-where.stderr index 7dce34650d7..637f86f7bec 100644 --- a/tests/ui/generic-associated-types/generic-associated-types-where.stderr +++ b/tests/ui/generic-associated-types/generic-associated-types-where.stderr @@ -2,9 +2,8 @@ error[E0277]: `T` doesn't implement `std::fmt::Display` --> $DIR/generic-associated-types-where.rs:18:22 | LL | type Assoc2<T> = Vec<T>; - | ^^^^^^ `T` cannot be formatted with the default formatter + | ^^^^^^ the trait `std::fmt::Display` is not implemented for `T` | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead help: consider restricting type parameter `T` with trait `Display` | LL | type Assoc2<T: std::fmt::Display> = Vec<T>; diff --git a/tests/ui/generic-associated-types/issue-84931.stderr b/tests/ui/generic-associated-types/issue-84931.stderr index 71d112277a3..01819481108 100644 --- a/tests/ui/generic-associated-types/issue-84931.stderr +++ b/tests/ui/generic-associated-types/issue-84931.stderr @@ -18,12 +18,13 @@ LL | type Item<'a> = &'a mut T where Self: 'a; | ++++++++++++++ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/issue-84931.rs:14:21 + --> $DIR/issue-84931.rs:14:5 | LL | type Item<'a> = &'a mut T; - | -- ^^^^^^^^^ ...so that the reference type `&'a mut T` does not outlive the data it points at - | | - | the parameter type `T` must be valid for the lifetime `'a` as defined here... + | ^^^^^^^^^^--^ + | | | + | | the parameter type `T` must be valid for the lifetime `'a` as defined here... + | ...so that the reference type `&'a mut T` does not outlive the data it points at | help: consider adding an explicit lifetime bound | diff --git a/tests/ui/generic-associated-types/static-lifetime-tip-with-default-type.stderr b/tests/ui/generic-associated-types/static-lifetime-tip-with-default-type.stderr index 7d985a9013f..786aa00350c 100644 --- a/tests/ui/generic-associated-types/static-lifetime-tip-with-default-type.stderr +++ b/tests/ui/generic-associated-types/static-lifetime-tip-with-default-type.stderr @@ -82,6 +82,14 @@ help: consider adding an explicit lifetime bound LL | struct Far<T: 'static | +++++++++ +error[E0392]: lifetime parameter `'a` is never used + --> $DIR/static-lifetime-tip-with-default-type.rs:22:10 + | +LL | struct S<'a, K: 'a = i32>(&'static K); + | ^^ unused lifetime parameter + | + = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` + error[E0310]: the parameter type `K` may not live long enough --> $DIR/static-lifetime-tip-with-default-type.rs:22:27 | @@ -96,14 +104,6 @@ help: consider adding an explicit lifetime bound LL | struct S<'a, K: 'a + 'static = i32>(&'static K); | +++++++++ -error[E0392]: lifetime parameter `'a` is never used - --> $DIR/static-lifetime-tip-with-default-type.rs:22:10 - | -LL | struct S<'a, K: 'a = i32>(&'static K); - | ^^ unused lifetime parameter - | - = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` - error: aborting due to 8 previous errors Some errors have detailed explanations: E0310, E0392. diff --git a/tests/ui/generic-const-items/assoc-const-AnonConst-ice-108220.rs b/tests/ui/generic-const-items/assoc-const-AnonConst-ice-108220.rs deleted file mode 100644 index f5babb67b56..00000000000 --- a/tests/ui/generic-const-items/assoc-const-AnonConst-ice-108220.rs +++ /dev/null @@ -1,35 +0,0 @@ -// ICE assertion failed: matches!(self.def_kind(ct.def.did), DefKind :: AnonConst) -// issue: rust-lang/rust#108220 -//@ check-pass - -#![feature(associated_const_equality)] -#![allow(unused)] - -use std::marker::PhantomData; - -pub struct NoPin; - -pub trait SetAlternate<const A: u8> {} - -impl SetAlternate<0> for NoPin {} - -pub trait PinA<PER> { - const A: u8; -} - -impl<PER> PinA<PER> for NoPin { - const A: u8 = 0; -} - -pub trait Pins<USART> {} - -impl<USART, T, const TA: u8> Pins<USART> for T where - T: PinA<USART, A = { TA }> + SetAlternate<TA> -{ -} - -struct Serial<USART>(PhantomData<USART>); - -impl<USART> Serial<USART> where NoPin: Pins<USART> {} - -fn main() {} diff --git a/tests/ui/generic-const-items/evaluatable-bounds.stderr b/tests/ui/generic-const-items/evaluatable-bounds.stderr index ca26d633658..8bc4a3d236f 100644 --- a/tests/ui/generic-const-items/evaluatable-bounds.stderr +++ b/tests/ui/generic-const-items/evaluatable-bounds.stderr @@ -2,7 +2,7 @@ error: unconstrained generic constant --> $DIR/evaluatable-bounds.rs:14:5 | LL | const ARRAY: [i32; Self::LEN]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | help: try adding a `where` bound | diff --git a/tests/ui/generics/default-type-params-well-formedness.rs b/tests/ui/generics/default-type-params-well-formedness.rs new file mode 100644 index 00000000000..22b8f5011f7 --- /dev/null +++ b/tests/ui/generics/default-type-params-well-formedness.rs @@ -0,0 +1,50 @@ +//! Test for well-formedness checking of default type parameters. +//! +//! Regression Test for: https://github.com/rust-lang/rust/issues/49344 + +//@ run-pass + +#![allow(dead_code)] + +trait Trait<T> {} +struct Foo<U, V = i32>(U, V) +where + U: Trait<V>; + +trait Marker {} +struct TwoParams<T, U>(T, U); +impl Marker for TwoParams<i32, i32> {} + +// Clauses with more than 1 param are not checked. +struct IndividuallyBogus<T = i32, U = i32>(TwoParams<T, U>) +where + TwoParams<T, U>: Marker; + +struct BogusTogether<T = u32, U = i32>(T, U) +where + TwoParams<T, U>: Marker; + +// Clauses with non-defaulted params are not checked. +struct NonDefaultedInClause<T, U = i32>(TwoParams<T, U>) +where + TwoParams<T, U>: Marker; + +struct DefaultedLhs<U, V = i32>(U, V) +where + V: Trait<U>; + +// Dependent defaults are not checked. +struct Dependent<T, U = T>(T, U) +where + U: Copy; + +trait SelfBound<T: Copy = Self> {} + +// Not even for well-formedness. +struct WellFormedProjection<A, T = <A as Iterator>::Item>(A, T); + +// Issue #49344, predicates with lifetimes should not be checked. +trait Scope<'a> {} +struct Request<'a, S: Scope<'a> = i32>(S, &'a ()); + +fn main() {} diff --git a/tests/ui/generics/generic-extern-lifetime.stderr b/tests/ui/generics/generic-extern-lifetime.stderr index 33332e760f5..6f9b496f1cd 100644 --- a/tests/ui/generics/generic-extern-lifetime.stderr +++ b/tests/ui/generics/generic-extern-lifetime.stderr @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/generic-extern-lifetime.rs:6:26 | LL | pub fn life2<'b>(x: &'a i32, y: &'b i32); - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `'a,` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | pub fn life2<'a, 'b>(x: &'a i32, y: &'b i32); + | +++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/generic-extern-lifetime.rs:8:37 diff --git a/tests/ui/generics/generic-params-nested-fn-scope-error.rs b/tests/ui/generics/generic-params-nested-fn-scope-error.rs new file mode 100644 index 00000000000..eaf514da337 --- /dev/null +++ b/tests/ui/generics/generic-params-nested-fn-scope-error.rs @@ -0,0 +1,14 @@ +//! Test that generic parameters from an outer function are not accessible +//! in nested functions. + +fn foo<U>(v: Vec<U>) -> U { + fn bar(w: [U]) -> U { + //~^ ERROR can't use generic parameters from outer item + //~| ERROR can't use generic parameters from outer item + return w[0]; + } + + return bar(v); +} + +fn main() {} diff --git a/tests/ui/nested-ty-params.stderr b/tests/ui/generics/generic-params-nested-fn-scope-error.stderr index 7ca65b421b2..7fd1069c651 100644 --- a/tests/ui/nested-ty-params.stderr +++ b/tests/ui/generics/generic-params-nested-fn-scope-error.stderr @@ -1,19 +1,19 @@ error[E0401]: can't use generic parameters from outer item - --> $DIR/nested-ty-params.rs:2:16 + --> $DIR/generic-params-nested-fn-scope-error.rs:5:16 | -LL | fn hd<U>(v: Vec<U> ) -> U { - | - type parameter from outer item -LL | fn hd1(w: [U]) -> U { return w[0]; } +LL | fn foo<U>(v: Vec<U>) -> U { + | - type parameter from outer item +LL | fn bar(w: [U]) -> U { | - ^ use of generic parameter from outer item | | | help: try introducing a local generic parameter here: `<U>` error[E0401]: can't use generic parameters from outer item - --> $DIR/nested-ty-params.rs:2:23 + --> $DIR/generic-params-nested-fn-scope-error.rs:5:23 | -LL | fn hd<U>(v: Vec<U> ) -> U { - | - type parameter from outer item -LL | fn hd1(w: [U]) -> U { return w[0]; } +LL | fn foo<U>(v: Vec<U>) -> U { + | - type parameter from outer item +LL | fn bar(w: [U]) -> U { | - ^ use of generic parameter from outer item | | | help: try introducing a local generic parameter here: `<U>` diff --git a/tests/ui/generics/impl-block-params-declared-in-wrong-spot-issue-113073.stderr b/tests/ui/generics/impl-block-params-declared-in-wrong-spot-issue-113073.stderr index c60c4c72a21..33d0c9c9707 100644 --- a/tests/ui/generics/impl-block-params-declared-in-wrong-spot-issue-113073.stderr +++ b/tests/ui/generics/impl-block-params-declared-in-wrong-spot-issue-113073.stderr @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:7:13 | LL | impl Foo<T: 'a + Default> for u8 {} - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `<'a>` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | impl<'a> Foo<T: 'a + Default> for u8 {} + | ++++ error[E0229]: associated item constraints are not allowed here --> $DIR/impl-block-params-declared-in-wrong-spot-issue-113073.rs:3:10 diff --git a/tests/ui/generics/newtype-with-generics.rs b/tests/ui/generics/newtype-with-generics.rs new file mode 100644 index 00000000000..c5e200e4bc4 --- /dev/null +++ b/tests/ui/generics/newtype-with-generics.rs @@ -0,0 +1,32 @@ +//! Test newtype pattern with generic parameters. + +//@ run-pass + +#[derive(Clone)] +struct MyVec<T>(Vec<T>); + +fn extract_inner_vec<T: Clone>(wrapper: MyVec<T>) -> Vec<T> { + let MyVec(inner_vec) = wrapper; + inner_vec.clone() +} + +fn get_first_element<T>(wrapper: MyVec<T>) -> T { + let MyVec(inner_vec) = wrapper; + inner_vec.into_iter().next().unwrap() +} + +pub fn main() { + let my_vec = MyVec(vec![1, 2, 3]); + let cloned_vec = my_vec.clone(); + + // Test extracting inner vector + let extracted = extract_inner_vec(cloned_vec); + assert_eq!(extracted[1], 2); + + // Test getting first element + assert_eq!(get_first_element(my_vec.clone()), 1); + + // Test direct destructuring + let MyVec(inner) = my_vec; + assert_eq!(inner[2], 3); +} diff --git a/tests/ui/generics/overlapping-errors-span-issue-123861.stderr b/tests/ui/generics/overlapping-errors-span-issue-123861.stderr index 9622dffda9f..7d08d8fed9f 100644 --- a/tests/ui/generics/overlapping-errors-span-issue-123861.stderr +++ b/tests/ui/generics/overlapping-errors-span-issue-123861.stderr @@ -30,12 +30,6 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures | LL | fn mainIterator<_ = _> {} | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn mainIterator<_ = _> {} -LL + fn mainIterator<T = T> {} - | error: aborting due to 4 previous errors diff --git a/tests/ui/seq-args.rs b/tests/ui/generics/trait-incorrect-generic-args.rs index 627dfcc3198..9715100b19c 100644 --- a/tests/ui/seq-args.rs +++ b/tests/ui/generics/trait-incorrect-generic-args.rs @@ -1,5 +1,7 @@ +//! Check for compilation errors when a trait is used with an incorrect number of generic arguments. + fn main() { - trait Seq { } + trait Seq {} impl<T> Seq<T> for Vec<T> { //~^ ERROR trait takes 0 generic arguments but 1 generic argument diff --git a/tests/ui/seq-args.stderr b/tests/ui/generics/trait-incorrect-generic-args.stderr index 6e0d484d013..afc4ff03d94 100644 --- a/tests/ui/seq-args.stderr +++ b/tests/ui/generics/trait-incorrect-generic-args.stderr @@ -1,5 +1,5 @@ error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/seq-args.rs:4:13 + --> $DIR/trait-incorrect-generic-args.rs:6:13 | LL | impl<T> Seq<T> for Vec<T> { | ^^^--- help: remove the unnecessary generics @@ -7,13 +7,13 @@ LL | impl<T> Seq<T> for Vec<T> { | expected 0 generic arguments | note: trait defined here, with 0 generic parameters - --> $DIR/seq-args.rs:2:11 + --> $DIR/trait-incorrect-generic-args.rs:4:11 | -LL | trait Seq { } +LL | trait Seq {} | ^^^ error[E0107]: trait takes 0 generic arguments but 1 generic argument was supplied - --> $DIR/seq-args.rs:9:10 + --> $DIR/trait-incorrect-generic-args.rs:11:10 | LL | impl Seq<bool> for u32 { | ^^^------ help: remove the unnecessary generics @@ -21,9 +21,9 @@ LL | impl Seq<bool> for u32 { | expected 0 generic arguments | note: trait defined here, with 0 generic parameters - --> $DIR/seq-args.rs:2:11 + --> $DIR/trait-incorrect-generic-args.rs:4:11 | -LL | trait Seq { } +LL | trait Seq {} | ^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/generics/unconstrained-type-params-inherent-impl.rs b/tests/ui/generics/unconstrained-type-params-inherent-impl.rs new file mode 100644 index 00000000000..c971de0d1f2 --- /dev/null +++ b/tests/ui/generics/unconstrained-type-params-inherent-impl.rs @@ -0,0 +1,32 @@ +//! Test for unconstrained type parameters in inherent implementations + +struct MyType; + +struct MyType1<T>(T); + +trait Bar { + type Out; +} + +impl<T> MyType { + //~^ ERROR the type parameter `T` is not constrained + // T is completely unused - this should fail +} + +impl<T> MyType1<T> { + // OK: T is used in the self type `MyType1<T>` +} + +impl<T, U> MyType1<T> { + //~^ ERROR the type parameter `U` is not constrained + // T is used in self type, but U is unconstrained - this should fail +} + +impl<T, U> MyType1<T> +where + T: Bar<Out = U>, +{ + // OK: T is used in self type, U is constrained through the where clause +} + +fn main() {} diff --git a/tests/ui/impl-unused-tps-inherent.stderr b/tests/ui/generics/unconstrained-type-params-inherent-impl.stderr index 43f63cf968c..19b02ad396c 100644 --- a/tests/ui/impl-unused-tps-inherent.stderr +++ b/tests/ui/generics/unconstrained-type-params-inherent-impl.stderr @@ -1,14 +1,14 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps-inherent.rs:9:6 + --> $DIR/unconstrained-type-params-inherent-impl.rs:11:6 | LL | impl<T> MyType { | ^ unconstrained type parameter error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps-inherent.rs:17:8 + --> $DIR/unconstrained-type-params-inherent-impl.rs:20:9 | -LL | impl<T,U> MyType1<T> { - | ^ unconstrained type parameter +LL | impl<T, U> MyType1<T> { + | ^ unconstrained type parameter error: aborting due to 2 previous errors diff --git a/tests/ui/issue-15924.rs b/tests/ui/higher-ranked/higher-ranked-encoding.rs index eb2aef9cee1..463e0f50e53 100644 --- a/tests/ui/issue-15924.rs +++ b/tests/ui/higher-ranked/higher-ranked-encoding.rs @@ -1,9 +1,7 @@ -//@ run-pass +//! Regression test for https://github.com/rust-lang/rust/issues/15924 -#![allow(unused_imports)] -#![allow(unused_must_use)] +//@ run-pass -use std::fmt; use std::marker::PhantomData; trait Encoder { @@ -26,9 +24,8 @@ impl Encoder for JsonEncoder<'_> { type Error = (); } -fn encode_json<T: for<'r> Encodable<JsonEncoder<'r>>>( - object: &T, -) -> Result<String, ()> { +// This function uses higher-ranked trait bounds, which previously caused ICE +fn encode_json<T: for<'r> Encodable<JsonEncoder<'r>>>(object: &T) -> Result<String, ()> { let s = String::new(); { let mut encoder = JsonEncoder(PhantomData); @@ -37,13 +34,15 @@ fn encode_json<T: for<'r> Encodable<JsonEncoder<'r>>>( Ok(s) } +// Structure with HRTB constraint that was problematic struct Foo<T: for<'a> Encodable<JsonEncoder<'a>>> { v: T, } +// Drop implementation that exercises the HRTB bounds impl<T: for<'a> Encodable<JsonEncoder<'a>>> Drop for Foo<T> { fn drop(&mut self) { - encode_json(&self.v); + let _ = encode_json(&self.v); } } diff --git a/tests/ui/higher-ranked/structually-relate-aliases.stderr b/tests/ui/higher-ranked/structually-relate-aliases.stderr index 025fcc5e170..b27a2dcceb1 100644 --- a/tests/ui/higher-ranked/structually-relate-aliases.stderr +++ b/tests/ui/higher-ranked/structually-relate-aliases.stderr @@ -1,4 +1,4 @@ - WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, '^0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a), "'a")], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit), .. } + WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: [?1t, '^0.Named(DefId(0:15 ~ structually_relate_aliases[de75]::{impl#1}::'a))], def_id: DefId(0:5 ~ structually_relate_aliases[de75]::ToUnit::Unit), .. } error[E0277]: the trait bound `for<'a> T: ToUnit<'a>` is not satisfied --> $DIR/structually-relate-aliases.rs:13:36 | diff --git a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr index 7fe803550bd..5ded3a5e76c 100644 --- a/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr +++ b/tests/ui/higher-ranked/trait-bounds/normalize-under-binder/issue-89118.stderr @@ -53,10 +53,10 @@ LL | Ctx<()>: for<'a> BufferUdpStateContext<&'a ()>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `EthernetWorker` error[E0277]: the trait bound `for<'a> &'a (): BufferMut` is not satisfied - --> $DIR/issue-89118.rs:22:20 + --> $DIR/issue-89118.rs:22:5 | LL | type Handler = Ctx<C::Dispatcher>; - | ^^^^^^^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` + | ^^^^^^^^^^^^ the trait `for<'a> BufferMut` is not implemented for `&'a ()` | help: this trait has no implementations, consider adding one --> $DIR/issue-89118.rs:1:1 diff --git a/tests/ui/hygiene/no_implicit_prelude.stderr b/tests/ui/hygiene/no_implicit_prelude.stderr index 5de6e3db327..42049da23eb 100644 --- a/tests/ui/hygiene/no_implicit_prelude.stderr +++ b/tests/ui/hygiene/no_implicit_prelude.stderr @@ -23,8 +23,6 @@ LL | ().clone() | ^^^^^ | = help: items from traits can only be used if the trait is in scope -help: there is a method `clone_from` with a similar name, but with different arguments - --> $SRC_DIR/core/src/clone.rs:LL:COL = note: this error originates in the macro `::bar::m` (in Nightly builds, run with -Z macro-backtrace for more info) help: trait `Clone` which provides `clone` is implemented but not in scope; perhaps you want to import it | diff --git a/tests/ui/impl-header-lifetime-elision/assoc-type.rs b/tests/ui/impl-header-lifetime-elision/assoc-type.rs index db3c416540f..14b2ea647f1 100644 --- a/tests/ui/impl-header-lifetime-elision/assoc-type.rs +++ b/tests/ui/impl-header-lifetime-elision/assoc-type.rs @@ -9,7 +9,7 @@ trait MyTrait { impl MyTrait for &i32 { type Output = &i32; - //~^ ERROR 11:19: 11:20: in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type + //~^ ERROR in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type } impl MyTrait for &u32 { diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.edition2015.stderr index a2d00edbb6d..68b4e2ed39f 100644 --- a/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.stderr +++ b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.edition2015.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl Sized + 'a` captures lifetime that does not appear in bounds - --> $DIR/rpit-hidden-erased-unsoundness.rs:16:5 + --> $DIR/rpit-hidden-erased-unsoundness.rs:19:5 | LL | fn step2<'a, 'b: 'a>() -> impl Sized + 'a { | -- --------------- opaque type defined here diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.edition2024.stderr b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.edition2024.stderr new file mode 100644 index 00000000000..6c0c1789582 --- /dev/null +++ b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.edition2024.stderr @@ -0,0 +1,10 @@ +error: lifetime may not live long enough + --> $DIR/rpit-hidden-erased-unsoundness.rs:24:5 + | +LL | fn step3<'a, 'b: 'a>() -> impl Send + 'a { + | -- lifetime `'b` defined here +LL | step2::<'a, 'b>() + | ^^^^^^^^^^^^^^^^^ returning this value requires that `'b` must outlive `'static` + +error: aborting due to 1 previous error + diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs index 6863a3c73ba..3338063d8c6 100644 --- a/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs +++ b/tests/ui/impl-trait/alias-liveness/rpit-hidden-erased-unsoundness.rs @@ -1,3 +1,6 @@ +//@revisions: edition2015 edition2024 +//@[edition2015] edition:2015 +//@[edition2024] edition:2024 // This test should never pass! #![feature(type_alias_impl_trait)] @@ -14,11 +17,12 @@ fn step1<'a, 'b: 'a>() -> impl Sized + Captures<'b> + 'a { fn step2<'a, 'b: 'a>() -> impl Sized + 'a { step1::<'a, 'b>() - //~^ ERROR hidden type for `impl Sized + 'a` captures lifetime that does not appear in bounds + //[edition2015]~^ ERROR hidden type for `impl Sized + 'a` captures lifetime that does not appear in bounds } fn step3<'a, 'b: 'a>() -> impl Send + 'a { step2::<'a, 'b>() + //[edition2024]~^ ERROR lifetime may not live long enough // This should not be Send unless `'b: 'static` } diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.edition2015.stderr index a1e92e53384..769a878a45c 100644 --- a/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.stderr +++ b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.edition2015.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds - --> $DIR/rpit-hide-lifetime-for-swap.rs:17:5 + --> $DIR/rpit-hide-lifetime-for-swap.rs:20:5 | LL | fn hide<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a { | -- -------------- opaque type defined here diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.edition2024.stderr b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.edition2024.stderr new file mode 100644 index 00000000000..6109184250b --- /dev/null +++ b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.edition2024.stderr @@ -0,0 +1,17 @@ +error[E0597]: `x` does not live long enough + --> $DIR/rpit-hide-lifetime-for-swap.rs:27:38 + | +LL | let x = [1, 2, 3]; + | - binding `x` declared here +LL | let short = Rc::new(RefCell::new(&x)); + | ^^ borrowed value does not live long enough +... +LL | let res: &'static [i32; 3] = *long.borrow(); + | ----------------- type annotation requires that `x` is borrowed for `'static` +LL | res +LL | } + | - `x` dropped here while still borrowed + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0597`. diff --git a/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs index 4de2ffbb808..c4eaec478b8 100644 --- a/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs +++ b/tests/ui/impl-trait/alias-liveness/rpit-hide-lifetime-for-swap.rs @@ -1,3 +1,6 @@ +//@revisions: edition2015 edition2024 +//@[edition2015] edition:2015 +//@[edition2024] edition:2024 // This test should never pass! use std::cell::RefCell; @@ -15,13 +18,14 @@ impl<T> Swap for Rc<RefCell<T>> { fn hide<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a { x - //~^ ERROR hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds + //[edition2015]~^ ERROR hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds } fn dangle() -> &'static [i32; 3] { let long = Rc::new(RefCell::new(&[4, 5, 6])); let x = [1, 2, 3]; let short = Rc::new(RefCell::new(&x)); + //[edition2024]~^ ERROR `x` does not live long enough hide(long.clone()).swap(hide(short)); let res: &'static [i32; 3] = *long.borrow(); res diff --git a/tests/ui/impl-trait/auto-trait-selection-freeze.old.stderr b/tests/ui/impl-trait/auto-trait-selection-freeze.old.stderr index b4d2229d408..b6c6e74f260 100644 --- a/tests/ui/impl-trait/auto-trait-selection-freeze.old.stderr +++ b/tests/ui/impl-trait/auto-trait-selection-freeze.old.stderr @@ -2,7 +2,9 @@ error[E0283]: type annotations needed --> $DIR/auto-trait-selection-freeze.rs:19:16 | LL | if false { is_trait(foo()) } else { Default::default() } - | ^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `is_trait` + | ^^^^^^^^ ----- type must be known at this point + | | + | cannot infer type of the type parameter `U` declared on the function `is_trait` | note: multiple `impl`s satisfying `impl Sized: Trait<_>` found --> $DIR/auto-trait-selection-freeze.rs:16:1 diff --git a/tests/ui/impl-trait/auto-trait-selection.old.stderr b/tests/ui/impl-trait/auto-trait-selection.old.stderr index 1b5fd95fdf9..8e441001771 100644 --- a/tests/ui/impl-trait/auto-trait-selection.old.stderr +++ b/tests/ui/impl-trait/auto-trait-selection.old.stderr @@ -2,7 +2,9 @@ error[E0283]: type annotations needed --> $DIR/auto-trait-selection.rs:15:16 | LL | if false { is_trait(foo()) } else { Default::default() } - | ^^^^^^^^ cannot infer type of the type parameter `U` declared on the function `is_trait` + | ^^^^^^^^ ----- type must be known at this point + | | + | cannot infer type of the type parameter `U` declared on the function `is_trait` | note: multiple `impl`s satisfying `impl Sized: Trait<_>` found --> $DIR/auto-trait-selection.rs:12:1 diff --git a/tests/ui/new-impl-syntax.rs b/tests/ui/impl-trait/basic-trait-impl.rs index 124d604e6a8..2706c9c1798 100644 --- a/tests/ui/new-impl-syntax.rs +++ b/tests/ui/impl-trait/basic-trait-impl.rs @@ -1,10 +1,12 @@ +//! Test basic trait implementation syntax for both simple and generic types. + //@ run-pass use std::fmt; struct Thingy { x: isize, - y: isize + y: isize, } impl fmt::Debug for Thingy { @@ -14,10 +16,10 @@ impl fmt::Debug for Thingy { } struct PolymorphicThingy<T> { - x: T + x: T, } -impl<T:fmt::Debug> fmt::Debug for PolymorphicThingy<T> { +impl<T: fmt::Debug> fmt::Debug for PolymorphicThingy<T> { fn fmt(&self, f: &mut fmt::Formatter) -> fmt::Result { write!(f, "{:?}", self.x) } diff --git a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.edition2015.stderr index 304d7d43b78..64f0b201ca2 100644 --- a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr +++ b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.edition2015.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:10:13 | LL | fn fuz() -> (usize, Trait) { (42, Struct) } | ^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -9,7 +9,7 @@ LL | fn fuz() -> (usize, Trait) { (42, Struct) } = note: the return type of a function must have a statically known size error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13 | LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -19,7 +19,7 @@ LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } = note: the return type of a function must have a statically known size error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13 | LL | fn bap() -> Trait { Struct } | ^^^^^ doesn't have a size known at compile-time @@ -34,7 +34,7 @@ LL | fn bap() -> Box<dyn Trait> { Box::new(Struct) } | +++++++ + +++++++++ + error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:17:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:22:13 | LL | fn ban() -> dyn Trait { Struct } | ^^^^^^^^^ doesn't have a size known at compile-time @@ -50,7 +50,7 @@ LL | fn ban() -> Box<dyn Trait> { Box::new(Struct) } | ++++ + +++++++++ + error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:24:13 | LL | fn bak() -> dyn Trait { unimplemented!() } | ^^^^^^^^^ doesn't have a size known at compile-time @@ -66,7 +66,7 @@ LL | fn bak() -> Box<dyn Trait> { Box::new(unimplemented!()) } | ++++ + +++++++++ + error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:21:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:26:13 | LL | fn bal() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time @@ -86,7 +86,7 @@ LL ~ Box::new(42) | error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:27:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:32:13 | LL | fn bax() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time @@ -106,7 +106,7 @@ LL ~ Box::new(42) | error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:62:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:67:13 | LL | fn bat() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time @@ -126,7 +126,7 @@ LL ~ Box::new(42) | error[E0746]: return type cannot be a trait object without pointer indirection - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:68:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:73:13 | LL | fn bay() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time @@ -146,7 +146,7 @@ LL ~ Box::new(42) | error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:35 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:10:35 | LL | fn fuz() -> (usize, Trait) { (42, Struct) } | ^^^^^^ expected `dyn Trait`, found `Struct` @@ -156,7 +156,7 @@ LL | fn fuz() -> (usize, Trait) { (42, Struct) } = help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:30 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:10:30 | LL | fn fuz() -> (usize, Trait) { (42, Struct) } | ^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -166,7 +166,7 @@ LL | fn fuz() -> (usize, Trait) { (42, Struct) } = note: tuples must have a statically known size to be initialized error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:39 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:39 | LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } | ^^^^^^ expected `dyn Trait`, found `Struct` @@ -176,7 +176,7 @@ LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } = help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:34 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:34 | LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } | ^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -186,7 +186,7 @@ LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } = note: tuples must have a statically known size to be initialized error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:36:16 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:41:16 | LL | fn bam() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -203,7 +203,7 @@ LL | return Box::new(Struct); | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:38:5 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:43:5 | LL | fn bam() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -220,7 +220,7 @@ LL | Box::new(42) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:42:16 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:47:16 | LL | fn baq() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -237,7 +237,7 @@ LL | return Box::new(0); | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:44:5 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:49:5 | LL | fn baq() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -254,7 +254,7 @@ LL | Box::new(42) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:48:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:53:9 | LL | fn baz() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -271,7 +271,7 @@ LL | Box::new(Struct) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:50:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:55:9 | LL | fn baz() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -288,7 +288,7 @@ LL | Box::new(42) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:55:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:60:9 | LL | fn baw() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -305,7 +305,7 @@ LL | Box::new(0) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:57:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:62:9 | LL | fn baw() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type diff --git a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.edition2021.stderr b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.edition2021.stderr new file mode 100644 index 00000000000..5811431b494 --- /dev/null +++ b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.edition2021.stderr @@ -0,0 +1,308 @@ +error[E0782]: expected a type, found a trait + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:10:21 + | +LL | fn fuz() -> (usize, Trait) { (42, Struct) } + | ^^^^^ + | +help: you can add the `dyn` keyword if you want a trait object + | +LL | fn fuz() -> (usize, dyn Trait) { (42, Struct) } + | +++ + +error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13 + | +LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } + | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` + = note: required because it appears within the type `(usize, (dyn Trait + 'static))` + = note: the return type of a function must have a statically known size + +error[E0782]: expected a type, found a trait + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13 + | +LL | fn bap() -> Trait { Struct } + | ^^^^^ + | +help: use `impl Trait` to return an opaque type, as long as you return a single underlying type + | +LL | fn bap() -> impl Trait { Struct } + | ++++ +help: alternatively, you can return an owned trait object + | +LL | fn bap() -> Box<dyn Trait> { Struct } + | +++++++ + + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:22:13 + | +LL | fn ban() -> dyn Trait { Struct } + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn ban() -> dyn Trait { Struct } +LL + fn ban() -> impl Trait { Struct } + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL | fn ban() -> Box<dyn Trait> { Box::new(Struct) } + | ++++ + +++++++++ + + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:24:13 + | +LL | fn bak() -> dyn Trait { unimplemented!() } + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn bak() -> dyn Trait { unimplemented!() } +LL + fn bak() -> impl Trait { unimplemented!() } + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL | fn bak() -> Box<dyn Trait> { Box::new(unimplemented!()) } + | ++++ + +++++++++ + + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:26:13 + | +LL | fn bal() -> dyn Trait { + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn bal() -> dyn Trait { +LL + fn bal() -> impl Trait { + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn bal() -> Box<dyn Trait> { +LL | if true { +LL ~ return Box::new(Struct); +LL | } +LL ~ Box::new(42) + | + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:32:13 + | +LL | fn bax() -> dyn Trait { + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn bax() -> dyn Trait { +LL + fn bax() -> impl Trait { + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn bax() -> Box<dyn Trait> { +LL | if true { +LL ~ Box::new(Struct) +LL | } else { +LL ~ Box::new(42) + | + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:67:13 + | +LL | fn bat() -> dyn Trait { + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn bat() -> dyn Trait { +LL + fn bat() -> impl Trait { + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn bat() -> Box<dyn Trait> { +LL | if true { +LL ~ return Box::new(0); +LL | } +LL ~ Box::new(42) + | + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:73:13 + | +LL | fn bay() -> dyn Trait { + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL - fn bay() -> dyn Trait { +LL + fn bay() -> impl Trait { + | +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn bay() -> Box<dyn Trait> { +LL | if true { +LL ~ Box::new(0) +LL | } else { +LL ~ Box::new(42) + | + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:39 + | +LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } + | ^^^^^^ expected `dyn Trait`, found `Struct` + | + = note: expected trait object `(dyn Trait + 'static)` + found struct `Struct` + = help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well + +error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:34 + | +LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } + | ^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` + = note: required because it appears within the type `(usize, (dyn Trait + 'static))` + = note: tuples must have a statically known size to be initialized + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:41:16 + | +LL | fn bam() -> Box<dyn Trait> { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +LL | if true { +LL | return Struct; + | ^^^^^^ expected `Box<dyn Trait>`, found `Struct` + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found struct `Struct` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | return Box::new(Struct); + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:43:5 + | +LL | fn bam() -> Box<dyn Trait> { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +... +LL | 42 + | ^^ expected `Box<dyn Trait>`, found integer + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Box::new(42) + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:47:16 + | +LL | fn baq() -> Box<dyn Trait> { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +LL | if true { +LL | return 0; + | ^ expected `Box<dyn Trait>`, found integer + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | return Box::new(0); + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:49:5 + | +LL | fn baq() -> Box<dyn Trait> { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +... +LL | 42 + | ^^ expected `Box<dyn Trait>`, found integer + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Box::new(42) + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:53:9 + | +LL | fn baz() -> Box<dyn Trait> { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +LL | if true { +LL | Struct + | ^^^^^^ expected `Box<dyn Trait>`, found `Struct` + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found struct `Struct` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Box::new(Struct) + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:55:9 + | +LL | fn baz() -> Box<dyn Trait> { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +... +LL | 42 + | ^^ expected `Box<dyn Trait>`, found integer + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Box::new(42) + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:60:9 + | +LL | fn baw() -> Box<dyn Trait> { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +LL | if true { +LL | 0 + | ^ expected `Box<dyn Trait>`, found integer + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Box::new(0) + | +++++++++ + + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:62:9 + | +LL | fn baw() -> Box<dyn Trait> { + | -------------- expected `Box<(dyn Trait + 'static)>` because of return type +... +LL | 42 + | ^^ expected `Box<dyn Trait>`, found integer + | + = note: expected struct `Box<(dyn Trait + 'static)>` + found type `{integer}` + = note: for more on the distinction between the stack and the heap, read https://doc.rust-lang.org/book/ch15-01-box.html, https://doc.rust-lang.org/rust-by-example/std/box.html, and https://doc.rust-lang.org/std/boxed/index.html +help: store this in the heap by calling `Box::new` + | +LL | Box::new(42) + | +++++++++ + + +error: aborting due to 19 previous errors + +Some errors have detailed explanations: E0277, E0308, E0746, E0782. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs index ccf0a1ad3d4..aa1f871d8ea 100644 --- a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs +++ b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs @@ -1,3 +1,6 @@ +//@revisions: edition2015 edition2021 +//@[edition2015] edition:2015 +//@[edition2021] edition:2021 #![allow(bare_trait_objects)] struct Struct; trait Trait {} @@ -5,15 +8,17 @@ impl Trait for Struct {} impl Trait for u32 {} fn fuz() -> (usize, Trait) { (42, Struct) } -//~^ ERROR E0277 -//~| ERROR E0277 -//~| ERROR E0308 +//[edition2015]~^ ERROR E0277 +//[edition2015]~| ERROR E0277 +//[edition2015]~| ERROR E0308 +//[edition2021]~^^^^ ERROR expected a type, found a trait fn bar() -> (usize, dyn Trait) { (42, Struct) } //~^ ERROR E0277 //~| ERROR E0277 //~| ERROR E0308 fn bap() -> Trait { Struct } -//~^ ERROR E0746 +//[edition2015]~^ ERROR E0746 +//[edition2021]~^^ ERROR expected a type, found a trait fn ban() -> dyn Trait { Struct } //~^ ERROR E0746 fn bak() -> dyn Trait { unimplemented!() } //~ ERROR E0746 diff --git a/tests/ui/impl-trait/hidden-lifetimes.stderr b/tests/ui/impl-trait/hidden-lifetimes.edition2015.stderr index 70d8c816ecb..b63115f7658 100644 --- a/tests/ui/impl-trait/hidden-lifetimes.stderr +++ b/tests/ui/impl-trait/hidden-lifetimes.edition2015.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds - --> $DIR/hidden-lifetimes.rs:29:5 + --> $DIR/hidden-lifetimes.rs:33:5 | LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a { | -- -------------- opaque type defined here @@ -14,7 +14,7 @@ LL | fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a + use<' | ++++++++++++++++ error[E0700]: hidden type for `impl Swap + 'a` captures lifetime that does not appear in bounds - --> $DIR/hidden-lifetimes.rs:46:5 + --> $DIR/hidden-lifetimes.rs:50:5 | LL | fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a { | -- -------------- opaque type defined here diff --git a/tests/ui/impl-trait/hidden-lifetimes.edition2024.stderr b/tests/ui/impl-trait/hidden-lifetimes.edition2024.stderr new file mode 100644 index 00000000000..d585bb50b13 --- /dev/null +++ b/tests/ui/impl-trait/hidden-lifetimes.edition2024.stderr @@ -0,0 +1,26 @@ +error[E0515]: cannot return value referencing local variable `x` + --> $DIR/hidden-lifetimes.rs:41:5 + | +LL | hide_ref(&mut res).swap(hide_ref(&mut &x)); + | -- `x` is borrowed here +LL | res + | ^^^ returns a value referencing data owned by the current function + +error[E0597]: `x` does not live long enough + --> $DIR/hidden-lifetimes.rs:57:38 + | +LL | let x = [1, 2, 3]; + | - binding `x` declared here +LL | let short = Rc::new(RefCell::new(&x)); + | ^^ borrowed value does not live long enough +LL | hide_rc_refcell(long.clone()).swap(hide_rc_refcell(short)); +LL | let res: &'static [i32; 3] = *long.borrow(); + | ----------------- type annotation requires that `x` is borrowed for `'static` +LL | res +LL | } + | - `x` dropped here while still borrowed + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0515, E0597. +For more information about an error, try `rustc --explain E0515`. diff --git a/tests/ui/impl-trait/hidden-lifetimes.rs b/tests/ui/impl-trait/hidden-lifetimes.rs index ae07c892768..b50c43bd3fa 100644 --- a/tests/ui/impl-trait/hidden-lifetimes.rs +++ b/tests/ui/impl-trait/hidden-lifetimes.rs @@ -1,3 +1,7 @@ +//@revisions: edition2015 edition2024 +//@[edition2015] edition:2015 +//@[edition2024] edition:2024 + // Test to show what happens if we were not careful and allowed invariant // lifetimes to escape though an impl trait. // @@ -27,14 +31,14 @@ impl<T> Swap for Rc<RefCell<T>> { // `&'a mut &'l T` are the same type. fn hide_ref<'a, 'b, T: 'static>(x: &'a mut &'b T) -> impl Swap + 'a { x - //~^ ERROR hidden type + //[edition2015]~^ ERROR hidden type } fn dangle_ref() -> &'static [i32; 3] { let mut res = &[4, 5, 6]; let x = [1, 2, 3]; hide_ref(&mut res).swap(hide_ref(&mut &x)); - res + res //[edition2024]~ ERROR cannot return value referencing local variable `x` } // Here we are hiding `'b` making the caller believe that `Rc<RefCell<&'s T>>` @@ -44,13 +48,13 @@ fn dangle_ref() -> &'static [i32; 3] { // only has a single lifetime. fn hide_rc_refcell<'a, 'b: 'a, T: 'static>(x: Rc<RefCell<&'b T>>) -> impl Swap + 'a { x - //~^ ERROR hidden type + //[edition2015]~^ ERROR hidden type } fn dangle_rc_refcell() -> &'static [i32; 3] { let long = Rc::new(RefCell::new(&[4, 5, 6])); let x = [1, 2, 3]; - let short = Rc::new(RefCell::new(&x)); + let short = Rc::new(RefCell::new(&x)); //[edition2024]~ ERROR `x` does not live long enough hide_rc_refcell(long.clone()).swap(hide_rc_refcell(short)); let res: &'static [i32; 3] = *long.borrow(); res diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr b/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.edition2015.stderr index 4e453c108d4..4ba59826231 100644 --- a/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.stderr +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.edition2015.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl Debug` captures lifetime that does not appear in bounds - --> $DIR/impl-fn-hrtb-bounds-2.rs:5:9 + --> $DIR/impl-fn-hrtb-bounds-2.rs:8:9 | LL | fn a() -> impl Fn(&u8) -> impl Debug { | ---------- opaque type defined here diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.edition2024.stderr b/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.edition2024.stderr new file mode 100644 index 00000000000..c7aedfe96bb --- /dev/null +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.edition2024.stderr @@ -0,0 +1,15 @@ +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` + --> $DIR/impl-fn-hrtb-bounds-2.rs:7:27 + | +LL | fn a() -> impl Fn(&u8) -> impl Debug { + | ^^^^^^^^^^ `impl Trait` implicitly captures all lifetimes in scope + | +note: lifetime declared here + --> $DIR/impl-fn-hrtb-bounds-2.rs:7:19 + | +LL | fn a() -> impl Fn(&u8) -> impl Debug { + | ^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.rs b/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.rs index b0aeded0ef7..f4bfbdeb9f3 100644 --- a/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.rs +++ b/tests/ui/impl-trait/impl-fn-hrtb-bounds-2.rs @@ -1,8 +1,11 @@ +//@revisions: edition2015 edition2024 +//@[edition2015] edition:2015 +//@[edition2024] edition:2024 #![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; -fn a() -> impl Fn(&u8) -> impl Debug { - |x| x //~ ERROR hidden type for `impl Debug` captures lifetime that does not appear in bounds +fn a() -> impl Fn(&u8) -> impl Debug { //[edition2024]~ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` + |x| x //[edition2015]~ ERROR hidden type for `impl Debug` captures lifetime that does not appear in bounds } fn main() {} diff --git a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.edition2015.stderr index 6064b09ef09..94476bcfbe8 100644 --- a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.stderr +++ b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.edition2015.stderr @@ -1,5 +1,5 @@ error[E0792]: expected generic lifetime parameter, found `'_` - --> $DIR/impl-fn-predefined-lifetimes.rs:5:9 + --> $DIR/impl-fn-predefined-lifetimes.rs:8:9 | LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { | -- this generic parameter must be used with a generic lifetime parameter diff --git a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.edition2024.stderr b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.edition2024.stderr new file mode 100644 index 00000000000..2f1eacb0c34 --- /dev/null +++ b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.edition2024.stderr @@ -0,0 +1,11 @@ +error[E0792]: expected generic lifetime parameter, found `'_` + --> $DIR/impl-fn-predefined-lifetimes.rs:8:9 + | +LL | fn a<'a>() -> impl Fn(&'a u8) -> (impl Debug + '_) { + | -- this generic parameter must be used with a generic lifetime parameter +LL | |x| x + | ^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs index 199cbbf4fcc..b2963cc10fa 100644 --- a/tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs +++ b/tests/ui/impl-trait/impl-fn-predefined-lifetimes.rs @@ -1,3 +1,6 @@ +//@revisions: edition2015 edition2024 +//@[edition2015] edition:2015 +//@[edition2024] edition:2024 #![feature(impl_trait_in_fn_trait_return)] use std::fmt::Debug; diff --git a/tests/ui/impl-trait/in-bindings/lifetime-equality.rs b/tests/ui/impl-trait/in-bindings/lifetime-equality.rs new file mode 100644 index 00000000000..6cf48dccc7d --- /dev/null +++ b/tests/ui/impl-trait/in-bindings/lifetime-equality.rs @@ -0,0 +1,19 @@ +//@ check-pass + +#![feature(impl_trait_in_bindings)] + +// A test for #61773 which would have been difficult to support if we +// were to represent `impl_trait_in_bindings` using opaque types. + +trait Trait<'a, 'b> { } +impl<T> Trait<'_, '_> for T { } + + +fn bar<'a, 'b>(data0: &'a u32, data1: &'b u32) { + let x: impl Trait<'_, '_> = (data0, data1); + force_equal(x); +} + +fn force_equal<'a>(t: impl Trait<'a, 'a>) { } + +fn main() { } diff --git a/tests/ui/impl-trait/in-bindings/region-lifetimes.rs b/tests/ui/impl-trait/in-bindings/region-lifetimes.rs new file mode 100644 index 00000000000..189ab85a276 --- /dev/null +++ b/tests/ui/impl-trait/in-bindings/region-lifetimes.rs @@ -0,0 +1,17 @@ +//@ check-pass + +#![feature(impl_trait_in_bindings)] + +// A test for #61773 which would have been difficult to support if we +// were to represent `impl_trait_in_bindings` using opaque types. + +trait Foo<'a> { } +impl Foo<'_> for &u32 { } + +fn bar<'a>(data: &'a u32) { + let x: impl Foo<'_> = data; +} + +fn main() { + let _: impl Foo<'_> = &44; +} diff --git a/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr b/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr index 119195f17ff..df89ed9f3b5 100644 --- a/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr +++ b/tests/ui/impl-trait/in-trait/doesnt-satisfy.stderr @@ -2,10 +2,8 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/doesnt-satisfy.rs:6:17 | LL | fn bar() -> () {} - | ^^ `()` cannot be formatted with the default formatter + | ^^ the trait `std::fmt::Display` is not implemented for `()` | - = help: the trait `std::fmt::Display` is not implemented for `()` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `Foo::bar::{anon_assoc#0}` --> $DIR/doesnt-satisfy.rs:2:22 | diff --git a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr index b6e7e02f331..2351b18fdfc 100644 --- a/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr +++ b/tests/ui/impl-trait/in-trait/false-positive-predicate-entailment-error.current.stderr @@ -19,11 +19,14 @@ help: consider further restricting type parameter `F` with trait `MyFn` LL | F: Callback<Self::CallbackArg> + MyFn<i32>, | +++++++++++ -error[E0277]: the trait bound `F: Callback<i32>` is not satisfied - --> $DIR/false-positive-predicate-entailment-error.rs:42:12 +error[E0277]: the trait bound `F: MyFn<i32>` is not satisfied + --> $DIR/false-positive-predicate-entailment-error.rs:36:5 | -LL | F: Callback<Self::CallbackArg>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyFn<i32>` is not implemented for `F` +LL | / fn autobatch<F>(self) -> impl Trait +... | +LL | | where +LL | | F: Callback<Self::CallbackArg>, + | |_______________________________________^ the trait `MyFn<i32>` is not implemented for `F` | note: required for `F` to implement `Callback<i32>` --> $DIR/false-positive-predicate-entailment-error.rs:14:21 @@ -32,27 +35,17 @@ LL | impl<A, F: MyFn<A>> Callback<A> for F { | ------- ^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here -note: the requirement `F: Callback<i32>` appears on the `impl`'s method `autobatch` but not on the corresponding trait's method - --> $DIR/false-positive-predicate-entailment-error.rs:25:8 - | -LL | trait ChannelSender { - | ------------- in this trait -... -LL | fn autobatch<F>(self) -> impl Trait - | ^^^^^^^^^ this trait's method doesn't have the requirement `F: Callback<i32>` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting type parameter `F` with trait `MyFn` | LL | F: Callback<Self::CallbackArg> + MyFn<i32>, | +++++++++++ -error[E0277]: the trait bound `F: MyFn<i32>` is not satisfied - --> $DIR/false-positive-predicate-entailment-error.rs:36:5 +error[E0277]: the trait bound `F: Callback<i32>` is not satisfied + --> $DIR/false-positive-predicate-entailment-error.rs:42:12 | -LL | / fn autobatch<F>(self) -> impl Trait -... | -LL | | where -LL | | F: Callback<Self::CallbackArg>, - | |_______________________________________^ the trait `MyFn<i32>` is not implemented for `F` +LL | F: Callback<Self::CallbackArg>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `MyFn<i32>` is not implemented for `F` | note: required for `F` to implement `Callback<i32>` --> $DIR/false-positive-predicate-entailment-error.rs:14:21 @@ -61,7 +54,14 @@ LL | impl<A, F: MyFn<A>> Callback<A> for F { | ------- ^^^^^^^^^^^ ^ | | | unsatisfied trait bound introduced here - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +note: the requirement `F: Callback<i32>` appears on the `impl`'s method `autobatch` but not on the corresponding trait's method + --> $DIR/false-positive-predicate-entailment-error.rs:25:8 + | +LL | trait ChannelSender { + | ------------- in this trait +... +LL | fn autobatch<F>(self) -> impl Trait + | ^^^^^^^^^ this trait's method doesn't have the requirement `F: Callback<i32>` help: consider further restricting type parameter `F` with trait `MyFn` | LL | F: Callback<Self::CallbackArg> + MyFn<i32>, diff --git a/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.current.stderr b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.current.stderr index 5d651245746..ff3a726477e 100644 --- a/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.current.stderr +++ b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.current.stderr @@ -46,11 +46,11 @@ note: ...which requires type-checking `<impl at $DIR/method-compatability-via-le LL | fn foo(b: bool) -> impl Sized { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{anon_assoc#0}`, completing the cycle -note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>` is well-formed - --> $DIR/method-compatability-via-leakage-cycle.rs:17:1 +note: cycle used when checking assoc item `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo` is compatible with trait definition + --> $DIR/method-compatability-via-leakage-cycle.rs:21:5 | -LL | impl Trait for u32 { - | ^^^^^^^^^^^^^^^^^^ +LL | fn foo(b: bool) -> impl Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error diff --git a/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.next.stderr b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.next.stderr index 4bbba62bd71..f0a20367a4a 100644 --- a/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.next.stderr +++ b/tests/ui/impl-trait/in-trait/method-compatability-via-leakage-cycle.next.stderr @@ -50,11 +50,11 @@ note: ...which requires type-checking `<impl at $DIR/method-compatability-via-le LL | fn foo(b: bool) -> impl Sized { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{anon_assoc#0}`, completing the cycle -note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>` is well-formed - --> $DIR/method-compatability-via-leakage-cycle.rs:17:1 +note: cycle used when checking assoc item `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo` is compatible with trait definition + --> $DIR/method-compatability-via-leakage-cycle.rs:21:5 | -LL | impl Trait for u32 { - | ^^^^^^^^^^^^^^^^^^ +LL | fn foo(b: bool) -> impl Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{anon_assoc#0}` @@ -109,11 +109,11 @@ note: ...which requires type-checking `<impl at $DIR/method-compatability-via-le LL | fn foo(b: bool) -> impl Sized { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: ...which again requires computing type of `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo::{anon_assoc#0}`, completing the cycle -note: cycle used when checking that `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>` is well-formed - --> $DIR/method-compatability-via-leakage-cycle.rs:17:1 +note: cycle used when checking assoc item `<impl at $DIR/method-compatability-via-leakage-cycle.rs:17:1: 17:19>::foo` is compatible with trait definition + --> $DIR/method-compatability-via-leakage-cycle.rs:21:5 | -LL | impl Trait for u32 { - | ^^^^^^^^^^^^^^^^^^ +LL | fn foo(b: bool) -> impl Sized { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr b/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr index 07f029d3bb7..c08fc511500 100644 --- a/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr +++ b/tests/ui/impl-trait/in-trait/not-inferred-generic.stderr @@ -5,7 +5,7 @@ LL | ().publish_typed(); | ^^^^^^^^^^^^^ cannot infer type of the type parameter `F` declared on the method `publish_typed` | = note: cannot satisfy `_: Clone` - = note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` + = note: opaque types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` note: required by a bound in `TypedClient::publish_typed::{anon_assoc#0}` --> $DIR/not-inferred-generic.rs:4:12 | diff --git a/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs b/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs index 894f592d9e2..8433fb72b5e 100644 --- a/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs +++ b/tests/ui/impl-trait/in-trait/refine-resolution-errors.rs @@ -9,6 +9,7 @@ pub trait Mirror { impl<T: ?Sized> Mirror for () { //~^ ERROR the type parameter `T` is not constrained type Assoc = T; + //~^ ERROR the size for values of type `T` cannot be known at compilation time } pub trait First { diff --git a/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr b/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr index 10ebad2a7d5..fd53c9fef44 100644 --- a/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr +++ b/tests/ui/impl-trait/in-trait/refine-resolution-errors.stderr @@ -4,6 +4,31 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T: ?Sized> Mirror for () { | ^ unconstrained type parameter -error: aborting due to 1 previous error +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/refine-resolution-errors.rs:11:18 + | +LL | impl<T: ?Sized> Mirror for () { + | - this type parameter needs to be `Sized` +LL | +LL | type Assoc = T; + | ^ doesn't have a size known at compile-time + | +note: required by a bound in `Mirror::Assoc` + --> $DIR/refine-resolution-errors.rs:7:5 + | +LL | type Assoc; + | ^^^^^^^^^^^ required by this bound in `Mirror::Assoc` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - impl<T: ?Sized> Mirror for () { +LL + impl<T> Mirror for () { + | +help: consider relaxing the implicit `Sized` restriction + | +LL | type Assoc: ?Sized; + | ++++++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0207, E0277. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.rs b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.rs new file mode 100644 index 00000000000..e3dc22c1992 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.rs @@ -0,0 +1,46 @@ +// issue#143560 + +trait T { + type Target; +} + +trait Foo { + fn foo() -> impl T<Target = impl T<Target = impl Sized>>; + fn foo() -> impl Sized; + //~^ ERROR: the name `foo` is defined multiple times +} + +trait Bar { + fn foo() -> impl T<Target = impl T<Target = impl Sized>>; + fn foo() -> impl T<Target = impl T<Target = impl Sized>>; + //~^ ERROR: the name `foo` is defined multiple times +} + +struct S<T> { + a: T +} + +trait Baz { + fn foo() -> S<impl T<Target = S<S<impl Sized>>>>; + fn foo() -> S<impl T<Target = S<S<impl Sized>>>>; + //~^ ERROR: the name `foo` is defined multiple times +} + +struct S1<T1, T2> { + a: T1, + b: T2 +} + +trait Qux { + fn foo() -> S1< + impl T<Target = impl T<Target = impl Sized>>, + impl T<Target = impl T<Target = S<impl Sized>>> + >; + fn foo() -> S1< + impl T<Target = impl T<Target = impl Sized>>, + impl T<Target = impl T<Target = S<impl Sized>>> + >; + //~^^^^ ERROR: the name `foo` is defined multiple times +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.stderr b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.stderr new file mode 100644 index 00000000000..f4e73dc1798 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn-with-nested.stderr @@ -0,0 +1,49 @@ +error[E0428]: the name `foo` is defined multiple times + --> $DIR/rpitit-duplicate-associated-fn-with-nested.rs:9:5 + | +LL | fn foo() -> impl T<Target = impl T<Target = impl Sized>>; + | --------------------------------------------------------- previous definition of the value `foo` here +LL | fn foo() -> impl Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^ `foo` redefined here + | + = note: `foo` must be defined only once in the value namespace of this trait + +error[E0428]: the name `foo` is defined multiple times + --> $DIR/rpitit-duplicate-associated-fn-with-nested.rs:15:5 + | +LL | fn foo() -> impl T<Target = impl T<Target = impl Sized>>; + | --------------------------------------------------------- previous definition of the value `foo` here +LL | fn foo() -> impl T<Target = impl T<Target = impl Sized>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `foo` redefined here + | + = note: `foo` must be defined only once in the value namespace of this trait + +error[E0428]: the name `foo` is defined multiple times + --> $DIR/rpitit-duplicate-associated-fn-with-nested.rs:25:5 + | +LL | fn foo() -> S<impl T<Target = S<S<impl Sized>>>>; + | ------------------------------------------------- previous definition of the value `foo` here +LL | fn foo() -> S<impl T<Target = S<S<impl Sized>>>>; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `foo` redefined here + | + = note: `foo` must be defined only once in the value namespace of this trait + +error[E0428]: the name `foo` is defined multiple times + --> $DIR/rpitit-duplicate-associated-fn-with-nested.rs:39:5 + | +LL | / fn foo() -> S1< +LL | | impl T<Target = impl T<Target = impl Sized>>, +LL | | impl T<Target = impl T<Target = S<impl Sized>>> +LL | | >; + | |__________- previous definition of the value `foo` here +LL | / fn foo() -> S1< +LL | | impl T<Target = impl T<Target = impl Sized>>, +LL | | impl T<Target = impl T<Target = S<impl Sized>>> +LL | | >; + | |__________^ `foo` redefined here + | + = note: `foo` must be defined only once in the value namespace of this trait + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0428`. diff --git a/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.rs b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.rs new file mode 100644 index 00000000000..6db0c88f6c0 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.rs @@ -0,0 +1,41 @@ +// issue#140796 + +trait Bar { + fn method() -> impl Sized; + fn method() -> impl Sized; //~ ERROR: the name `method` is defined multiple times +} + +impl Bar for () { //~ ERROR: not all trait items implemented, missing: `method` + fn method() -> impl Sized { + 42 + } + fn method() -> impl Sized { //~ ERROR: duplicate definitions with name `method` + 42 + } +} + +trait T { + fn method() -> impl Sized; +} + +impl T for () { + fn method() -> impl Sized { + 42 + } + fn method() -> impl Sized { //~ ERROR: duplicate definitions with name `method` + 42 + } +} + +trait Baz { + fn foo(); + fn foo() -> impl Sized; //~ ERROR: the name `foo` is defined multiple times +} + +trait Foo { + fn foo() -> impl Sized; + fn foo(); //~ ERROR: the name `foo` is defined multiple times + fn foo() -> impl Sized; //~ ERROR: the name `foo` is defined multiple times +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.stderr b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.stderr new file mode 100644 index 00000000000..faa65f45d33 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/rpitit-duplicate-associated-fn.stderr @@ -0,0 +1,84 @@ +error[E0428]: the name `method` is defined multiple times + --> $DIR/rpitit-duplicate-associated-fn.rs:5:5 + | +LL | fn method() -> impl Sized; + | -------------------------- previous definition of the value `method` here +LL | fn method() -> impl Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ `method` redefined here + | + = note: `method` must be defined only once in the value namespace of this trait + +error[E0428]: the name `foo` is defined multiple times + --> $DIR/rpitit-duplicate-associated-fn.rs:32:5 + | +LL | fn foo(); + | --------- previous definition of the value `foo` here +LL | fn foo() -> impl Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^ `foo` redefined here + | + = note: `foo` must be defined only once in the value namespace of this trait + +error[E0428]: the name `foo` is defined multiple times + --> $DIR/rpitit-duplicate-associated-fn.rs:37:5 + | +LL | fn foo() -> impl Sized; + | ----------------------- previous definition of the value `foo` here +LL | fn foo(); + | ^^^^^^^^^ `foo` redefined here + | + = note: `foo` must be defined only once in the value namespace of this trait + +error[E0428]: the name `foo` is defined multiple times + --> $DIR/rpitit-duplicate-associated-fn.rs:38:5 + | +LL | fn foo() -> impl Sized; + | ----------------------- previous definition of the value `foo` here +LL | fn foo(); +LL | fn foo() -> impl Sized; + | ^^^^^^^^^^^^^^^^^^^^^^^ `foo` redefined here + | + = note: `foo` must be defined only once in the value namespace of this trait + +error[E0201]: duplicate definitions with name `method`: + --> $DIR/rpitit-duplicate-associated-fn.rs:12:5 + | +LL | fn method() -> impl Sized; + | -------------------------- item in trait +... +LL | / fn method() -> impl Sized { +LL | | 42 +LL | | } + | |_____- previous definition here +LL | / fn method() -> impl Sized { +LL | | 42 +LL | | } + | |_____^ duplicate definition + +error[E0201]: duplicate definitions with name `method`: + --> $DIR/rpitit-duplicate-associated-fn.rs:25:5 + | +LL | fn method() -> impl Sized; + | -------------------------- item in trait +... +LL | / fn method() -> impl Sized { +LL | | 42 +LL | | } + | |_____- previous definition here +LL | / fn method() -> impl Sized { +LL | | 42 +LL | | } + | |_____^ duplicate definition + +error[E0046]: not all trait items implemented, missing: `method` + --> $DIR/rpitit-duplicate-associated-fn.rs:8:1 + | +LL | fn method() -> impl Sized; + | -------------------------- `method` from trait +... +LL | impl Bar for () { + | ^^^^^^^^^^^^^^^ missing `method` in implementation + +error: aborting due to 7 previous errors + +Some errors have detailed explanations: E0046, E0201, E0428. +For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr b/tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr index eaa320455bb..f95f6fab413 100644 --- a/tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr +++ b/tests/ui/impl-trait/in-trait/span-bug-issue-121457.stderr @@ -1,3 +1,15 @@ +error[E0195]: lifetime parameters or bounds on associated type `Item` do not match the trait declaration + --> $DIR/span-bug-issue-121457.rs:10:14 + | +LL | type Item<'a> + | ---- lifetimes in impl do not match this associated type in trait +LL | where +LL | Self: 'a; + | -- this bound might be missing in the impl +... +LL | type Item = u32; + | ^ lifetimes do not match associated type in trait + error[E0582]: binding for associated type `Item` references lifetime `'missing`, which does not appear in the trait input types --> $DIR/span-bug-issue-121457.rs:13:51 | @@ -12,18 +24,6 @@ LL | fn iter(&self) -> impl for<'missing> Iterator<Item = Self::Item<'missin | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0195]: lifetime parameters or bounds on associated type `Item` do not match the trait declaration - --> $DIR/span-bug-issue-121457.rs:10:14 - | -LL | type Item<'a> - | ---- lifetimes in impl do not match this associated type in trait -LL | where -LL | Self: 'a; - | -- this bound might be missing in the impl -... -LL | type Item = u32; - | ^ lifetimes do not match associated type in trait - error[E0277]: `()` is not an iterator --> $DIR/span-bug-issue-121457.rs:13:23 | diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.rs b/tests/ui/impl-trait/in-trait/unconstrained-lt.rs index ff3753de5a2..12e0a4263f5 100644 --- a/tests/ui/impl-trait/in-trait/unconstrained-lt.rs +++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.rs @@ -6,6 +6,7 @@ impl<'a, T> Foo for T { //~^ ERROR the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates fn test() -> &'a () { + //~^ WARN: does not match trait method signature &() } } diff --git a/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr b/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr index 4c5a42c0b4b..27340c5b362 100644 --- a/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr +++ b/tests/ui/impl-trait/in-trait/unconstrained-lt.stderr @@ -1,9 +1,27 @@ +warning: impl trait in impl method signature does not match trait method signature + --> $DIR/unconstrained-lt.rs:8:18 + | +LL | fn test() -> impl Sized; + | ---------- return type from trait method defined here +... +LL | fn test() -> &'a () { + | ^^^^^^ + | + = note: add `#[allow(refining_impl_trait)]` if it is intended for this to be part of the public API of this crate + = note: we are soliciting feedback, see issue #121718 <https://github.com/rust-lang/rust/issues/121718> for more information + = note: `#[warn(refining_impl_trait_internal)]` on by default +help: replace the return type so that it matches the trait + | +LL - fn test() -> &'a () { +LL + fn test() -> impl Sized { + | + error[E0207]: the lifetime parameter `'a` is not constrained by the impl trait, self type, or predicates --> $DIR/unconstrained-lt.rs:5:6 | LL | impl<'a, T> Foo for T { | ^^ unconstrained lifetime parameter -error: aborting due to 1 previous error +error: aborting due to 1 previous error; 1 warning emitted For more information about this error, try `rustc --explain E0207`. diff --git a/tests/ui/impl-trait/in-trait/wf-bounds.stderr b/tests/ui/impl-trait/in-trait/wf-bounds.stderr index 634557094ce..40a029cdc92 100644 --- a/tests/ui/impl-trait/in-trait/wf-bounds.stderr +++ b/tests/ui/impl-trait/in-trait/wf-bounds.stderr @@ -39,9 +39,8 @@ error[E0277]: `T` doesn't implement `std::fmt::Display` --> $DIR/wf-bounds.rs:21:26 | LL | fn nya4<T>() -> impl Wf<NeedsDisplay<T>>; - | ^^^^^^^^^^^^^^^^^^^ `T` cannot be formatted with the default formatter + | ^^^^^^^^^^^^^^^^^^^ the trait `std::fmt::Display` is not implemented for `T` | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `NeedsDisplay` --> $DIR/wf-bounds.rs:9:24 | diff --git a/tests/ui/impl-trait/issues/issue-54895.stderr b/tests/ui/impl-trait/issues/issue-54895.edition2015.stderr index 64b425328e3..27a3c6c8b7c 100644 --- a/tests/ui/impl-trait/issues/issue-54895.stderr +++ b/tests/ui/impl-trait/issues/issue-54895.edition2015.stderr @@ -1,11 +1,11 @@ error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` - --> $DIR/issue-54895.rs:15:53 + --> $DIR/issue-54895.rs:18:53 | LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { | ^^ | note: lifetime declared here - --> $DIR/issue-54895.rs:15:20 + --> $DIR/issue-54895.rs:18:20 | LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { | ^^ diff --git a/tests/ui/impl-trait/issues/issue-54895.edition2024.stderr b/tests/ui/impl-trait/issues/issue-54895.edition2024.stderr new file mode 100644 index 00000000000..54aa29e62d8 --- /dev/null +++ b/tests/ui/impl-trait/issues/issue-54895.edition2024.stderr @@ -0,0 +1,27 @@ +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` + --> $DIR/issue-54895.rs:18:40 + | +LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { + | ^^^^^^^^^^^^^^^ `impl Trait` implicitly captures all lifetimes in scope + | +note: lifetime declared here + --> $DIR/issue-54895.rs:18:20 + | +LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { + | ^^ + +error[E0657]: `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` + --> $DIR/issue-54895.rs:18:53 + | +LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { + | ^^ + | +note: lifetime declared here + --> $DIR/issue-54895.rs:18:20 + | +LL | fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { + | ^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0657`. diff --git a/tests/ui/impl-trait/issues/issue-54895.rs b/tests/ui/impl-trait/issues/issue-54895.rs index 13c0038ce43..bc1841209e1 100644 --- a/tests/ui/impl-trait/issues/issue-54895.rs +++ b/tests/ui/impl-trait/issues/issue-54895.rs @@ -1,3 +1,6 @@ +//@revisions: edition2015 edition2024 +//@[edition2015] edition:2015 +//@[edition2024] edition:2024 trait Trait<'a> { type Out; fn call(&'a self) -> Self::Out; @@ -14,6 +17,7 @@ impl<'a> Trait<'a> for X { fn f() -> impl for<'a> Trait<'a, Out = impl Sized + 'a> { //~^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` + //[edition2024]~^^ ERROR `impl Trait` cannot capture higher-ranked lifetime from outer `impl Trait` X(()) } diff --git a/tests/ui/impl-trait/issues/issue-79099.stderr b/tests/ui/impl-trait/issues/issue-79099.edition2015.stderr index d7c0c494454..ee1a479310d 100644 --- a/tests/ui/impl-trait/issues/issue-79099.stderr +++ b/tests/ui/impl-trait/issues/issue-79099.edition2015.stderr @@ -1,5 +1,5 @@ error: expected identifier, found `1` - --> $DIR/issue-79099.rs:3:65 + --> $DIR/issue-79099.rs:6:65 | LL | let f: impl core::future::Future<Output = u8> = async { 1 }; | ----- ^ expected identifier @@ -10,7 +10,7 @@ LL | let f: impl core::future::Future<Output = u8> = async { 1 }; = note: for more on editions, read https://doc.rust-lang.org/edition-guide error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/issue-79099.rs:3:16 + --> $DIR/issue-79099.rs:6:16 | LL | let f: impl core::future::Future<Output = u8> = async { 1 }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/impl-trait/issues/issue-79099.edition2024.stderr b/tests/ui/impl-trait/issues/issue-79099.edition2024.stderr new file mode 100644 index 00000000000..3e422e25136 --- /dev/null +++ b/tests/ui/impl-trait/issues/issue-79099.edition2024.stderr @@ -0,0 +1,14 @@ +error[E0562]: `impl Trait` is not allowed in the type of variable bindings + --> $DIR/issue-79099.rs:6:16 + | +LL | let f: impl core::future::Future<Output = u8> = async { 1 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: `impl Trait` is only allowed in arguments and return types of functions and methods + = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information + = help: add `#![feature(impl_trait_in_bindings)]` 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 1 previous error + +For more information about this error, try `rustc --explain E0562`. diff --git a/tests/ui/impl-trait/issues/issue-79099.rs b/tests/ui/impl-trait/issues/issue-79099.rs index c2bad59045b..8426298620f 100644 --- a/tests/ui/impl-trait/issues/issue-79099.rs +++ b/tests/ui/impl-trait/issues/issue-79099.rs @@ -1,8 +1,11 @@ +//@revisions: edition2015 edition2024 +//@[edition2015] edition:2015 +//@[edition2024] edition:2024 struct Bug { V1: [(); { let f: impl core::future::Future<Output = u8> = async { 1 }; //~^ ERROR `impl Trait` is not allowed in the type of variable bindings - //~| ERROR expected identifier + //[edition2015]~| ERROR expected identifier 1 }], } diff --git a/tests/ui/impl-trait/name-mentioning-macro.rs b/tests/ui/impl-trait/name-mentioning-macro.rs new file mode 100644 index 00000000000..8a81911c0bb --- /dev/null +++ b/tests/ui/impl-trait/name-mentioning-macro.rs @@ -0,0 +1,12 @@ +trait Foo<T> {} + +macro_rules! bar { + () => { () } +} + +fn foo(x: impl Foo<bar!()>) { + let () = x; + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/impl-trait/name-mentioning-macro.stderr b/tests/ui/impl-trait/name-mentioning-macro.stderr new file mode 100644 index 00000000000..adb4c64f812 --- /dev/null +++ b/tests/ui/impl-trait/name-mentioning-macro.stderr @@ -0,0 +1,16 @@ +error[E0308]: mismatched types + --> $DIR/name-mentioning-macro.rs:8:9 + | +LL | fn foo(x: impl Foo<bar!()>) { + | ---------------- expected this type parameter +LL | let () = x; + | ^^ - this expression has type `impl Foo<bar!()>` + | | + | expected type parameter `impl Foo<bar!()>`, found `()` + | + = note: expected type parameter `impl Foo<bar!()>` + found unit type `()` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/impl-trait/normalize-tait-in-const.rs b/tests/ui/impl-trait/normalize-tait-in-const.rs index a735ef76673..0c7969c0e9e 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.rs +++ b/tests/ui/impl-trait/normalize-tait-in-const.rs @@ -24,7 +24,7 @@ mod foo { } use foo::*; -const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { +const fn with_positive<F: for<'a> [const] Fn(&'a Alias<'a>) + [const] Destruct>(fun: F) { fun(filter_positive()); } diff --git a/tests/ui/impl-trait/normalize-tait-in-const.stderr b/tests/ui/impl-trait/normalize-tait-in-const.stderr index 2b6825b1ac6..e17737d1860 100644 --- a/tests/ui/impl-trait/normalize-tait-in-const.stderr +++ b/tests/ui/impl-trait/normalize-tait-in-const.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/normalize-tait-in-const.rs:27:35 | -LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { - | ^^^^^^ can't be applied to `Fn` +LL | const fn with_positive<F: for<'a> [const] Fn(&'a Alias<'a>) + [const] Destruct>(fun: F) { + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/normalize-tait-in-const.rs:27:35 | -LL | const fn with_positive<F: for<'a> ~const Fn(&'a Alias<'a>) + ~const Destruct>(fun: F) { - | ^^^^^^ can't be applied to `Fn` +LL | const fn with_positive<F: for<'a> [const] Fn(&'a Alias<'a>) + [const] Destruct>(fun: F) { + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/impl-trait/precise-capturing/bad-lifetimes.stderr b/tests/ui/impl-trait/precise-capturing/bad-lifetimes.stderr index 98f629f52cf..ddb09690faf 100644 --- a/tests/ui/impl-trait/precise-capturing/bad-lifetimes.stderr +++ b/tests/ui/impl-trait/precise-capturing/bad-lifetimes.stderr @@ -15,9 +15,12 @@ error[E0261]: use of undeclared lifetime name `'missing` --> $DIR/bad-lifetimes.rs:7:37 | LL | fn missing_lt() -> impl Sized + use<'missing> {} - | - ^^^^^^^^ undeclared lifetime - | | - | help: consider introducing lifetime `'missing` here: `<'missing>` + | ^^^^^^^^ undeclared lifetime + | +help: consider introducing lifetime `'missing` here + | +LL | fn missing_lt<'missing>() -> impl Sized + use<'missing> {} + | ++++++++++ error: expected lifetime parameter in `use<...>` precise captures list, found `'static` --> $DIR/bad-lifetimes.rs:4:36 diff --git a/tests/ui/impl-trait/precise-capturing/dyn-use.stderr b/tests/ui/impl-trait/precise-capturing/dyn-use.edition2015.stderr index d8903fc4129..9951e9e0965 100644 --- a/tests/ui/impl-trait/precise-capturing/dyn-use.stderr +++ b/tests/ui/impl-trait/precise-capturing/dyn-use.edition2015.stderr @@ -1,5 +1,5 @@ error: expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use` - --> $DIR/dyn-use.rs:1:26 + --> $DIR/dyn-use.rs:4:26 | LL | fn dyn() -> &'static dyn use<> { &() } | ^^^ expected one of `!`, `(`, `::`, `<`, `where`, or `{` diff --git a/tests/ui/impl-trait/precise-capturing/dyn-use.edition2024.stderr b/tests/ui/impl-trait/precise-capturing/dyn-use.edition2024.stderr new file mode 100644 index 00000000000..cb3fe4cb583 --- /dev/null +++ b/tests/ui/impl-trait/precise-capturing/dyn-use.edition2024.stderr @@ -0,0 +1,26 @@ +error: expected identifier, found keyword `dyn` + --> $DIR/dyn-use.rs:4:4 + | +LL | fn dyn() -> &'static dyn use<> { &() } + | ^^^ expected identifier, found keyword + | +help: escape `dyn` to use it as an identifier + | +LL | fn r#dyn() -> &'static dyn use<> { &() } + | ++ + +error: `use<...>` precise capturing syntax not allowed in `dyn` trait object bounds + --> $DIR/dyn-use.rs:4:26 + | +LL | fn dyn() -> &'static dyn use<> { &() } + | ^^^^^ + +error[E0224]: at least one trait is required for an object type + --> $DIR/dyn-use.rs:4:22 + | +LL | fn dyn() -> &'static dyn use<> { &() } + | ^^^^^^^^^ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0224`. diff --git a/tests/ui/impl-trait/precise-capturing/dyn-use.rs b/tests/ui/impl-trait/precise-capturing/dyn-use.rs index fb2f83e2d21..0b6a9467ff7 100644 --- a/tests/ui/impl-trait/precise-capturing/dyn-use.rs +++ b/tests/ui/impl-trait/precise-capturing/dyn-use.rs @@ -1,2 +1,10 @@ +//@revisions: edition2015 edition2024 +//@[edition2015] edition:2015 +//@[edition2024] edition:2024 fn dyn() -> &'static dyn use<> { &() } -//~^ ERROR expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use` +//[edition2015]~^ ERROR expected one of `!`, `(`, `::`, `<`, `where`, or `{`, found keyword `use` +//[edition2024]~^^ ERROR expected identifier, found keyword `dyn` +//[edition2024]~| ERROR `use<...>` precise capturing syntax not allowed in `dyn` trait object bounds +//[edition2024]~| ERROR at least one trait is required for an object type + +fn main() {} diff --git a/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.stderr b/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.edition2015.stderr index 0d8fa650df4..c16722bb80f 100644 --- a/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.stderr +++ b/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.edition2015.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds - --> $DIR/hidden-type-suggestion.rs:3:5 + --> $DIR/hidden-type-suggestion.rs:6:5 | LL | fn lifetime<'a, 'b>(x: &'a ()) -> impl Sized + use<'b> { | -- -------------------- opaque type defined here @@ -15,7 +15,7 @@ LL | fn lifetime<'a, 'b>(x: &'a ()) -> impl Sized + use<'b, 'a> { | ++++ error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds - --> $DIR/hidden-type-suggestion.rs:9:5 + --> $DIR/hidden-type-suggestion.rs:12:5 | LL | fn param<'a, T>(x: &'a ()) -> impl Sized + use<T> { | -- ------------------- opaque type defined here @@ -31,7 +31,7 @@ LL | fn param<'a, T>(x: &'a ()) -> impl Sized + use<'a, T> { | +++ error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds - --> $DIR/hidden-type-suggestion.rs:15:5 + --> $DIR/hidden-type-suggestion.rs:18:5 | LL | fn empty<'a>(x: &'a ()) -> impl Sized + use<> { | -- ------------------ opaque type defined here @@ -47,7 +47,7 @@ LL | fn empty<'a>(x: &'a ()) -> impl Sized + use<'a> { | ++ error[E0700]: hidden type for `impl Captures<'captured>` captures lifetime that does not appear in bounds - --> $DIR/hidden-type-suggestion.rs:24:5 + --> $DIR/hidden-type-suggestion.rs:27:5 | LL | fn missing<'a, 'captured, 'not_captured, Captured>(x: &'a ()) -> impl Captures<'captured> { | -- ------------------------ opaque type defined here @@ -63,7 +63,7 @@ LL | fn missing<'a, 'captured, 'not_captured, Captured>(x: &'a ()) -> impl Captu | ++++++++++++++++++++++++++++++ error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds - --> $DIR/hidden-type-suggestion.rs:30:5 + --> $DIR/hidden-type-suggestion.rs:33:5 | LL | fn no_params_yet(_: impl Sized, y: &()) -> impl Sized { | --- ---------- opaque type defined here @@ -74,7 +74,7 @@ LL | y | ^ | note: you could use a `use<...>` bound to explicitly capture `'_`, but argument-position `impl Trait`s are not nameable - --> $DIR/hidden-type-suggestion.rs:28:21 + --> $DIR/hidden-type-suggestion.rs:31:21 | LL | fn no_params_yet(_: impl Sized, y: &()) -> impl Sized { | ^^^^^^^^^^ @@ -85,7 +85,7 @@ LL + fn no_params_yet<T: Sized>(_: T, y: &()) -> impl Sized + use<'_, T> { | error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds - --> $DIR/hidden-type-suggestion.rs:36:5 + --> $DIR/hidden-type-suggestion.rs:39:5 | LL | fn yes_params_yet<'a, T>(_: impl Sized, y: &'a ()) -> impl Sized { | -- ---------- opaque type defined here @@ -96,7 +96,7 @@ LL | y | ^ | note: you could use a `use<...>` bound to explicitly capture `'a`, but argument-position `impl Trait`s are not nameable - --> $DIR/hidden-type-suggestion.rs:34:29 + --> $DIR/hidden-type-suggestion.rs:37:29 | LL | fn yes_params_yet<'a, T>(_: impl Sized, y: &'a ()) -> impl Sized { | ^^^^^^^^^^ diff --git a/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.edition2024.stderr b/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.edition2024.stderr new file mode 100644 index 00000000000..308dc9b00fc --- /dev/null +++ b/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.edition2024.stderr @@ -0,0 +1,51 @@ +error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds + --> $DIR/hidden-type-suggestion.rs:6:5 + | +LL | fn lifetime<'a, 'b>(x: &'a ()) -> impl Sized + use<'b> { + | -- -------------------- opaque type defined here + | | + | hidden type `&'a ()` captures the lifetime `'a` as defined here +LL | +LL | x + | ^ + | +help: add `'a` to the `use<...>` bound to explicitly capture it + | +LL | fn lifetime<'a, 'b>(x: &'a ()) -> impl Sized + use<'b, 'a> { + | ++++ + +error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds + --> $DIR/hidden-type-suggestion.rs:12:5 + | +LL | fn param<'a, T>(x: &'a ()) -> impl Sized + use<T> { + | -- ------------------- opaque type defined here + | | + | hidden type `&'a ()` captures the lifetime `'a` as defined here +LL | +LL | x + | ^ + | +help: add `'a` to the `use<...>` bound to explicitly capture it + | +LL | fn param<'a, T>(x: &'a ()) -> impl Sized + use<'a, T> { + | +++ + +error[E0700]: hidden type for `impl Sized` captures lifetime that does not appear in bounds + --> $DIR/hidden-type-suggestion.rs:18:5 + | +LL | fn empty<'a>(x: &'a ()) -> impl Sized + use<> { + | -- ------------------ opaque type defined here + | | + | hidden type `&'a ()` captures the lifetime `'a` as defined here +LL | +LL | x + | ^ + | +help: add `'a` to the `use<...>` bound to explicitly capture it + | +LL | fn empty<'a>(x: &'a ()) -> impl Sized + use<'a> { + | ++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0700`. diff --git a/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs b/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs index d34c6135596..9712eac859a 100644 --- a/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs +++ b/tests/ui/impl-trait/precise-capturing/hidden-type-suggestion.rs @@ -1,3 +1,6 @@ +//@revisions: edition2015 edition2024 +//@[edition2015] edition:2015 +//@[edition2024] edition:2024 fn lifetime<'a, 'b>(x: &'a ()) -> impl Sized + use<'b> { //~^ HELP add `'a` to the `use<...>` bound x @@ -20,21 +23,21 @@ trait Captures<'a> {} impl<T> Captures<'_> for T {} fn missing<'a, 'captured, 'not_captured, Captured>(x: &'a ()) -> impl Captures<'captured> { -//~^ HELP add a `use<...>` bound +//[edition2015]~^ HELP add a `use<...>` bound x -//~^ ERROR hidden type for +//[edition2015]~^ ERROR hidden type for } fn no_params_yet(_: impl Sized, y: &()) -> impl Sized { -//~^ HELP add a `use<...>` bound +//[edition2015]~^ HELP add a `use<...>` bound y -//~^ ERROR hidden type for +//[edition2015]~^ ERROR hidden type for } fn yes_params_yet<'a, T>(_: impl Sized, y: &'a ()) -> impl Sized { -//~^ HELP add a `use<...>` bound +//[edition2015]~^ HELP add a `use<...>` bound y -//~^ ERROR hidden type for +//[edition2015]~^ ERROR hidden type for } fn main() {} diff --git a/tests/ui/impl-trait/struct-field-fragment-in-name.rs b/tests/ui/impl-trait/struct-field-fragment-in-name.rs new file mode 100644 index 00000000000..b98cd864ccb --- /dev/null +++ b/tests/ui/impl-trait/struct-field-fragment-in-name.rs @@ -0,0 +1,16 @@ +//@ check-pass + +trait Trait<T> {} + +fn a(_: impl Trait< + [(); { + struct D { + #[rustfmt::skip] + bar: (), + } + 0 + }], +>) { +} + +fn main() {} diff --git a/tests/ui/impl-unused-rps-in-assoc-type.rs b/tests/ui/impl-unused-rps-in-assoc-type.rs deleted file mode 100644 index ea41997a698..00000000000 --- a/tests/ui/impl-unused-rps-in-assoc-type.rs +++ /dev/null @@ -1,18 +0,0 @@ -// Test that lifetime parameters must be constrained if they appear in -// an associated type def'n. Issue #22077. - -trait Fun { - type Output; - fn call<'x>(&'x self) -> Self::Output; -} - -struct Holder { x: String } - -impl<'a> Fun for Holder { //~ ERROR E0207 - type Output = &'a str; - fn call<'b>(&'b self) -> &'b str { - &self.x[..] - } -} - -fn main() { } diff --git a/tests/ui/impl-unused-tps-inherent.rs b/tests/ui/impl-unused-tps-inherent.rs deleted file mode 100644 index 83a228e551a..00000000000 --- a/tests/ui/impl-unused-tps-inherent.rs +++ /dev/null @@ -1,25 +0,0 @@ -struct MyType; - -struct MyType1<T>(T); - -trait Bar { - type Out; -} - -impl<T> MyType { - //~^ ERROR the type parameter `T` is not constrained -} - -impl<T> MyType1<T> { - // OK, T is used in `Foo<T>`. -} - -impl<T,U> MyType1<T> { - //~^ ERROR the type parameter `U` is not constrained -} - -impl<T,U> MyType1<T> where T: Bar<Out=U> { - // OK, T is used in `Foo<T>`. -} - -fn main() { } diff --git a/tests/ui/implicit-method-bind.rs b/tests/ui/implicit-method-bind.rs deleted file mode 100644 index 5e27516a89a..00000000000 --- a/tests/ui/implicit-method-bind.rs +++ /dev/null @@ -1,3 +0,0 @@ -fn main() { - let _f = 10i32.abs; //~ ERROR attempted to take value of method -} diff --git a/tests/ui/implicit-method-bind.stderr b/tests/ui/implicit-method-bind.stderr deleted file mode 100644 index e9357113f36..00000000000 --- a/tests/ui/implicit-method-bind.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0615]: attempted to take value of method `abs` on type `i32` - --> $DIR/implicit-method-bind.rs:2:20 - | -LL | let _f = 10i32.abs; - | ^^^ method, not a field - | -help: use parentheses to call the method - | -LL | let _f = 10i32.abs(); - | ++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0615`. diff --git a/tests/ui/implied-bounds/impl-header-unnormalized-types.stderr b/tests/ui/implied-bounds/impl-header-unnormalized-types.stderr index 07cb0aecda8..dcb68fbf2cd 100644 --- a/tests/ui/implied-bounds/impl-header-unnormalized-types.stderr +++ b/tests/ui/implied-bounds/impl-header-unnormalized-types.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a &'b ()`, reference has a longer lifetime than the data it references - --> $DIR/impl-header-unnormalized-types.rs:15:18 + --> $DIR/impl-header-unnormalized-types.rs:15:5 | LL | type Assoc = &'a &'b (); - | ^^^^^^^^^^ + | ^^^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/impl-header-unnormalized-types.rs:14:6 diff --git a/tests/ui/double-type-import.rs b/tests/ui/imports/duplicate-use-bindings.rs index 6b1eb65d5ae..8cec23ea732 100644 --- a/tests/ui/double-type-import.rs +++ b/tests/ui/imports/duplicate-use-bindings.rs @@ -1,3 +1,5 @@ +//! Test that duplicate use bindings in same namespace produce error + mod foo { pub use self::bar::X; use self::bar::X; diff --git a/tests/ui/double-type-import.stderr b/tests/ui/imports/duplicate-use-bindings.stderr index 8a8fe05ec19..1d4f1fc82db 100644 --- a/tests/ui/double-type-import.stderr +++ b/tests/ui/imports/duplicate-use-bindings.stderr @@ -1,5 +1,5 @@ error[E0252]: the name `X` is defined multiple times - --> $DIR/double-type-import.rs:3:9 + --> $DIR/duplicate-use-bindings.rs:5:9 | LL | pub use self::bar::X; | ------------ previous import of the type `X` here diff --git a/tests/ui/imports/import-from-missing-star-2.stderr b/tests/ui/imports/import-from-missing-star-2.edition2015.stderr index 9fe2bdbcfa2..cd1a9581d30 100644 --- a/tests/ui/imports/import-from-missing-star-2.stderr +++ b/tests/ui/imports/import-from-missing-star-2.edition2015.stderr @@ -1,5 +1,5 @@ error[E0432]: unresolved import `spam` - --> $DIR/import-from-missing-star-2.rs:2:9 + --> $DIR/import-from-missing-star-2.rs:6:9 | LL | use spam::*; | ^^^^ use of unresolved module or unlinked crate `spam` diff --git a/tests/ui/imports/import-from-missing-star-2.edition2024.stderr b/tests/ui/imports/import-from-missing-star-2.edition2024.stderr new file mode 100644 index 00000000000..086b7a576b2 --- /dev/null +++ b/tests/ui/imports/import-from-missing-star-2.edition2024.stderr @@ -0,0 +1,11 @@ +error[E0432]: unresolved import `spam` + --> $DIR/import-from-missing-star-2.rs:6:9 + | +LL | use spam::*; + | ^^^^ use of unresolved module or unlinked crate `spam` + | + = help: you might be missing a crate named `spam` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/imports/import-from-missing-star-2.rs b/tests/ui/imports/import-from-missing-star-2.rs index cb341b0b0ca..9dad2d4886b 100644 --- a/tests/ui/imports/import-from-missing-star-2.rs +++ b/tests/ui/imports/import-from-missing-star-2.rs @@ -1,5 +1,10 @@ +//@revisions: edition2015 edition2024 +//@[edition2015] edition:2015 +//@[edition2024] edition:2024 mod foo { +//[edition2015]~^ HELP you might be missing a crate named `spam`, add it to your project and import it in your code use spam::*; //~ ERROR unresolved import `spam` [E0432] + //[edition2024]~^ HELP you might be missing a crate named `spam` } fn main() { diff --git a/tests/ui/imports/issue-28134.rs b/tests/ui/imports/issue-28134.rs index 70d3a327c1a..aef2fe8facd 100644 --- a/tests/ui/imports/issue-28134.rs +++ b/tests/ui/imports/issue-28134.rs @@ -2,4 +2,4 @@ #![allow(soft_unstable)] #![test] -//~^ ERROR 4:1: 4:9: `test` attribute cannot be used at crate level +//~^ ERROR `test` attribute cannot be used at crate level diff --git a/tests/ui/imports/multiple-extern-by-macro-for-underscore.stderr b/tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2015.stderr index 1da5aa87070..985cd654c39 100644 --- a/tests/ui/imports/multiple-extern-by-macro-for-underscore.stderr +++ b/tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2015.stderr @@ -1,5 +1,5 @@ error: expected identifier, found reserved identifier `_` - --> $DIR/multiple-extern-by-macro-for-underscore.rs:16:11 + --> $DIR/multiple-extern-by-macro-for-underscore.rs:18:11 | LL | use ::_; | ^ expected identifier, found reserved identifier diff --git a/tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2021.stderr b/tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2021.stderr new file mode 100644 index 00000000000..985cd654c39 --- /dev/null +++ b/tests/ui/imports/multiple-extern-by-macro-for-underscore.ed2021.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/multiple-extern-by-macro-for-underscore.rs:18:11 + | +LL | use ::_; + | ^ expected identifier, found reserved identifier + +error: aborting due to 1 previous error + diff --git a/tests/ui/imports/multiple-extern-by-macro-for-underscore.rs b/tests/ui/imports/multiple-extern-by-macro-for-underscore.rs index ddf735d8947..ab877e06246 100644 --- a/tests/ui/imports/multiple-extern-by-macro-for-underscore.rs +++ b/tests/ui/imports/multiple-extern-by-macro-for-underscore.rs @@ -1,4 +1,6 @@ -//@ edition: 2021 +//@ revisions: ed2015 ed2021 +//@[ed2015] edition: 2015 +//@[ed2021] edition: 2021 // issue#128813 diff --git a/tests/ui/indexing/indexing-integral-types.rs b/tests/ui/indexing/indexing-integral-types.rs new file mode 100644 index 00000000000..a91696a6fd5 --- /dev/null +++ b/tests/ui/indexing/indexing-integral-types.rs @@ -0,0 +1,20 @@ +//! Test that only usize can be used for indexing arrays and slices. + +pub fn main() { + let v: Vec<isize> = vec![0, 1, 2, 3, 4, 5]; + let s: String = "abcdef".to_string(); + + // Valid indexing with usize + v[3_usize]; + v[3]; + v[3u8]; //~ ERROR the type `[isize]` cannot be indexed by `u8` + v[3i8]; //~ ERROR the type `[isize]` cannot be indexed by `i8` + v[3u32]; //~ ERROR the type `[isize]` cannot be indexed by `u32` + v[3i32]; //~ ERROR the type `[isize]` cannot be indexed by `i32` + s.as_bytes()[3_usize]; + s.as_bytes()[3]; + s.as_bytes()[3u8]; //~ ERROR the type `[u8]` cannot be indexed by `u8` + s.as_bytes()[3i8]; //~ ERROR the type `[u8]` cannot be indexed by `i8` + s.as_bytes()[3u32]; //~ ERROR the type `[u8]` cannot be indexed by `u32` + s.as_bytes()[3i32]; //~ ERROR the type `[u8]` cannot be indexed by `i32` +} diff --git a/tests/ui/integral-indexing.stderr b/tests/ui/indexing/indexing-integral-types.stderr index 26253e078cb..b63991ec2c4 100644 --- a/tests/ui/integral-indexing.stderr +++ b/tests/ui/indexing/indexing-integral-types.stderr @@ -1,5 +1,5 @@ error[E0277]: the type `[isize]` cannot be indexed by `u8` - --> $DIR/integral-indexing.rs:6:7 + --> $DIR/indexing-integral-types.rs:10:7 | LL | v[3u8]; | ^^^ slice indices are of type `usize` or ranges of `usize` @@ -11,7 +11,7 @@ LL | v[3u8]; = note: required for `Vec<isize>` to implement `Index<u8>` error[E0277]: the type `[isize]` cannot be indexed by `i8` - --> $DIR/integral-indexing.rs:7:7 + --> $DIR/indexing-integral-types.rs:11:7 | LL | v[3i8]; | ^^^ slice indices are of type `usize` or ranges of `usize` @@ -23,7 +23,7 @@ LL | v[3i8]; = note: required for `Vec<isize>` to implement `Index<i8>` error[E0277]: the type `[isize]` cannot be indexed by `u32` - --> $DIR/integral-indexing.rs:8:7 + --> $DIR/indexing-integral-types.rs:12:7 | LL | v[3u32]; | ^^^^ slice indices are of type `usize` or ranges of `usize` @@ -35,7 +35,7 @@ LL | v[3u32]; = note: required for `Vec<isize>` to implement `Index<u32>` error[E0277]: the type `[isize]` cannot be indexed by `i32` - --> $DIR/integral-indexing.rs:9:7 + --> $DIR/indexing-integral-types.rs:13:7 | LL | v[3i32]; | ^^^^ slice indices are of type `usize` or ranges of `usize` @@ -47,7 +47,7 @@ LL | v[3i32]; = note: required for `Vec<isize>` to implement `Index<i32>` error[E0277]: the type `[u8]` cannot be indexed by `u8` - --> $DIR/integral-indexing.rs:12:18 + --> $DIR/indexing-integral-types.rs:16:18 | LL | s.as_bytes()[3u8]; | ^^^ slice indices are of type `usize` or ranges of `usize` @@ -59,7 +59,7 @@ LL | s.as_bytes()[3u8]; = note: required for `[u8]` to implement `Index<u8>` error[E0277]: the type `[u8]` cannot be indexed by `i8` - --> $DIR/integral-indexing.rs:13:18 + --> $DIR/indexing-integral-types.rs:17:18 | LL | s.as_bytes()[3i8]; | ^^^ slice indices are of type `usize` or ranges of `usize` @@ -71,7 +71,7 @@ LL | s.as_bytes()[3i8]; = note: required for `[u8]` to implement `Index<i8>` error[E0277]: the type `[u8]` cannot be indexed by `u32` - --> $DIR/integral-indexing.rs:14:18 + --> $DIR/indexing-integral-types.rs:18:18 | LL | s.as_bytes()[3u32]; | ^^^^ slice indices are of type `usize` or ranges of `usize` @@ -83,7 +83,7 @@ LL | s.as_bytes()[3u32]; = note: required for `[u8]` to implement `Index<u32>` error[E0277]: the type `[u8]` cannot be indexed by `i32` - --> $DIR/integral-indexing.rs:15:18 + --> $DIR/indexing-integral-types.rs:19:18 | LL | s.as_bytes()[3i32]; | ^^^^ slice indices are of type `usize` or ranges of `usize` diff --git a/tests/ui/inference/deref-suggestion.stderr b/tests/ui/inference/deref-suggestion.stderr index 096989db0b4..8ccd28198af 100644 --- a/tests/ui/inference/deref-suggestion.stderr +++ b/tests/ui/inference/deref-suggestion.stderr @@ -164,21 +164,18 @@ LL | *b error[E0308]: `if` and `else` have incompatible types --> $DIR/deref-suggestion.rs:69:12 | -LL | let val = if true { - | ________________- -LL | | *a - | | -- expected because of this -LL | | } else if true { - | | ____________^ -LL | || -LL | || b -LL | || } else { -LL | || &0 -LL | || }; - | || ^ - | ||_____| - | |_____`if` and `else` have incompatible types - | expected `i32`, found `&{integer}` +LL | let val = if true { + | ------- `if` and `else` have incompatible types +LL | *a + | -- expected because of this +LL | } else if true { + | ____________^ +LL | | +LL | | b +LL | | } else { +LL | | &0 +LL | | }; + | |_____^ expected `i32`, found `&{integer}` error[E0308]: mismatched types --> $DIR/deref-suggestion.rs:81:15 diff --git a/tests/ui/inference/hint-closure-signature-119266.rs b/tests/ui/inference/hint-closure-signature-119266.rs index 35be600fd6a..6e136c57cca 100644 --- a/tests/ui/inference/hint-closure-signature-119266.rs +++ b/tests/ui/inference/hint-closure-signature-119266.rs @@ -3,7 +3,7 @@ fn main() { //~^ NOTE: the found closure let x: fn(i32) = x; - //~^ ERROR: 5:22: 5:23: mismatched types [E0308] + //~^ ERROR: mismatched types [E0308] //~| NOTE: incorrect number of function parameters //~| NOTE: expected due to this //~| NOTE: expected fn pointer `fn(i32)` diff --git a/tests/ui/inference/ice-ifer-var-leaked-out-of-rollback-122098.stderr b/tests/ui/inference/ice-ifer-var-leaked-out-of-rollback-122098.stderr index ce01e24770d..c2ebaee2441 100644 --- a/tests/ui/inference/ice-ifer-var-leaked-out-of-rollback-122098.stderr +++ b/tests/ui/inference/ice-ifer-var-leaked-out-of-rollback-122098.stderr @@ -23,9 +23,12 @@ error[E0261]: use of undeclared lifetime name `'q` --> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:14:21 | LL | impl<'static> Query<'q> { - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'q` here: `'q,` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'q` here + | +LL | impl<'q, 'static> Query<'q> { + | +++ error[E0392]: lifetime parameter `'q` is never used --> $DIR/ice-ifer-var-leaked-out-of-rollback-122098.rs:11:14 diff --git a/tests/ui/inference/issue-107090.stderr b/tests/ui/inference/issue-107090.stderr index e509e262fb1..0deafdfb931 100644 --- a/tests/ui/inference/issue-107090.stderr +++ b/tests/ui/inference/issue-107090.stderr @@ -33,15 +33,23 @@ error[E0261]: use of undeclared lifetime name `'b` --> $DIR/issue-107090.rs:11:47 | LL | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> { - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'b` here: `'b,` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'b` here + | +LL | impl<'b, 'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> { + | +++ error[E0261]: use of undeclared lifetime name `'out` --> $DIR/issue-107090.rs:11:67 | LL | impl<'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> { - | - help: consider introducing lifetime `'out` here: `'out,` ^^^^ undeclared lifetime + | ^^^^ undeclared lifetime + | +help: consider introducing lifetime `'out` here + | +LL | impl<'out, 'long: 'short, 'short, T> Convert<'long, 'b> for Foo<'short, 'out, T> { + | +++++ error[E0261]: use of undeclared lifetime name `'out` --> $DIR/issue-107090.rs:14:49 @@ -62,9 +70,12 @@ error[E0261]: use of undeclared lifetime name `'short` --> $DIR/issue-107090.rs:20:68 | LL | fn badboi<'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T { - | - ^^^^^^ undeclared lifetime - | | - | help: consider introducing lifetime `'short` here: `'short,` + | ^^^^^^ undeclared lifetime + | +help: consider introducing lifetime `'short` here + | +LL | fn badboi<'short, 'in_, 'out, T>(x: Foo<'in_, 'out, T>, sadness: &'in_ Foo<'short, 'out, T>) -> &'out T { + | +++++++ error: aborting due to 6 previous errors diff --git a/tests/ui/infinite/infinite-trait-alias-recursion.stderr b/tests/ui/infinite/infinite-trait-alias-recursion.stderr index 5b0cbd58231..fa51914415d 100644 --- a/tests/ui/infinite/infinite-trait-alias-recursion.stderr +++ b/tests/ui/infinite/infinite-trait-alias-recursion.stderr @@ -20,7 +20,7 @@ note: cycle used when checking that `T1` is well-formed --> $DIR/infinite-trait-alias-recursion.rs:3:1 | LL | trait T1 = T2; - | ^^^^^^^^^^^^^^ + | ^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 1 previous error diff --git a/tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr b/tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr index 3dec2c3084f..e586248f5d2 100644 --- a/tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr +++ b/tests/ui/infinite/infinite-type-alias-mutual-recursion.feature.stderr @@ -1,24 +1,24 @@ error[E0275]: overflow normalizing the type alias `X2` - --> $DIR/infinite-type-alias-mutual-recursion.rs:6:11 + --> $DIR/infinite-type-alias-mutual-recursion.rs:6:1 | LL | type X1 = X2; - | ^^ + | ^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead error[E0275]: overflow normalizing the type alias `X3` - --> $DIR/infinite-type-alias-mutual-recursion.rs:9:11 + --> $DIR/infinite-type-alias-mutual-recursion.rs:9:1 | LL | type X2 = X3; - | ^^ + | ^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead error[E0275]: overflow normalizing the type alias `X1` - --> $DIR/infinite-type-alias-mutual-recursion.rs:11:11 + --> $DIR/infinite-type-alias-mutual-recursion.rs:11:1 | LL | type X3 = X1; - | ^^ + | ^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead diff --git a/tests/ui/infinite/infinite-vec-type-recursion.feature.stderr b/tests/ui/infinite/infinite-vec-type-recursion.feature.stderr index 5c8d50341c1..3e07a46ea26 100644 --- a/tests/ui/infinite/infinite-vec-type-recursion.feature.stderr +++ b/tests/ui/infinite/infinite-vec-type-recursion.feature.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow normalizing the type alias `X` - --> $DIR/infinite-vec-type-recursion.rs:6:10 + --> $DIR/infinite-vec-type-recursion.rs:6:1 | LL | type X = Vec<X>; - | ^^^^^^ + | ^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead diff --git a/tests/ui/inline-const/in-pat-recovery.rs b/tests/ui/inline-const/in-pat-recovery.rs index e9e60116ff4..a46e56e3be6 100644 --- a/tests/ui/inline-const/in-pat-recovery.rs +++ b/tests/ui/inline-const/in-pat-recovery.rs @@ -4,7 +4,7 @@ fn main() { match 1 { const { 1 + 7 } => {} - //~^ ERROR `inline_const_pat` has been removed + //~^ ERROR const blocks cannot be used as patterns 2 => {} _ => {} } diff --git a/tests/ui/inline-const/in-pat-recovery.stderr b/tests/ui/inline-const/in-pat-recovery.stderr index e1f2e681e77..0698cff1480 100644 --- a/tests/ui/inline-const/in-pat-recovery.stderr +++ b/tests/ui/inline-const/in-pat-recovery.stderr @@ -1,10 +1,10 @@ -error: `inline_const_pat` has been removed +error: const blocks cannot be used as patterns --> $DIR/in-pat-recovery.rs:6:15 | LL | const { 1 + 7 } => {} | ^^^^^^^^^ | - = help: use a named `const`-item or an `if`-guard instead + = help: use a named `const`-item or an `if`-guard (`x if x == const { ... }`) instead error: aborting due to 1 previous error diff --git a/tests/ui/inlined-main.rs b/tests/ui/inlined-main.rs deleted file mode 100644 index 731ac0dddca..00000000000 --- a/tests/ui/inlined-main.rs +++ /dev/null @@ -1,4 +0,0 @@ -//@ run-pass - -#[inline(always)] -fn main() {} diff --git a/tests/ui/inner-attrs-on-impl.rs b/tests/ui/inner-attrs-on-impl.rs deleted file mode 100644 index 1dce1cdd261..00000000000 --- a/tests/ui/inner-attrs-on-impl.rs +++ /dev/null @@ -1,24 +0,0 @@ -//@ run-pass - -struct Foo; - -impl Foo { - #![cfg(false)] - - fn method(&self) -> bool { false } -} - -impl Foo { - #![cfg(not(FALSE))] - - // check that we don't eat attributes too eagerly. - #[cfg(false)] - fn method(&self) -> bool { false } - - fn method(&self) -> bool { true } -} - - -pub fn main() { - assert!(Foo.method()); -} diff --git a/tests/ui/inner-module.rs b/tests/ui/inner-module.rs deleted file mode 100644 index 111f2cab857..00000000000 --- a/tests/ui/inner-module.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -mod inner { - pub mod inner2 { - pub fn hello() { println!("hello, modular world"); } - } - pub fn hello() { inner2::hello(); } -} - -pub fn main() { inner::hello(); inner::inner2::hello(); } diff --git a/tests/ui/inner-static-type-parameter.rs b/tests/ui/inner-static-type-parameter.rs deleted file mode 100644 index a1994e7529c..00000000000 --- a/tests/ui/inner-static-type-parameter.rs +++ /dev/null @@ -1,11 +0,0 @@ -// see #9186 - -enum Bar<T> { What } //~ ERROR parameter `T` is never used - -fn foo<T>() { - static a: Bar<T> = Bar::What; -//~^ ERROR can't use generic parameters from outer item -} - -fn main() { -} diff --git a/tests/ui/integral-indexing.rs b/tests/ui/integral-indexing.rs deleted file mode 100644 index f076dfcb0a4..00000000000 --- a/tests/ui/integral-indexing.rs +++ /dev/null @@ -1,16 +0,0 @@ -pub fn main() { - let v: Vec<isize> = vec![0, 1, 2, 3, 4, 5]; - let s: String = "abcdef".to_string(); - v[3_usize]; - v[3]; - v[3u8]; //~ERROR : the type `[isize]` cannot be indexed by `u8` - v[3i8]; //~ERROR : the type `[isize]` cannot be indexed by `i8` - v[3u32]; //~ERROR : the type `[isize]` cannot be indexed by `u32` - v[3i32]; //~ERROR : the type `[isize]` cannot be indexed by `i32` - s.as_bytes()[3_usize]; - s.as_bytes()[3]; - s.as_bytes()[3u8]; //~ERROR : the type `[u8]` cannot be indexed by `u8` - s.as_bytes()[3i8]; //~ERROR : the type `[u8]` cannot be indexed by `i8` - s.as_bytes()[3u32]; //~ERROR : the type `[u8]` cannot be indexed by `u32` - s.as_bytes()[3i32]; //~ERROR : the type `[u8]` cannot be indexed by `i32` -} diff --git a/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr b/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr index 7879e7358c0..8b9ad78db37 100644 --- a/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr +++ b/tests/ui/invalid/invalid_rustc_layout_scalar_valid_range.stderr @@ -1,20 +1,38 @@ -error: expected exactly one integer literal argument +error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:3:1 | LL | #[rustc_layout_scalar_valid_range_start(u32::MAX)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------^^ + | | | + | | expected an integer literal here + | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` -error: expected exactly one integer literal argument +error[E0805]: malformed `rustc_layout_scalar_valid_range_end` attribute input --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:6:1 | LL | #[rustc_layout_scalar_valid_range_end(1, 2)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------^ + | | | + | | expected a single argument here + | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` -error: expected exactly one integer literal argument +error[E0539]: malformed `rustc_layout_scalar_valid_range_end` attribute input --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:9:1 | LL | #[rustc_layout_scalar_valid_range_end(a = "a")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------^^ + | | | + | | expected an integer literal here + | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` + +error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input + --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:18:1 + | +LL | #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------------------------------------^^ + | | | + | | expected an integer literal here + | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` error: attribute should be applied to a struct --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:12:1 @@ -27,11 +45,7 @@ LL | | Y = 14, LL | | } | |_- not a struct -error: expected exactly one integer literal argument - --> $DIR/invalid_rustc_layout_scalar_valid_range.rs:18:1 - | -LL | #[rustc_layout_scalar_valid_range_start(rustc_layout_scalar_valid_range_start)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 5 previous errors +Some errors have detailed explanations: E0539, E0805. +For more information about an error, try `rustc --explain E0539`. diff --git a/tests/ui/stdio-is-blocking.rs b/tests/ui/io-checks/io-stdout-blocking-writes.rs index 615530dcd47..1197b7f43be 100644 --- a/tests/ui/stdio-is-blocking.rs +++ b/tests/ui/io-checks/io-stdout-blocking-writes.rs @@ -1,10 +1,12 @@ +//! Check that writes to standard output are blocking, avoiding interleaving +//! even with concurrent writes from multiple threads. + //@ run-pass //@ needs-subprocess -use std::env; use std::io::prelude::*; use std::process::Command; -use std::thread; +use std::{env, thread}; const THREADS: usize = 20; const WRITES: usize = 100; @@ -33,14 +35,16 @@ fn parent() { } fn child() { - let threads = (0..THREADS).map(|_| { - thread::spawn(|| { - let buf = [b'a'; WRITE_SIZE]; - for _ in 0..WRITES { - write_all(&buf); - } + let threads = (0..THREADS) + .map(|_| { + thread::spawn(|| { + let buf = [b'a'; WRITE_SIZE]; + for _ in 0..WRITES { + write_all(&buf); + } + }) }) - }).collect::<Vec<_>>(); + .collect::<Vec<_>>(); for thread in threads { thread.join().unwrap(); @@ -63,8 +67,8 @@ fn write_all(buf: &[u8]) { fn write_all(buf: &[u8]) { use std::fs::File; use std::mem; - use std::os::windows::raw::*; use std::os::windows::prelude::*; + use std::os::windows::raw::*; const STD_OUTPUT_HANDLE: u32 = (-11i32) as u32; diff --git a/tests/ui/print-stdout-eprint-stderr.rs b/tests/ui/io-checks/stdout-stderr-separation.rs index 4b356e2fe61..1bb3f16d3a1 100644 --- a/tests/ui/print-stdout-eprint-stderr.rs +++ b/tests/ui/io-checks/stdout-stderr-separation.rs @@ -1,3 +1,6 @@ +//! Test that print!/println! output to stdout and eprint!/eprintln! +//! output to stderr correctly. + //@ run-pass //@ needs-subprocess diff --git a/tests/ui/issue-16822.rs b/tests/ui/issue-16822.rs deleted file mode 100644 index 94d89f88f47..00000000000 --- a/tests/ui/issue-16822.rs +++ /dev/null @@ -1,22 +0,0 @@ -//@ run-pass -//@ aux-build:issue-16822.rs - -extern crate issue_16822 as lib; - -use std::cell::RefCell; - -struct App { - i: isize -} - -impl lib::Update for App { - fn update(&mut self) { - self.i += 1; - } -} - -fn main(){ - let app = App { i: 5 }; - let window = lib::Window { data: RefCell::new(app) }; - window.update(1); -} diff --git a/tests/ui/issues/issue-32950.rs b/tests/ui/issues/issue-32950.rs deleted file mode 100644 index b51ac296776..00000000000 --- a/tests/ui/issues/issue-32950.rs +++ /dev/null @@ -1,10 +0,0 @@ -#![feature(concat_idents)] -#![expect(deprecated)] // concat_idents is deprecated - -#[derive(Debug)] -struct Baz<T>( - concat_idents!(Foo, Bar) //~ ERROR `derive` cannot be used on items with type macros - //~^ ERROR cannot find type `FooBar` in this scope -); - -fn main() {} diff --git a/tests/ui/issues/issue-32950.stderr b/tests/ui/issues/issue-32950.stderr deleted file mode 100644 index 38a82542f89..00000000000 --- a/tests/ui/issues/issue-32950.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error: `derive` cannot be used on items with type macros - --> $DIR/issue-32950.rs:6:5 - | -LL | concat_idents!(Foo, Bar) - | ^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0412]: cannot find type `FooBar` in this scope - --> $DIR/issue-32950.rs:6:5 - | -LL | concat_idents!(Foo, Bar) - | ^^^^^^^^^^^^^^^^^^^^^^^^ not found in this scope - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0412`. diff --git a/tests/ui/issues/issue-46604.rs b/tests/ui/issues/issue-46604.rs index 6ec6e7bdcb8..e15f0b52da2 100644 --- a/tests/ui/issues/issue-46604.rs +++ b/tests/ui/issues/issue-46604.rs @@ -1,4 +1,4 @@ -static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //~ ERROR mutable references are not allowed +static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; //~ ERROR mutable borrows of temporaries fn write<T: AsRef<[u8]>>(buffer: T) { } fn main() { diff --git a/tests/ui/issues/issue-46604.stderr b/tests/ui/issues/issue-46604.stderr index 7faa2d79ba4..d983674995e 100644 --- a/tests/ui/issues/issue-46604.stderr +++ b/tests/ui/issues/issue-46604.stderr @@ -1,8 +1,12 @@ -error[E0764]: mutable references are not allowed in the final value of statics +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/issue-46604.rs:1:25 | LL | static buf: &mut [u8] = &mut [1u8,2,3,4,5,7]; - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error[E0594]: cannot assign to `buf[_]`, as `buf` is an immutable static item --> $DIR/issue-46604.rs:6:5 diff --git a/tests/ui/issues/issue-50403.rs b/tests/ui/issues/issue-50403.rs deleted file mode 100644 index f14958afc34..00000000000 --- a/tests/ui/issues/issue-50403.rs +++ /dev/null @@ -1,6 +0,0 @@ -#![feature(concat_idents)] -#![expect(deprecated)] // concat_idents is deprecated - -fn main() { - let x = concat_idents!(); //~ ERROR `concat_idents!()` takes 1 or more arguments -} diff --git a/tests/ui/issues/issue-50403.stderr b/tests/ui/issues/issue-50403.stderr deleted file mode 100644 index e7dd05bb018..00000000000 --- a/tests/ui/issues/issue-50403.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: `concat_idents!()` takes 1 or more arguments - --> $DIR/issue-50403.rs:5:13 - | -LL | let x = concat_idents!(); - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/issues/issue-54410.stderr b/tests/ui/issues/issue-54410.stderr index 2cd5a2a49ef..cb68ada7e13 100644 --- a/tests/ui/issues/issue-54410.stderr +++ b/tests/ui/issues/issue-54410.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `[i8]` cannot be known at compilation time - --> $DIR/issue-54410.rs:2:28 + --> $DIR/issue-54410.rs:2:5 | LL | pub static mut symbol: [i8]; - | ^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[i8]` = note: statics and constants must have a statically known size diff --git a/tests/ui/issues/issue-59488.stderr b/tests/ui/issues/issue-59488.stderr index ac8862716c0..b6611ad63a8 100644 --- a/tests/ui/issues/issue-59488.stderr +++ b/tests/ui/issues/issue-59488.stderr @@ -87,18 +87,16 @@ error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug` --> $DIR/issue-59488.rs:30:5 | LL | assert_eq!(Foo::Bar, i); - | ^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}` | - = help: the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `fn(usize) -> Foo {Foo::Bar}` doesn't implement `Debug` --> $DIR/issue-59488.rs:30:5 | LL | assert_eq!(Foo::Bar, i); - | ^^^^^^^^^^^^^^^^^^^^^^^ `fn(usize) -> Foo {Foo::Bar}` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}` | - = help: the trait `Debug` is not implemented for fn item `fn(usize) -> Foo {Foo::Bar}` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 10 previous errors diff --git a/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr b/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr index b30bcfb776c..736002c9335 100644 --- a/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr +++ b/tests/ui/issues/issue-70724-add_type_neq_err_label-unwrap.stderr @@ -26,9 +26,8 @@ LL | fn a() -> i32 { | - consider calling this function ... LL | assert_eq!(a, 0); - | ^^^^^^^^^^^^^^^^ `fn() -> i32 {a}` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for fn item `fn() -> i32 {a}` | - = help: the trait `Debug` is not implemented for fn item `fn() -> i32 {a}` = help: use parentheses to call this function: `a()` = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/issues/issue-92741.rs b/tests/ui/issues/issue-92741.rs index f2e5fdafd9c..1c5d5810a57 100644 --- a/tests/ui/issues/issue-92741.rs +++ b/tests/ui/issues/issue-92741.rs @@ -1,17 +1,17 @@ //@ run-rustfix fn main() {} fn _foo() -> bool { - & //~ ERROR 4:5: 6:36: mismatched types [E0308] + & //~ ERROR mismatched types [E0308] mut if true { true } else { false } } fn _bar() -> bool { - & //~ ERROR 10:5: 11:40: mismatched types [E0308] + & //~ ERROR mismatched types [E0308] mut if true { true } else { false } } fn _baz() -> bool { - & mut //~ ERROR 15:5: 16:36: mismatched types [E0308] + & mut //~ ERROR mismatched types [E0308] if true { true } else { false } } diff --git a/tests/ui/item-name-overload.rs b/tests/ui/item-name-overload.rs deleted file mode 100644 index dd2925aa53f..00000000000 --- a/tests/ui/item-name-overload.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] - - - - -mod foo { - pub fn baz() { } -} - -mod bar { - pub fn baz() { } -} - -pub fn main() { } diff --git a/tests/ui/kinds-of-primitive-impl.rs b/tests/ui/kinds-of-primitive-impl.rs deleted file mode 100644 index f1c2ee8e550..00000000000 --- a/tests/ui/kinds-of-primitive-impl.rs +++ /dev/null @@ -1,26 +0,0 @@ -impl u8 { -//~^ error: cannot define inherent `impl` for primitive types - pub const B: u8 = 0; -} - -impl str { -//~^ error: cannot define inherent `impl` for primitive types - fn foo() {} - fn bar(self) {} //~ ERROR: size for values of type `str` cannot be known -} - -impl char { -//~^ error: cannot define inherent `impl` for primitive types - pub const B: u8 = 0; - pub const C: u8 = 0; - fn foo() {} - fn bar(self) {} -} - -struct MyType; -impl &MyType { -//~^ error: cannot define inherent `impl` for primitive types - pub fn for_ref(self) {} -} - -fn main() {} diff --git a/tests/ui/last-use-in-block.rs b/tests/ui/last-use-in-block.rs deleted file mode 100644 index 4a166b97bda..00000000000 --- a/tests/ui/last-use-in-block.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -#![allow(unused_parens)] -// Issue #1818 - - -fn lp<T, F>(s: String, mut f: F) -> T where F: FnMut(String) -> T { - while false { - let r = f(s); - return (r); - } - panic!(); -} - -fn apply<T, F>(s: String, mut f: F) -> T where F: FnMut(String) -> T { - fn g<T, F>(s: String, mut f: F) -> T where F: FnMut(String) -> T {f(s)} - g(s, |v| { let r = f(v); r }) -} - -pub fn main() {} diff --git a/tests/ui/last-use-in-cap-clause.rs b/tests/ui/last-use-in-cap-clause.rs deleted file mode 100644 index 23c263c9805..00000000000 --- a/tests/ui/last-use-in-cap-clause.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -// Make sure #1399 stays fixed - -struct A { a: Box<isize> } - -fn foo() -> Box<dyn FnMut() -> isize + 'static> { - let k: Box<_> = Box::new(22); - let _u = A {a: k.clone()}; - let result = || 22; - Box::new(result) -} - -pub fn main() { - assert_eq!(foo()(), 22); -} diff --git a/tests/ui/last-use-is-capture.rs b/tests/ui/last-use-is-capture.rs deleted file mode 100644 index 6e07895f1d3..00000000000 --- a/tests/ui/last-use-is-capture.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -// Make sure #1399 stays fixed - -struct A { a: Box<isize> } - -pub fn main() { - fn invoke<F>(f: F) where F: FnOnce() { f(); } - let k: Box<_> = 22.into(); - let _u = A {a: k.clone()}; - invoke(|| println!("{}", k.clone()) ) -} diff --git a/tests/ui/layout/ice-non-last-unsized-field-issue-121473.stderr b/tests/ui/layout/ice-non-last-unsized-field-issue-121473.stderr index 626be7ac283..b0ea655fc67 100644 --- a/tests/ui/layout/ice-non-last-unsized-field-issue-121473.stderr +++ b/tests/ui/layout/ice-non-last-unsized-field-issue-121473.stderr @@ -70,6 +70,18 @@ help: the `Box` type always has a statically known size and allocates its conten LL | field2: Box<str>, // Unsized | ++++ + +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/ice-non-last-unsized-field-issue-121473.rs:46:5 + | +LL | field2: str, // Unsized + | ^^^^^^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | field2: std::mem::ManuallyDrop<str>, // Unsized + | +++++++++++++++++++++++ + + error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/ice-non-last-unsized-field-issue-121473.rs:46:13 | @@ -88,18 +100,6 @@ help: the `Box` type always has a statically known size and allocates its conten LL | field2: Box<str>, // Unsized | ++++ + -error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/ice-non-last-unsized-field-issue-121473.rs:46:5 - | -LL | field2: str, // Unsized - | ^^^^^^^^^^^ - | - = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` -help: wrap the field type in `ManuallyDrop<...>` - | -LL | field2: std::mem::ManuallyDrop<str>, // Unsized - | +++++++++++++++++++++++ + - error: aborting due to 6 previous errors Some errors have detailed explanations: E0277, E0740. diff --git a/tests/ui/nullable-pointer-size.rs b/tests/ui/layout/null-pointer-optimization-sizes.rs index aabdfa140df..95310b32e25 100644 --- a/tests/ui/nullable-pointer-size.rs +++ b/tests/ui/layout/null-pointer-optimization-sizes.rs @@ -1,10 +1,20 @@ +//! null pointer optimization preserves type sizes. +//! +//! Verifies that Option<T> has the same size as T for non-null pointer types, +//! and for custom enums that have a niche. + //@ run-pass +// Needs for Nothing variat in Enum #![allow(dead_code)] use std::mem; -enum E<T> { Thing(isize, T), Nothing((), ((), ()), [i8; 0]) } +enum E<T> { + Thing(isize, T), + Nothing((), ((), ()), [i8; 0]), +} + struct S<T>(isize, T); // These are macros so we get useful assert messages. @@ -12,20 +22,20 @@ struct S<T>(isize, T); macro_rules! check_option { ($T:ty) => { assert_eq!(mem::size_of::<Option<$T>>(), mem::size_of::<$T>()); - } + }; } macro_rules! check_fancy { ($T:ty) => { assert_eq!(mem::size_of::<E<$T>>(), mem::size_of::<S<$T>>()); - } + }; } macro_rules! check_type { ($T:ty) => {{ check_option!($T); check_fancy!($T); - }} + }}; } pub fn main() { diff --git a/tests/ui/nullable-pointer-iotareduction.rs b/tests/ui/layout/null-pointer-optimization.rs index 1b73164c9fc..5e77c8d22ab 100644 --- a/tests/ui/nullable-pointer-iotareduction.rs +++ b/tests/ui/layout/null-pointer-optimization.rs @@ -1,27 +1,34 @@ -//@ run-pass +//! null pointer optimization with iota-reduction for enums. +//! +//! Iota-reduction is a rule from the Calculus of (Co-)Inductive Constructions: +//! "a destructor applied to an object built from a constructor behaves as expected". +//! See <https://coq.inria.fr/doc/language/core/conversion.html#iota-reduction>. +//! +//! This test verifies that null pointer optimization works correctly for both +//! Option<T> and custom enums, accounting for pointers and regions. -// Iota-reduction is a rule in the Calculus of (Co-)Inductive Constructions, -// which "says that a destructor applied to an object built from a constructor -// behaves as expected". -- https://coq.inria.fr/doc/language/core/conversion.html#iota-reduction -// -// It's a little more complicated here, because of pointers and regions and -// trying to get assert failure messages that at least identify which case -// failed. +//@ run-pass #![allow(unpredictable_function_pointer_comparisons)] -enum E<T> { Thing(isize, T), #[allow(dead_code)] Nothing((), ((), ()), [i8; 0]) } +enum E<T> { + Thing(isize, T), + #[allow(dead_code)] + Nothing((), ((), ()), [i8; 0]), +} + impl<T> E<T> { fn is_none(&self) -> bool { match *self { E::Thing(..) => false, - E::Nothing(..) => true + E::Nothing(..) => true, } } + fn get_ref(&self) -> (isize, &T) { match *self { - E::Nothing(..) => panic!("E::get_ref(Nothing::<{}>)", stringify!(T)), - E::Thing(x, ref y) => (x, y) + E::Nothing(..) => panic!("E::get_ref(Nothing::<{}>)", stringify!(T)), + E::Thing(x, ref y) => (x, y), } } } @@ -36,7 +43,7 @@ macro_rules! check_option { let s_ = Some::<$T>(e); let $v = s_.as_ref().unwrap(); $chk - }} + }}; } macro_rules! check_fancy { @@ -48,11 +55,10 @@ macro_rules! check_fancy { let e = $e; let t_ = E::Thing::<$T>(23, e); match t_.get_ref() { - (23, $v) => { $chk } - _ => panic!("Thing::<{}>(23, {}).get_ref() != (23, _)", - stringify!($T), stringify!($e)) + (23, $v) => $chk, + _ => panic!("Thing::<{}>(23, {}).get_ref() != (23, _)", stringify!($T), stringify!($e)), } - }} + }}; } macro_rules! check_type { @@ -67,7 +73,5 @@ pub fn main() { check_type!(Box::new(18), Box<isize>); check_type!("foo".to_string(), String); check_type!(vec![20, 22], Vec<isize>); - check_type!(main, fn(), |pthing| { - assert_eq!(main as fn(), *pthing as fn()) - }); + check_type!(main, fn(), |pthing| assert_eq!(main as fn(), *pthing as fn())); } diff --git a/tests/ui/layout/rust-call-abi-not-a-tuple-ice-81974.stderr b/tests/ui/layout/rust-call-abi-not-a-tuple-ice-81974.stderr index 32a564e466b..75ee936d9e8 100644 --- a/tests/ui/layout/rust-call-abi-not-a-tuple-ice-81974.stderr +++ b/tests/ui/layout/rust-call-abi-not-a-tuple-ice-81974.stderr @@ -1,4 +1,17 @@ error[E0059]: type parameter to bare `FnOnce` trait must be a tuple + --> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:31:5 + | +LL | extern "rust-call" fn call_once(mut self, a: A) -> Self::Output { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `A` + | +note: required by a bound in `FnOnce` + --> $SRC_DIR/core/src/ops/function.rs:LL:COL +help: consider further restricting type parameter `A` with unstable trait `Tuple` + | +LL | A: Eq + Hash + Clone + std::marker::Tuple, + | ++++++++++++++++++++ + +error[E0059]: type parameter to bare `FnOnce` trait must be a tuple --> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:24:12 | LL | impl<A, B> FnOnce<A> for CachedFun<A, B> @@ -12,9 +25,9 @@ LL | A: Eq + Hash + Clone + std::marker::Tuple, | ++++++++++++++++++++ error[E0059]: type parameter to bare `FnOnce` trait must be a tuple - --> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:31:5 + --> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:45:5 | -LL | extern "rust-call" fn call_once(mut self, a: A) -> Self::Output { +LL | extern "rust-call" fn call_mut(&mut self, a: A) -> Self::Output { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `A` | note: required by a bound in `FnOnce` @@ -37,19 +50,6 @@ help: consider further restricting type parameter `A` with unstable trait `Tuple LL | A: Eq + Hash + Clone + std::marker::Tuple, | ++++++++++++++++++++ -error[E0059]: type parameter to bare `FnOnce` trait must be a tuple - --> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:45:5 - | -LL | extern "rust-call" fn call_mut(&mut self, a: A) -> Self::Output { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Tuple` is not implemented for `A` - | -note: required by a bound in `FnOnce` - --> $SRC_DIR/core/src/ops/function.rs:LL:COL -help: consider further restricting type parameter `A` with unstable trait `Tuple` - | -LL | A: Eq + Hash + Clone + std::marker::Tuple, - | ++++++++++++++++++++ - error[E0277]: functions with the "rust-call" ABI must take a single non-self tuple argument --> $DIR/rust-call-abi-not-a-tuple-ice-81974.rs:31:5 | diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr b/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr index 85ac98f4050..e91946066bd 100644 --- a/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr +++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.current.stderr @@ -1,8 +1,8 @@ error[E0275]: overflow normalizing the type alias `Loop` - --> $DIR/inherent-impls-overflow.rs:8:13 + --> $DIR/inherent-impls-overflow.rs:8:1 | LL | type Loop = Loop; - | ^^^^ + | ^^^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead @@ -15,18 +15,18 @@ LL | impl Loop {} = note: in case this is a recursive type alias, consider using a struct, enum, or union instead error[E0275]: overflow normalizing the type alias `Poly0<(((((((...,),),),),),),)>` - --> $DIR/inherent-impls-overflow.rs:17:17 + --> $DIR/inherent-impls-overflow.rs:17:1 | LL | type Poly0<T> = Poly1<(T,)>; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead error[E0275]: overflow normalizing the type alias `Poly1<(((((((...,),),),),),),)>` - --> $DIR/inherent-impls-overflow.rs:21:17 + --> $DIR/inherent-impls-overflow.rs:21:1 | LL | type Poly1<T> = Poly0<(T,)>; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead diff --git a/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr b/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr index e94f29de44f..62ed6e8e513 100644 --- a/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr +++ b/tests/ui/lazy-type-alias/inherent-impls-overflow.next.stderr @@ -1,8 +1,8 @@ error[E0271]: type mismatch resolving `Loop normalizes-to _` - --> $DIR/inherent-impls-overflow.rs:8:13 + --> $DIR/inherent-impls-overflow.rs:8:1 | LL | type Loop = Loop; - | ^^^^ types differ + | ^^^^^^^^^ types differ error[E0271]: type mismatch resolving `Loop normalizes-to _` --> $DIR/inherent-impls-overflow.rs:12:1 @@ -17,10 +17,10 @@ LL | impl Loop {} | ^^^^ types differ error[E0275]: overflow evaluating the requirement `Poly1<(T,)> == _` - --> $DIR/inherent-impls-overflow.rs:17:17 + --> $DIR/inherent-impls-overflow.rs:17:1 | LL | type Poly0<T> = Poly1<(T,)>; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_impls_overflow`) @@ -36,10 +36,10 @@ LL | type Poly0<T> = Poly1<(T,)>; = note: all type parameters must be used in a non-recursive way in order to constrain their variance error[E0275]: overflow evaluating the requirement `Poly0<(T,)> == _` - --> $DIR/inherent-impls-overflow.rs:21:17 + --> $DIR/inherent-impls-overflow.rs:21:1 | LL | type Poly1<T> = Poly0<(T,)>; - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^ | = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`inherent_impls_overflow`) diff --git a/tests/ui/lazy-type-alias/unconstrained-params-in-impl-due-to-overflow.stderr b/tests/ui/lazy-type-alias/unconstrained-params-in-impl-due-to-overflow.stderr index bcffa02ddd4..d8270a0abdd 100644 --- a/tests/ui/lazy-type-alias/unconstrained-params-in-impl-due-to-overflow.stderr +++ b/tests/ui/lazy-type-alias/unconstrained-params-in-impl-due-to-overflow.stderr @@ -5,10 +5,10 @@ LL | impl<T> Loop<T> {} | ^ unconstrained type parameter error[E0275]: overflow normalizing the type alias `Loop<T>` - --> $DIR/unconstrained-params-in-impl-due-to-overflow.rs:6:16 + --> $DIR/unconstrained-params-in-impl-due-to-overflow.rs:6:1 | LL | type Loop<T> = Loop<T>; - | ^^^^^^^ + | ^^^^^^^^^^^^ | = note: in case this is a recursive type alias, consider using a struct, enum, or union instead diff --git a/tests/ui/lifetimes/issue-107988.stderr b/tests/ui/lifetimes/issue-107988.stderr index c2d8c7050e9..7d93c1d2024 100644 --- a/tests/ui/lifetimes/issue-107988.stderr +++ b/tests/ui/lifetimes/issue-107988.stderr @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'tcx` --> $DIR/issue-107988.rs:7:52 | LL | impl<T: ?Sized + TraitEngine<'tcx>> TraitEngineExt<'tcx> for T { - | - ^^^^ undeclared lifetime - | | - | help: consider introducing lifetime `'tcx` here: `'tcx,` + | ^^^^ undeclared lifetime + | +help: consider introducing lifetime `'tcx` here + | +LL | impl<'tcx, T: ?Sized + TraitEngine<'tcx>> TraitEngineExt<'tcx> for T { + | +++++ error[E0261]: use of undeclared lifetime name `'tcx` --> $DIR/issue-107988.rs:7:30 diff --git a/tests/ui/lifetimes/issue-64173-unused-lifetimes.stderr b/tests/ui/lifetimes/issue-64173-unused-lifetimes.stderr index 534ba933ba5..4bfbe0eeff7 100644 --- a/tests/ui/lifetimes/issue-64173-unused-lifetimes.stderr +++ b/tests/ui/lifetimes/issue-64173-unused-lifetimes.stderr @@ -7,12 +7,6 @@ LL | beta: [(); foo::<&'a ()>()], = note: lifetime parameters may not be used in const expressions = help: add `#![feature(generic_const_exprs)]` to allow generic const expressions -error: generic `Self` types are currently not permitted in anonymous constants - --> $DIR/issue-64173-unused-lifetimes.rs:4:28 - | -LL | array: [(); size_of::<&Self>()], - | ^^^^ - error[E0392]: lifetime parameter `'s` is never used --> $DIR/issue-64173-unused-lifetimes.rs:3:12 | @@ -21,6 +15,12 @@ LL | struct Foo<'s> { | = help: consider removing `'s`, referring to it in a field, or using a marker such as `PhantomData` +error: generic `Self` types are currently not permitted in anonymous constants + --> $DIR/issue-64173-unused-lifetimes.rs:4:28 + | +LL | array: [(); size_of::<&Self>()], + | ^^^^ + error[E0392]: lifetime parameter `'a` is never used --> $DIR/issue-64173-unused-lifetimes.rs:15:12 | diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs index eab436fa341..d6fda129e36 100644 --- a/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs +++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.rs @@ -7,10 +7,12 @@ async fn wrapper<F>(f: F) //~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` //~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` //~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` -//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` where F:, for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, +//~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` +//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` +//~| ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` { //~^ ERROR: expected a `FnOnce(&'a mut i32)` closure, found `i32` let mut i = 41; diff --git a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr index 90572fed0ed..945d38d17f6 100644 --- a/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr +++ b/tests/ui/lifetimes/issue-76168-hr-outlives-3.stderr @@ -10,10 +10,26 @@ LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32` - --> $DIR/issue-76168-hr-outlives-3.rs:6:10 + --> $DIR/issue-76168-hr-outlives-3.rs:12:50 | -LL | async fn wrapper<F>(f: F) - | ^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32` +LL | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, + | ^^^^^^^^^^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32` + | + = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` + +error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32` + --> $DIR/issue-76168-hr-outlives-3.rs:12:57 + | +LL | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, + | ^^^^^^^^^^^ expected an `FnOnce(&'a mut i32)` closure, found `i32` + | + = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` + +error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32` + --> $DIR/issue-76168-hr-outlives-3.rs:12:72 + | +LL | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a, + | ^^ expected an `FnOnce(&'a mut i32)` closure, found `i32` | = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` @@ -41,7 +57,7 @@ LL | | for<'a> <i32 as FnOnce<(&'a mut i32,)>>::Output: Future<Output = ()> + 'a = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0277]: expected a `FnOnce(&'a mut i32)` closure, found `i32` - --> $DIR/issue-76168-hr-outlives-3.rs:14:1 + --> $DIR/issue-76168-hr-outlives-3.rs:16:1 | LL | / { LL | | @@ -52,6 +68,6 @@ LL | | } | = help: the trait `for<'a> FnOnce(&'a mut i32)` is not implemented for `i32` -error: aborting due to 5 previous errors +error: aborting due to 7 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/lifetimes/issue-95023.stderr b/tests/ui/lifetimes/issue-95023.stderr index cbc0eeebee1..dffa033fb17 100644 --- a/tests/ui/lifetimes/issue-95023.stderr +++ b/tests/ui/lifetimes/issue-95023.stderr @@ -32,6 +32,14 @@ help: parenthesized trait syntax expands to `Fn<(&isize,), Output=()>` LL | impl Fn(&isize) for Error { | ^^^^^^^^^^ +error[E0046]: not all trait items implemented, missing: `call` + --> $DIR/issue-95023.rs:3:1 + | +LL | impl Fn(&isize) for Error { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation + | + = help: implement the missing item: `fn call(&self, _: (&isize,)) -> <Self as FnOnce<(&isize,)>>::Output { todo!() }` + error[E0277]: expected a `FnMut(&isize)` closure, found `Error` --> $DIR/issue-95023.rs:3:21 | @@ -42,14 +50,6 @@ LL | impl Fn(&isize) for Error { note: required by a bound in `Fn` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error[E0046]: not all trait items implemented, missing: `call` - --> $DIR/issue-95023.rs:3:1 - | -LL | impl Fn(&isize) for Error { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation - | - = help: implement the missing item: `fn call(&self, _: (&isize,)) -> <Self as FnOnce<(&isize,)>>::Output { todo!() }` - error[E0220]: associated type `B` not found for `Self` --> $DIR/issue-95023.rs:8:44 | diff --git a/tests/ui/lifetimes/no_lending_iterators.rs b/tests/ui/lifetimes/no_lending_iterators.rs index b3e8ad08ba1..88b8cda0898 100644 --- a/tests/ui/lifetimes/no_lending_iterators.rs +++ b/tests/ui/lifetimes/no_lending_iterators.rs @@ -2,7 +2,7 @@ struct Data(String); impl Iterator for Data { type Item = &str; - //~^ ERROR 4:17: 4:18: associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type + //~^ ERROR associated type `Iterator::Item` is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type fn next(&mut self) -> Option<Self::Item> { Some(&self.0) @@ -16,7 +16,7 @@ trait Bar { impl Bar for usize { type Item = &usize; - //~^ ERROR 18:17: 18:18: in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type + //~^ ERROR in the trait associated type is declared without lifetime parameters, so using a borrowed type for them requires that lifetime to come from the implemented type fn poke(&mut self, item: Self::Item) { self += *item; @@ -25,7 +25,7 @@ impl Bar for usize { impl Bar for isize { type Item<'a> = &'a isize; - //~^ ERROR 27:14: 27:18: lifetime parameters or bounds on associated type `Item` do not match the trait declaration [E0195] + //~^ ERROR lifetime parameters or bounds on associated type `Item` do not match the trait declaration [E0195] fn poke(&mut self, item: Self::Item) { self += *item; diff --git a/tests/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr b/tests/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr index 0d6ade41511..f90133e9fb1 100644 --- a/tests/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr +++ b/tests/ui/lifetimes/undeclared-lifetime-used-in-debug-macro-issue-70152.stderr @@ -1,10 +1,13 @@ error[E0261]: use of undeclared lifetime name `'b` --> $DIR/undeclared-lifetime-used-in-debug-macro-issue-70152.rs:3:9 | -LL | struct Test { - | - help: consider introducing lifetime `'b` here: `<'b>` LL | a: &'b str, | ^^ undeclared lifetime + | +help: consider introducing lifetime `'b` here + | +LL | struct Test<'b> { + | ++++ error[E0261]: use of undeclared lifetime name `'b` --> $DIR/undeclared-lifetime-used-in-debug-macro-issue-70152.rs:3:9 @@ -12,9 +15,13 @@ error[E0261]: use of undeclared lifetime name `'b` LL | #[derive(Eq, PartialEq)] | -- lifetime `'b` is missing in item created through this procedural macro LL | struct Test { - | - help: consider introducing lifetime `'b` here: `<'b>` LL | a: &'b str, | ^^ undeclared lifetime + | +help: consider introducing lifetime `'b` here + | +LL | struct Test<'b> { + | ++++ error[E0261]: use of undeclared lifetime name `'b` --> $DIR/undeclared-lifetime-used-in-debug-macro-issue-70152.rs:13:13 diff --git a/tests/ui/auxiliary/msvc-data-only-lib.rs b/tests/ui/linkage-attr/auxiliary/msvc-static-data-import-lib.rs index b8a8f905e8b..b8a8f905e8b 100644 --- a/tests/ui/auxiliary/msvc-data-only-lib.rs +++ b/tests/ui/linkage-attr/auxiliary/msvc-static-data-import-lib.rs diff --git a/tests/ui/link-section.rs b/tests/ui/linkage-attr/link-section-placement.rs index a8de8c2e1e7..6a143bfedb4 100644 --- a/tests/ui/link-section.rs +++ b/tests/ui/linkage-attr/link-section-placement.rs @@ -1,8 +1,9 @@ +//! Test placement of functions and statics in custom link sections + //@ run-pass // FIXME(static_mut_refs): Do not allow `static_mut_refs` lint #![allow(static_mut_refs)] - #![allow(non_upper_case_globals)] #[cfg(not(target_vendor = "apple"))] #[link_section = ".moretext"] diff --git a/tests/ui/linkage-attr/msvc-static-data-import.rs b/tests/ui/linkage-attr/msvc-static-data-import.rs new file mode 100644 index 00000000000..e53eb404ef6 --- /dev/null +++ b/tests/ui/linkage-attr/msvc-static-data-import.rs @@ -0,0 +1,18 @@ +//! Test that static data from external crates can be imported on MSVC targets. +//! +//! On Windows MSVC targets, static data from external rlibs must be imported +//! through `__imp_<symbol>` stubs to ensure proper linking. Without this, +//! the linker would fail with "unresolved external symbol" errors when trying +//! to reference static data from another crate. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/26591>. +//! Fixed in <https://github.com/rust-lang/rust/pull/28646>. + +//@ run-pass +//@ aux-build:msvc-static-data-import-lib.rs + +extern crate msvc_static_data_import_lib; + +fn main() { + println!("The answer is {}!", msvc_static_data_import_lib::FOO); +} diff --git a/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.rs b/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.rs index 9babc20d1a1..9ccc9ce4fdb 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.rs +++ b/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.rs @@ -11,7 +11,7 @@ extern crate minicore; #[link(name = "foo", kind = "raw-dylib")] extern "stdcall" { -//~^ WARN: calling convention not supported on this target +//~^ WARN: unsupported_calling_conventions //~| WARN: previously accepted fn f(x: i32); //~^ ERROR ABI not supported by `#[link(kind = "raw-dylib")]` on this architecture diff --git a/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.stderr b/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.stderr index 95ea9080486..91e42f2909e 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.stderr +++ b/tests/ui/linkage-attr/raw-dylib/windows/unsupported-abi.stderr @@ -1,4 +1,4 @@ -warning: use of calling convention not supported on this target +warning: "stdcall" is not a supported ABI for the current target --> $DIR/unsupported-abi.rs:13:1 | LL | / extern "stdcall" { diff --git a/tests/ui/lint/lint-non-uppercase-usages.fixed b/tests/ui/lint/lint-non-uppercase-usages.fixed new file mode 100644 index 00000000000..231991dcae0 --- /dev/null +++ b/tests/ui/lint/lint-non-uppercase-usages.fixed @@ -0,0 +1,44 @@ +// Checks that the `non_upper_case_globals` emits suggestions for usages as well +// <https://github.com/rust-lang/rust/issues/124061> + +//@ check-pass +//@ run-rustfix + +#![allow(dead_code)] + +use std::cell::Cell; + +const MY_STATIC: u32 = 0; +//~^ WARN constant `my_static` should have an upper case name +//~| SUGGESTION MY_STATIC + +const LOL: u32 = MY_STATIC + 0; +//~^ SUGGESTION MY_STATIC + +mod my_mod { + const INSIDE_MOD: u32 = super::MY_STATIC + 0; + //~^ SUGGESTION MY_STATIC +} + +thread_local! { + static FOO_FOO: Cell<usize> = unreachable!(); + //~^ WARN constant `fooFOO` should have an upper case name + //~| SUGGESTION FOO_FOO +} + +fn foo<const FOO: u32>() { + //~^ WARN const parameter `foo` should have an upper case name + //~| SUGGESTION FOO + let _a = FOO + 1; + //~^ SUGGESTION FOO +} + +fn main() { + let _a = crate::MY_STATIC; + //~^ SUGGESTION MY_STATIC + + FOO_FOO.set(9); + //~^ SUGGESTION FOO_FOO + println!("{}", FOO_FOO.get()); + //~^ SUGGESTION FOO_FOO +} diff --git a/tests/ui/lint/lint-non-uppercase-usages.rs b/tests/ui/lint/lint-non-uppercase-usages.rs new file mode 100644 index 00000000000..9cdf5e47003 --- /dev/null +++ b/tests/ui/lint/lint-non-uppercase-usages.rs @@ -0,0 +1,44 @@ +// Checks that the `non_upper_case_globals` emits suggestions for usages as well +// <https://github.com/rust-lang/rust/issues/124061> + +//@ check-pass +//@ run-rustfix + +#![allow(dead_code)] + +use std::cell::Cell; + +const my_static: u32 = 0; +//~^ WARN constant `my_static` should have an upper case name +//~| SUGGESTION MY_STATIC + +const LOL: u32 = my_static + 0; +//~^ SUGGESTION MY_STATIC + +mod my_mod { + const INSIDE_MOD: u32 = super::my_static + 0; + //~^ SUGGESTION MY_STATIC +} + +thread_local! { + static fooFOO: Cell<usize> = unreachable!(); + //~^ WARN constant `fooFOO` should have an upper case name + //~| SUGGESTION FOO_FOO +} + +fn foo<const foo: u32>() { + //~^ WARN const parameter `foo` should have an upper case name + //~| SUGGESTION FOO + let _a = foo + 1; + //~^ SUGGESTION FOO +} + +fn main() { + let _a = crate::my_static; + //~^ SUGGESTION MY_STATIC + + fooFOO.set(9); + //~^ SUGGESTION FOO_FOO + println!("{}", fooFOO.get()); + //~^ SUGGESTION FOO_FOO +} diff --git a/tests/ui/lint/lint-non-uppercase-usages.stderr b/tests/ui/lint/lint-non-uppercase-usages.stderr new file mode 100644 index 00000000000..7c7e573a88e --- /dev/null +++ b/tests/ui/lint/lint-non-uppercase-usages.stderr @@ -0,0 +1,39 @@ +warning: constant `my_static` should have an upper case name + --> $DIR/lint-non-uppercase-usages.rs:11:7 + | +LL | const my_static: u32 = 0; + | ^^^^^^^^^ + | + = note: `#[warn(non_upper_case_globals)]` on by default +help: convert the identifier to upper case + | +LL - const my_static: u32 = 0; +LL + const MY_STATIC: u32 = 0; + | + +warning: constant `fooFOO` should have an upper case name + --> $DIR/lint-non-uppercase-usages.rs:24:12 + | +LL | static fooFOO: Cell<usize> = unreachable!(); + | ^^^^^^ + | +help: convert the identifier to upper case + | +LL - static fooFOO: Cell<usize> = unreachable!(); +LL + static FOO_FOO: Cell<usize> = unreachable!(); + | + +warning: const parameter `foo` should have an upper case name + --> $DIR/lint-non-uppercase-usages.rs:29:14 + | +LL | fn foo<const foo: u32>() { + | ^^^ + | +help: convert the identifier to upper case (notice the capitalization difference) + | +LL - fn foo<const foo: u32>() { +LL + fn foo<const FOO: u32>() { + | + +warning: 3 warnings emitted + diff --git a/tests/ui/lint/lint-unnecessary-parens.fixed b/tests/ui/lint/lint-unnecessary-parens.fixed index a8c8dd1d512..be322a31363 100644 --- a/tests/ui/lint/lint-unnecessary-parens.fixed +++ b/tests/ui/lint/lint-unnecessary-parens.fixed @@ -1,5 +1,6 @@ //@ run-rustfix +#![feature(impl_trait_in_fn_trait_return)] #![deny(unused_parens)] #![allow(while_true)] // for rustfix @@ -16,11 +17,11 @@ fn bar(y: bool) -> X { return X { y }; //~ ERROR unnecessary parentheses around `return` value } -pub fn unused_parens_around_return_type() -> u32 { //~ ERROR unnecessary parentheses around type +pub fn around_return_type() -> u32 { //~ ERROR unnecessary parentheses around type panic!() } -pub fn unused_parens_around_block_return() -> u32 { +pub fn around_block_return() -> u32 { let _foo = { 5 //~ ERROR unnecessary parentheses around block return value }; @@ -31,10 +32,90 @@ pub trait Trait { fn test(&self); } -pub fn passes_unused_parens_lint() -> &'static (dyn Trait) { +pub fn around_multi_bound_ref() -> &'static (dyn Trait + Send) { panic!() } +//~v ERROR unnecessary parentheses around type +pub fn around_single_bound_ref() -> &'static dyn Trait { + panic!() +} + +pub fn around_multi_bound_ptr() -> *const (dyn Trait + Send) { + panic!() +} + +//~v ERROR unnecessary parentheses around type +pub fn around_single_bound_ptr() -> *const dyn Trait { + panic!() +} + +pub fn around_multi_bound_dyn_fn_output() -> &'static dyn FnOnce() -> (impl Send + Sync) { + &|| () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_single_bound_dyn_fn_output() -> &'static dyn FnOnce() -> impl Send { + &|| () +} + +pub fn around_dyn_fn_output_given_more_bounds() -> &'static (dyn FnOnce() -> (impl Send) + Sync) { + &|| () +} + +pub fn around_multi_bound_impl_fn_output() -> impl FnOnce() -> (impl Send + Sync) { + || () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_single_bound_impl_fn_output() -> impl FnOnce() -> impl Send { + || () +} + +pub fn around_impl_fn_output_given_more_bounds() -> impl FnOnce() -> (impl Send) + Sync { + || () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_dyn_bound() -> &'static dyn FnOnce() { + &|| () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_impl_trait_bound() -> impl FnOnce() { + || () +} + +// these parens aren't strictly required but they help disambiguate => no lint +pub fn around_fn_bound_with_explicit_ret_ty() -> impl (Fn() -> ()) + Send { + || () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_fn_bound_with_implicit_ret_ty() -> impl Fn() + Send { + || () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_last_fn_bound_with_explicit_ret_ty() -> impl Send + Fn() -> () { + || () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_regular_bound1() -> &'static (dyn Send + Sync) { + &|| () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_regular_bound2() -> &'static (dyn Send + Sync) { + &|| () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_regular_bound3() -> &'static (dyn Send + ::std::marker::Sync) { + &|| () +} + pub fn parens_with_keyword(e: &[()]) -> i32 { if true {} //~ ERROR unnecessary parentheses around `if` while true {} //~ ERROR unnecessary parentheses around `while` diff --git a/tests/ui/lint/lint-unnecessary-parens.rs b/tests/ui/lint/lint-unnecessary-parens.rs index 02aa78283c7..dccad07311b 100644 --- a/tests/ui/lint/lint-unnecessary-parens.rs +++ b/tests/ui/lint/lint-unnecessary-parens.rs @@ -1,5 +1,6 @@ //@ run-rustfix +#![feature(impl_trait_in_fn_trait_return)] #![deny(unused_parens)] #![allow(while_true)] // for rustfix @@ -16,11 +17,11 @@ fn bar(y: bool) -> X { return (X { y }); //~ ERROR unnecessary parentheses around `return` value } -pub fn unused_parens_around_return_type() -> (u32) { //~ ERROR unnecessary parentheses around type +pub fn around_return_type() -> (u32) { //~ ERROR unnecessary parentheses around type panic!() } -pub fn unused_parens_around_block_return() -> u32 { +pub fn around_block_return() -> u32 { let _foo = { (5) //~ ERROR unnecessary parentheses around block return value }; @@ -31,10 +32,90 @@ pub trait Trait { fn test(&self); } -pub fn passes_unused_parens_lint() -> &'static (dyn Trait) { +pub fn around_multi_bound_ref() -> &'static (dyn Trait + Send) { panic!() } +//~v ERROR unnecessary parentheses around type +pub fn around_single_bound_ref() -> &'static (dyn Trait) { + panic!() +} + +pub fn around_multi_bound_ptr() -> *const (dyn Trait + Send) { + panic!() +} + +//~v ERROR unnecessary parentheses around type +pub fn around_single_bound_ptr() -> *const (dyn Trait) { + panic!() +} + +pub fn around_multi_bound_dyn_fn_output() -> &'static dyn FnOnce() -> (impl Send + Sync) { + &|| () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_single_bound_dyn_fn_output() -> &'static dyn FnOnce() -> (impl Send) { + &|| () +} + +pub fn around_dyn_fn_output_given_more_bounds() -> &'static (dyn FnOnce() -> (impl Send) + Sync) { + &|| () +} + +pub fn around_multi_bound_impl_fn_output() -> impl FnOnce() -> (impl Send + Sync) { + || () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_single_bound_impl_fn_output() -> impl FnOnce() -> (impl Send) { + || () +} + +pub fn around_impl_fn_output_given_more_bounds() -> impl FnOnce() -> (impl Send) + Sync { + || () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_dyn_bound() -> &'static dyn (FnOnce()) { + &|| () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_impl_trait_bound() -> impl (FnOnce()) { + || () +} + +// these parens aren't strictly required but they help disambiguate => no lint +pub fn around_fn_bound_with_explicit_ret_ty() -> impl (Fn() -> ()) + Send { + || () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_fn_bound_with_implicit_ret_ty() -> impl (Fn()) + Send { + || () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_last_fn_bound_with_explicit_ret_ty() -> impl Send + (Fn() -> ()) { + || () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_regular_bound1() -> &'static (dyn (Send) + Sync) { + &|| () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_regular_bound2() -> &'static (dyn Send + (Sync)) { + &|| () +} + +//~v ERROR unnecessary parentheses around type +pub fn around_regular_bound3() -> &'static (dyn Send + (::std::marker::Sync)) { + &|| () +} + pub fn parens_with_keyword(e: &[()]) -> i32 { if(true) {} //~ ERROR unnecessary parentheses around `if` while(true) {} //~ ERROR unnecessary parentheses around `while` diff --git a/tests/ui/lint/lint-unnecessary-parens.stderr b/tests/ui/lint/lint-unnecessary-parens.stderr index f2e5debd6e0..a7fc1e89c6c 100644 --- a/tests/ui/lint/lint-unnecessary-parens.stderr +++ b/tests/ui/lint/lint-unnecessary-parens.stderr @@ -1,11 +1,11 @@ error: unnecessary parentheses around `return` value - --> $DIR/lint-unnecessary-parens.rs:13:12 + --> $DIR/lint-unnecessary-parens.rs:14:12 | LL | return (1); | ^ ^ | note: the lint level is defined here - --> $DIR/lint-unnecessary-parens.rs:3:9 + --> $DIR/lint-unnecessary-parens.rs:4:9 | LL | #![deny(unused_parens)] | ^^^^^^^^^^^^^ @@ -16,7 +16,7 @@ LL + return 1; | error: unnecessary parentheses around `return` value - --> $DIR/lint-unnecessary-parens.rs:16:12 + --> $DIR/lint-unnecessary-parens.rs:17:12 | LL | return (X { y }); | ^ ^ @@ -28,19 +28,19 @@ LL + return X { y }; | error: unnecessary parentheses around type - --> $DIR/lint-unnecessary-parens.rs:19:46 + --> $DIR/lint-unnecessary-parens.rs:20:32 | -LL | pub fn unused_parens_around_return_type() -> (u32) { - | ^ ^ +LL | pub fn around_return_type() -> (u32) { + | ^ ^ | help: remove these parentheses | -LL - pub fn unused_parens_around_return_type() -> (u32) { -LL + pub fn unused_parens_around_return_type() -> u32 { +LL - pub fn around_return_type() -> (u32) { +LL + pub fn around_return_type() -> u32 { | error: unnecessary parentheses around block return value - --> $DIR/lint-unnecessary-parens.rs:25:9 + --> $DIR/lint-unnecessary-parens.rs:26:9 | LL | (5) | ^ ^ @@ -52,7 +52,7 @@ LL + 5 | error: unnecessary parentheses around block return value - --> $DIR/lint-unnecessary-parens.rs:27:5 + --> $DIR/lint-unnecessary-parens.rs:28:5 | LL | (5) | ^ ^ @@ -63,8 +63,140 @@ LL - (5) LL + 5 | +error: unnecessary parentheses around type + --> $DIR/lint-unnecessary-parens.rs:40:46 + | +LL | pub fn around_single_bound_ref() -> &'static (dyn Trait) { + | ^ ^ + | +help: remove these parentheses + | +LL - pub fn around_single_bound_ref() -> &'static (dyn Trait) { +LL + pub fn around_single_bound_ref() -> &'static dyn Trait { + | + +error: unnecessary parentheses around type + --> $DIR/lint-unnecessary-parens.rs:49:44 + | +LL | pub fn around_single_bound_ptr() -> *const (dyn Trait) { + | ^ ^ + | +help: remove these parentheses + | +LL - pub fn around_single_bound_ptr() -> *const (dyn Trait) { +LL + pub fn around_single_bound_ptr() -> *const dyn Trait { + | + +error: unnecessary parentheses around type + --> $DIR/lint-unnecessary-parens.rs:58:72 + | +LL | pub fn around_single_bound_dyn_fn_output() -> &'static dyn FnOnce() -> (impl Send) { + | ^ ^ + | +help: remove these parentheses + | +LL - pub fn around_single_bound_dyn_fn_output() -> &'static dyn FnOnce() -> (impl Send) { +LL + pub fn around_single_bound_dyn_fn_output() -> &'static dyn FnOnce() -> impl Send { + | + +error: unnecessary parentheses around type + --> $DIR/lint-unnecessary-parens.rs:71:65 + | +LL | pub fn around_single_bound_impl_fn_output() -> impl FnOnce() -> (impl Send) { + | ^ ^ + | +help: remove these parentheses + | +LL - pub fn around_single_bound_impl_fn_output() -> impl FnOnce() -> (impl Send) { +LL + pub fn around_single_bound_impl_fn_output() -> impl FnOnce() -> impl Send { + | + +error: unnecessary parentheses around type + --> $DIR/lint-unnecessary-parens.rs:80:43 + | +LL | pub fn around_dyn_bound() -> &'static dyn (FnOnce()) { + | ^ ^ + | +help: remove these parentheses + | +LL - pub fn around_dyn_bound() -> &'static dyn (FnOnce()) { +LL + pub fn around_dyn_bound() -> &'static dyn FnOnce() { + | + +error: unnecessary parentheses around type + --> $DIR/lint-unnecessary-parens.rs:85:42 + | +LL | pub fn around_impl_trait_bound() -> impl (FnOnce()) { + | ^ ^ + | +help: remove these parentheses + | +LL - pub fn around_impl_trait_bound() -> impl (FnOnce()) { +LL + pub fn around_impl_trait_bound() -> impl FnOnce() { + | + +error: unnecessary parentheses around type + --> $DIR/lint-unnecessary-parens.rs:95:55 + | +LL | pub fn around_fn_bound_with_implicit_ret_ty() -> impl (Fn()) + Send { + | ^ ^ + | +help: remove these parentheses + | +LL - pub fn around_fn_bound_with_implicit_ret_ty() -> impl (Fn()) + Send { +LL + pub fn around_fn_bound_with_implicit_ret_ty() -> impl Fn() + Send { + | + +error: unnecessary parentheses around type + --> $DIR/lint-unnecessary-parens.rs:100:67 + | +LL | pub fn around_last_fn_bound_with_explicit_ret_ty() -> impl Send + (Fn() -> ()) { + | ^ ^ + | +help: remove these parentheses + | +LL - pub fn around_last_fn_bound_with_explicit_ret_ty() -> impl Send + (Fn() -> ()) { +LL + pub fn around_last_fn_bound_with_explicit_ret_ty() -> impl Send + Fn() -> () { + | + +error: unnecessary parentheses around type + --> $DIR/lint-unnecessary-parens.rs:105:49 + | +LL | pub fn around_regular_bound1() -> &'static (dyn (Send) + Sync) { + | ^ ^ + | +help: remove these parentheses + | +LL - pub fn around_regular_bound1() -> &'static (dyn (Send) + Sync) { +LL + pub fn around_regular_bound1() -> &'static (dyn Send + Sync) { + | + +error: unnecessary parentheses around type + --> $DIR/lint-unnecessary-parens.rs:110:56 + | +LL | pub fn around_regular_bound2() -> &'static (dyn Send + (Sync)) { + | ^ ^ + | +help: remove these parentheses + | +LL - pub fn around_regular_bound2() -> &'static (dyn Send + (Sync)) { +LL + pub fn around_regular_bound2() -> &'static (dyn Send + Sync) { + | + +error: unnecessary parentheses around type + --> $DIR/lint-unnecessary-parens.rs:115:56 + | +LL | pub fn around_regular_bound3() -> &'static (dyn Send + (::std::marker::Sync)) { + | ^ ^ + | +help: remove these parentheses + | +LL - pub fn around_regular_bound3() -> &'static (dyn Send + (::std::marker::Sync)) { +LL + pub fn around_regular_bound3() -> &'static (dyn Send + ::std::marker::Sync) { + | + error: unnecessary parentheses around `if` condition - --> $DIR/lint-unnecessary-parens.rs:39:7 + --> $DIR/lint-unnecessary-parens.rs:120:7 | LL | if(true) {} | ^ ^ @@ -76,7 +208,7 @@ LL + if true {} | error: unnecessary parentheses around `while` condition - --> $DIR/lint-unnecessary-parens.rs:40:10 + --> $DIR/lint-unnecessary-parens.rs:121:10 | LL | while(true) {} | ^ ^ @@ -88,7 +220,7 @@ LL + while true {} | error: unnecessary parentheses around `for` iterator expression - --> $DIR/lint-unnecessary-parens.rs:41:13 + --> $DIR/lint-unnecessary-parens.rs:122:13 | LL | for _ in(e) {} | ^ ^ @@ -100,7 +232,7 @@ LL + for _ in e {} | error: unnecessary parentheses around `match` scrutinee expression - --> $DIR/lint-unnecessary-parens.rs:42:10 + --> $DIR/lint-unnecessary-parens.rs:123:10 | LL | match(1) { _ => ()} | ^ ^ @@ -112,7 +244,7 @@ LL + match 1 { _ => ()} | error: unnecessary parentheses around `return` value - --> $DIR/lint-unnecessary-parens.rs:43:11 + --> $DIR/lint-unnecessary-parens.rs:124:11 | LL | return(1); | ^ ^ @@ -124,7 +256,7 @@ LL + return 1; | error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:74:31 + --> $DIR/lint-unnecessary-parens.rs:155:31 | LL | pub const CONST_ITEM: usize = (10); | ^ ^ @@ -136,7 +268,7 @@ LL + pub const CONST_ITEM: usize = 10; | error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:75:33 + --> $DIR/lint-unnecessary-parens.rs:156:33 | LL | pub static STATIC_ITEM: usize = (10); | ^ ^ @@ -148,7 +280,7 @@ LL + pub static STATIC_ITEM: usize = 10; | error: unnecessary parentheses around function argument - --> $DIR/lint-unnecessary-parens.rs:79:9 + --> $DIR/lint-unnecessary-parens.rs:160:9 | LL | bar((true)); | ^ ^ @@ -160,7 +292,7 @@ LL + bar(true); | error: unnecessary parentheses around `if` condition - --> $DIR/lint-unnecessary-parens.rs:81:8 + --> $DIR/lint-unnecessary-parens.rs:162:8 | LL | if (true) {} | ^ ^ @@ -172,7 +304,7 @@ LL + if true {} | error: unnecessary parentheses around `while` condition - --> $DIR/lint-unnecessary-parens.rs:82:11 + --> $DIR/lint-unnecessary-parens.rs:163:11 | LL | while (true) {} | ^ ^ @@ -184,7 +316,7 @@ LL + while true {} | error: unnecessary parentheses around `match` scrutinee expression - --> $DIR/lint-unnecessary-parens.rs:83:11 + --> $DIR/lint-unnecessary-parens.rs:164:11 | LL | match (true) { | ^ ^ @@ -196,7 +328,7 @@ LL + match true { | error: unnecessary parentheses around `let` scrutinee expression - --> $DIR/lint-unnecessary-parens.rs:86:16 + --> $DIR/lint-unnecessary-parens.rs:167:16 | LL | if let 1 = (1) {} | ^ ^ @@ -208,7 +340,7 @@ LL + if let 1 = 1 {} | error: unnecessary parentheses around `let` scrutinee expression - --> $DIR/lint-unnecessary-parens.rs:87:19 + --> $DIR/lint-unnecessary-parens.rs:168:19 | LL | while let 1 = (2) {} | ^ ^ @@ -220,7 +352,7 @@ LL + while let 1 = 2 {} | error: unnecessary parentheses around method argument - --> $DIR/lint-unnecessary-parens.rs:103:24 + --> $DIR/lint-unnecessary-parens.rs:184:24 | LL | X { y: false }.foo((true)); | ^ ^ @@ -232,7 +364,7 @@ LL + X { y: false }.foo(true); | error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:105:18 + --> $DIR/lint-unnecessary-parens.rs:186:18 | LL | let mut _a = (0); | ^ ^ @@ -244,7 +376,7 @@ LL + let mut _a = 0; | error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:106:10 + --> $DIR/lint-unnecessary-parens.rs:187:10 | LL | _a = (0); | ^ ^ @@ -256,7 +388,7 @@ LL + _a = 0; | error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:107:11 + --> $DIR/lint-unnecessary-parens.rs:188:11 | LL | _a += (1); | ^ ^ @@ -268,7 +400,7 @@ LL + _a += 1; | error: unnecessary parentheses around pattern - --> $DIR/lint-unnecessary-parens.rs:109:8 + --> $DIR/lint-unnecessary-parens.rs:190:8 | LL | let(mut _a) = 3; | ^ ^ @@ -280,7 +412,7 @@ LL + let mut _a = 3; | error: unnecessary parentheses around pattern - --> $DIR/lint-unnecessary-parens.rs:110:9 + --> $DIR/lint-unnecessary-parens.rs:191:9 | LL | let (mut _a) = 3; | ^ ^ @@ -292,7 +424,7 @@ LL + let mut _a = 3; | error: unnecessary parentheses around pattern - --> $DIR/lint-unnecessary-parens.rs:111:8 + --> $DIR/lint-unnecessary-parens.rs:192:8 | LL | let( mut _a) = 3; | ^^ ^ @@ -304,7 +436,7 @@ LL + let mut _a = 3; | error: unnecessary parentheses around pattern - --> $DIR/lint-unnecessary-parens.rs:113:8 + --> $DIR/lint-unnecessary-parens.rs:194:8 | LL | let(_a) = 3; | ^ ^ @@ -316,7 +448,7 @@ LL + let _a = 3; | error: unnecessary parentheses around pattern - --> $DIR/lint-unnecessary-parens.rs:114:9 + --> $DIR/lint-unnecessary-parens.rs:195:9 | LL | let (_a) = 3; | ^ ^ @@ -328,7 +460,7 @@ LL + let _a = 3; | error: unnecessary parentheses around pattern - --> $DIR/lint-unnecessary-parens.rs:115:8 + --> $DIR/lint-unnecessary-parens.rs:196:8 | LL | let( _a) = 3; | ^^ ^ @@ -340,7 +472,7 @@ LL + let _a = 3; | error: unnecessary parentheses around block return value - --> $DIR/lint-unnecessary-parens.rs:121:9 + --> $DIR/lint-unnecessary-parens.rs:202:9 | LL | (unit!() - One) | ^ ^ @@ -352,7 +484,7 @@ LL + unit!() - One | error: unnecessary parentheses around block return value - --> $DIR/lint-unnecessary-parens.rs:123:9 + --> $DIR/lint-unnecessary-parens.rs:204:9 | LL | (unit![] - One) | ^ ^ @@ -364,7 +496,7 @@ LL + unit![] - One | error: unnecessary parentheses around block return value - --> $DIR/lint-unnecessary-parens.rs:126:9 + --> $DIR/lint-unnecessary-parens.rs:207:9 | LL | (unit! {} - One) | ^ ^ @@ -376,7 +508,7 @@ LL + unit! {} - One | error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:131:14 + --> $DIR/lint-unnecessary-parens.rs:212:14 | LL | let _r = (&x); | ^ ^ @@ -388,7 +520,7 @@ LL + let _r = &x; | error: unnecessary parentheses around assigned value - --> $DIR/lint-unnecessary-parens.rs:132:14 + --> $DIR/lint-unnecessary-parens.rs:213:14 | LL | let _r = (&mut x); | ^ ^ @@ -399,5 +531,5 @@ LL - let _r = (&mut x); LL + let _r = &mut x; | -error: aborting due to 33 previous errors +error: aborting due to 44 previous errors diff --git a/tests/ui/lint/lint_map_unit_fn.stderr b/tests/ui/lint/lint_map_unit_fn.stderr index 91542af0f6d..930ecd30d1d 100644 --- a/tests/ui/lint/lint_map_unit_fn.stderr +++ b/tests/ui/lint/lint_map_unit_fn.stderr @@ -25,19 +25,18 @@ LL + x.iter_mut().for_each(foo); error: `Iterator::map` call that discard the iterator's values --> $DIR/lint_map_unit_fn.rs:11:18 | -LL | x.iter_mut().map(|items| { - | ^ ------- - | | | - | ____________________|___this function returns `()`, which is likely not what you wanted - | | __________________| - | | | -LL | | | -LL | | | items.sort(); -LL | | | }); - | | | -^ after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items - | | |_____|| - | |_______| - | called `Iterator::map` with callable that returns `()` +LL | x.iter_mut().map(|items| { + | ^ ------- + | | | + | ___________________|___this function returns `()`, which is likely not what you wanted + | | __________________| + | || +LL | || +LL | || items.sort(); +LL | || }); + | ||_____-^ after this call to map, the resulting iterator is `impl Iterator<Item = ()>`, which means the only information carried by the iterator is the number of items + | |______| + | called `Iterator::map` with callable that returns `()` | = note: `Iterator::map`, like many of the methods on `Iterator`, gets executed lazily, meaning that its effects won't be visible until it is iterated help: you might have meant to use `Iterator::for_each` diff --git a/tests/ui/missing_debug_impls.rs b/tests/ui/lint/missing-debug-implementations-lint.rs index 3abc0706887..8a93f052f9c 100644 --- a/tests/ui/missing_debug_impls.rs +++ b/tests/ui/lint/missing-debug-implementations-lint.rs @@ -1,3 +1,7 @@ +//! Test the `missing_debug_implementations` lint that warns about public types without Debug. +//! +//! See https://github.com/rust-lang/rust/issues/20855 + //@ compile-flags: --crate-type lib #![deny(missing_debug_implementations)] #![allow(unused)] @@ -10,7 +14,6 @@ pub enum A {} //~ ERROR type does not implement `Debug` pub enum B {} pub enum C {} - impl fmt::Debug for C { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { Ok(()) @@ -23,15 +26,14 @@ pub struct Foo; //~ ERROR type does not implement `Debug` pub struct Bar; pub struct Baz; - impl fmt::Debug for Baz { fn fmt(&self, fmt: &mut fmt::Formatter) -> fmt::Result { Ok(()) } } +// Private types should not trigger the lint struct PrivateStruct; - enum PrivateEnum {} #[derive(Debug)] diff --git a/tests/ui/missing_debug_impls.stderr b/tests/ui/lint/missing-debug-implementations-lint.stderr index 0538f207b44..288ab981034 100644 --- a/tests/ui/missing_debug_impls.stderr +++ b/tests/ui/lint/missing-debug-implementations-lint.stderr @@ -1,17 +1,17 @@ error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation - --> $DIR/missing_debug_impls.rs:7:1 + --> $DIR/missing-debug-implementations-lint.rs:11:1 | LL | pub enum A {} | ^^^^^^^^^^^^^ | note: the lint level is defined here - --> $DIR/missing_debug_impls.rs:2:9 + --> $DIR/missing-debug-implementations-lint.rs:6:9 | LL | #![deny(missing_debug_implementations)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: type does not implement `Debug`; consider adding `#[derive(Debug)]` or a manual implementation - --> $DIR/missing_debug_impls.rs:20:1 + --> $DIR/missing-debug-implementations-lint.rs:23:1 | LL | pub struct Foo; | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/unused/issue-105061-should-lint.rs b/tests/ui/lint/unused/issue-105061-should-lint.rs index 433c2882089..74a0ff83739 100644 --- a/tests/ui/lint/unused/issue-105061-should-lint.rs +++ b/tests/ui/lint/unused/issue-105061-should-lint.rs @@ -14,7 +14,7 @@ where trait Hello<T> {} fn with_dyn_bound<T>() where - (dyn Hello<(for<'b> fn(&'b ()))>): Hello<T> //~ ERROR unnecessary parentheses around type + dyn Hello<(for<'b> fn(&'b ()))>: Hello<T> //~ ERROR unnecessary parentheses around type {} fn main() { diff --git a/tests/ui/lint/unused/issue-105061-should-lint.stderr b/tests/ui/lint/unused/issue-105061-should-lint.stderr index e591f1ffb6b..ae69f018eae 100644 --- a/tests/ui/lint/unused/issue-105061-should-lint.stderr +++ b/tests/ui/lint/unused/issue-105061-should-lint.stderr @@ -17,15 +17,15 @@ LL + for<'b> for<'a> fn(Inv<'a>): Trait<'b>, | error: unnecessary parentheses around type - --> $DIR/issue-105061-should-lint.rs:17:16 + --> $DIR/issue-105061-should-lint.rs:17:15 | -LL | (dyn Hello<(for<'b> fn(&'b ()))>): Hello<T> - | ^ ^ +LL | dyn Hello<(for<'b> fn(&'b ()))>: Hello<T> + | ^ ^ | help: remove these parentheses | -LL - (dyn Hello<(for<'b> fn(&'b ()))>): Hello<T> -LL + (dyn Hello<for<'b> fn(&'b ())>): Hello<T> +LL - dyn Hello<(for<'b> fn(&'b ()))>: Hello<T> +LL + dyn Hello<for<'b> fn(&'b ())>: Hello<T> | error: aborting due to 2 previous errors diff --git a/tests/ui/lint/unused/must-use-macros.fixed b/tests/ui/lint/unused/must-use-macros.fixed new file mode 100644 index 00000000000..609d0c6392b --- /dev/null +++ b/tests/ui/lint/unused/must-use-macros.fixed @@ -0,0 +1,60 @@ +// Makes sure the suggestions of the `unused_must_use` lint are not inside +// +// See <https://github.com/rust-lang/rust/issues/143025> + +//@ check-pass +//@ run-rustfix + +#![expect(unused_macros)] +#![warn(unused_must_use)] + +fn main() { + { + macro_rules! cmp { + ($a:tt, $b:tt) => { + $a == $b + }; + } + + // FIXME(Urgau): For some unknown reason the spans we get are not + // recorded to be from any expansions, preventing us from either + // suggesting in front of the macro or not at all. + // cmp!(1, 1); + } + + { + macro_rules! cmp { + ($a:ident, $b:ident) => { + $a == $b + }; //~^ WARN unused comparison that must be used + } + + let a = 1; + let b = 1; + let _ = cmp!(a, b); + //~^ SUGGESTION let _ + } + + { + macro_rules! cmp { + ($a:expr, $b:expr) => { + $a == $b + }; //~^ WARN unused comparison that must be used + } + + let _ = cmp!(1, 1); + //~^ SUGGESTION let _ + } + + { + macro_rules! cmp { + ($a:tt, $b:tt) => { + $a.eq(&$b) + }; + } + + let _ = cmp!(1, 1); + //~^ WARN unused return value + //~| SUGGESTION let _ + } +} diff --git a/tests/ui/lint/unused/must-use-macros.rs b/tests/ui/lint/unused/must-use-macros.rs new file mode 100644 index 00000000000..63e246ed374 --- /dev/null +++ b/tests/ui/lint/unused/must-use-macros.rs @@ -0,0 +1,60 @@ +// Makes sure the suggestions of the `unused_must_use` lint are not inside +// +// See <https://github.com/rust-lang/rust/issues/143025> + +//@ check-pass +//@ run-rustfix + +#![expect(unused_macros)] +#![warn(unused_must_use)] + +fn main() { + { + macro_rules! cmp { + ($a:tt, $b:tt) => { + $a == $b + }; + } + + // FIXME(Urgau): For some unknown reason the spans we get are not + // recorded to be from any expansions, preventing us from either + // suggesting in front of the macro or not at all. + // cmp!(1, 1); + } + + { + macro_rules! cmp { + ($a:ident, $b:ident) => { + $a == $b + }; //~^ WARN unused comparison that must be used + } + + let a = 1; + let b = 1; + cmp!(a, b); + //~^ SUGGESTION let _ + } + + { + macro_rules! cmp { + ($a:expr, $b:expr) => { + $a == $b + }; //~^ WARN unused comparison that must be used + } + + cmp!(1, 1); + //~^ SUGGESTION let _ + } + + { + macro_rules! cmp { + ($a:tt, $b:tt) => { + $a.eq(&$b) + }; + } + + cmp!(1, 1); + //~^ WARN unused return value + //~| SUGGESTION let _ + } +} diff --git a/tests/ui/lint/unused/must-use-macros.stderr b/tests/ui/lint/unused/must-use-macros.stderr new file mode 100644 index 00000000000..2ad174e10b5 --- /dev/null +++ b/tests/ui/lint/unused/must-use-macros.stderr @@ -0,0 +1,48 @@ +warning: unused comparison that must be used + --> $DIR/must-use-macros.rs:28:17 + | +LL | $a == $b + | ^^^^^^^^ the comparison produces a value +... +LL | cmp!(a, b); + | ---------- in this macro invocation + | +note: the lint level is defined here + --> $DIR/must-use-macros.rs:9:9 + | +LL | #![warn(unused_must_use)] + | ^^^^^^^^^^^^^^^ + = note: this warning originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = cmp!(a, b); + | +++++++ + +warning: unused comparison that must be used + --> $DIR/must-use-macros.rs:41:17 + | +LL | $a == $b + | ^^^^^^^^ the comparison produces a value +... +LL | cmp!(1, 1); + | ---------- in this macro invocation + | + = note: this warning originates in the macro `cmp` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = cmp!(1, 1); + | +++++++ + +warning: unused return value of `std::cmp::PartialEq::eq` that must be used + --> $DIR/must-use-macros.rs:56:9 + | +LL | cmp!(1, 1); + | ^^^^^^^^^^ + | +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = cmp!(1, 1); + | +++++++ + +warning: 3 warnings emitted + diff --git a/tests/ui/lint/unused/unused-attr-duplicate.rs b/tests/ui/lint/unused/unused-attr-duplicate.rs index 407af40654e..bf94a42f6e0 100644 --- a/tests/ui/lint/unused/unused-attr-duplicate.rs +++ b/tests/ui/lint/unused/unused-attr-duplicate.rs @@ -102,4 +102,10 @@ pub fn no_mangle_test() {} #[used] //~ ERROR unused attribute static FOO: u32 = 0; +#[link_section = ".text"] +//~^ ERROR unused attribute +//~| WARN this was previously accepted +#[link_section = ".bss"] +pub extern "C" fn example() {} + fn main() {} diff --git a/tests/ui/lint/unused/unused-attr-duplicate.stderr b/tests/ui/lint/unused/unused-attr-duplicate.stderr index 03ce9757014..2310c12c80b 100644 --- a/tests/ui/lint/unused/unused-attr-duplicate.stderr +++ b/tests/ui/lint/unused/unused-attr-duplicate.stderr @@ -28,31 +28,6 @@ LL | #[macro_use] | ^^^^^^^^^^^^ error: unused attribute - --> $DIR/unused-attr-duplicate.rs:47:1 - | -LL | #[path = "bar.rs"] - | ^^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:46:1 - | -LL | #[path = "auxiliary/lint_unused_extern_crate.rs"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -error: unused attribute - --> $DIR/unused-attr-duplicate.rs:53:1 - | -LL | #[ignore = "some text"] - | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:52:1 - | -LL | #[ignore] - | ^^^^^^^^^ - -error: unused attribute --> $DIR/unused-attr-duplicate.rs:55:1 | LL | #[should_panic(expected = "values don't match")] @@ -66,31 +41,6 @@ LL | #[should_panic] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! error: unused attribute - --> $DIR/unused-attr-duplicate.rs:60:1 - | -LL | #[must_use = "some message"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:59:1 - | -LL | #[must_use] - | ^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -error: unused attribute - --> $DIR/unused-attr-duplicate.rs:66:1 - | -LL | #[non_exhaustive] - | ^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:65:1 - | -LL | #[non_exhaustive] - | ^^^^^^^^^^^^^^^^^ - -error: unused attribute --> $DIR/unused-attr-duplicate.rs:70:1 | LL | #[automatically_derived] @@ -103,68 +53,6 @@ LL | #[automatically_derived] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: unused attribute - --> $DIR/unused-attr-duplicate.rs:79:1 - | -LL | #[track_caller] - | ^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:78:1 - | -LL | #[track_caller] - | ^^^^^^^^^^^^^^^ - -error: unused attribute - --> $DIR/unused-attr-duplicate.rs:92:1 - | -LL | #[export_name = "exported_symbol_name"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:94:1 - | -LL | #[export_name = "exported_symbol_name2"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -error: unused attribute - --> $DIR/unused-attr-duplicate.rs:98:1 - | -LL | #[no_mangle] - | ^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:97:1 - | -LL | #[no_mangle] - | ^^^^^^^^^^^^ - -error: unused attribute - --> $DIR/unused-attr-duplicate.rs:102:1 - | -LL | #[used] - | ^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:101:1 - | -LL | #[used] - | ^^^^^^^ - -error: unused attribute - --> $DIR/unused-attr-duplicate.rs:86:5 - | -LL | #[link_name = "this_does_not_exist"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:88:5 - | -LL | #[link_name = "rust_dbg_extern_identity_u32"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - -error: unused attribute --> $DIR/unused-attr-duplicate.rs:14:1 | LL | #![crate_name = "unused_attr_duplicate2"] @@ -216,18 +104,6 @@ LL | #![no_std] | ^^^^^^^^^^ error: unused attribute - --> $DIR/unused-attr-duplicate.rs:25:1 - | -LL | #![no_implicit_prelude] - | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute - | -note: attribute also specified here - --> $DIR/unused-attr-duplicate.rs:24:1 - | -LL | #![no_implicit_prelude] - | ^^^^^^^^^^^^^^^^^^^^^^^ - -error: unused attribute --> $DIR/unused-attr-duplicate.rs:27:1 | LL | #![windows_subsystem = "windows"] @@ -265,6 +141,56 @@ LL | #[macro_export] | ^^^^^^^^^^^^^^^ error: unused attribute + --> $DIR/unused-attr-duplicate.rs:47:1 + | +LL | #[path = "bar.rs"] + | ^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:46:1 + | +LL | #[path = "auxiliary/lint_unused_extern_crate.rs"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:53:1 + | +LL | #[ignore = "some text"] + | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:52:1 + | +LL | #[ignore] + | ^^^^^^^^^ + +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:60:1 + | +LL | #[must_use = "some message"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:59:1 + | +LL | #[must_use] + | ^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:66:1 + | +LL | #[non_exhaustive] + | ^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:65:1 + | +LL | #[non_exhaustive] + | ^^^^^^^^^^^^^^^^^ + +error: unused attribute --> $DIR/unused-attr-duplicate.rs:74:1 | LL | #[inline(never)] @@ -289,5 +215,92 @@ note: attribute also specified here LL | #[cold] | ^^^^^^^ -error: aborting due to 23 previous errors +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:79:1 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:78:1 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ + +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:86:5 + | +LL | #[link_name = "this_does_not_exist"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:88:5 + | +LL | #[link_name = "rust_dbg_extern_identity_u32"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:92:1 + | +LL | #[export_name = "exported_symbol_name"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:94:1 + | +LL | #[export_name = "exported_symbol_name2"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:98:1 + | +LL | #[no_mangle] + | ^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:97:1 + | +LL | #[no_mangle] + | ^^^^^^^^^^^^ + +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:102:1 + | +LL | #[used] + | ^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:101:1 + | +LL | #[used] + | ^^^^^^^ + +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:105:1 + | +LL | #[link_section = ".text"] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:108:1 + | +LL | #[link_section = ".bss"] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + +error: unused attribute + --> $DIR/unused-attr-duplicate.rs:25:1 + | +LL | #![no_implicit_prelude] + | ^^^^^^^^^^^^^^^^^^^^^^^ help: remove this attribute + | +note: attribute also specified here + --> $DIR/unused-attr-duplicate.rs:24:1 + | +LL | #![no_implicit_prelude] + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 24 previous errors diff --git a/tests/ui/lint/unused/unused-attr-macro-rules.stderr b/tests/ui/lint/unused/unused-attr-macro-rules.stderr index e3ca90d9acd..4698e381425 100644 --- a/tests/ui/lint/unused/unused-attr-macro-rules.stderr +++ b/tests/ui/lint/unused/unused-attr-macro-rules.stderr @@ -10,17 +10,17 @@ note: the lint level is defined here LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -error: `#[path]` only has an effect on modules - --> $DIR/unused-attr-macro-rules.rs:8:1 - | -LL | #[path="foo"] - | ^^^^^^^^^^^^^ - error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` --> $DIR/unused-attr-macro-rules.rs:9:1 | LL | #[recursion_limit="1"] | ^^^^^^^^^^^^^^^^^^^^^^ +error: `#[path]` only has an effect on modules + --> $DIR/unused-attr-macro-rules.rs:8:1 + | +LL | #[path="foo"] + | ^^^^^^^^^^^^^ + error: aborting due to 3 previous errors diff --git a/tests/ui/lint/unused/unused-parens-trait-obj.edition2018.fixed b/tests/ui/lint/unused/unused-parens-trait-obj.edition2018.fixed new file mode 100644 index 00000000000..f95418868e1 --- /dev/null +++ b/tests/ui/lint/unused/unused-parens-trait-obj.edition2018.fixed @@ -0,0 +1,27 @@ +//@ revisions: edition2015 edition2018 +//@[edition2015] check-pass +//@[edition2015] edition: 2015 +//@[edition2018] run-rustfix +//@[edition2018] edition: 2018 + +#![deny(unused_parens)] + +#[allow(unused)] +macro_rules! edition2015_only { + () => { + mod dyn { + pub type IsAContextualKeywordIn2015 = (); + } + + pub type DynIsAContextualKeywordIn2015A = dyn::IsAContextualKeywordIn2015; + } +} + +#[cfg(edition2015)] +edition2015_only!(); + +// there's a lint for 2018 and later only because of how dyn is parsed in edition 2015 +//[edition2018]~v ERROR unnecessary parentheses around type +pub type DynIsAContextualKeywordIn2015B = Box<dyn ::std::ops::Fn()>; + +fn main() {} diff --git a/tests/ui/lint/unused/unused-parens-trait-obj.edition2018.stderr b/tests/ui/lint/unused/unused-parens-trait-obj.edition2018.stderr new file mode 100644 index 00000000000..aed8cec68e8 --- /dev/null +++ b/tests/ui/lint/unused/unused-parens-trait-obj.edition2018.stderr @@ -0,0 +1,19 @@ +error: unnecessary parentheses around type + --> $DIR/unused-parens-trait-obj.rs:25:51 + | +LL | pub type DynIsAContextualKeywordIn2015B = Box<dyn (::std::ops::Fn())>; + | ^ ^ + | +note: the lint level is defined here + --> $DIR/unused-parens-trait-obj.rs:7:9 + | +LL | #![deny(unused_parens)] + | ^^^^^^^^^^^^^ +help: remove these parentheses + | +LL - pub type DynIsAContextualKeywordIn2015B = Box<dyn (::std::ops::Fn())>; +LL + pub type DynIsAContextualKeywordIn2015B = Box<dyn ::std::ops::Fn()>; + | + +error: aborting due to 1 previous error + diff --git a/tests/ui/lint/unused/unused-parens-trait-obj.rs b/tests/ui/lint/unused/unused-parens-trait-obj.rs new file mode 100644 index 00000000000..2192baa2e02 --- /dev/null +++ b/tests/ui/lint/unused/unused-parens-trait-obj.rs @@ -0,0 +1,27 @@ +//@ revisions: edition2015 edition2018 +//@[edition2015] check-pass +//@[edition2015] edition: 2015 +//@[edition2018] run-rustfix +//@[edition2018] edition: 2018 + +#![deny(unused_parens)] + +#[allow(unused)] +macro_rules! edition2015_only { + () => { + mod dyn { + pub type IsAContextualKeywordIn2015 = (); + } + + pub type DynIsAContextualKeywordIn2015A = dyn::IsAContextualKeywordIn2015; + } +} + +#[cfg(edition2015)] +edition2015_only!(); + +// there's a lint for 2018 and later only because of how dyn is parsed in edition 2015 +//[edition2018]~v ERROR unnecessary parentheses around type +pub type DynIsAContextualKeywordIn2015B = Box<dyn (::std::ops::Fn())>; + +fn main() {} diff --git a/tests/ui/log-err-phi.rs b/tests/ui/log-err-phi.rs deleted file mode 100644 index 1bb97758782..00000000000 --- a/tests/ui/log-err-phi.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -pub fn main() { - if false { - println!("{}", "foobar"); - } -} diff --git a/tests/ui/log-knows-the-names-of-variants.rs b/tests/ui/log-knows-the-names-of-variants.rs deleted file mode 100644 index cb82cb4878a..00000000000 --- a/tests/ui/log-knows-the-names-of-variants.rs +++ /dev/null @@ -1,21 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] -#![allow(dead_code)] -#[derive(Debug)] -enum foo { - a(usize), - b(String), - c, -} - -#[derive(Debug)] -enum bar { - d, e, f -} - -pub fn main() { - assert_eq!("a(22)".to_string(), format!("{:?}", foo::a(22))); - assert_eq!("c".to_string(), format!("{:?}", foo::c)); - assert_eq!("d".to_string(), format!("{:?}", bar::d)); -} diff --git a/tests/ui/loop-match/break-to-block.rs b/tests/ui/loop-match/break-to-block.rs new file mode 100644 index 00000000000..e7451a944c3 --- /dev/null +++ b/tests/ui/loop-match/break-to-block.rs @@ -0,0 +1,23 @@ +// Test that a `break` without `#[const_continue]` still works as expected. + +//@ run-pass + +#![allow(incomplete_features)] +#![feature(loop_match)] + +fn main() { + assert_eq!(helper(), 1); +} + +fn helper() -> u8 { + let mut state = 0u8; + #[loop_match] + 'a: loop { + state = 'blk: { + match state { + 0 => break 'blk 1, + _ => break 'a state, + } + } + } +} diff --git a/tests/ui/loop-match/const-continue-to-block.rs b/tests/ui/loop-match/const-continue-to-block.rs new file mode 100644 index 00000000000..fd7ebeefeb6 --- /dev/null +++ b/tests/ui/loop-match/const-continue-to-block.rs @@ -0,0 +1,26 @@ +// Test that a `#[const_continue]` that breaks to a normal labeled block (that +// is not part of a `#[loop_match]`) produces an error. + +#![allow(incomplete_features)] +#![feature(loop_match)] +#![crate_type = "lib"] + +fn const_continue_to_block() -> u8 { + let state = 0; + #[loop_match] + loop { + state = 'blk: { + match state { + 0 => { + #[const_continue] + break 'blk 1; + } + _ => 'b: { + #[const_continue] + break 'b 2; + //~^ ERROR `#[const_continue]` must break to a labeled block that participates in a `#[loop_match]` + } + } + } + } +} diff --git a/tests/ui/loop-match/const-continue-to-block.stderr b/tests/ui/loop-match/const-continue-to-block.stderr new file mode 100644 index 00000000000..3a5339a0394 --- /dev/null +++ b/tests/ui/loop-match/const-continue-to-block.stderr @@ -0,0 +1,8 @@ +error: `#[const_continue]` must break to a labeled block that participates in a `#[loop_match]` + --> $DIR/const-continue-to-block.rs:20:27 + | +LL | break 'b 2; + | ^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/loop-match/const-continue-to-loop.rs b/tests/ui/loop-match/const-continue-to-loop.rs new file mode 100644 index 00000000000..c363e617cfb --- /dev/null +++ b/tests/ui/loop-match/const-continue-to-loop.rs @@ -0,0 +1,27 @@ +// Test that a `#[const_continue]` that breaks to the label of the loop itself +// rather than to the label of the block within the `#[loop_match]` produces an +// error. + +#![allow(incomplete_features)] +#![feature(loop_match)] +#![crate_type = "lib"] + +fn const_continue_to_loop() -> u8 { + let mut state = 0; + #[loop_match] + 'a: loop { + state = 'blk: { + match state { + 0 => { + #[const_continue] + break 'blk 1; + } + _ => { + #[const_continue] + break 'a 2; + //~^ ERROR `#[const_continue]` must break to a labeled block that participates in a `#[loop_match]` + } + } + } + } +} diff --git a/tests/ui/loop-match/const-continue-to-loop.stderr b/tests/ui/loop-match/const-continue-to-loop.stderr new file mode 100644 index 00000000000..a217b3ac72c --- /dev/null +++ b/tests/ui/loop-match/const-continue-to-loop.stderr @@ -0,0 +1,8 @@ +error: `#[const_continue]` must break to a labeled block that participates in a `#[loop_match]` + --> $DIR/const-continue-to-loop.rs:21:27 + | +LL | break 'a 2; + | ^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/loop-match/const-continue-to-polymorphic-const.rs b/tests/ui/loop-match/const-continue-to-polymorphic-const.rs new file mode 100644 index 00000000000..9a91c977911 --- /dev/null +++ b/tests/ui/loop-match/const-continue-to-polymorphic-const.rs @@ -0,0 +1,29 @@ +// Test that a `#[const_continue]` that breaks on a polymorphic constant produces an error. +// A polymorphic constant does not have a concrete value at MIR building time, and therefore the +// `#[loop_match]~ desugaring can't handle such values. +#![allow(incomplete_features)] +#![feature(loop_match)] +#![crate_type = "lib"] + +trait Foo { + const TARGET: u8; + + fn test_u8(mut state: u8) -> &'static str { + #[loop_match] + loop { + state = 'blk: { + match state { + 0 => { + #[const_continue] + break 'blk Self::TARGET; + //~^ ERROR could not determine the target branch for this `#[const_continue]` + } + + 1 => return "bar", + 2 => return "baz", + _ => unreachable!(), + } + } + } + } +} diff --git a/tests/ui/loop-match/const-continue-to-polymorphic-const.stderr b/tests/ui/loop-match/const-continue-to-polymorphic-const.stderr new file mode 100644 index 00000000000..4d183a2fbeb --- /dev/null +++ b/tests/ui/loop-match/const-continue-to-polymorphic-const.stderr @@ -0,0 +1,8 @@ +error: could not determine the target branch for this `#[const_continue]` + --> $DIR/const-continue-to-polymorphic-const.rs:18:36 + | +LL | break 'blk Self::TARGET; + | ^^^^^^^^^^^^ this value is too generic + +error: aborting due to 1 previous error + diff --git a/tests/ui/loop-match/drop-in-match-arm.rs b/tests/ui/loop-match/drop-in-match-arm.rs new file mode 100644 index 00000000000..731af659012 --- /dev/null +++ b/tests/ui/loop-match/drop-in-match-arm.rs @@ -0,0 +1,47 @@ +// Test that dropping values works in match arms, which is nontrivial +// because each match arm needs its own scope. + +//@ run-pass + +#![allow(incomplete_features)] +#![feature(loop_match)] + +use std::sync::atomic::{AtomicBool, Ordering}; + +fn main() { + assert_eq!(helper(), 1); + assert!(DROPPED.load(Ordering::Relaxed)); +} + +static DROPPED: AtomicBool = AtomicBool::new(false); + +struct X; + +impl Drop for X { + fn drop(&mut self) { + DROPPED.store(true, Ordering::Relaxed); + } +} + +#[no_mangle] +#[inline(never)] +fn helper() -> i32 { + let mut state = 0; + #[loop_match] + 'a: loop { + state = 'blk: { + match state { + 0 => match X { + _ => { + assert!(!DROPPED.load(Ordering::Relaxed)); + break 'blk 1; + } + }, + _ => { + assert!(DROPPED.load(Ordering::Relaxed)); + break 'a state; + } + } + }; + } +} diff --git a/tests/ui/loop-match/invalid-attribute.rs b/tests/ui/loop-match/invalid-attribute.rs new file mode 100644 index 00000000000..d8d2f605eb4 --- /dev/null +++ b/tests/ui/loop-match/invalid-attribute.rs @@ -0,0 +1,43 @@ +// Test that the `#[loop_match]` and `#[const_continue]` attributes can only be +// placed on expressions. + +#![allow(incomplete_features)] +#![feature(loop_match)] +#![loop_match] //~ ERROR should be applied to a loop +#![const_continue] //~ ERROR should be applied to a break expression + +extern "C" { + #[loop_match] //~ ERROR should be applied to a loop + #[const_continue] //~ ERROR should be applied to a break expression + fn f(); +} + +#[loop_match] //~ ERROR should be applied to a loop +#[const_continue] //~ ERROR should be applied to a break expression +#[repr(C)] +struct S { + a: u32, + b: u32, +} + +trait Invoke { + #[loop_match] //~ ERROR should be applied to a loop + #[const_continue] //~ ERROR should be applied to a break expression + extern "C" fn invoke(&self); +} + +#[loop_match] //~ ERROR should be applied to a loop +#[const_continue] //~ ERROR should be applied to a break expression +extern "C" fn ok() {} + +fn main() { + #[loop_match] //~ ERROR should be applied to a loop + #[const_continue] //~ ERROR should be applied to a break expression + || {}; + + { + #[loop_match] //~ ERROR should be applied to a loop + #[const_continue] //~ ERROR should be applied to a break expression + 5 + }; +} diff --git a/tests/ui/loop-match/invalid-attribute.stderr b/tests/ui/loop-match/invalid-attribute.stderr new file mode 100644 index 00000000000..07015311f9c --- /dev/null +++ b/tests/ui/loop-match/invalid-attribute.stderr @@ -0,0 +1,131 @@ +error: `#[const_continue]` should be applied to a break expression + --> $DIR/invalid-attribute.rs:16:1 + | +LL | #[const_continue] + | ^^^^^^^^^^^^^^^^^ +LL | #[repr(C)] +LL | struct S { + | -------- not a break expression + +error: `#[loop_match]` should be applied to a loop + --> $DIR/invalid-attribute.rs:15:1 + | +LL | #[loop_match] + | ^^^^^^^^^^^^^ +... +LL | struct S { + | -------- not a loop + +error: `#[const_continue]` should be applied to a break expression + --> $DIR/invalid-attribute.rs:30:1 + | +LL | #[const_continue] + | ^^^^^^^^^^^^^^^^^ +LL | extern "C" fn ok() {} + | ------------------ not a break expression + +error: `#[loop_match]` should be applied to a loop + --> $DIR/invalid-attribute.rs:29:1 + | +LL | #[loop_match] + | ^^^^^^^^^^^^^ +LL | #[const_continue] +LL | extern "C" fn ok() {} + | ------------------ not a loop + +error: `#[const_continue]` should be applied to a break expression + --> $DIR/invalid-attribute.rs:35:5 + | +LL | #[const_continue] + | ^^^^^^^^^^^^^^^^^ +LL | || {}; + | -- not a break expression + +error: `#[loop_match]` should be applied to a loop + --> $DIR/invalid-attribute.rs:34:5 + | +LL | #[loop_match] + | ^^^^^^^^^^^^^ +LL | #[const_continue] +LL | || {}; + | -- not a loop + +error: `#[const_continue]` should be applied to a break expression + --> $DIR/invalid-attribute.rs:40:9 + | +LL | #[const_continue] + | ^^^^^^^^^^^^^^^^^ +LL | 5 + | - not a break expression + +error: `#[loop_match]` should be applied to a loop + --> $DIR/invalid-attribute.rs:39:9 + | +LL | #[loop_match] + | ^^^^^^^^^^^^^ +LL | #[const_continue] +LL | 5 + | - not a loop + +error: `#[const_continue]` should be applied to a break expression + --> $DIR/invalid-attribute.rs:25:5 + | +LL | #[const_continue] + | ^^^^^^^^^^^^^^^^^ +LL | extern "C" fn invoke(&self); + | ---------------------------- not a break expression + +error: `#[loop_match]` should be applied to a loop + --> $DIR/invalid-attribute.rs:24:5 + | +LL | #[loop_match] + | ^^^^^^^^^^^^^ +LL | #[const_continue] +LL | extern "C" fn invoke(&self); + | ---------------------------- not a loop + +error: `#[const_continue]` should be applied to a break expression + --> $DIR/invalid-attribute.rs:11:5 + | +LL | #[const_continue] + | ^^^^^^^^^^^^^^^^^ +LL | fn f(); + | ------- not a break expression + +error: `#[loop_match]` should be applied to a loop + --> $DIR/invalid-attribute.rs:10:5 + | +LL | #[loop_match] + | ^^^^^^^^^^^^^ +LL | #[const_continue] +LL | fn f(); + | ------- not a loop + +error: `#[const_continue]` should be applied to a break expression + --> $DIR/invalid-attribute.rs:7:1 + | +LL | / #![allow(incomplete_features)] +LL | | #![feature(loop_match)] +LL | | #![loop_match] +LL | | #![const_continue] + | | ^^^^^^^^^^^^^^^^^^ +... | +LL | | }; +LL | | } + | |_- not a break expression + +error: `#[loop_match]` should be applied to a loop + --> $DIR/invalid-attribute.rs:6:1 + | +LL | / #![allow(incomplete_features)] +LL | | #![feature(loop_match)] +LL | | #![loop_match] + | | ^^^^^^^^^^^^^^ +LL | | #![const_continue] +... | +LL | | }; +LL | | } + | |_- not a loop + +error: aborting due to 14 previous errors + diff --git a/tests/ui/loop-match/invalid.rs b/tests/ui/loop-match/invalid.rs new file mode 100644 index 00000000000..0c47b1e0057 --- /dev/null +++ b/tests/ui/loop-match/invalid.rs @@ -0,0 +1,192 @@ +// Test that the correct error is emitted when `#[loop_match]` is applied to +// syntax it does not support. +#![allow(incomplete_features)] +#![feature(loop_match)] +#![crate_type = "lib"] + +enum State { + A, + B, + C, +} + +fn invalid_update() { + let mut fake = State::A; + let state = State::A; + #[loop_match] + loop { + fake = 'blk: { + //~^ ERROR invalid update of the `#[loop_match]` state + match state { + _ => State::B, + } + } + } +} + +fn invalid_scrutinee() { + let mut state = State::A; + #[loop_match] + loop { + state = 'blk: { + match State::A { + //~^ ERROR invalid match on `#[loop_match]` state + _ => State::B, + } + } + } +} + +fn bad_statements_1() { + let mut state = State::A; + #[loop_match] + loop { + 1; + //~^ ERROR statements are not allowed in this position within a `#[loop_match]` + state = 'blk: { + match State::A { + _ => State::B, + } + } + } +} + +fn bad_statements_2() { + let mut state = State::A; + #[loop_match] + loop { + state = 'blk: { + 1; + //~^ ERROR statements are not allowed in this position within a `#[loop_match]` + match State::A { + _ => State::B, + } + } + } +} + +fn bad_rhs_1() { + let mut state = State::A; + #[loop_match] + loop { + state = State::B + //~^ ERROR this expression must be a single `match` wrapped in a labeled block + } +} + +fn bad_rhs_2() { + let mut state = State::A; + #[loop_match] + loop { + state = 'blk: { + State::B + //~^ ERROR this expression must be a single `match` wrapped in a labeled block + } + } +} + +fn bad_rhs_3() { + let mut state = (); + #[loop_match] + loop { + state = 'blk: { + //~^ ERROR this expression must be a single `match` wrapped in a labeled block + } + } +} + +fn missing_assignment() { + #[loop_match] + loop { + () //~ ERROR expected a single assignment expression + } +} + +fn empty_loop_body() { + #[loop_match] + loop { + //~^ ERROR expected a single assignment expression + } +} + +fn break_without_value() { + let mut state = State::A; + #[loop_match] + 'a: loop { + state = 'blk: { + match state { + State::A => { + #[const_continue] + break 'blk; + //~^ ERROR mismatched types + } + _ => break 'a, + } + } + } +} + +fn break_without_value_unit() { + let mut state = (); + #[loop_match] + 'a: loop { + state = 'blk: { + match state { + () => { + #[const_continue] + break 'blk; + //~^ ERROR a `#[const_continue]` must break to a label with a value + } + } + } + } +} + +fn arm_has_guard(cond: bool) { + let mut state = State::A; + #[loop_match] + 'a: loop { + state = 'blk: { + match state { + State::A => { + #[const_continue] + break 'blk State::B; + } + State::B if cond => break 'a, + //~^ ERROR match arms that are part of a `#[loop_match]` cannot have guards + _ => break 'a, + } + } + } +} + +fn non_exhaustive() { + let mut state = State::A; + #[loop_match] + loop { + state = 'blk: { + match state { + //~^ ERROR non-exhaustive patterns: `State::B` and `State::C` not covered + State::A => State::B, + } + } + } +} + +fn invalid_range_pattern(state: f32) { + #[loop_match] + loop { + state = 'blk: { + match state { + 1.0 => { + #[const_continue] + break 'blk 2.5; + } + 4.0..3.0 => { + //~^ ERROR lower range bound must be less than upper + todo!() + } + } + } + } +} diff --git a/tests/ui/loop-match/invalid.stderr b/tests/ui/loop-match/invalid.stderr new file mode 100644 index 00000000000..70f246caa9c --- /dev/null +++ b/tests/ui/loop-match/invalid.stderr @@ -0,0 +1,121 @@ +error[E0308]: mismatched types + --> $DIR/invalid.rs:120:21 + | +LL | break 'blk; + | ^^^^^^^^^^ expected `State`, found `()` + | +help: give the `break` a value of the expected type + | +LL | break 'blk /* value */; + | +++++++++++ + +error: invalid update of the `#[loop_match]` state + --> $DIR/invalid.rs:18:9 + | +LL | fake = 'blk: { + | ^^^^ +LL | +LL | match state { + | ----- the assignment must update this variable + +error: invalid match on `#[loop_match]` state + --> $DIR/invalid.rs:32:19 + | +LL | match State::A { + | ^^^^^^^^ + | + = note: a local variable must be the scrutinee within a `#[loop_match]` + +error: statements are not allowed in this position within a `#[loop_match]` + --> $DIR/invalid.rs:44:9 + | +LL | 1; + | ^^ + +error: statements are not allowed in this position within a `#[loop_match]` + --> $DIR/invalid.rs:59:13 + | +LL | 1; + | ^^ + +error: this expression must be a single `match` wrapped in a labeled block + --> $DIR/invalid.rs:72:17 + | +LL | state = State::B + | ^^^^^^^^ + +error: this expression must be a single `match` wrapped in a labeled block + --> $DIR/invalid.rs:82:13 + | +LL | State::B + | ^^^^^^^^ + +error: this expression must be a single `match` wrapped in a labeled block + --> $DIR/invalid.rs:92:17 + | +LL | state = 'blk: { + | _________________^ +LL | | +LL | | } + | |_________^ + +error: expected a single assignment expression + --> $DIR/invalid.rs:101:9 + | +LL | () + | ^^ + +error: expected a single assignment expression + --> $DIR/invalid.rs:107:10 + | +LL | loop { + | __________^ +LL | | +LL | | } + | |_____^ + +error: a `#[const_continue]` must break to a label with a value + --> $DIR/invalid.rs:137:21 + | +LL | break 'blk; + | ^^^^^^^^^^ + +error: match arms that are part of a `#[loop_match]` cannot have guards + --> $DIR/invalid.rs:155:29 + | +LL | State::B if cond => break 'a, + | ^^^^ + +error[E0004]: non-exhaustive patterns: `State::B` and `State::C` not covered + --> $DIR/invalid.rs:168:19 + | +LL | match state { + | ^^^^^ patterns `State::B` and `State::C` not covered + | +note: `State` defined here + --> $DIR/invalid.rs:7:6 + | +LL | enum State { + | ^^^^^ +LL | A, +LL | B, + | - not covered +LL | C, + | - not covered + = note: the matched value is of type `State` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern, a match arm with multiple or-patterns as shown, or multiple match arms + | +LL ~ State::A => State::B, +LL ~ State::B | State::C => todo!(), + | + +error[E0579]: lower range bound must be less than upper + --> $DIR/invalid.rs:185:17 + | +LL | 4.0..3.0 => { + | ^^^^^^^^ + +error: aborting due to 14 previous errors + +Some errors have detailed explanations: E0004, E0308, E0579. +For more information about an error, try `rustc --explain E0004`. diff --git a/tests/ui/loop-match/loop-match.rs b/tests/ui/loop-match/loop-match.rs new file mode 100644 index 00000000000..f38bc01f333 --- /dev/null +++ b/tests/ui/loop-match/loop-match.rs @@ -0,0 +1,45 @@ +// Test that a basic correct example of `#[loop_match]` with `#[const_continue]` +// works correctly. + +//@ run-pass + +#![allow(incomplete_features)] +#![feature(loop_match)] + +enum State { + A, + B, + C, +} + +fn main() { + let mut state = State::A; + #[loop_match] + 'a: loop { + state = 'blk: { + match state { + State::A => { + #[const_continue] + break 'blk State::B; + } + State::B => { + // Without special logic, the compiler believes this is a + // reassignment to an immutable variable because of the + // `loop`. So this tests that local variables work. + let _a = 0; + + if true { + #[const_continue] + break 'blk State::C; + } else { + #[const_continue] + break 'blk State::A; + } + } + State::C => break 'a, + } + }; + } + + assert!(matches!(state, State::C)) +} diff --git a/tests/ui/loop-match/macro.rs b/tests/ui/loop-match/macro.rs new file mode 100644 index 00000000000..98c98b9b627 --- /dev/null +++ b/tests/ui/loop-match/macro.rs @@ -0,0 +1,48 @@ +// Test that macros can be defined in the labeled block. This should not trigger an error about +// statements not being allowed in that position, and should of course work as expected. + +//@ run-pass + +#![allow(incomplete_features)] +#![feature(loop_match)] + +enum State { + A, + B, + C, +} + +fn main() { + let mut state = State::A; + #[loop_match] + 'a: loop { + state = 'blk: { + macro_rules! const_continue { + ($e:expr) => { + #[const_continue] + break 'blk $e; + }; + } + match state { + State::A => { + const_continue!(State::B); + } + State::B => { + // Without special logic, the compiler believes this is a + // reassignment to an immutable variable because of the + // `loop`. So this tests that local variables work. + let _a = 0; + + if true { + const_continue!(State::C); + } else { + const_continue!(State::A); + } + } + State::C => break 'a, + } + }; + } + + assert!(matches!(state, State::C)) +} diff --git a/tests/ui/loop-match/nested.rs b/tests/ui/loop-match/nested.rs new file mode 100644 index 00000000000..aaddfae11de --- /dev/null +++ b/tests/ui/loop-match/nested.rs @@ -0,0 +1,83 @@ +// Test that a nested `#[loop_match]` works as expected, and that e.g. a +// `#[const_continue]` of the inner `#[loop_match]` does not interact with the +// outer `#[loop_match]`. + +//@ run-pass + +#![allow(incomplete_features)] +#![feature(loop_match)] + +enum State1 { + A, + B, + C, +} + +enum State2 { + X, + Y, + Z, +} + +fn main() { + assert_eq!(run(), concat!("ab", "xyz", "xyz", "c")) +} + +fn run() -> String { + let mut accum = String::new(); + + let mut state1 = State1::A; + let mut state2 = State2::X; + + let mut first = true; + + #[loop_match] + 'a: loop { + state1 = 'blk1: { + match state1 { + State1::A => { + accum.push('a'); + #[const_continue] + break 'blk1 State1::B; + } + State1::B => { + accum.push('b'); + #[loop_match] + loop { + state2 = 'blk2: { + match state2 { + State2::X => { + accum.push('x'); + #[const_continue] + break 'blk2 State2::Y; + } + State2::Y => { + accum.push('y'); + #[const_continue] + break 'blk2 State2::Z; + } + State2::Z => { + accum.push('z'); + if first { + first = false; + #[const_continue] + break 'blk2 State2::X; + } else { + #[const_continue] + break 'blk1 State1::C; + } + } + } + } + } + } + State1::C => { + accum.push('c'); + break 'a; + } + } + } + } + + accum +} diff --git a/tests/ui/loop-match/or-patterns.rs b/tests/ui/loop-match/or-patterns.rs new file mode 100644 index 00000000000..775243b9c62 --- /dev/null +++ b/tests/ui/loop-match/or-patterns.rs @@ -0,0 +1,54 @@ +// Test that `#[loop_match]` supports or-patterns. + +//@ run-pass + +#![allow(incomplete_features)] +#![feature(loop_match)] + +#[derive(Debug, Clone, Copy, PartialEq, Eq)] +enum State { + A, + B, + C, + D, +} + +fn main() { + let mut states = vec![]; + let mut first = true; + let mut state = State::A; + #[loop_match] + 'a: loop { + state = 'blk: { + match state { + State::A => { + states.push(state); + if first { + #[const_continue] + break 'blk State::B; + } else { + #[const_continue] + break 'blk State::D; + } + } + State::B | State::D => { + states.push(state); + if first { + first = false; + #[const_continue] + break 'blk State::A; + } else { + #[const_continue] + break 'blk State::C; + } + } + State::C => { + states.push(state); + break 'a; + } + } + } + } + + assert_eq!(states, [State::A, State::B, State::A, State::D, State::C]); +} diff --git a/tests/ui/loop-match/panic-in-const.rs b/tests/ui/loop-match/panic-in-const.rs new file mode 100644 index 00000000000..2ae67445496 --- /dev/null +++ b/tests/ui/loop-match/panic-in-const.rs @@ -0,0 +1,22 @@ +#![allow(incomplete_features)] +#![feature(loop_match)] +#![crate_type = "lib"] + +const CONST_THAT_PANICS: u8 = panic!("diverge!"); +//~^ ERROR: evaluation panicked: diverge! + +fn test(mut state: u8) { + #[loop_match] + loop { + state = 'blk: { + match state { + 0 => { + #[const_continue] + break 'blk CONST_THAT_PANICS; + } + + _ => unreachable!(), + } + } + } +} diff --git a/tests/ui/loop-match/panic-in-const.stderr b/tests/ui/loop-match/panic-in-const.stderr new file mode 100644 index 00000000000..b6ed3177883 --- /dev/null +++ b/tests/ui/loop-match/panic-in-const.stderr @@ -0,0 +1,9 @@ +error[E0080]: evaluation panicked: diverge! + --> $DIR/panic-in-const.rs:5:31 + | +LL | const CONST_THAT_PANICS: u8 = panic!("diverge!"); + | ^^^^^^^^^^^^^^^^^^ evaluation of `CONST_THAT_PANICS` failed here + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/loop-match/unsupported-type.rs b/tests/ui/loop-match/unsupported-type.rs new file mode 100644 index 00000000000..9100a1103ab --- /dev/null +++ b/tests/ui/loop-match/unsupported-type.rs @@ -0,0 +1,27 @@ +// Test that the right error is emitted when the `#[loop_match]` state is an +// unsupported type. + +#![allow(incomplete_features)] +#![feature(loop_match)] +#![crate_type = "lib"] + +fn unsupported_type() { + let mut state = Some(false); + #[loop_match] + 'a: loop { + state = 'blk: { + //~^ ERROR this `#[loop_match]` state value has type `Option<bool>`, which is not supported + match state { + Some(false) => { + #[const_continue] + break 'blk Some(true); + } + Some(true) => { + #[const_continue] + break 'blk None; + } + None => break 'a, + } + } + } +} diff --git a/tests/ui/loop-match/unsupported-type.stderr b/tests/ui/loop-match/unsupported-type.stderr new file mode 100644 index 00000000000..ede3d86796f --- /dev/null +++ b/tests/ui/loop-match/unsupported-type.stderr @@ -0,0 +1,10 @@ +error: this `#[loop_match]` state value has type `Option<bool>`, which is not supported + --> $DIR/unsupported-type.rs:12:9 + | +LL | state = 'blk: { + | ^^^^^ + | + = note: only integers, floats, bool, char, and enums without fields are supported + +error: aborting due to 1 previous error + diff --git a/tests/ui/loop-match/unwind.rs b/tests/ui/loop-match/unwind.rs new file mode 100644 index 00000000000..39e2e4537b1 --- /dev/null +++ b/tests/ui/loop-match/unwind.rs @@ -0,0 +1,53 @@ +// Test that `#[const_continue]` correctly emits cleanup paths for drops. +// +// Here, we first drop `DropBomb`, causing an unwind. Then `ExitOnDrop` should +// be dropped, causing us to exit with `0` rather than with some non-zero value +// due to the panic, which is what causes the test to pass. + +//@ run-pass +//@ needs-unwind + +#![allow(incomplete_features)] +#![feature(loop_match)] + +enum State { + A, + B, +} + +struct ExitOnDrop; + +impl Drop for ExitOnDrop { + fn drop(&mut self) { + std::process::exit(0); + } +} + +struct DropBomb; + +impl Drop for DropBomb { + fn drop(&mut self) { + panic!("this must unwind"); + } +} + +fn main() { + let mut state = State::A; + #[loop_match] + 'a: loop { + state = 'blk: { + match state { + State::A => { + let _exit = ExitOnDrop; + let _bomb = DropBomb; + + #[const_continue] + break 'blk State::B; + } + State::B => break 'a, + } + }; + } + + unreachable!(); +} diff --git a/tests/ui/loop-match/valid-patterns.rs b/tests/ui/loop-match/valid-patterns.rs new file mode 100644 index 00000000000..4e0e4798a0b --- /dev/null +++ b/tests/ui/loop-match/valid-patterns.rs @@ -0,0 +1,117 @@ +// Test that signed and unsigned integer patterns work with `#[loop_match]`. + +//@ run-pass + +#![allow(incomplete_features)] +#![feature(loop_match)] + +fn main() { + assert_eq!(integer(0), 2); + assert_eq!(integer(-1), 2); + assert_eq!(integer(2), 2); + + assert_eq!(boolean(true), false); + assert_eq!(boolean(false), false); + + assert_eq!(character('a'), 'b'); + assert_eq!(character('b'), 'b'); + assert_eq!(character('c'), 'd'); + assert_eq!(character('d'), 'd'); + + assert_eq!(test_f32(1.0), core::f32::consts::PI); + assert_eq!(test_f32(2.5), core::f32::consts::PI); + assert_eq!(test_f32(4.0), 4.0); + + assert_eq!(test_f64(1.0), core::f64::consts::PI); + assert_eq!(test_f64(2.5), core::f64::consts::PI); + assert_eq!(test_f64(4.0), 4.0); +} + +fn integer(mut state: i32) -> i32 { + #[loop_match] + 'a: loop { + state = 'blk: { + match state { + -1 => { + #[const_continue] + break 'blk 2; + } + 0 => { + #[const_continue] + break 'blk -1; + } + 2 => break 'a, + _ => unreachable!("weird value {:?}", state), + } + } + } + + state +} + +fn boolean(mut state: bool) -> bool { + #[loop_match] + loop { + state = 'blk: { + match state { + true => { + #[const_continue] + break 'blk false; + } + false => return state, + } + } + } +} + +fn character(mut state: char) -> char { + #[loop_match] + loop { + state = 'blk: { + match state { + 'a' => { + #[const_continue] + break 'blk 'b'; + } + 'b' => return state, + 'c' => { + #[const_continue] + break 'blk 'd'; + } + _ => return state, + } + } + } +} + +fn test_f32(mut state: f32) -> f32 { + #[loop_match] + loop { + state = 'blk: { + match state { + 1.0 => { + #[const_continue] + break 'blk 2.5; + } + 2.0..3.0 => return core::f32::consts::PI, + _ => return state, + } + } + } +} + +fn test_f64(mut state: f64) -> f64 { + #[loop_match] + loop { + state = 'blk: { + match state { + 1.0 => { + #[const_continue] + break 'blk 2.5; + } + 2.0..3.0 => return core::f64::consts::PI, + _ => return state, + } + } + } +} diff --git a/tests/ui/loud_ui.rs b/tests/ui/loud_ui.rs deleted file mode 100644 index 2a73e49e172..00000000000 --- a/tests/ui/loud_ui.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ should-fail - -// this test ensures that when we forget to use -// any `//~ ERROR` comments whatsoever, that the test doesn't succeed - -fn main() {} diff --git a/tests/ui/lowering/issue-121108.stderr b/tests/ui/lowering/issue-121108.stderr index e4942e8cb07..f68655a7002 100644 --- a/tests/ui/lowering/issue-121108.stderr +++ b/tests/ui/lowering/issue-121108.stderr @@ -5,7 +5,7 @@ LL | #![derive(Clone, Copy)] | ^^^^^^^^^^^^^^^^^^^^^^^ LL | LL | use std::ptr::addr_of; - | ------- the inner attribute doesn't annotate this `use` import + | ------- the inner attribute doesn't annotate this import | help: perhaps you meant to use an outer attribute | diff --git a/tests/ui/macros/issue-118048.rs b/tests/ui/macros/issue-118048.rs index 15a834fa2df..3b3ab3b4fc9 100644 --- a/tests/ui/macros/issue-118048.rs +++ b/tests/ui/macros/issue-118048.rs @@ -6,5 +6,6 @@ macro_rules! foo { foo!(_); //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions +//~| ERROR the placeholder `_` is not allowed within types on item signatures for functions fn main() {} diff --git a/tests/ui/macros/issue-118048.stderr b/tests/ui/macros/issue-118048.stderr index 4dc5ef71fec..f5468b341bc 100644 --- a/tests/ui/macros/issue-118048.stderr +++ b/tests/ui/macros/issue-118048.stderr @@ -2,20 +2,16 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/issue-118048.rs:7:6 | LL | foo!(_); - | ^ - | | - | not allowed in type signatures - | not allowed in type signatures - | -help: use type parameters instead + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/issue-118048.rs:7:6 | -LL ~ fn foo<T>(_: $ty, _: $ty) {} -LL | } -LL | } -LL | -LL ~ foo!(T); +LL | foo!(_); + | ^ not allowed in type signatures | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/macros/macro-comma-support-rpass.rs b/tests/ui/macros/macro-comma-support-rpass.rs index 5a4bac70b1c..ef6c1ff6fd0 100644 --- a/tests/ui/macros/macro-comma-support-rpass.rs +++ b/tests/ui/macros/macro-comma-support-rpass.rs @@ -15,7 +15,6 @@ #![cfg_attr(core, no_std)] #![allow(deprecated)] // for deprecated `try!()` macro -#![feature(concat_idents)] #[cfg(std)] use std::fmt; #[cfg(core)] use core::fmt; @@ -80,17 +79,6 @@ fn concat() { } #[test] -fn concat_idents() { - fn foo() {} - fn foobar() {} - - concat_idents!(foo)(); - concat_idents!(foo,)(); - concat_idents!(foo, bar)(); - concat_idents!(foo, bar,)(); -} - -#[test] fn debug_assert() { debug_assert!(true); debug_assert!(true, ); diff --git a/tests/ui/macros/macro-match-nonterminal.rs b/tests/ui/macros/macro-match-nonterminal.rs index fa2af945a1f..1643cddb192 100644 --- a/tests/ui/macros/macro-match-nonterminal.rs +++ b/tests/ui/macros/macro-match-nonterminal.rs @@ -2,11 +2,10 @@ macro_rules! test { ($a, $b) => { //~^ ERROR missing fragment //~| ERROR missing fragment - //~| ERROR missing fragment () }; } fn main() { - test!() + test!() //~ ERROR unexpected end of macro invocation } diff --git a/tests/ui/macros/macro-match-nonterminal.stderr b/tests/ui/macros/macro-match-nonterminal.stderr index 8196d795c4c..a92d099ca00 100644 --- a/tests/ui/macros/macro-match-nonterminal.stderr +++ b/tests/ui/macros/macro-match-nonterminal.stderr @@ -24,7 +24,16 @@ help: try adding a specifier here LL | ($a, $b:spec) => { | +++++ -error: missing fragment specifier +error: unexpected end of macro invocation + --> $DIR/macro-match-nonterminal.rs:10:5 + | +LL | macro_rules! test { + | ----------------- when calling this macro +... +LL | test!() + | ^^^^^^^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$a:tt` --> $DIR/macro-match-nonterminal.rs:2:6 | LL | ($a, $b) => { diff --git a/tests/ui/macros/macro-metavar-expr-concat/empty-input.rs b/tests/ui/macros/macro-metavar-expr-concat/empty-input.rs new file mode 100644 index 00000000000..caad63c5f6b --- /dev/null +++ b/tests/ui/macros/macro-metavar-expr-concat/empty-input.rs @@ -0,0 +1,12 @@ +// Issue 50403 +// Ensure that `concat` can't create empty identifiers +// FIXME(macro_metavar_expr_concat): this error message could be improved + +macro_rules! empty { + () => { ${concat()} } //~ ERROR expected identifier or string literal + //~^ERROR expected expression +} + +fn main() { + let x = empty!(); +} diff --git a/tests/ui/macros/macro-metavar-expr-concat/empty-input.stderr b/tests/ui/macros/macro-metavar-expr-concat/empty-input.stderr new file mode 100644 index 00000000000..e95032dd247 --- /dev/null +++ b/tests/ui/macros/macro-metavar-expr-concat/empty-input.stderr @@ -0,0 +1,19 @@ +error: expected identifier or string literal + --> $DIR/empty-input.rs:6:14 + | +LL | () => { ${concat()} } + | ^^^^^^^^^^ + +error: expected expression, found `$` + --> $DIR/empty-input.rs:6:13 + | +LL | () => { ${concat()} } + | ^ expected expression +... +LL | let x = empty!(); + | -------- in this macro invocation + | + = note: this error originates in the macro `empty` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + diff --git a/tests/ui/macros/macro-missing-fragment-deduplication.rs b/tests/ui/macros/macro-missing-fragment-deduplication.rs index 481f08fa111..fc81c713b4d 100644 --- a/tests/ui/macros/macro-missing-fragment-deduplication.rs +++ b/tests/ui/macros/macro-missing-fragment-deduplication.rs @@ -2,12 +2,11 @@ macro_rules! m { ($name) => {}; //~ ERROR missing fragment - //~| ERROR missing fragment } fn main() { - m!(); - m!(); - m!(); - m!(); + m!(); //~ ERROR unexpected end + m!(); //~ ERROR unexpected end + m!(); //~ ERROR unexpected end + m!(); //~ ERROR unexpected end } diff --git a/tests/ui/macros/macro-missing-fragment-deduplication.stderr b/tests/ui/macros/macro-missing-fragment-deduplication.stderr index 820f7eb3cf7..29d2ae0e16e 100644 --- a/tests/ui/macros/macro-missing-fragment-deduplication.stderr +++ b/tests/ui/macros/macro-missing-fragment-deduplication.stderr @@ -11,11 +11,65 @@ help: try adding a specifier here LL | ($name:spec) => {}; | +++++ -error: missing fragment specifier +error: unexpected end of macro invocation + --> $DIR/macro-missing-fragment-deduplication.rs:8:5 + | +LL | macro_rules! m { + | -------------- when calling this macro +... +LL | m!(); + | ^^^^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$name:tt` + --> $DIR/macro-missing-fragment-deduplication.rs:4:6 + | +LL | ($name) => {}; + | ^^^^^ + +error: unexpected end of macro invocation + --> $DIR/macro-missing-fragment-deduplication.rs:9:5 + | +LL | macro_rules! m { + | -------------- when calling this macro +... +LL | m!(); + | ^^^^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$name:tt` + --> $DIR/macro-missing-fragment-deduplication.rs:4:6 + | +LL | ($name) => {}; + | ^^^^^ + +error: unexpected end of macro invocation + --> $DIR/macro-missing-fragment-deduplication.rs:10:5 + | +LL | macro_rules! m { + | -------------- when calling this macro +... +LL | m!(); + | ^^^^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$name:tt` + --> $DIR/macro-missing-fragment-deduplication.rs:4:6 + | +LL | ($name) => {}; + | ^^^^^ + +error: unexpected end of macro invocation + --> $DIR/macro-missing-fragment-deduplication.rs:11:5 + | +LL | macro_rules! m { + | -------------- when calling this macro +... +LL | m!(); + | ^^^^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$name:tt` --> $DIR/macro-missing-fragment-deduplication.rs:4:6 | LL | ($name) => {}; | ^^^^^ -error: aborting due to 2 previous errors +error: aborting due to 5 previous errors diff --git a/tests/ui/macros/macro-missing-fragment.rs b/tests/ui/macros/macro-missing-fragment.rs index 533aa147bcb..7ed9074020e 100644 --- a/tests/ui/macros/macro-missing-fragment.rs +++ b/tests/ui/macros/macro-missing-fragment.rs @@ -2,7 +2,6 @@ macro_rules! used_arm { ( $( any_token $field_rust_type )* ) => {}; //~ ERROR missing fragment - //~| ERROR missing fragment } macro_rules! used_macro_unused_arm { diff --git a/tests/ui/macros/macro-missing-fragment.stderr b/tests/ui/macros/macro-missing-fragment.stderr index 4a99d7d949c..886292378d1 100644 --- a/tests/ui/macros/macro-missing-fragment.stderr +++ b/tests/ui/macros/macro-missing-fragment.stderr @@ -12,7 +12,7 @@ LL | ( $( any_token $field_rust_type:spec )* ) => {}; | +++++ error: missing fragment specifier - --> $DIR/macro-missing-fragment.rs:10:7 + --> $DIR/macro-missing-fragment.rs:9:7 | LL | ( $name ) => {}; | ^^^^^ @@ -25,7 +25,7 @@ LL | ( $name:spec ) => {}; | +++++ error: missing fragment specifier - --> $DIR/macro-missing-fragment.rs:14:7 + --> $DIR/macro-missing-fragment.rs:13:7 | LL | ( $name ) => {}; | ^^^^^ @@ -37,11 +37,5 @@ help: try adding a specifier here LL | ( $name:spec ) => {}; | +++++ -error: missing fragment specifier - --> $DIR/macro-missing-fragment.rs:4:20 - | -LL | ( $( any_token $field_rust_type )* ) => {}; - | ^^^^^^^^^^^^^^^^ - -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors diff --git a/tests/ui/macros/macro-reexport-removed.rs b/tests/ui/macros/macro-reexport-removed.rs index c1267f14cd8..4a054686d77 100644 --- a/tests/ui/macros/macro-reexport-removed.rs +++ b/tests/ui/macros/macro-reexport-removed.rs @@ -1,5 +1,4 @@ //@ aux-build:two_macros.rs -//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION" #![feature(macro_reexport)] //~ ERROR feature has been removed diff --git a/tests/ui/macros/macro-reexport-removed.stderr b/tests/ui/macros/macro-reexport-removed.stderr index d4940eeb775..8130fe0c4bd 100644 --- a/tests/ui/macros/macro-reexport-removed.stderr +++ b/tests/ui/macros/macro-reexport-removed.stderr @@ -1,14 +1,14 @@ error[E0557]: feature has been removed - --> $DIR/macro-reexport-removed.rs:4:12 + --> $DIR/macro-reexport-removed.rs:3:12 | LL | #![feature(macro_reexport)] | ^^^^^^^^^^^^^^ feature has been removed | - = note: removed in 1.0.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/49982> for more information + = note: removed in 1.0.0; see <https://github.com/rust-lang/rust/pull/49982> for more information = note: subsumed by `pub use` error: cannot find attribute `macro_reexport` in this scope - --> $DIR/macro-reexport-removed.rs:6:3 + --> $DIR/macro-reexport-removed.rs:5:3 | LL | #[macro_reexport(macro_one)] | ^^^^^^^^^^^^^^ help: a built-in attribute with a similar name exists: `macro_export` diff --git a/tests/ui/macros/macro-span-issue-116502.rs b/tests/ui/macros/macro-span-issue-116502.rs index 4c254289ee6..b5ae383efca 100644 --- a/tests/ui/macros/macro-span-issue-116502.rs +++ b/tests/ui/macros/macro-span-issue-116502.rs @@ -5,6 +5,8 @@ fn bug() { macro_rules! m { () => { _ //~ ERROR the placeholder `_` is not allowed within types on item signatures for structs + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for structs + //~| ERROR the placeholder `_` is not allowed within types on item signatures for structs }; } struct S<T = m!()>(m!(), T) diff --git a/tests/ui/macros/macro-span-issue-116502.stderr b/tests/ui/macros/macro-span-issue-116502.stderr index 2a581f7031b..024656e685f 100644 --- a/tests/ui/macros/macro-span-issue-116502.stderr +++ b/tests/ui/macros/macro-span-issue-116502.stderr @@ -2,22 +2,35 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures --> $DIR/macro-span-issue-116502.rs:7:13 | LL | _ - | ^ - | | - | not allowed in type signatures - | not allowed in type signatures - | not allowed in type signatures + | ^ not allowed in type signatures ... LL | struct S<T = m!()>(m!(), T) - | ---- ---- in this macro invocation - | | - | in this macro invocation -LL | where + | ---- in this macro invocation + | + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/macro-span-issue-116502.rs:7:13 + | +LL | _ + | ^ not allowed in type signatures +... LL | T: Trait<m!()>; | ---- in this macro invocation | = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 1 previous error +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/macro-span-issue-116502.rs:7:13 + | +LL | _ + | ^ not allowed in type signatures +... +LL | struct S<T = m!()>(m!(), T) + | ---- in this macro invocation + | + = note: this error originates in the macro `m` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/macros/macros-nonfatal-errors.rs b/tests/ui/macros/macros-nonfatal-errors.rs index 091d64ea5d9..1349d741510 100644 --- a/tests/ui/macros/macros-nonfatal-errors.rs +++ b/tests/ui/macros/macros-nonfatal-errors.rs @@ -3,9 +3,8 @@ // test that errors in a (selection) of macros don't kill compilation // immediately, so that we get more errors listed at a time. -#![feature(trace_macros, concat_idents)] +#![feature(trace_macros)] #![feature(stmt_expr_attributes)] -#![expect(deprecated)] // concat_idents is deprecated use std::arch::asm; @@ -105,8 +104,6 @@ fn main() { asm!(invalid); //~ ERROR llvm_asm!(invalid); //~ ERROR - concat_idents!("not", "idents"); //~ ERROR - option_env!(invalid); //~ ERROR env!(invalid); //~ ERROR env!(foo, abr, baz); //~ ERROR diff --git a/tests/ui/macros/macros-nonfatal-errors.stderr b/tests/ui/macros/macros-nonfatal-errors.stderr index 2f990cb24e2..bc34bd1c8ec 100644 --- a/tests/ui/macros/macros-nonfatal-errors.stderr +++ b/tests/ui/macros/macros-nonfatal-errors.stderr @@ -1,5 +1,5 @@ error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:14:5 + --> $DIR/macros-nonfatal-errors.rs:13:5 | LL | #[default] | ^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | #[default] = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:19:36 + --> $DIR/macros-nonfatal-errors.rs:18:36 | LL | struct DefaultInnerAttrTupleStruct(#[default] ()); | ^^^^^^^^^^ @@ -15,7 +15,7 @@ LL | struct DefaultInnerAttrTupleStruct(#[default] ()); = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:23:1 + --> $DIR/macros-nonfatal-errors.rs:22:1 | LL | #[default] | ^^^^^^^^^^ @@ -23,7 +23,7 @@ LL | #[default] = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:27:1 + --> $DIR/macros-nonfatal-errors.rs:26:1 | LL | #[default] | ^^^^^^^^^^ @@ -31,7 +31,7 @@ LL | #[default] = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:37:11 + --> $DIR/macros-nonfatal-errors.rs:36:11 | LL | Foo = #[default] 0, | ^^^^^^^^^^ @@ -39,7 +39,7 @@ LL | Foo = #[default] 0, = help: consider a manual implementation of `Default` error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:38:14 + --> $DIR/macros-nonfatal-errors.rs:37:14 | LL | Bar([u8; #[default] 1]), | ^^^^^^^^^^ @@ -47,7 +47,7 @@ LL | Bar([u8; #[default] 1]), = help: consider a manual implementation of `Default` error[E0665]: `#[derive(Default)]` on enum with no `#[default]` - --> $DIR/macros-nonfatal-errors.rs:43:10 + --> $DIR/macros-nonfatal-errors.rs:42:10 | LL | #[derive(Default)] | ^^^^^^^ @@ -67,7 +67,7 @@ LL | #[default] Bar, | ++++++++++ error[E0665]: `#[derive(Default)]` on enum with no `#[default]` - --> $DIR/macros-nonfatal-errors.rs:49:10 + --> $DIR/macros-nonfatal-errors.rs:48:10 | LL | #[derive(Default)] | ^^^^^^^ @@ -78,7 +78,7 @@ LL | | } | |_- this enum needs a unit variant marked with `#[default]` error: multiple declared defaults - --> $DIR/macros-nonfatal-errors.rs:55:10 + --> $DIR/macros-nonfatal-errors.rs:54:10 | LL | #[derive(Default)] | ^^^^^^^ @@ -95,7 +95,7 @@ LL | Baz, = note: only one variant can be default error: `#[default]` attribute does not accept a value - --> $DIR/macros-nonfatal-errors.rs:67:5 + --> $DIR/macros-nonfatal-errors.rs:66:5 | LL | #[default = 1] | ^^^^^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | #[default = 1] = help: try using `#[default]` error: multiple `#[default]` attributes - --> $DIR/macros-nonfatal-errors.rs:75:5 + --> $DIR/macros-nonfatal-errors.rs:74:5 | LL | #[default] | ---------- `#[default]` used here @@ -114,13 +114,13 @@ LL | Foo, | = note: only one `#[default]` attribute is needed help: try removing this - --> $DIR/macros-nonfatal-errors.rs:74:5 + --> $DIR/macros-nonfatal-errors.rs:73:5 | LL | #[default] | ^^^^^^^^^^ error: multiple `#[default]` attributes - --> $DIR/macros-nonfatal-errors.rs:85:5 + --> $DIR/macros-nonfatal-errors.rs:84:5 | LL | #[default] | ---------- `#[default]` used here @@ -132,7 +132,7 @@ LL | Foo, | = note: only one `#[default]` attribute is needed help: try removing these - --> $DIR/macros-nonfatal-errors.rs:82:5 + --> $DIR/macros-nonfatal-errors.rs:81:5 | LL | #[default] | ^^^^^^^^^^ @@ -142,7 +142,7 @@ LL | #[default] | ^^^^^^^^^^ error: the `#[default]` attribute may only be used on unit enum variants - --> $DIR/macros-nonfatal-errors.rs:92:5 + --> $DIR/macros-nonfatal-errors.rs:91:5 | LL | Foo {}, | ^^^ @@ -150,7 +150,7 @@ LL | Foo {}, = help: consider a manual implementation of `Default` error: default variant must be exhaustive - --> $DIR/macros-nonfatal-errors.rs:100:5 + --> $DIR/macros-nonfatal-errors.rs:99:5 | LL | #[non_exhaustive] | ----------------- declared `#[non_exhaustive]` here @@ -160,37 +160,31 @@ LL | Foo, = help: consider a manual implementation of `Default` error: asm template must be a string literal - --> $DIR/macros-nonfatal-errors.rs:105:10 + --> $DIR/macros-nonfatal-errors.rs:104:10 | LL | asm!(invalid); | ^^^^^^^ -error: `concat_idents!()` requires ident args - --> $DIR/macros-nonfatal-errors.rs:108:5 - | -LL | concat_idents!("not", "idents"); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:110:17 + --> $DIR/macros-nonfatal-errors.rs:107:17 | LL | option_env!(invalid); | ^^^^^^^ error: expected string literal - --> $DIR/macros-nonfatal-errors.rs:111:10 + --> $DIR/macros-nonfatal-errors.rs:108:10 | LL | env!(invalid); | ^^^^^^^ error: `env!()` takes 1 or 2 arguments - --> $DIR/macros-nonfatal-errors.rs:112:5 + --> $DIR/macros-nonfatal-errors.rs:109:5 | LL | env!(foo, abr, baz); | ^^^^^^^^^^^^^^^^^^^ error: environment variable `RUST_HOPEFULLY_THIS_DOESNT_EXIST` not defined at compile time - --> $DIR/macros-nonfatal-errors.rs:113:5 + --> $DIR/macros-nonfatal-errors.rs:110:5 | LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -198,7 +192,7 @@ LL | env!("RUST_HOPEFULLY_THIS_DOESNT_EXIST"); = help: use `std::env::var("RUST_HOPEFULLY_THIS_DOESNT_EXIST")` to read the variable at run time error: format argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:115:13 + --> $DIR/macros-nonfatal-errors.rs:112:13 | LL | format!(invalid); | ^^^^^^^ @@ -209,43 +203,43 @@ LL | format!("{}", invalid); | +++++ error: argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:117:14 + --> $DIR/macros-nonfatal-errors.rs:114:14 | LL | include!(invalid); | ^^^^^^^ error: argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:119:18 + --> $DIR/macros-nonfatal-errors.rs:116:18 | LL | include_str!(invalid); | ^^^^^^^ error: couldn't read `$DIR/i'd be quite surprised if a file with this name existed`: $FILE_NOT_FOUND_MSG - --> $DIR/macros-nonfatal-errors.rs:120:5 + --> $DIR/macros-nonfatal-errors.rs:117:5 | LL | include_str!("i'd be quite surprised if a file with this name existed"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: argument must be a string literal - --> $DIR/macros-nonfatal-errors.rs:121:20 + --> $DIR/macros-nonfatal-errors.rs:118:20 | LL | include_bytes!(invalid); | ^^^^^^^ error: couldn't read `$DIR/i'd be quite surprised if a file with this name existed`: $FILE_NOT_FOUND_MSG - --> $DIR/macros-nonfatal-errors.rs:122:5 + --> $DIR/macros-nonfatal-errors.rs:119:5 | LL | include_bytes!("i'd be quite surprised if a file with this name existed"); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: trace_macros! accepts only `true` or `false` - --> $DIR/macros-nonfatal-errors.rs:124:5 + --> $DIR/macros-nonfatal-errors.rs:121:5 | LL | trace_macros!(invalid); | ^^^^^^^^^^^^^^^^^^^^^^ error: default variant must be exhaustive - --> $DIR/macros-nonfatal-errors.rs:134:9 + --> $DIR/macros-nonfatal-errors.rs:131:9 | LL | #[non_exhaustive] | ----------------- declared `#[non_exhaustive]` here @@ -255,11 +249,11 @@ LL | Foo, = help: consider a manual implementation of `Default` error: cannot find macro `llvm_asm` in this scope - --> $DIR/macros-nonfatal-errors.rs:106:5 + --> $DIR/macros-nonfatal-errors.rs:105:5 | LL | llvm_asm!(invalid); | ^^^^^^^^ -error: aborting due to 29 previous errors +error: aborting due to 28 previous errors For more information about this error, try `rustc --explain E0665`. diff --git a/tests/ui/macros/macro-metavar-expr-concat/allowed-operations.rs b/tests/ui/macros/metavar-expressions/concat-allowed-operations.rs index 695a752fe17..695a752fe17 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/allowed-operations.rs +++ b/tests/ui/macros/metavar-expressions/concat-allowed-operations.rs diff --git a/tests/ui/macros/macro-metavar-expr-concat/hygiene.rs b/tests/ui/macros/metavar-expressions/concat-hygiene.rs index 24b0e36498a..24b0e36498a 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/hygiene.rs +++ b/tests/ui/macros/metavar-expressions/concat-hygiene.rs diff --git a/tests/ui/macros/macro-metavar-expr-concat/hygiene.stderr b/tests/ui/macros/metavar-expressions/concat-hygiene.stderr index ef2326dce85..f3150d385ee 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/hygiene.stderr +++ b/tests/ui/macros/metavar-expressions/concat-hygiene.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find value `abcdef` in this scope - --> $DIR/hygiene.rs:5:10 + --> $DIR/concat-hygiene.rs:5:10 | LL | ${concat($lhs, $rhs)} | ^^^^^^^^^^^^^^^^^^^^ not found in this scope diff --git a/tests/ui/macros/macro-metavar-expr-concat/raw-identifiers.rs b/tests/ui/macros/metavar-expressions/concat-raw-identifiers.rs index b1cb2141cc4..b1cb2141cc4 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/raw-identifiers.rs +++ b/tests/ui/macros/metavar-expressions/concat-raw-identifiers.rs diff --git a/tests/ui/macros/macro-metavar-expr-concat/raw-identifiers.stderr b/tests/ui/macros/metavar-expressions/concat-raw-identifiers.stderr index 4e11e20acc5..7abab6a5103 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/raw-identifiers.stderr +++ b/tests/ui/macros/metavar-expressions/concat-raw-identifiers.stderr @@ -1,47 +1,47 @@ error: expected identifier or string literal - --> $DIR/raw-identifiers.rs:28:22 + --> $DIR/concat-raw-identifiers.rs:28:22 | LL | let ${concat(r#abc, abc)}: () = (); | ^^^^^ error: expected identifier or string literal - --> $DIR/raw-identifiers.rs:32:27 + --> $DIR/concat-raw-identifiers.rs:32:27 | LL | let ${concat(abc, r#abc)}: () = (); | ^^^^^ error: expected identifier or string literal - --> $DIR/raw-identifiers.rs:35:22 + --> $DIR/concat-raw-identifiers.rs:35:22 | LL | let ${concat(r#abc, r#abc)}: () = (); | ^^^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:5:28 + --> $DIR/concat-raw-identifiers.rs:5:28 | LL | let ${concat(abc, $rhs)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:12:23 + --> $DIR/concat-raw-identifiers.rs:12:23 | LL | let ${concat($lhs, abc)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:19:23 + --> $DIR/concat-raw-identifiers.rs:19:23 | LL | let ${concat($lhs, $rhs)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:19:29 + --> $DIR/concat-raw-identifiers.rs:19:29 | LL | let ${concat($lhs, $rhs)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:19:23 + --> $DIR/concat-raw-identifiers.rs:19:23 | LL | let ${concat($lhs, $rhs)}: () = (); | ^^^ @@ -49,31 +49,31 @@ LL | let ${concat($lhs, $rhs)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:42:28 + --> $DIR/concat-raw-identifiers.rs:42:28 | LL | let ${concat(abc, $rhs)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:49:23 + --> $DIR/concat-raw-identifiers.rs:49:23 | LL | let ${concat($lhs, abc)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:56:23 + --> $DIR/concat-raw-identifiers.rs:56:23 | LL | let ${concat($lhs, $rhs)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:56:29 + --> $DIR/concat-raw-identifiers.rs:56:29 | LL | let ${concat($lhs, $rhs)}: () = (); | ^^^ error: `${concat(..)}` currently does not support raw identifiers - --> $DIR/raw-identifiers.rs:56:23 + --> $DIR/concat-raw-identifiers.rs:56:23 | LL | let ${concat($lhs, $rhs)}: () = (); | ^^^ @@ -81,7 +81,7 @@ LL | let ${concat($lhs, $rhs)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: expected pattern, found `$` - --> $DIR/raw-identifiers.rs:28:13 + --> $DIR/concat-raw-identifiers.rs:28:13 | LL | let ${concat(r#abc, abc)}: () = (); | ^ expected pattern diff --git a/tests/ui/macros/macro-metavar-expr-concat/repetitions.rs b/tests/ui/macros/metavar-expressions/concat-repetitions.rs index 52a7d5cd8a7..52a7d5cd8a7 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/repetitions.rs +++ b/tests/ui/macros/metavar-expressions/concat-repetitions.rs diff --git a/tests/ui/macros/macro-metavar-expr-concat/repetitions.stderr b/tests/ui/macros/metavar-expressions/concat-repetitions.stderr index c3006c4be5d..18b0a90c1c8 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/repetitions.stderr +++ b/tests/ui/macros/metavar-expressions/concat-repetitions.stderr @@ -1,17 +1,17 @@ error: invalid syntax - --> $DIR/repetitions.rs:14:20 + --> $DIR/concat-repetitions.rs:14:20 | LL | const ${concat($a, Z)}: i32 = 3; | ^^^^^^^^^^^^^^^ error: invalid syntax - --> $DIR/repetitions.rs:22:17 + --> $DIR/concat-repetitions.rs:22:17 | LL | read::<${concat($t, $en)}>() | ^^^^^^^^^^^^^^^^^ error: invalid syntax - --> $DIR/repetitions.rs:22:17 + --> $DIR/concat-repetitions.rs:22:17 | LL | read::<${concat($t, $en)}>() | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/macros/metavar-expressions/concat-trace-errors.rs b/tests/ui/macros/metavar-expressions/concat-trace-errors.rs new file mode 100644 index 00000000000..45407f5e86d --- /dev/null +++ b/tests/ui/macros/metavar-expressions/concat-trace-errors.rs @@ -0,0 +1,33 @@ +// Our diagnostics should be able to point to a specific input that caused an invalid +// identifier. + +#![feature(macro_metavar_expr_concat)] + +// See what we can do without expanding anything +macro_rules! pre_expansion { + ($a:ident) => { + ${concat("hi", " bye ")}; + ${concat("hi", "-", "bye")}; + ${concat($a, "-")}; + } +} + +macro_rules! post_expansion { + ($a:literal) => { + const _: () = ${concat("hi", $a, "bye")}; + //~^ ERROR is not generating a valid identifier + } +} + +post_expansion!("!"); + +macro_rules! post_expansion_many { + ($a:ident, $b:ident, $c:ident, $d:literal, $e:ident) => { + const _: () = ${concat($a, $b, $c, $d, $e)}; + //~^ ERROR is not generating a valid identifier + } +} + +post_expansion_many!(a, b, c, ".d", e); + +fn main() {} diff --git a/tests/ui/macros/metavar-expressions/concat-trace-errors.stderr b/tests/ui/macros/metavar-expressions/concat-trace-errors.stderr new file mode 100644 index 00000000000..dac8b58a15c --- /dev/null +++ b/tests/ui/macros/metavar-expressions/concat-trace-errors.stderr @@ -0,0 +1,24 @@ +error: `${concat(..)}` is not generating a valid identifier + --> $DIR/concat-trace-errors.rs:17:24 + | +LL | const _: () = ${concat("hi", $a, "bye")}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | post_expansion!("!"); + | -------------------- in this macro invocation + | + = note: this error originates in the macro `post_expansion` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: `${concat(..)}` is not generating a valid identifier + --> $DIR/concat-trace-errors.rs:26:24 + | +LL | const _: () = ${concat($a, $b, $c, $d, $e)}; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +... +LL | post_expansion_many!(a, b, c, ".d", e); + | -------------------------------------- in this macro invocation + | + = note: this error originates in the macro `post_expansion_many` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 2 previous errors + diff --git a/tests/ui/macros/macro-metavar-expr-concat/unicode-expansion.rs b/tests/ui/macros/metavar-expressions/concat-unicode-expansion.rs index 4eeb2384deb..4eeb2384deb 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/unicode-expansion.rs +++ b/tests/ui/macros/metavar-expressions/concat-unicode-expansion.rs diff --git a/tests/ui/macros/macro-metavar-expr-concat/syntax-errors.rs b/tests/ui/macros/metavar-expressions/concat-usage-errors.rs index 7673bd3200f..7d8756de9e2 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/syntax-errors.rs +++ b/tests/ui/macros/metavar-expressions/concat-usage-errors.rs @@ -1,6 +1,8 @@ +//@ edition: 2021 + #![feature(macro_metavar_expr_concat)] -macro_rules! wrong_concat_declarations { +macro_rules! syntax_errors { ($ex:expr) => { ${concat()} //~^ ERROR expected identifier @@ -90,11 +92,31 @@ macro_rules! unsupported_literals { //~| ERROR expected pattern let ${concat(_a, 1)}: () = (); //~^ ERROR expected identifier or string literal + let ${concat(_a, 1.5)}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat(_a, c"hi")}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat(_a, b"hi")}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat(_a, b'b')}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat(_a, b'b')}: () = (); + //~^ ERROR expected identifier or string literal let ${concat($ident, 'b')}: () = (); //~^ ERROR expected identifier or string literal let ${concat($ident, 1)}: () = (); //~^ ERROR expected identifier or string literal + let ${concat($ident, 1.5)}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat($ident, c"hi")}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat($ident, b"hi")}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat($ident, b'b')}: () = (); + //~^ ERROR expected identifier or string literal + let ${concat($ident, b'b')}: () = (); + //~^ ERROR expected identifier or string literal }}; } @@ -132,7 +154,7 @@ macro_rules! bad_tt_literal { } fn main() { - wrong_concat_declarations!(1); + syntax_errors!(1); dollar_sign_without_referenced_ident!(VAR); diff --git a/tests/ui/macros/macro-metavar-expr-concat/syntax-errors.stderr b/tests/ui/macros/metavar-expressions/concat-usage-errors.stderr index 2de6d2b3ce3..8be3e792ec3 100644 --- a/tests/ui/macros/macro-metavar-expr-concat/syntax-errors.stderr +++ b/tests/ui/macros/metavar-expressions/concat-usage-errors.stderr @@ -1,71 +1,131 @@ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:5:10 + --> $DIR/concat-usage-errors.rs:7:10 | LL | ${concat()} | ^^^^^^^^^^ error: `concat` must have at least two elements - --> $DIR/syntax-errors.rs:8:11 + --> $DIR/concat-usage-errors.rs:10:11 | LL | ${concat(aaaa)} | ^^^^^^ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:11:10 + --> $DIR/concat-usage-errors.rs:13:10 | LL | ${concat(aaaa,)} | ^^^^^^^^^^^^^^^ error: expected comma - --> $DIR/syntax-errors.rs:16:10 + --> $DIR/concat-usage-errors.rs:18:10 | LL | ${concat(aaaa aaaa)} | ^^^^^^^^^^^^^^^^^^^ error: `concat` must have at least two elements - --> $DIR/syntax-errors.rs:19:11 + --> $DIR/concat-usage-errors.rs:21:11 | LL | ${concat($ex)} | ^^^^^^ error: expected comma - --> $DIR/syntax-errors.rs:25:10 + --> $DIR/concat-usage-errors.rs:27:10 | LL | ${concat($ex, aaaa 123)} | ^^^^^^^^^^^^^^^^^^^^^^^ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:28:10 + --> $DIR/concat-usage-errors.rs:30:10 | LL | ${concat($ex, aaaa,)} | ^^^^^^^^^^^^^^^^^^^^ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:88:26 + --> $DIR/concat-usage-errors.rs:90:26 | LL | let ${concat(_a, 'b')}: () = (); | ^^^ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:91:26 + --> $DIR/concat-usage-errors.rs:93:26 | LL | let ${concat(_a, 1)}: () = (); | ^ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:94:30 + --> $DIR/concat-usage-errors.rs:95:26 + | +LL | let ${concat(_a, 1.5)}: () = (); + | ^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:97:26 + | +LL | let ${concat(_a, c"hi")}: () = (); + | ^^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:99:26 + | +LL | let ${concat(_a, b"hi")}: () = (); + | ^^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:101:26 + | +LL | let ${concat(_a, b'b')}: () = (); + | ^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:103:26 + | +LL | let ${concat(_a, b'b')}: () = (); + | ^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:106:30 | LL | let ${concat($ident, 'b')}: () = (); | ^^^ error: expected identifier or string literal - --> $DIR/syntax-errors.rs:96:30 + --> $DIR/concat-usage-errors.rs:108:30 | LL | let ${concat($ident, 1)}: () = (); | ^ +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:110:30 + | +LL | let ${concat($ident, 1.5)}: () = (); + | ^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:112:30 + | +LL | let ${concat($ident, c"hi")}: () = (); + | ^^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:114:30 + | +LL | let ${concat($ident, b"hi")}: () = (); + | ^^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:116:30 + | +LL | let ${concat($ident, b'b')}: () = (); + | ^^^^ + +error: expected identifier or string literal + --> $DIR/concat-usage-errors.rs:118:30 + | +LL | let ${concat($ident, b'b')}: () = (); + | ^^^^ + error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:22:19 + --> $DIR/concat-usage-errors.rs:24:19 | LL | ${concat($ex, aaaa)} | ^^ @@ -73,13 +133,13 @@ LL | ${concat($ex, aaaa)} = note: currently only string literals are supported error: variable `foo` is not recognized in meta-variable expression - --> $DIR/syntax-errors.rs:35:30 + --> $DIR/concat-usage-errors.rs:37:30 | LL | const ${concat(FOO, $foo)}: i32 = 2; | ^^^ error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:42:14 + --> $DIR/concat-usage-errors.rs:44:14 | LL | let ${concat("1", $ident)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^ @@ -90,7 +150,7 @@ LL | starting_number!(_abc); = note: this error originates in the macro `starting_number` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:55:14 + --> $DIR/concat-usage-errors.rs:57:14 | LL | let ${concat("\u{00BD}", $ident)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -101,7 +161,7 @@ LL | starting_invalid_unicode!(_abc); = note: this error originates in the macro `starting_invalid_unicode` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:74:14 + --> $DIR/concat-usage-errors.rs:76:14 | LL | let ${concat($ident, "\u{00BD}")}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +172,7 @@ LL | ending_invalid_unicode!(_abc); = note: this error originates in the macro `ending_invalid_unicode` (in Nightly builds, run with -Z macro-backtrace for more info) error: expected pattern, found `$` - --> $DIR/syntax-errors.rs:88:13 + --> $DIR/concat-usage-errors.rs:90:13 | LL | let ${concat(_a, 'b')}: () = (); | ^ expected pattern @@ -123,7 +183,7 @@ LL | unsupported_literals!(_abc); = note: this error originates in the macro `unsupported_literals` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:81:14 + --> $DIR/concat-usage-errors.rs:83:14 | LL | let ${concat("", "")}: () = (); | ^^^^^^^^^^^^^^^^ @@ -134,7 +194,7 @@ LL | empty!(); = note: this error originates in the macro `empty` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -145,7 +205,7 @@ LL | bad_literal_string!("\u{00BD}"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -156,7 +216,7 @@ LL | bad_literal_string!("\x41"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -167,7 +227,7 @@ LL | bad_literal_string!("🤷"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -178,7 +238,7 @@ LL | bad_literal_string!("d[-_-]b"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -189,7 +249,7 @@ LL | bad_literal_string!("-1"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -200,7 +260,7 @@ LL | bad_literal_string!("1.0"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: `${concat(..)}` is not generating a valid identifier - --> $DIR/syntax-errors.rs:103:16 + --> $DIR/concat-usage-errors.rs:125:16 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -211,7 +271,7 @@ LL | bad_literal_string!("'1'"); = note: this error originates in the macro `bad_literal_string` (in Nightly builds, run with -Z macro-backtrace for more info) error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:116:31 + --> $DIR/concat-usage-errors.rs:138:31 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^ @@ -219,7 +279,7 @@ LL | const ${concat(_foo, $literal)}: () = (); = note: currently only string literals are supported error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:116:31 + --> $DIR/concat-usage-errors.rs:138:31 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^ @@ -228,7 +288,7 @@ LL | const ${concat(_foo, $literal)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:116:31 + --> $DIR/concat-usage-errors.rs:138:31 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^ @@ -237,7 +297,7 @@ LL | const ${concat(_foo, $literal)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:116:31 + --> $DIR/concat-usage-errors.rs:138:31 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^ @@ -246,7 +306,7 @@ LL | const ${concat(_foo, $literal)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:116:31 + --> $DIR/concat-usage-errors.rs:138:31 | LL | const ${concat(_foo, $literal)}: () = (); | ^^^^^^^ @@ -255,7 +315,7 @@ LL | const ${concat(_foo, $literal)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:127:31 + --> $DIR/concat-usage-errors.rs:149:31 | LL | const ${concat(_foo, $tt)}: () = (); | ^^ @@ -263,7 +323,7 @@ LL | const ${concat(_foo, $tt)}: () = (); = note: currently only string literals are supported error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:127:31 + --> $DIR/concat-usage-errors.rs:149:31 | LL | const ${concat(_foo, $tt)}: () = (); | ^^ @@ -272,7 +332,7 @@ LL | const ${concat(_foo, $tt)}: () = (); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: metavariables of `${concat(..)}` must be of type `ident`, `literal` or `tt` - --> $DIR/syntax-errors.rs:127:31 + --> $DIR/concat-usage-errors.rs:149:31 | LL | const ${concat(_foo, $tt)}: () = (); | ^^ @@ -280,5 +340,5 @@ LL | const ${concat(_foo, $tt)}: () = (); = note: currently only string literals are supported = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 33 previous errors +error: aborting due to 43 previous errors diff --git a/tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs b/tests/ui/macros/metavar-expressions/count-and-length-are-distinct.rs index 8ca453273cd..8ca453273cd 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/count-and-length-are-distinct.rs +++ b/tests/ui/macros/metavar-expressions/count-and-length-are-distinct.rs diff --git a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs b/tests/ui/macros/metavar-expressions/count-empty-index-arg.rs index 3000bfed6a8..69880ee7fa9 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.rs +++ b/tests/ui/macros/metavar-expressions/count-empty-index-arg.rs @@ -1,3 +1,6 @@ +// Issue: https://github.com/rust-lang/rust/issues/111904 +// Ensure that a trailing `,` is not interpreted as a `0`. + #![feature(macro_metavar_expr)] macro_rules! foo { @@ -10,5 +13,4 @@ fn test() { foo!(a, a; b, b); } -fn main() { -} +fn main() {} diff --git a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr b/tests/ui/macros/metavar-expressions/count-empty-index-arg.stderr index fd53c1686cf..e1f9d020b7f 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/issue-111904.stderr +++ b/tests/ui/macros/metavar-expressions/count-empty-index-arg.stderr @@ -1,11 +1,11 @@ error: `count` followed by a comma must have an associated index indicating its depth - --> $DIR/issue-111904.rs:4:37 + --> $DIR/count-empty-index-arg.rs:7:37 | LL | ( $( $($t:ident),* );* ) => { ${count($t,)} } | ^^^^^ error: expected expression, found `$` - --> $DIR/issue-111904.rs:4:35 + --> $DIR/count-empty-index-arg.rs:7:35 | LL | ( $( $($t:ident),* );* ) => { ${count($t,)} } | ^ expected expression diff --git a/tests/ui/macros/rfc-3086-metavar-expr/dollar-dollar-has-correct-behavior.rs b/tests/ui/macros/metavar-expressions/dollar-dollar-has-correct-behavior.rs index 9b8e3216a68..9b8e3216a68 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/dollar-dollar-has-correct-behavior.rs +++ b/tests/ui/macros/metavar-expressions/dollar-dollar-has-correct-behavior.rs diff --git a/tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs b/tests/ui/macros/metavar-expressions/feature-gate-macro_metavar_expr.rs index 51445221c57..51445221c57 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/feature-gate-macro_metavar_expr.rs +++ b/tests/ui/macros/metavar-expressions/feature-gate-macro_metavar_expr.rs diff --git a/tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs b/tests/ui/macros/metavar-expressions/macro-expansion.rs index 1d34275874b..1d34275874b 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/macro-expansion.rs +++ b/tests/ui/macros/metavar-expressions/macro-expansion.rs diff --git a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs b/tests/ui/macros/metavar-expressions/out-of-bounds-arguments.rs index 0caa3ea89e4..0caa3ea89e4 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.rs +++ b/tests/ui/macros/metavar-expressions/out-of-bounds-arguments.rs diff --git a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr b/tests/ui/macros/metavar-expressions/out-of-bounds-arguments.stderr index 0b441cad083..0b441cad083 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/out-of-bounds-arguments.stderr +++ b/tests/ui/macros/metavar-expressions/out-of-bounds-arguments.stderr diff --git a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs b/tests/ui/macros/metavar-expressions/required-feature.rs index 77c165e3855..77c165e3855 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.rs +++ b/tests/ui/macros/metavar-expressions/required-feature.rs diff --git a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.stderr b/tests/ui/macros/metavar-expressions/required-feature.stderr index f28f822a058..f28f822a058 100644 --- a/tests/ui/macros/rfc-3086-metavar-expr/required-feature.stderr +++ b/tests/ui/macros/metavar-expressions/required-feature.stderr diff --git a/tests/ui/macros/metavar-expressions/syntax-errors.rs b/tests/ui/macros/metavar-expressions/syntax-errors.rs new file mode 100644 index 00000000000..8fc76a74baa --- /dev/null +++ b/tests/ui/macros/metavar-expressions/syntax-errors.rs @@ -0,0 +1,117 @@ +// General syntax errors that apply to all matavariable expressions +// +// We don't invoke the macros here to ensure code gets rejected at the definition rather than +// only when expanded. + +#![feature(macro_metavar_expr)] + +macro_rules! dollar_dollar_in_the_lhs { + ( $$ $a:ident ) => { + //~^ ERROR unexpected token: $ + }; +} + +macro_rules! metavar_in_the_lhs { + ( ${ len() } ) => { + //~^ ERROR unexpected token: { + //~| ERROR expected one of: `*`, `+`, or `?` + }; +} + +macro_rules! metavar_token_without_ident { + ( $( $i:ident ),* ) => { ${ ignore() } }; + //~^ ERROR meta-variable expressions must be referenced using a dollar sign +} + +macro_rules! metavar_with_literal_suffix { + ( $( $i:ident ),* ) => { ${ index(1u32) } }; + //~^ ERROR only unsuffixes integer literals are supported in meta-variable expressions +} + +macro_rules! mve_without_parens { + ( $( $i:ident ),* ) => { ${ count } }; + //~^ ERROR meta-variable expression parameter must be wrapped in parentheses +} + +#[rustfmt::skip] +macro_rules! empty_expression { + () => { ${} }; + //~^ ERROR expected identifier or string literal +} + +#[rustfmt::skip] +macro_rules! open_brackets_with_lit { + () => { ${ "hi" } }; + //~^ ERROR expected identifier + } + +macro_rules! mve_wrong_delim { + ( $( $i:ident ),* ) => { ${ count{i} } }; + //~^ ERROR meta-variable expression parameter must be wrapped in parentheses +} + +macro_rules! invalid_metavar { + () => { ${ignore($123)} } + //~^ ERROR expected identifier, found `123` +} + +#[rustfmt::skip] +macro_rules! open_brackets_with_group { + ( $( $i:ident ),* ) => { ${ {} } }; + //~^ ERROR expected identifier +} + +macro_rules! extra_garbage_after_metavar { + ( $( $i:ident ),* ) => { + ${count() a b c} + //~^ ERROR unexpected token: a + ${count($i a b c)} + //~^ ERROR unexpected token: a + ${count($i, 1 a b c)} + //~^ ERROR unexpected token: a + ${count($i) a b c} + //~^ ERROR unexpected token: a + + ${ignore($i) a b c} + //~^ ERROR unexpected token: a + ${ignore($i a b c)} + //~^ ERROR unexpected token: a + + ${index() a b c} + //~^ ERROR unexpected token: a + ${index(1 a b c)} + //~^ ERROR unexpected token: a + + ${index() a b c} + //~^ ERROR unexpected token: a + ${index(1 a b c)} + //~^ ERROR unexpected token: a + }; +} + +const IDX: usize = 1; +macro_rules! metavar_depth_is_not_literal { + ( $( $i:ident ),* ) => { ${ index(IDX) } }; + //~^ ERROR meta-variable expression depth must be a literal +} + +macro_rules! unknown_count_ident { + ( $( $i:ident )* ) => { + ${count(foo)} + //~^ ERROR meta-variable expressions must be referenced using a dollar sign + }; +} + +macro_rules! unknown_ignore_ident { + ( $( $i:ident )* ) => { + ${ignore(bar)} + //~^ ERROR meta-variable expressions must be referenced using a dollar sign + }; +} + +macro_rules! unknown_metavar { + ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; + //~^ ERROR unrecognized meta-variable expression +} + +fn main() {} diff --git a/tests/ui/macros/metavar-expressions/syntax-errors.stderr b/tests/ui/macros/metavar-expressions/syntax-errors.stderr new file mode 100644 index 00000000000..20d2358facc --- /dev/null +++ b/tests/ui/macros/metavar-expressions/syntax-errors.stderr @@ -0,0 +1,224 @@ +error: unexpected token: $ + --> $DIR/syntax-errors.rs:9:8 + | +LL | ( $$ $a:ident ) => { + | ^ + +note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions + --> $DIR/syntax-errors.rs:9:8 + | +LL | ( $$ $a:ident ) => { + | ^ + +error: unexpected token: { + --> $DIR/syntax-errors.rs:15:8 + | +LL | ( ${ len() } ) => { + | ^^^^^^^^^ + +note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions + --> $DIR/syntax-errors.rs:15:8 + | +LL | ( ${ len() } ) => { + | ^^^^^^^^^ + +error: expected one of: `*`, `+`, or `?` + --> $DIR/syntax-errors.rs:15:8 + | +LL | ( ${ len() } ) => { + | ^^^^^^^^^ + +error: meta-variables within meta-variable expressions must be referenced using a dollar sign + --> $DIR/syntax-errors.rs:22:33 + | +LL | ( $( $i:ident ),* ) => { ${ ignore() } }; + | ^^^^^^ + +error: only unsuffixes integer literals are supported in meta-variable expressions + --> $DIR/syntax-errors.rs:27:33 + | +LL | ( $( $i:ident ),* ) => { ${ index(1u32) } }; + | ^^^^^ + +error: meta-variable expression parameter must be wrapped in parentheses + --> $DIR/syntax-errors.rs:32:33 + | +LL | ( $( $i:ident ),* ) => { ${ count } }; + | ^^^^^ + +error: meta-variable expression parameter must be wrapped in parentheses + --> $DIR/syntax-errors.rs:49:33 + | +LL | ( $( $i:ident ),* ) => { ${ count{i} } }; + | ^^^^^ + +error: expected identifier, found `123` + --> $DIR/syntax-errors.rs:54:23 + | +LL | () => { ${ignore($123)} } + | ^^^ help: try removing `123` + +error: unexpected token: a + --> $DIR/syntax-errors.rs:66:19 + | +LL | ${count() a b c} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:66:19 + | +LL | ${count() a b c} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:68:20 + | +LL | ${count($i a b c)} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:68:20 + | +LL | ${count($i a b c)} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:70:23 + | +LL | ${count($i, 1 a b c)} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:70:23 + | +LL | ${count($i, 1 a b c)} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:72:21 + | +LL | ${count($i) a b c} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:72:21 + | +LL | ${count($i) a b c} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:75:22 + | +LL | ${ignore($i) a b c} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:75:22 + | +LL | ${ignore($i) a b c} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:77:21 + | +LL | ${ignore($i a b c)} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:77:21 + | +LL | ${ignore($i a b c)} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:80:19 + | +LL | ${index() a b c} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:80:19 + | +LL | ${index() a b c} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:82:19 + | +LL | ${index(1 a b c)} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:82:19 + | +LL | ${index(1 a b c)} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:85:19 + | +LL | ${index() a b c} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:85:19 + | +LL | ${index() a b c} + | ^ + +error: unexpected token: a + --> $DIR/syntax-errors.rs:87:19 + | +LL | ${index(1 a b c)} + | ^ + | +note: meta-variable expression must not have trailing tokens + --> $DIR/syntax-errors.rs:87:19 + | +LL | ${index(1 a b c)} + | ^ + +error: meta-variable expression depth must be a literal + --> $DIR/syntax-errors.rs:94:33 + | +LL | ( $( $i:ident ),* ) => { ${ index(IDX) } }; + | ^^^^^ + +error: meta-variables within meta-variable expressions must be referenced using a dollar sign + --> $DIR/syntax-errors.rs:100:11 + | +LL | ${count(foo)} + | ^^^^^ + +error: meta-variables within meta-variable expressions must be referenced using a dollar sign + --> $DIR/syntax-errors.rs:107:11 + | +LL | ${ignore(bar)} + | ^^^^^^ + +error: unrecognized meta-variable expression + --> $DIR/syntax-errors.rs:113:33 + | +LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; + | ^^^^^^^^^^^^^^ help: supported expressions are count, ignore, index and len + +error: expected identifier or string literal + --> $DIR/syntax-errors.rs:38:14 + | +LL | () => { ${} }; + | ^^ + +error: expected identifier, found `"hi"` + --> $DIR/syntax-errors.rs:44:17 + | +LL | () => { ${ "hi" } }; + | ^^^^ help: try removing `"hi"` + +error: expected identifier or string literal + --> $DIR/syntax-errors.rs:60:33 + | +LL | ( $( $i:ident ),* ) => { ${ {} } }; + | ^^ + +error: aborting due to 25 previous errors + diff --git a/tests/ui/macros/metavar-expressions/usage-errors.rs b/tests/ui/macros/metavar-expressions/usage-errors.rs new file mode 100644 index 00000000000..feff02e2ce4 --- /dev/null +++ b/tests/ui/macros/metavar-expressions/usage-errors.rs @@ -0,0 +1,55 @@ +// Errors for the `count` and `length` metavariable expressions + +#![feature(macro_metavar_expr)] + +// `curly` = Right hand side curly brackets +// `no_rhs_dollar` = No dollar sign at the right hand side meta variable "function" +// `round` = Left hand side round brackets + +macro_rules! curly__no_rhs_dollar__round { + ( $( $i:ident ),* ) => { ${ count($i) } }; +} +const _: u32 = curly__no_rhs_dollar__round!(a, b, c); + +macro_rules! curly__no_rhs_dollar__no_round { + ( $i:ident ) => { ${ count($i) } }; + //~^ ERROR `count` can not be placed inside the innermost repetition +} +curly__no_rhs_dollar__no_round!(a); + +macro_rules! curly__rhs_dollar__no_round { + ( $i:ident ) => { ${ count($i) } }; + //~^ ERROR `count` can not be placed inside the innermost repetition +} +curly__rhs_dollar__no_round !(a); + +#[rustfmt::skip] // autoformatters can break a few of the error traces +macro_rules! no_curly__no_rhs_dollar__round { + ( $( $i:ident ),* ) => { count(i) }; + //~^ ERROR missing `fn` or `struct` for function or struct definition +} +no_curly__no_rhs_dollar__round !(a, b, c); + +#[rustfmt::skip] // autoformatters can break a few of the error traces +macro_rules! no_curly__no_rhs_dollar__no_round { + ( $i:ident ) => { count(i) }; + //~^ ERROR missing `fn` or `struct` for function or struct definition +} +no_curly__no_rhs_dollar__no_round !(a); + +#[rustfmt::skip] // autoformatters can break a few of the error traces +macro_rules! no_curly__rhs_dollar__round { + ( $( $i:ident ),* ) => { count($i) }; + //~^ ERROR variable `i` is still repeating at this depth +} +no_curly__rhs_dollar__round! (a); + +#[rustfmt::skip] // autoformatters can break a few of the error traces +macro_rules! no_curly__rhs_dollar__no_round { + ( $i:ident ) => { count($i) }; + //~^ ERROR cannot find function `count` in this scope +} +const _: u32 = no_curly__rhs_dollar__no_round! (a); +//~^ ERROR cannot find value `a` in this scope + +fn main() {} diff --git a/tests/ui/macros/metavar-expressions/usage-errors.stderr b/tests/ui/macros/metavar-expressions/usage-errors.stderr new file mode 100644 index 00000000000..f66f522e23b --- /dev/null +++ b/tests/ui/macros/metavar-expressions/usage-errors.stderr @@ -0,0 +1,71 @@ +error: `count` can not be placed inside the innermost repetition + --> $DIR/usage-errors.rs:15:24 + | +LL | ( $i:ident ) => { ${ count($i) } }; + | ^^^^^^^^^^^^^ + +error: `count` can not be placed inside the innermost repetition + --> $DIR/usage-errors.rs:21:24 + | +LL | ( $i:ident ) => { ${ count($i) } }; + | ^^^^^^^^^^^^^ + +error: missing `fn` or `struct` for function or struct definition + --> $DIR/usage-errors.rs:28:30 + | +LL | ( $( $i:ident ),* ) => { count(i) }; + | ^^^^^ +... +LL | no_curly__no_rhs_dollar__round !(a, b, c); + | ----------------------------------------- in this macro invocation + | + = note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) +help: if you meant to call a macro, try + | +LL | ( $( $i:ident ),* ) => { count!(i) }; + | + + +error: missing `fn` or `struct` for function or struct definition + --> $DIR/usage-errors.rs:35:23 + | +LL | ( $i:ident ) => { count(i) }; + | ^^^^^ +... +LL | no_curly__no_rhs_dollar__no_round !(a); + | -------------------------------------- in this macro invocation + | + = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) +help: if you meant to call a macro, try + | +LL | ( $i:ident ) => { count!(i) }; + | + + +error: variable `i` is still repeating at this depth + --> $DIR/usage-errors.rs:42:36 + | +LL | ( $( $i:ident ),* ) => { count($i) }; + | ^^ + +error[E0425]: cannot find value `a` in this scope + --> $DIR/usage-errors.rs:52:49 + | +LL | ( $i:ident ) => { count($i) }; + | -- due to this macro variable +... +LL | const _: u32 = no_curly__rhs_dollar__no_round! (a); + | ^ not found in this scope + +error[E0425]: cannot find function `count` in this scope + --> $DIR/usage-errors.rs:49:23 + | +LL | ( $i:ident ) => { count($i) }; + | ^^^^^ not found in this scope +... +LL | const _: u32 = no_curly__rhs_dollar__no_round! (a); + | ----------------------------------- in this macro invocation + | + = note: this error originates in the macro `no_curly__rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/macros/missing-semi.stderr b/tests/ui/macros/missing-semi.stderr index 0a7afe50059..c2e12adbb4b 100644 --- a/tests/ui/macros/missing-semi.stderr +++ b/tests/ui/macros/missing-semi.stderr @@ -1,8 +1,10 @@ error: expected `;`, found `(` --> $DIR/missing-semi.rs:6:5 | +LL | } + | - expected `;` LL | () => { - | ^ no rules expected this token in macro call + | ^ unexpected token error: aborting due to 1 previous error diff --git a/tests/ui/macros/missing-writer-issue-139830.rs b/tests/ui/macros/missing-writer-issue-139830.rs new file mode 100644 index 00000000000..da4608776c3 --- /dev/null +++ b/tests/ui/macros/missing-writer-issue-139830.rs @@ -0,0 +1,9 @@ +// Make sure we don't suggest a method change inside the `write!` macro. +// +// See <https://github.com/rust-lang/rust/issues/139830> + +fn main() { + let mut buf = String::new(); + let _ = write!(buf, "foo"); + //~^ ERROR cannot write into `String` +} diff --git a/tests/ui/macros/missing-writer-issue-139830.stderr b/tests/ui/macros/missing-writer-issue-139830.stderr new file mode 100644 index 00000000000..34dd61328e0 --- /dev/null +++ b/tests/ui/macros/missing-writer-issue-139830.stderr @@ -0,0 +1,23 @@ +error[E0599]: cannot write into `String` + --> $DIR/missing-writer-issue-139830.rs:7:20 + | +LL | let _ = write!(buf, "foo"); + | ^^^ + --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL + | + = note: the method is available for `String` here + | +note: must implement `io::Write`, `fmt::Write`, or have a `write_fmt` method + --> $DIR/missing-writer-issue-139830.rs:7:20 + | +LL | let _ = write!(buf, "foo"); + | ^^^ + = help: items from traits can only be used if the trait is in scope +help: trait `Write` which provides `write_fmt` is implemented but not in scope; perhaps you want to import it + | +LL + use std::fmt::Write; + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/macros/must-use-in-macro-55516.stderr b/tests/ui/macros/must-use-in-macro-55516.stderr index 7bf4aaab51c..b93d40d7e5a 100644 --- a/tests/ui/macros/must-use-in-macro-55516.stderr +++ b/tests/ui/macros/must-use-in-macro-55516.stderr @@ -7,7 +7,10 @@ LL | write!(&mut example, "{}", 42); = note: this `Result` may be an `Err` variant, which should be handled = note: `-W unused-must-use` implied by `-W unused` = help: to override `-W unused` add `#[allow(unused_must_use)]` - = note: this warning originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use `let _ = ...` to ignore the resulting value + | +LL | let _ = write!(&mut example, "{}", 42); + | +++++++ warning: 1 warning emitted diff --git a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs b/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs deleted file mode 100644 index 78cede92526..00000000000 --- a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.rs +++ /dev/null @@ -1,164 +0,0 @@ -#![feature(macro_metavar_expr)] - -// `curly` = Right hand side curly brackets -// `no_rhs_dollar` = No dollar sign at the right hand side meta variable "function" -// `round` = Left hand side round brackets - -macro_rules! curly__no_rhs_dollar__round { - ( $( $i:ident ),* ) => { ${ count($i) } }; -} - -macro_rules! curly__no_rhs_dollar__no_round { - ( $i:ident ) => { ${ count($i) } }; - //~^ ERROR `count` can not be placed inside the innermost repetition -} - -macro_rules! curly__rhs_dollar__no_round { - ( $i:ident ) => { ${ count($i) } }; - //~^ ERROR `count` can not be placed inside the innermost repetition -} - -#[rustfmt::skip] // autoformatters can break a few of the error traces -macro_rules! no_curly__no_rhs_dollar__round { - ( $( $i:ident ),* ) => { count(i) }; - //~^ ERROR cannot find function `count` in this scope - //~| ERROR cannot find value `i` in this scope -} - -#[rustfmt::skip] // autoformatters can break a few of the error traces -macro_rules! no_curly__no_rhs_dollar__no_round { - ( $i:ident ) => { count(i) }; - //~^ ERROR cannot find function `count` in this scope - //~| ERROR cannot find value `i` in this scope -} - -#[rustfmt::skip] // autoformatters can break a few of the error traces -macro_rules! no_curly__rhs_dollar__round { - ( $( $i:ident ),* ) => { count($i) }; - //~^ ERROR variable `i` is still repeating at this depth -} - -#[rustfmt::skip] // autoformatters can break a few of the error traces -macro_rules! no_curly__rhs_dollar__no_round { - ( $i:ident ) => { count($i) }; - //~^ ERROR cannot find function `count` in this scope -} - -// Other scenarios - -macro_rules! dollar_dollar_in_the_lhs { - ( $$ $a:ident ) => { - //~^ ERROR unexpected token: $ - }; -} - -macro_rules! extra_garbage_after_metavar { - ( $( $i:ident ),* ) => { - ${count() a b c} - //~^ ERROR unexpected token: a - //~| ERROR expected expression, found `$` - ${count($i a b c)} - //~^ ERROR unexpected token: a - ${count($i, 1 a b c)} - //~^ ERROR unexpected token: a - ${count($i) a b c} - //~^ ERROR unexpected token: a - - ${ignore($i) a b c} - //~^ ERROR unexpected token: a - ${ignore($i a b c)} - //~^ ERROR unexpected token: a - - ${index() a b c} - //~^ ERROR unexpected token: a - ${index(1 a b c)} - //~^ ERROR unexpected token: a - - ${index() a b c} - //~^ ERROR unexpected token: a - ${index(1 a b c)} - //~^ ERROR unexpected token: a - }; -} - -const IDX: usize = 1; -macro_rules! metavar_depth_is_not_literal { - ( $( $i:ident ),* ) => { ${ index(IDX) } }; - //~^ ERROR meta-variable expression depth must be a literal - //~| ERROR expected expression, found `$` -} - -macro_rules! metavar_in_the_lhs { - ( ${ len() } ) => { - //~^ ERROR unexpected token: { - //~| ERROR expected one of: `*`, `+`, or `?` - }; -} - -macro_rules! metavar_token_without_ident { - ( $( $i:ident ),* ) => { ${ ignore() } }; - //~^ ERROR meta-variable expressions must be referenced using a dollar sign - //~| ERROR expected expression -} - -macro_rules! metavar_with_literal_suffix { - ( $( $i:ident ),* ) => { ${ index(1u32) } }; - //~^ ERROR only unsuffixes integer literals are supported in meta-variable expressions - //~| ERROR expected expression, found `$` -} - -macro_rules! metavar_without_parens { - ( $( $i:ident ),* ) => { ${ count{i} } }; - //~^ ERROR meta-variable expression parameter must be wrapped in parentheses - //~| ERROR expected expression, found `$` -} - -#[rustfmt::skip] -macro_rules! open_brackets_without_tokens { - ( $( $i:ident ),* ) => { ${ {} } }; - //~^ ERROR expected expression, found `$` - //~| ERROR expected identifier -} - -macro_rules! unknown_count_ident { - ( $( $i:ident )* ) => { - ${count(foo)} - //~^ ERROR meta-variable expressions must be referenced using a dollar sign - //~| ERROR expected expression - }; -} - -macro_rules! unknown_ignore_ident { - ( $( $i:ident )* ) => { - ${ignore(bar)} - //~^ ERROR meta-variable expressions must be referenced using a dollar sign - //~| ERROR expected expression - }; -} - -macro_rules! unknown_metavar { - ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; - //~^ ERROR unrecognized meta-variable expression - //~| ERROR expected expression -} - -fn main() { - curly__no_rhs_dollar__round!(a, b, c); - curly__no_rhs_dollar__no_round!(a); - curly__rhs_dollar__no_round!(a); - no_curly__no_rhs_dollar__round!(a, b, c); - no_curly__no_rhs_dollar__no_round!(a); - no_curly__rhs_dollar__round!(a, b, c); - no_curly__rhs_dollar__no_round!(a); - //~^ ERROR cannot find value `a` in this scope - - extra_garbage_after_metavar!(a); - metavar_depth_is_not_literal!(a); - metavar_token_without_ident!(a); - metavar_with_literal_suffix!(a); - metavar_without_parens!(a); - open_brackets_without_tokens!(a); - unknown_count_ident!(a); - unknown_ignore_ident!(a); - unknown_metavar!(a); -} diff --git a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr b/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr deleted file mode 100644 index d9646760cea..00000000000 --- a/tests/ui/macros/rfc-3086-metavar-expr/syntax-errors.stderr +++ /dev/null @@ -1,382 +0,0 @@ -error: unexpected token: $ - --> $DIR/syntax-errors.rs:50:8 - | -LL | ( $$ $a:ident ) => { - | ^ - -note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions - --> $DIR/syntax-errors.rs:50:8 - | -LL | ( $$ $a:ident ) => { - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:57:19 - | -LL | ${count() a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:57:19 - | -LL | ${count() a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:60:20 - | -LL | ${count($i a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:60:20 - | -LL | ${count($i a b c)} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:62:23 - | -LL | ${count($i, 1 a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:62:23 - | -LL | ${count($i, 1 a b c)} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:64:21 - | -LL | ${count($i) a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:64:21 - | -LL | ${count($i) a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:67:22 - | -LL | ${ignore($i) a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:67:22 - | -LL | ${ignore($i) a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:69:21 - | -LL | ${ignore($i a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:69:21 - | -LL | ${ignore($i a b c)} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:72:19 - | -LL | ${index() a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:72:19 - | -LL | ${index() a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:74:19 - | -LL | ${index(1 a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:74:19 - | -LL | ${index(1 a b c)} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:77:19 - | -LL | ${index() a b c} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:77:19 - | -LL | ${index() a b c} - | ^ - -error: unexpected token: a - --> $DIR/syntax-errors.rs:79:19 - | -LL | ${index(1 a b c)} - | ^ - | -note: meta-variable expression must not have trailing tokens - --> $DIR/syntax-errors.rs:79:19 - | -LL | ${index(1 a b c)} - | ^ - -error: meta-variable expression depth must be a literal - --> $DIR/syntax-errors.rs:86:33 - | -LL | ( $( $i:ident ),* ) => { ${ index(IDX) } }; - | ^^^^^ - -error: unexpected token: { - --> $DIR/syntax-errors.rs:92:8 - | -LL | ( ${ len() } ) => { - | ^^^^^^^^^ - -note: `$$` and meta-variable expressions are not allowed inside macro parameter definitions - --> $DIR/syntax-errors.rs:92:8 - | -LL | ( ${ len() } ) => { - | ^^^^^^^^^ - -error: expected one of: `*`, `+`, or `?` - --> $DIR/syntax-errors.rs:92:8 - | -LL | ( ${ len() } ) => { - | ^^^^^^^^^ - -error: meta-variables within meta-variable expressions must be referenced using a dollar sign - --> $DIR/syntax-errors.rs:99:33 - | -LL | ( $( $i:ident ),* ) => { ${ ignore() } }; - | ^^^^^^ - -error: only unsuffixes integer literals are supported in meta-variable expressions - --> $DIR/syntax-errors.rs:105:33 - | -LL | ( $( $i:ident ),* ) => { ${ index(1u32) } }; - | ^^^^^ - -error: meta-variable expression parameter must be wrapped in parentheses - --> $DIR/syntax-errors.rs:111:33 - | -LL | ( $( $i:ident ),* ) => { ${ count{i} } }; - | ^^^^^ - -error: meta-variables within meta-variable expressions must be referenced using a dollar sign - --> $DIR/syntax-errors.rs:125:11 - | -LL | ${count(foo)} - | ^^^^^ - -error: meta-variables within meta-variable expressions must be referenced using a dollar sign - --> $DIR/syntax-errors.rs:133:11 - | -LL | ${ignore(bar)} - | ^^^^^^ - -error: unrecognized meta-variable expression - --> $DIR/syntax-errors.rs:140:33 - | -LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; - | ^^^^^^^^^^^^^^ help: supported expressions are count, ignore, index and len - -error: expected identifier or string literal - --> $DIR/syntax-errors.rs:118:33 - | -LL | ( $( $i:ident ),* ) => { ${ {} } }; - | ^^ - -error: `count` can not be placed inside the innermost repetition - --> $DIR/syntax-errors.rs:12:24 - | -LL | ( $i:ident ) => { ${ count($i) } }; - | ^^^^^^^^^^^^^ - -error: `count` can not be placed inside the innermost repetition - --> $DIR/syntax-errors.rs:17:24 - | -LL | ( $i:ident ) => { ${ count($i) } }; - | ^^^^^^^^^^^^^ - -error: variable `i` is still repeating at this depth - --> $DIR/syntax-errors.rs:37:36 - | -LL | ( $( $i:ident ),* ) => { count($i) }; - | ^^ - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:57:9 - | -LL | ${count() a b c} - | ^ expected expression -... -LL | extra_garbage_after_metavar!(a); - | ------------------------------- in this macro invocation - | - = note: this error originates in the macro `extra_garbage_after_metavar` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:86:30 - | -LL | ( $( $i:ident ),* ) => { ${ index(IDX) } }; - | ^ expected expression -... -LL | metavar_depth_is_not_literal!(a); - | -------------------------------- in this macro invocation - | - = note: this error originates in the macro `metavar_depth_is_not_literal` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:99:30 - | -LL | ( $( $i:ident ),* ) => { ${ ignore() } }; - | ^ expected expression -... -LL | metavar_token_without_ident!(a); - | ------------------------------- in this macro invocation - | - = note: this error originates in the macro `metavar_token_without_ident` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:105:30 - | -LL | ( $( $i:ident ),* ) => { ${ index(1u32) } }; - | ^ expected expression -... -LL | metavar_with_literal_suffix!(a); - | ------------------------------- in this macro invocation - | - = note: this error originates in the macro `metavar_with_literal_suffix` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:111:30 - | -LL | ( $( $i:ident ),* ) => { ${ count{i} } }; - | ^ expected expression -... -LL | metavar_without_parens!(a); - | -------------------------- in this macro invocation - | - = note: this error originates in the macro `metavar_without_parens` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:118:30 - | -LL | ( $( $i:ident ),* ) => { ${ {} } }; - | ^ expected expression -... -LL | open_brackets_without_tokens!(a); - | -------------------------------- in this macro invocation - | - = note: this error originates in the macro `open_brackets_without_tokens` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:125:9 - | -LL | ${count(foo)} - | ^ expected expression -... -LL | unknown_count_ident!(a); - | ----------------------- in this macro invocation - | - = note: this error originates in the macro `unknown_count_ident` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:133:9 - | -LL | ${ignore(bar)} - | ^ expected expression -... -LL | unknown_ignore_ident!(a); - | ------------------------ in this macro invocation - | - = note: this error originates in the macro `unknown_ignore_ident` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: expected expression, found `$` - --> $DIR/syntax-errors.rs:140:30 - | -LL | ( $( $i:ident ),* ) => { ${ aaaaaaaaaaaaaa(i) } }; - | ^ expected expression -... -LL | unknown_metavar!(a); - | ------------------- in this macro invocation - | - = note: this error originates in the macro `unknown_metavar` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find value `i` in this scope - --> $DIR/syntax-errors.rs:23:36 - | -LL | ( $( $i:ident ),* ) => { count(i) }; - | ^ not found in this scope -... -LL | no_curly__no_rhs_dollar__round!(a, b, c); - | ---------------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find value `i` in this scope - --> $DIR/syntax-errors.rs:30:29 - | -LL | ( $i:ident ) => { count(i) }; - | ^ not found in this scope -... -LL | no_curly__no_rhs_dollar__no_round!(a); - | ------------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find value `a` in this scope - --> $DIR/syntax-errors.rs:152:37 - | -LL | ( $i:ident ) => { count($i) }; - | -- due to this macro variable -... -LL | no_curly__rhs_dollar__no_round!(a); - | ^ not found in this scope - -error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:23:30 - | -LL | ( $( $i:ident ),* ) => { count(i) }; - | ^^^^^ not found in this scope -... -LL | no_curly__no_rhs_dollar__round!(a, b, c); - | ---------------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__no_rhs_dollar__round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:30:23 - | -LL | ( $i:ident ) => { count(i) }; - | ^^^^^ not found in this scope -... -LL | no_curly__no_rhs_dollar__no_round!(a); - | ------------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__no_rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error[E0425]: cannot find function `count` in this scope - --> $DIR/syntax-errors.rs:43:23 - | -LL | ( $i:ident ) => { count($i) }; - | ^^^^^ not found in this scope -... -LL | no_curly__rhs_dollar__no_round!(a); - | ---------------------------------- in this macro invocation - | - = note: this error originates in the macro `no_curly__rhs_dollar__no_round` (in Nightly builds, run with -Z macro-backtrace for more info) - -error: aborting due to 39 previous errors - -For more information about this error, try `rustc --explain E0425`. diff --git a/tests/ui/macros/stringify.rs b/tests/ui/macros/stringify.rs index 3f3d9252adb..fa06da5cbfb 100644 --- a/tests/ui/macros/stringify.rs +++ b/tests/ui/macros/stringify.rs @@ -1,5 +1,5 @@ //@ run-pass -//@ edition:2021 +//@ edition:2024 //@ compile-flags: --test #![allow(incomplete_features)] @@ -10,7 +10,6 @@ #![feature(decl_macro)] #![feature(explicit_tail_calls)] #![feature(if_let_guard)] -#![feature(let_chains)] #![feature(more_qualified_paths)] #![feature(never_patterns)] #![feature(trait_alias)] @@ -483,7 +482,6 @@ fn test_item() { c1!(item, [ impl<T> Struct<T> {} ], "impl<T> Struct<T> {}"); c1!(item, [ pub impl Trait for Struct {} ], "pub impl Trait for Struct {}"); c1!(item, [ impl<T> const Trait for T {} ], "impl<T> const Trait for T {}"); - c1!(item, [ impl ~const Struct {} ], "impl ~const Struct {}"); // ItemKind::MacCall c1!(item, [ mac!(); ], "mac!();"); @@ -730,7 +728,7 @@ fn test_ty() { c1!(ty, [ dyn Send + 'a ], "dyn Send + 'a"); c1!(ty, [ dyn 'a + Send ], "dyn 'a + Send"); c1!(ty, [ dyn ?Sized ], "dyn ?Sized"); - c1!(ty, [ dyn ~const Clone ], "dyn ~const Clone"); + c1!(ty, [ dyn [const] Clone ], "dyn [const] Clone"); c1!(ty, [ dyn for<'a> Send ], "dyn for<'a> Send"); // TyKind::ImplTrait @@ -738,7 +736,7 @@ fn test_ty() { c1!(ty, [ impl Send + 'a ], "impl Send + 'a"); c1!(ty, [ impl 'a + Send ], "impl 'a + Send"); c1!(ty, [ impl ?Sized ], "impl ?Sized"); - c1!(ty, [ impl ~const Clone ], "impl ~const Clone"); + c1!(ty, [ impl [const] Clone ], "impl [const] Clone"); c1!(ty, [ impl for<'a> Send ], "impl for<'a> Send"); // TyKind::Paren diff --git a/tests/ui/malformed/malformed-regressions.stderr b/tests/ui/malformed/malformed-regressions.stderr index 535db55a13d..8c22919a1c2 100644 --- a/tests/ui/malformed/malformed-regressions.stderr +++ b/tests/ui/malformed/malformed-regressions.stderr @@ -8,15 +8,6 @@ LL | #[doc] = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> = note: `#[deny(ill_formed_attribute_input)]` on by default -error: valid forms for the attribute are `#[ignore]` and `#[ignore = "reason"]` - --> $DIR/malformed-regressions.rs:3:1 - | -LL | #[ignore()] - | ^^^^^^^^^^^ - | - = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! - = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> - error: attribute must be of the form `#[link(name = "...", /*opt*/ kind = "dylib|static|...", /*opt*/ wasm_import_module = "...", /*opt*/ import_name_type = "decorated|noprefix|undecorated")]` --> $DIR/malformed-regressions.rs:7:1 | @@ -35,6 +26,15 @@ LL | #[link = ""] = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> +error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` + --> $DIR/malformed-regressions.rs:3:1 + | +LL | #[ignore()] + | ^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> + error: valid forms for the attribute are `#[inline(always|never)]` and `#[inline]` --> $DIR/malformed-regressions.rs:5:1 | diff --git a/tests/ui/maximal_mir_to_hir_coverage.rs b/tests/ui/maximal_mir_to_hir_coverage.rs deleted file mode 100644 index e57c83d007e..00000000000 --- a/tests/ui/maximal_mir_to_hir_coverage.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ compile-flags: -Zmaximal-hir-to-mir-coverage -//@ run-pass - -// Just making sure this flag is accepted and doesn't crash the compiler - -fn main() { - let x = 1; - let y = x + 1; - println!("{y}"); -} diff --git a/tests/ui/maybe-bounds.rs b/tests/ui/maybe-bounds.rs deleted file mode 100644 index 02ed45c656f..00000000000 --- a/tests/ui/maybe-bounds.rs +++ /dev/null @@ -1,9 +0,0 @@ -trait Tr: ?Sized {} -//~^ ERROR `?Trait` is not permitted in supertraits - -type A1 = dyn Tr + (?Sized); -//~^ ERROR `?Trait` is not permitted in trait object types -type A2 = dyn for<'a> Tr + (?Sized); -//~^ ERROR `?Trait` is not permitted in trait object types - -fn main() {} diff --git a/tests/ui/method-output-diff-issue-127263.rs b/tests/ui/method-output-diff-issue-127263.rs deleted file mode 100644 index 85a903e2453..00000000000 --- a/tests/ui/method-output-diff-issue-127263.rs +++ /dev/null @@ -1,8 +0,0 @@ -fn bar() {} -fn foo(x: i32) -> u32 { - 0 -} -fn main() { - let b: fn() -> u32 = bar; //~ ERROR mismatched types [E0308] - let f: fn(i32) = foo; //~ ERROR mismatched types [E0308] -} diff --git a/tests/ui/methods/dont-ice-on-object-lookup-w-error-region.stderr b/tests/ui/methods/dont-ice-on-object-lookup-w-error-region.stderr index 2c33941be43..00267ce359a 100644 --- a/tests/ui/methods/dont-ice-on-object-lookup-w-error-region.stderr +++ b/tests/ui/methods/dont-ice-on-object-lookup-w-error-region.stderr @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'missing` --> $DIR/dont-ice-on-object-lookup-w-error-region.rs:6:20 | LL | fn project(x: Pin<&'missing mut dyn Future<Output = ()>>) { - | - ^^^^^^^^ undeclared lifetime - | | - | help: consider introducing lifetime `'missing` here: `<'missing>` + | ^^^^^^^^ undeclared lifetime + | +help: consider introducing lifetime `'missing` here + | +LL | fn project<'missing>(x: Pin<&'missing mut dyn Future<Output = ()>>) { + | ++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/methods/filter-relevant-fn-bounds.rs b/tests/ui/methods/filter-relevant-fn-bounds.rs index 76ececf7baa..6233c9db53a 100644 --- a/tests/ui/methods/filter-relevant-fn-bounds.rs +++ b/tests/ui/methods/filter-relevant-fn-bounds.rs @@ -7,11 +7,10 @@ struct Wrapper; impl Wrapper { fn do_something_wrapper<O, F>(self, _: F) //~^ ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied - //~| ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied where F: for<'a> FnOnce(<F as Output<'a>>::Type), - //~^ ERROR the trait bound `F: Output<'_>` is not satisfied - //~| ERROR the trait bound `F: Output<'_>` is not satisfied + //~^ ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied + //~| ERROR the trait bound `for<'a> F: Output<'a>` is not satisfied { } } diff --git a/tests/ui/methods/filter-relevant-fn-bounds.stderr b/tests/ui/methods/filter-relevant-fn-bounds.stderr index 0e00adf6ea6..82103e62ddf 100644 --- a/tests/ui/methods/filter-relevant-fn-bounds.stderr +++ b/tests/ui/methods/filter-relevant-fn-bounds.stderr @@ -3,7 +3,6 @@ error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied | LL | / fn do_something_wrapper<O, F>(self, _: F) LL | | -LL | | LL | | where LL | | F: for<'a> FnOnce(<F as Output<'a>>::Type), | |___________________________________________________^ the trait `for<'a> Output<'a>` is not implemented for `F` @@ -14,54 +13,43 @@ LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + for<'a> Output<'a>, | ++++++++++++++++++++ error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied - --> $DIR/filter-relevant-fn-bounds.rs:8:8 + --> $DIR/filter-relevant-fn-bounds.rs:11:12 | -LL | fn do_something_wrapper<O, F>(self, _: F) - | ^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F` +LL | F: for<'a> FnOnce(<F as Output<'a>>::Type), + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F` | help: consider further restricting type parameter `F` with trait `Output` | LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + for<'a> Output<'a>, | ++++++++++++++++++++ -error[E0277]: the trait bound `F: Output<'_>` is not satisfied - --> $DIR/filter-relevant-fn-bounds.rs:12:12 - | -LL | F: for<'a> FnOnce(<F as Output<'a>>::Type), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Output<'_>` is not implemented for `F` - | -help: consider further restricting type parameter `F` with trait `Output` - | -LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + Output<'_>, - | ++++++++++++ - -error[E0277]: the trait bound `F: Output<'_>` is not satisfied - --> $DIR/filter-relevant-fn-bounds.rs:12:20 +error[E0277]: the trait bound `for<'a> F: Output<'a>` is not satisfied + --> $DIR/filter-relevant-fn-bounds.rs:11:20 | LL | F: for<'a> FnOnce(<F as Output<'a>>::Type), - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Output<'_>` is not implemented for `F` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `for<'a> Output<'a>` is not implemented for `F` | help: consider further restricting type parameter `F` with trait `Output` | -LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + Output<'_>, - | ++++++++++++ +LL | F: for<'a> FnOnce(<F as Output<'a>>::Type) + for<'a> Output<'a>, + | ++++++++++++++++++++ -error[E0277]: expected a `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41}` - --> $DIR/filter-relevant-fn-bounds.rs:21:34 +error[E0277]: expected a `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}` + --> $DIR/filter-relevant-fn-bounds.rs:20:34 | LL | wrapper.do_something_wrapper(|value| ()); - | -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41}` + | -------------------- ^^^^^^^^^^ expected an `FnOnce(<{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41} as Output<'a>>::Type)` closure, found `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:21:34: 21:41}` + = help: the trait `for<'a> Output<'a>` is not implemented for closure `{closure@$DIR/filter-relevant-fn-bounds.rs:20:34: 20:41}` help: this trait has no implementations, consider adding one --> $DIR/filter-relevant-fn-bounds.rs:1:1 | LL | trait Output<'a> { | ^^^^^^^^^^^^^^^^ note: required by a bound in `Wrapper::do_something_wrapper` - --> $DIR/filter-relevant-fn-bounds.rs:12:12 + --> $DIR/filter-relevant-fn-bounds.rs:11:12 | LL | fn do_something_wrapper<O, F>(self, _: F) | -------------------- required by a bound in this associated function @@ -69,6 +57,6 @@ LL | fn do_something_wrapper<O, F>(self, _: F) LL | F: for<'a> FnOnce(<F as Output<'a>>::Type), | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `Wrapper::do_something_wrapper` -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/methods/method-call-lifetime-args-unresolved.stderr b/tests/ui/methods/method-call-lifetime-args-unresolved.stderr index c72e7e0cdc3..d3bd74a49fb 100644 --- a/tests/ui/methods/method-call-lifetime-args-unresolved.stderr +++ b/tests/ui/methods/method-call-lifetime-args-unresolved.stderr @@ -1,10 +1,13 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/method-call-lifetime-args-unresolved.rs:2:15 | -LL | fn main() { - | - help: consider introducing lifetime `'a` here: `<'a>` LL | 0.clone::<'a>(); | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn main<'a>() { + | ++++ warning: cannot specify lifetime arguments explicitly if late bound lifetime parameters are present --> $DIR/method-call-lifetime-args-unresolved.rs:2:15 diff --git a/tests/ui/methods/method-missing-call.rs b/tests/ui/methods/method-missing-call.rs deleted file mode 100644 index 7ce1e9a4f1b..00000000000 --- a/tests/ui/methods/method-missing-call.rs +++ /dev/null @@ -1,30 +0,0 @@ -// Tests to make sure that parens are needed for method calls without arguments. -// outputs text to make sure either an anonymous function is provided or -// open-close '()' parens are given - - -struct Point { - x: isize, - y: isize -} -impl Point { - fn new() -> Point { - Point{x:0, y:0} - } - fn get_x(&self) -> isize { - self.x - } -} - -fn main() { - let point: Point = Point::new(); - let px: isize = point - .get_x;//~ ERROR attempted to take value of method `get_x` on type `Point` - - // Ensure the span is useful - let ys = &[1,2,3,4,5,6,7]; - let a = ys.iter() - .map(|x| x) - .filter(|&&x| x == 1) - .filter_map; //~ ERROR attempted to take value of method `filter_map` on type -} diff --git a/tests/ui/methods/method-missing-call.stderr b/tests/ui/methods/method-missing-call.stderr deleted file mode 100644 index bc508461b69..00000000000 --- a/tests/ui/methods/method-missing-call.stderr +++ /dev/null @@ -1,25 +0,0 @@ -error[E0615]: attempted to take value of method `get_x` on type `Point` - --> $DIR/method-missing-call.rs:22:26 - | -LL | .get_x; - | ^^^^^ method, not a field - | -help: use parentheses to call the method - | -LL | .get_x(); - | ++ - -error[E0615]: attempted to take value of method `filter_map` on type `Filter<Map<std::slice::Iter<'_, {integer}>, {closure@$DIR/method-missing-call.rs:27:20: 27:23}>, {closure@$DIR/method-missing-call.rs:28:23: 28:28}>` - --> $DIR/method-missing-call.rs:29:16 - | -LL | .filter_map; - | ^^^^^^^^^^ method, not a field - | -help: use parentheses to call the method - | -LL | .filter_map(_); - | +++ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0615`. diff --git a/tests/ui/methods/method-value-without-call.rs b/tests/ui/methods/method-value-without-call.rs new file mode 100644 index 00000000000..43bee4864b4 --- /dev/null +++ b/tests/ui/methods/method-value-without-call.rs @@ -0,0 +1,33 @@ +//! Test taking a method value without parentheses + +struct Point { + x: isize, + y: isize, +} + +impl Point { + fn new() -> Point { + Point { x: 0, y: 0 } + } + + fn get_x(&self) -> isize { + self.x + } +} + +fn main() { + // Test with primitive type method + let _f = 10i32.abs; //~ ERROR attempted to take value of method + + // Test with custom type method + let point: Point = Point::new(); + let px: isize = point.get_x; //~ ERROR attempted to take value of method `get_x` on type `Point` + + // Test with method chains - ensure the span is useful + let ys = &[1, 2, 3, 4, 5, 6, 7]; + let a = ys + .iter() + .map(|x| x) + .filter(|&&x| x == 1) + .filter_map; //~ ERROR attempted to take value of method `filter_map` on type +} diff --git a/tests/ui/methods/method-value-without-call.stderr b/tests/ui/methods/method-value-without-call.stderr new file mode 100644 index 00000000000..0c3870e2868 --- /dev/null +++ b/tests/ui/methods/method-value-without-call.stderr @@ -0,0 +1,36 @@ +error[E0615]: attempted to take value of method `abs` on type `i32` + --> $DIR/method-value-without-call.rs:20:20 + | +LL | let _f = 10i32.abs; + | ^^^ method, not a field + | +help: use parentheses to call the method + | +LL | let _f = 10i32.abs(); + | ++ + +error[E0615]: attempted to take value of method `get_x` on type `Point` + --> $DIR/method-value-without-call.rs:24:27 + | +LL | let px: isize = point.get_x; + | ^^^^^ method, not a field + | +help: use parentheses to call the method + | +LL | let px: isize = point.get_x(); + | ++ + +error[E0615]: attempted to take value of method `filter_map` on type `Filter<Map<std::slice::Iter<'_, {integer}>, {closure@$DIR/method-value-without-call.rs:30:14: 30:17}>, {closure@$DIR/method-value-without-call.rs:31:17: 31:22}>` + --> $DIR/method-value-without-call.rs:32:10 + | +LL | .filter_map; + | ^^^^^^^^^^ method, not a field + | +help: use parentheses to call the method + | +LL | .filter_map(_); + | +++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0615`. diff --git a/tests/ui/methods/suggest-convert-ptr-to-ref.stderr b/tests/ui/methods/suggest-convert-ptr-to-ref.stderr index 7d52b20121e..8cb97ea458b 100644 --- a/tests/ui/methods/suggest-convert-ptr-to-ref.stderr +++ b/tests/ui/methods/suggest-convert-ptr-to-ref.stderr @@ -2,7 +2,7 @@ error[E0599]: `*const u8` doesn't implement `std::fmt::Display` --> $DIR/suggest-convert-ptr-to-ref.rs:5:22 | LL | println!("{}", z.to_string()); - | ^^^^^^^^^ `*const u8` cannot be formatted with the default formatter + | ^^^^^^^^^ method cannot be called on `*const u8` due to unsatisfied trait bounds | note: the method `to_string` exists on the type `&u8` --> $SRC_DIR/alloc/src/string.rs:LL:COL @@ -11,13 +11,12 @@ note: the method `to_string` exists on the type `&u8` = note: the following trait bounds were not satisfied: `*const u8: std::fmt::Display` which is required by `*const u8: ToString` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead error[E0599]: `*mut u8` doesn't implement `std::fmt::Display` --> $DIR/suggest-convert-ptr-to-ref.rs:8:22 | LL | println!("{}", t.to_string()); - | ^^^^^^^^^ `*mut u8` cannot be formatted with the default formatter + | ^^^^^^^^^ method cannot be called on `*mut u8` due to unsatisfied trait bounds | note: the method `to_string` exists on the type `&&mut u8` --> $SRC_DIR/alloc/src/string.rs:LL:COL @@ -26,7 +25,6 @@ note: the method `to_string` exists on the type `&&mut u8` = note: the following trait bounds were not satisfied: `*mut u8: std::fmt::Display` which is required by `*mut u8: ToString` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead error[E0599]: no method named `make_ascii_lowercase` found for raw pointer `*mut u8` in the current scope --> $DIR/suggest-convert-ptr-to-ref.rs:9:7 diff --git a/tests/ui/mir/enum/convert_non_enum_break.rs b/tests/ui/mir/enum/convert_non_enum_break.rs new file mode 100644 index 00000000000..de062c39907 --- /dev/null +++ b/tests/ui/mir/enum/convert_non_enum_break.rs @@ -0,0 +1,20 @@ +//@ run-fail +//@ compile-flags: -C debug-assertions +//@ error-pattern: trying to construct an enum from an invalid value 0x10000 + +#[allow(dead_code)] +#[repr(u32)] +enum Foo { + A, + B, +} + +#[allow(dead_code)] +struct Bar { + a: u16, + b: u16, +} + +fn main() { + let _val: Foo = unsafe { std::mem::transmute::<_, Foo>(Bar { a: 0, b: 1 }) }; +} diff --git a/tests/ui/mir/enum/convert_non_enum_niche_break.rs b/tests/ui/mir/enum/convert_non_enum_niche_break.rs new file mode 100644 index 00000000000..9ff4849c5b1 --- /dev/null +++ b/tests/ui/mir/enum/convert_non_enum_niche_break.rs @@ -0,0 +1,27 @@ +//@ run-fail +//@ compile-flags: -C debug-assertions +//@ error-pattern: trying to construct an enum from an invalid value 0x5 + +#[allow(dead_code)] +#[repr(u16)] +enum Mix { + A, + B(u16), +} + +#[allow(dead_code)] +enum Nested { + C(Mix), + D, + E, +} + +#[allow(dead_code)] +struct Bar { + a: u16, + b: u16, +} + +fn main() { + let _val: Nested = unsafe { std::mem::transmute::<_, Nested>(Bar { a: 5, b: 0 }) }; +} diff --git a/tests/ui/mir/enum/convert_non_enum_niche_ok.rs b/tests/ui/mir/enum/convert_non_enum_niche_ok.rs new file mode 100644 index 00000000000..24027da5458 --- /dev/null +++ b/tests/ui/mir/enum/convert_non_enum_niche_ok.rs @@ -0,0 +1,29 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions + +#[allow(dead_code)] +#[repr(u16)] +enum Mix { + A, + B(u16), +} + +#[allow(dead_code)] +enum Nested { + C(Mix), + D, + E, +} + +#[allow(dead_code)] +struct Bar { + a: u16, + b: u16, +} + +fn main() { + let _val: Nested = unsafe { std::mem::transmute::<_, Nested>(Bar { a: 0, b: 0 }) }; + let _val: Nested = unsafe { std::mem::transmute::<_, Nested>(Bar { a: 1, b: 0 }) }; + let _val: Nested = unsafe { std::mem::transmute::<_, Nested>(Bar { a: 2, b: 0 }) }; + let _val: Nested = unsafe { std::mem::transmute::<_, Nested>(Bar { a: 3, b: 0 }) }; +} diff --git a/tests/ui/mir/enum/convert_non_enum_ok.rs b/tests/ui/mir/enum/convert_non_enum_ok.rs new file mode 100644 index 00000000000..37fc64342ca --- /dev/null +++ b/tests/ui/mir/enum/convert_non_enum_ok.rs @@ -0,0 +1,20 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions + +#[allow(dead_code)] +#[repr(u32)] +enum Foo { + A, + B, +} + +#[allow(dead_code)] +struct Bar { + a: u16, + b: u16, +} + +fn main() { + let _val: Foo = unsafe { std::mem::transmute::<_, Foo>(Bar { a: 0, b: 0 }) }; + let _val: Foo = unsafe { std::mem::transmute::<_, Foo>(Bar { a: 1, b: 0 }) }; +} diff --git a/tests/ui/mir/enum/negative_discr_break.rs b/tests/ui/mir/enum/negative_discr_break.rs new file mode 100644 index 00000000000..fa1284f72a0 --- /dev/null +++ b/tests/ui/mir/enum/negative_discr_break.rs @@ -0,0 +1,14 @@ +//@ run-fail +//@ compile-flags: -C debug-assertions +//@ error-pattern: trying to construct an enum from an invalid value 0xfd + +#[allow(dead_code)] +enum Foo { + A = -2, + B = -1, + C = 1, +} + +fn main() { + let _val: Foo = unsafe { std::mem::transmute::<i8, Foo>(-3) }; +} diff --git a/tests/ui/mir/enum/negative_discr_ok.rs b/tests/ui/mir/enum/negative_discr_ok.rs new file mode 100644 index 00000000000..5c15b33fa84 --- /dev/null +++ b/tests/ui/mir/enum/negative_discr_ok.rs @@ -0,0 +1,53 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions + +#[allow(dead_code)] +#[derive(Debug, PartialEq)] +enum Foo { + A = -12121, + B = -2, + C = -1, + D = 1, + E = 2, + F = 12121, +} + +#[allow(dead_code)] +#[repr(i64)] +#[derive(Debug, PartialEq)] +enum Bar { + A = i64::MIN, + B = -2, + C = -1, + D = 1, + E = 2, + F = i64::MAX, +} + +fn main() { + let val: Foo = unsafe { std::mem::transmute::<i16, Foo>(-12121) }; + assert_eq!(val, Foo::A); + let val: Foo = unsafe { std::mem::transmute::<i16, Foo>(-2) }; + assert_eq!(val, Foo::B); + let val: Foo = unsafe { std::mem::transmute::<i16, Foo>(-1) }; + assert_eq!(val, Foo::C); + let val: Foo = unsafe { std::mem::transmute::<i16, Foo>(1) }; + assert_eq!(val, Foo::D); + let val: Foo = unsafe { std::mem::transmute::<i16, Foo>(2) }; + assert_eq!(val, Foo::E); + let val: Foo = unsafe { std::mem::transmute::<i16, Foo>(12121) }; + assert_eq!(val, Foo::F); + + let val: Bar = unsafe { std::mem::transmute::<i64, Bar>(i64::MIN) }; + assert_eq!(val, Bar::A); + let val: Bar = unsafe { std::mem::transmute::<i64, Bar>(-2) }; + assert_eq!(val, Bar::B); + let val: Bar = unsafe { std::mem::transmute::<i64, Bar>(-1) }; + assert_eq!(val, Bar::C); + let val: Bar = unsafe { std::mem::transmute::<i64, Bar>(1) }; + assert_eq!(val, Bar::D); + let val: Bar = unsafe { std::mem::transmute::<i64, Bar>(2) }; + assert_eq!(val, Bar::E); + let val: Bar = unsafe { std::mem::transmute::<i64, Bar>(i64::MAX) }; + assert_eq!(val, Bar::F); +} diff --git a/tests/ui/mir/enum/niche_option_tuple_break.rs b/tests/ui/mir/enum/niche_option_tuple_break.rs new file mode 100644 index 00000000000..43eef3a4cc5 --- /dev/null +++ b/tests/ui/mir/enum/niche_option_tuple_break.rs @@ -0,0 +1,20 @@ +//@ run-fail +//@ compile-flags: -C debug-assertions +//@ error-pattern: trying to construct an enum from an invalid value 0x3 + +#[allow(dead_code)] +enum Foo { + A, + B, +} + +#[allow(dead_code)] +struct Bar { + a: usize, + b: usize, +} + +fn main() { + let _val: Option<(usize, Foo)> = + unsafe { std::mem::transmute::<_, Option<(usize, Foo)>>(Bar { a: 3, b: 3 }) }; +} diff --git a/tests/ui/mir/enum/niche_option_tuple_ok.rs b/tests/ui/mir/enum/niche_option_tuple_ok.rs new file mode 100644 index 00000000000..71c885c7edb --- /dev/null +++ b/tests/ui/mir/enum/niche_option_tuple_ok.rs @@ -0,0 +1,21 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions + +#[allow(dead_code)] +enum Foo { + A, + B, +} + +#[allow(dead_code)] +struct Bar { + a: usize, + b: usize, +} + +fn main() { + let _val: Option<(usize, Foo)> = + unsafe { std::mem::transmute::<_, Option<(usize, Foo)>>(Bar { a: 0, b: 0 }) }; + let _val: Option<(usize, Foo)> = + unsafe { std::mem::transmute::<_, Option<(usize, Foo)>>(Bar { a: 1, b: 0 }) }; +} diff --git a/tests/ui/mir/enum/numbered_variants_break.rs b/tests/ui/mir/enum/numbered_variants_break.rs new file mode 100644 index 00000000000..e3e71dc8aec --- /dev/null +++ b/tests/ui/mir/enum/numbered_variants_break.rs @@ -0,0 +1,13 @@ +//@ run-fail +//@ compile-flags: -C debug-assertions +//@ error-pattern: trying to construct an enum from an invalid value 0x3 + +#[allow(dead_code)] +enum Foo { + A, + B, +} + +fn main() { + let _val: Foo = unsafe { std::mem::transmute::<u8, Foo>(3) }; +} diff --git a/tests/ui/mir/enum/numbered_variants_ok.rs b/tests/ui/mir/enum/numbered_variants_ok.rs new file mode 100644 index 00000000000..995a2f6511b --- /dev/null +++ b/tests/ui/mir/enum/numbered_variants_ok.rs @@ -0,0 +1,13 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions + +#[allow(dead_code)] +enum Foo { + A, + B, +} + +fn main() { + let _val: Foo = unsafe { std::mem::transmute::<u8, Foo>(0) }; + let _val: Foo = unsafe { std::mem::transmute::<u8, Foo>(1) }; +} diff --git a/tests/ui/mir/enum/option_with_bigger_niche_break.rs b/tests/ui/mir/enum/option_with_bigger_niche_break.rs new file mode 100644 index 00000000000..c66614b845b --- /dev/null +++ b/tests/ui/mir/enum/option_with_bigger_niche_break.rs @@ -0,0 +1,14 @@ +//@ run-fail +//@ compile-flags: -C debug-assertions +//@ error-pattern: trying to construct an enum from an invalid value 0x0 + +#[repr(u32)] +#[allow(dead_code)] +enum Foo { + A = 2, + B, +} + +fn main() { + let _val: Option<Foo> = unsafe { std::mem::transmute::<u32, Option<Foo>>(0) }; +} diff --git a/tests/ui/mir/enum/option_with_bigger_niche_ok.rs b/tests/ui/mir/enum/option_with_bigger_niche_ok.rs new file mode 100644 index 00000000000..1d44ffd28fc --- /dev/null +++ b/tests/ui/mir/enum/option_with_bigger_niche_ok.rs @@ -0,0 +1,14 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions + +#[repr(u32)] +#[allow(dead_code)] +enum Foo { + A = 2, + B, +} + +fn main() { + let _val: Option<Foo> = unsafe { std::mem::transmute::<u32, Option<Foo>>(2) }; + let _val: Option<Foo> = unsafe { std::mem::transmute::<u32, Option<Foo>>(3) }; +} diff --git a/tests/ui/mir/enum/plain_no_data_break.rs b/tests/ui/mir/enum/plain_no_data_break.rs new file mode 100644 index 00000000000..db68e752479 --- /dev/null +++ b/tests/ui/mir/enum/plain_no_data_break.rs @@ -0,0 +1,14 @@ +//@ run-fail +//@ compile-flags: -C debug-assertions +//@ error-pattern: trying to construct an enum from an invalid value 0x1 + +#[repr(u32)] +#[allow(dead_code)] +enum Foo { + A = 2, + B, +} + +fn main() { + let _val: Foo = unsafe { std::mem::transmute::<u32, Foo>(1) }; +} diff --git a/tests/ui/mir/enum/plain_no_data_ok.rs b/tests/ui/mir/enum/plain_no_data_ok.rs new file mode 100644 index 00000000000..bbdc18f96dc --- /dev/null +++ b/tests/ui/mir/enum/plain_no_data_ok.rs @@ -0,0 +1,14 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions + +#[repr(u32)] +#[allow(dead_code)] +enum Foo { + A = 2, + B, +} + +fn main() { + let _val: Foo = unsafe { std::mem::transmute::<u32, Foo>(2) }; + let _val: Foo = unsafe { std::mem::transmute::<u32, Foo>(3) }; +} diff --git a/tests/ui/mir/enum/single_ok.rs b/tests/ui/mir/enum/single_ok.rs new file mode 100644 index 00000000000..06b5a237c68 --- /dev/null +++ b/tests/ui/mir/enum/single_ok.rs @@ -0,0 +1,11 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions + +#[allow(dead_code)] +enum Single { + A +} + +fn main() { + let _val: Single = unsafe { std::mem::transmute::<(), Single>(()) }; +} diff --git a/tests/ui/mir/enum/single_with_repr_break.rs b/tests/ui/mir/enum/single_with_repr_break.rs new file mode 100644 index 00000000000..5a4ec85a9b5 --- /dev/null +++ b/tests/ui/mir/enum/single_with_repr_break.rs @@ -0,0 +1,13 @@ +//@ run-fail +//@ compile-flags: -C debug-assertions +//@ error-pattern: trying to construct an enum from an invalid value 0x1 + +#[allow(dead_code)] +#[repr(u16)] +enum Single { + A +} + +fn main() { + let _val: Single = unsafe { std::mem::transmute::<u16, Single>(1) }; +} diff --git a/tests/ui/mir/enum/single_with_repr_ok.rs b/tests/ui/mir/enum/single_with_repr_ok.rs new file mode 100644 index 00000000000..b0ed2bad660 --- /dev/null +++ b/tests/ui/mir/enum/single_with_repr_ok.rs @@ -0,0 +1,12 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions + +#[allow(dead_code)] +#[repr(u16)] +enum Single { + A +} + +fn main() { + let _val: Single = unsafe { std::mem::transmute::<u16, Single>(0) }; +} diff --git a/tests/ui/mir/enum/with_niche_int_break.rs b/tests/ui/mir/enum/with_niche_int_break.rs new file mode 100644 index 00000000000..0ec60a33564 --- /dev/null +++ b/tests/ui/mir/enum/with_niche_int_break.rs @@ -0,0 +1,21 @@ +//@ run-fail +//@ compile-flags: -C debug-assertions +//@ error-pattern: trying to construct an enum from an invalid value 0x4 + +#[allow(dead_code)] +#[repr(u16)] +enum Mix { + A, + B(u16), +} + +#[allow(dead_code)] +enum Nested { + C(Mix), + D, + E, +} + +fn main() { + let _val: Nested = unsafe { std::mem::transmute::<u32, Nested>(4) }; +} diff --git a/tests/ui/mir/enum/with_niche_int_ok.rs b/tests/ui/mir/enum/with_niche_int_ok.rs new file mode 100644 index 00000000000..9a3ff3a73be --- /dev/null +++ b/tests/ui/mir/enum/with_niche_int_ok.rs @@ -0,0 +1,23 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions + +#[allow(dead_code)] +#[repr(u16)] +enum Mix { + A, + B(u16), +} + +#[allow(dead_code)] +enum Nested { + C(Mix), + D, + E, +} + +fn main() { + let _val: Nested = unsafe { std::mem::transmute::<u32, Nested>(0) }; + let _val: Nested = unsafe { std::mem::transmute::<u32, Nested>(1) }; + let _val: Nested = unsafe { std::mem::transmute::<u32, Nested>(2) }; + let _val: Nested = unsafe { std::mem::transmute::<u32, Nested>(3) }; +} diff --git a/tests/ui/mir/enum/with_niche_ptr_ok.rs b/tests/ui/mir/enum/with_niche_ptr_ok.rs new file mode 100644 index 00000000000..969d955f7a4 --- /dev/null +++ b/tests/ui/mir/enum/with_niche_ptr_ok.rs @@ -0,0 +1,14 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions + +fn main() { + let _val = unsafe { + std::mem::transmute::<*const usize, Option<unsafe extern "C" fn()>>(std::ptr::null()) + }; + let _val = unsafe { + std::mem::transmute::<*const usize, Option<unsafe extern "C" fn()>>(usize::MAX as *const _) + }; + let _val = unsafe { std::mem::transmute::<usize, Option<unsafe extern "C" fn()>>(0) }; + let _val = unsafe { std::mem::transmute::<usize, Option<unsafe extern "C" fn()>>(1) }; + let _val = unsafe { std::mem::transmute::<usize, Option<unsafe extern "C" fn()>>(usize::MAX) }; +} diff --git a/tests/ui/mir/enum/wrap_break.rs b/tests/ui/mir/enum/wrap_break.rs new file mode 100644 index 00000000000..4491394ca5a --- /dev/null +++ b/tests/ui/mir/enum/wrap_break.rs @@ -0,0 +1,14 @@ +//@ run-fail +//@ compile-flags: -C debug-assertions +//@ error-pattern: trying to construct an enum from an invalid value 0x0 +#![feature(never_type)] +#![allow(invalid_value)] + +#[allow(dead_code)] +enum Wrap { + A(!), +} + +fn main() { + let _val: Wrap = unsafe { std::mem::transmute::<(), Wrap>(()) }; +} diff --git a/tests/ui/mir/enum/wrap_ok.rs b/tests/ui/mir/enum/wrap_ok.rs new file mode 100644 index 00000000000..2881675c9ce --- /dev/null +++ b/tests/ui/mir/enum/wrap_ok.rs @@ -0,0 +1,12 @@ +//@ run-pass +//@ compile-flags: -C debug-assertions + +#[allow(dead_code)] +enum Wrap { + A(u32), +} + +fn main() { + let _val: Wrap = unsafe { std::mem::transmute::<u32, Wrap>(2) }; + let _val: Wrap = unsafe { std::mem::transmute::<u32, Wrap>(u32::MAX) }; +} diff --git a/tests/ui/mir/mir_let_chains_drop_order.rs b/tests/ui/mir/mir_let_chains_drop_order.rs index 4794f3427dd..8a54f21b57f 100644 --- a/tests/ui/mir/mir_let_chains_drop_order.rs +++ b/tests/ui/mir/mir_let_chains_drop_order.rs @@ -1,12 +1,9 @@ //@ run-pass //@ needs-unwind -//@ revisions: edition2021 edition2024 -//@ [edition2021] edition: 2021 -//@ [edition2024] edition: 2024 +//@ edition: 2024 // See `mir_drop_order.rs` for more information -#![cfg_attr(edition2021, feature(let_chains))] #![allow(irrefutable_let_patterns)] use std::cell::RefCell; @@ -64,9 +61,6 @@ fn main() { d(10, None) }, ); - #[cfg(edition2021)] - assert_eq!(get(), vec![8, 7, 1, 3, 2]); - #[cfg(edition2024)] assert_eq!(get(), vec![3, 2, 8, 7, 1]); } assert_eq!(get(), vec![0, 4, 6, 9, 5]); @@ -101,8 +95,5 @@ fn main() { panic::panic_any(InjectedFailure), ); }); - #[cfg(edition2021)] - assert_eq!(get(), vec![20, 17, 15, 11, 19, 18, 16, 12, 14, 13]); - #[cfg(edition2024)] assert_eq!(get(), vec![14, 13, 19, 18, 20, 17, 15, 11, 16, 12]); } diff --git a/tests/crashes/131451.rs b/tests/ui/mir/unreachable-loop-jump-threading.rs index cd5b44bad8a..8403906bb5c 100644 --- a/tests/crashes/131451.rs +++ b/tests/ui/mir/unreachable-loop-jump-threading.rs @@ -1,9 +1,10 @@ -//@ known-bug: #131451 +//@ build-pass //@ needs-rustc-debug-assertions //@ compile-flags: -Zmir-enable-passes=+GVN -Zmir-enable-passes=+JumpThreading --crate-type=lib pub fn fun(terminate: bool) { while true {} + //~^ WARN denote infinite loops with `loop { ... }` while !terminate {} } diff --git a/tests/ui/mir/unreachable-loop-jump-threading.stderr b/tests/ui/mir/unreachable-loop-jump-threading.stderr new file mode 100644 index 00000000000..21b174c8021 --- /dev/null +++ b/tests/ui/mir/unreachable-loop-jump-threading.stderr @@ -0,0 +1,10 @@ +warning: denote infinite loops with `loop { ... }` + --> $DIR/unreachable-loop-jump-threading.rs:6:5 + | +LL | while true {} + | ^^^^^^^^^^ help: use `loop` + | + = note: `#[warn(while_true)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/mismatched_types/closure-parameter-type-inference-mismatch.rs b/tests/ui/mismatched_types/closure-parameter-type-inference-mismatch.rs new file mode 100644 index 00000000000..1cd41114bbd --- /dev/null +++ b/tests/ui/mismatched_types/closure-parameter-type-inference-mismatch.rs @@ -0,0 +1,25 @@ +//! Test closure parameter type inference and type mismatch errors. +//! +//! Related to <https://github.com/rust-lang/rust/issues/2093>. + +//@ dont-require-annotations: NOTE + +fn let_in<T, F>(x: T, f: F) +where + F: FnOnce(T), +{ +} + +fn main() { + let_in(3u32, |i| { + assert!(i == 3i32); + //~^ ERROR mismatched types + //~| NOTE expected `u32`, found `i32` + }); + + let_in(3i32, |i| { + assert!(i == 3u32); + //~^ ERROR mismatched types + //~| NOTE expected `i32`, found `u32` + }); +} diff --git a/tests/ui/mismatched_types/closure-parameter-type-inference-mismatch.stderr b/tests/ui/mismatched_types/closure-parameter-type-inference-mismatch.stderr new file mode 100644 index 00000000000..c75e90ce4ef --- /dev/null +++ b/tests/ui/mismatched_types/closure-parameter-type-inference-mismatch.stderr @@ -0,0 +1,31 @@ +error[E0308]: mismatched types + --> $DIR/closure-parameter-type-inference-mismatch.rs:15:22 + | +LL | assert!(i == 3i32); + | - ^^^^ expected `u32`, found `i32` + | | + | expected because this is `u32` + | +help: change the type of the numeric literal from `i32` to `u32` + | +LL - assert!(i == 3i32); +LL + assert!(i == 3u32); + | + +error[E0308]: mismatched types + --> $DIR/closure-parameter-type-inference-mismatch.rs:21:22 + | +LL | assert!(i == 3u32); + | - ^^^^ expected `i32`, found `u32` + | | + | expected because this is `i32` + | +help: change the type of the numeric literal from `u32` to `i32` + | +LL - assert!(i == 3u32); +LL + assert!(i == 3i32); + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/mismatched_types/elide-on-tuple-mismatch.rs b/tests/ui/mismatched_types/elide-on-tuple-mismatch.rs new file mode 100644 index 00000000000..c36d041d296 --- /dev/null +++ b/tests/ui/mismatched_types/elide-on-tuple-mismatch.rs @@ -0,0 +1,25 @@ +//! Regression test for issue #50333: elide irrelevant E0277 errors on tuple mismatch + +// Hide irrelevant E0277 errors (#50333) + +trait T {} + +struct A; + +impl T for A {} + +impl A { + fn new() -> Self { + Self {} + } +} + +fn main() { + // This creates a tuple type mismatch: 2-element tuple destructured into 3 variables + let (a, b, c) = (A::new(), A::new()); + //~^ ERROR mismatched types + + // This line should NOT produce an E0277 error about `Sized` trait bounds, + // because `a`, `b`, and `c` are `TyErr` due to the mismatch above + let _ts: Vec<&dyn T> = vec![&a, &b, &c]; +} diff --git a/tests/ui/elide-errors-on-mismatched-tuple.stderr b/tests/ui/mismatched_types/elide-on-tuple-mismatch.stderr index f852a223b42..7de45eb40ca 100644 --- a/tests/ui/elide-errors-on-mismatched-tuple.stderr +++ b/tests/ui/mismatched_types/elide-on-tuple-mismatch.stderr @@ -1,7 +1,7 @@ error[E0308]: mismatched types - --> $DIR/elide-errors-on-mismatched-tuple.rs:14:9 + --> $DIR/elide-on-tuple-mismatch.rs:19:9 | -LL | let (a, b, c) = (A::new(), A::new()); // This tuple is 2 elements, should be three +LL | let (a, b, c) = (A::new(), A::new()); | ^^^^^^^^^ -------------------- this expression has type `(A, A)` | | | expected a tuple with 2 elements, found one with 3 elements diff --git a/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs new file mode 100644 index 00000000000..e28ca3e55b5 --- /dev/null +++ b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.rs @@ -0,0 +1,16 @@ +//! This test checks that when there's a type mismatch between a function item and +//! a function pointer, the error message focuses on the actual type difference +//! (return types, argument types) rather than the confusing "pointer vs item" distinction. +//! +//! See https://github.com/rust-lang/rust/issues/127263 + +fn bar() {} + +fn foo(x: i32) -> u32 { + 0 +} + +fn main() { + let b: fn() -> u32 = bar; //~ ERROR mismatched types [E0308] + let f: fn(i32) = foo; //~ ERROR mismatched types [E0308] +} diff --git a/tests/ui/method-output-diff-issue-127263.stderr b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.stderr index 35b86114f16..8d63f2ea2d3 100644 --- a/tests/ui/method-output-diff-issue-127263.stderr +++ b/tests/ui/mismatched_types/fn-pointer-mismatch-diagnostics.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/method-output-diff-issue-127263.rs:6:26 + --> $DIR/fn-pointer-mismatch-diagnostics.rs:14:26 | LL | let b: fn() -> u32 = bar; | ----------- ^^^ expected fn pointer, found fn item @@ -10,7 +10,7 @@ LL | let b: fn() -> u32 = bar; found fn item `fn() -> () {bar}` error[E0308]: mismatched types - --> $DIR/method-output-diff-issue-127263.rs:7:22 + --> $DIR/fn-pointer-mismatch-diagnostics.rs:15:22 | LL | let f: fn(i32) = foo; | ------- ^^^ expected fn pointer, found fn item diff --git a/tests/ui/integral-variable-unification-error.rs b/tests/ui/mismatched_types/int-float-type-mismatch.rs index 8d1621321e8..b45d02730d9 100644 --- a/tests/ui/integral-variable-unification-error.rs +++ b/tests/ui/mismatched_types/int-float-type-mismatch.rs @@ -1,3 +1,6 @@ +//! Check that a type mismatch error is reported when trying +//! to unify a {float} value assignment to an {integer} variable. + fn main() { let mut x //~ NOTE expected due to the type of this binding = diff --git a/tests/ui/integral-variable-unification-error.stderr b/tests/ui/mismatched_types/int-float-type-mismatch.stderr index 1caa6042fd2..43b8609a49d 100644 --- a/tests/ui/integral-variable-unification-error.stderr +++ b/tests/ui/mismatched_types/int-float-type-mismatch.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/integral-variable-unification-error.rs:5:9 + --> $DIR/int-float-type-mismatch.rs:8:9 | LL | let mut x | ----- expected due to the type of this binding diff --git a/tests/ui/mismatched_types/method-help-unsatisfied-bound.stderr b/tests/ui/mismatched_types/method-help-unsatisfied-bound.stderr index be3a3e2abf1..23bc9dc0f84 100644 --- a/tests/ui/mismatched_types/method-help-unsatisfied-bound.stderr +++ b/tests/ui/mismatched_types/method-help-unsatisfied-bound.stderr @@ -2,9 +2,8 @@ error[E0277]: `Foo` doesn't implement `Debug` --> $DIR/method-help-unsatisfied-bound.rs:5:7 | LL | a.unwrap(); - | ^^^^^^ `Foo` cannot be formatted using `{:?}` + | ^^^^^^ the trait `Debug` is not implemented for `Foo` | - = help: the trait `Debug` is not implemented for `Foo` = note: add `#[derive(Debug)]` to `Foo` or manually `impl Debug for Foo` note: required by a bound in `Result::<T, E>::unwrap` --> $SRC_DIR/core/src/result.rs:LL:COL diff --git a/tests/ui/mismatched_types/transforming-option-ref-issue-127545.rs b/tests/ui/mismatched_types/transforming-option-ref-issue-127545.rs index f589e88f68e..0632b822c55 100644 --- a/tests/ui/mismatched_types/transforming-option-ref-issue-127545.rs +++ b/tests/ui/mismatched_types/transforming-option-ref-issue-127545.rs @@ -2,17 +2,17 @@ #![crate_type = "lib"] pub fn foo(arg: Option<&Vec<i32>>) -> Option<&[i32]> { - arg //~ ERROR 5:5: 5:8: mismatched types [E0308] + arg //~ ERROR mismatched types [E0308] } pub fn bar(arg: Option<&Vec<i32>>) -> &[i32] { - arg.unwrap_or(&[]) //~ ERROR 9:19: 9:22: mismatched types [E0308] + arg.unwrap_or(&[]) //~ ERROR mismatched types [E0308] } pub fn barzz<'a>(arg: Option<&'a Vec<i32>>, v: &'a [i32]) -> &'a [i32] { - arg.unwrap_or(v) //~ ERROR 13:19: 13:20: mismatched types [E0308] + arg.unwrap_or(v) //~ ERROR mismatched types [E0308] } pub fn convert_result(arg: Result<&Vec<i32>, ()>) -> &[i32] { - arg.unwrap_or(&[]) //~ ERROR 17:19: 17:22: mismatched types [E0308] + arg.unwrap_or(&[]) //~ ERROR mismatched types [E0308] } diff --git a/tests/ui/point-to-type-err-cause-on-impl-trait-return-2.rs b/tests/ui/mismatched_types/type-error-diagnostic-in-complex-return.rs index 50f1fe873cb..6711d303eb3 100644 --- a/tests/ui/point-to-type-err-cause-on-impl-trait-return-2.rs +++ b/tests/ui/mismatched_types/type-error-diagnostic-in-complex-return.rs @@ -1,4 +1,8 @@ -fn unrelated() -> Result<(), std::string::ParseError> { // #57664 +//! Regression test for <https://github.com/rust-lang/rust/issues/57664>. +//! Checks that compiler doesn't get confused by `?` operator and complex +//! return types when reporting type mismatches. + +fn unrelated() -> Result<(), std::string::ParseError> { let x = 0; match x { diff --git a/tests/ui/point-to-type-err-cause-on-impl-trait-return-2.stderr b/tests/ui/mismatched_types/type-error-diagnostic-in-complex-return.stderr index 34aaea5b70b..38392fe99d6 100644 --- a/tests/ui/point-to-type-err-cause-on-impl-trait-return-2.stderr +++ b/tests/ui/mismatched_types/type-error-diagnostic-in-complex-return.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/point-to-type-err-cause-on-impl-trait-return-2.rs:9:41 + --> $DIR/type-error-diagnostic-in-complex-return.rs:13:41 | LL | let value: &bool = unsafe { &42 }; | ^^^ expected `&bool`, found `&{integer}` diff --git a/tests/ui/mod-subitem-as-enum-variant.rs b/tests/ui/mod-subitem-as-enum-variant.rs deleted file mode 100644 index 959024c46f4..00000000000 --- a/tests/ui/mod-subitem-as-enum-variant.rs +++ /dev/null @@ -1,9 +0,0 @@ -mod Mod { - pub struct FakeVariant<T>(pub T); -} - -fn main() { - Mod::FakeVariant::<i32>(0); - Mod::<i32>::FakeVariant(0); - //~^ ERROR type arguments are not allowed on module `Mod` [E0109] -} diff --git a/tests/ui/modules/issue-107649.stderr b/tests/ui/modules/issue-107649.stderr index 0d203c1aacb..802ac669a10 100644 --- a/tests/ui/modules/issue-107649.stderr +++ b/tests/ui/modules/issue-107649.stderr @@ -2,11 +2,10 @@ error[E0277]: `Dummy` doesn't implement `Debug` --> $DIR/issue-107649.rs:105:5 | 105 | dbg!(lib::Dummy); - | ^^^^^^^^^^^^^^^^ `Dummy` cannot be formatted using `{:?}` + | ^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `Dummy` | - = help: the trait `Debug` is not implemented for `Dummy` = note: add `#[derive(Debug)]` to `Dummy` or manually `impl Debug for Dummy` - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `Dummy` with `#[derive(Debug)]` --> $DIR/auxiliary/dummy_lib.rs:2:1 | diff --git a/tests/ui/modules/mod-same-item-names.rs b/tests/ui/modules/mod-same-item-names.rs new file mode 100644 index 00000000000..1e9a9caa5fc --- /dev/null +++ b/tests/ui/modules/mod-same-item-names.rs @@ -0,0 +1,15 @@ +//! Test that items with identical names can coexist in different modules + +//@ run-pass + +#![allow(dead_code)] + +mod foo { + pub fn baz() {} +} + +mod bar { + pub fn baz() {} +} + +pub fn main() {} diff --git a/tests/ui/modules/module_suggestion_when_module_not_found/submodule/mod.rs b/tests/ui/modules/module_suggestion_when_module_not_found/submodule/mod.rs new file mode 100644 index 00000000000..cb924172efe --- /dev/null +++ b/tests/ui/modules/module_suggestion_when_module_not_found/submodule/mod.rs @@ -0,0 +1 @@ +//@ ignore-auxiliary diff --git a/tests/ui/modules/module_suggestion_when_module_not_found/submodule2.rs b/tests/ui/modules/module_suggestion_when_module_not_found/submodule2.rs new file mode 100644 index 00000000000..cb924172efe --- /dev/null +++ b/tests/ui/modules/module_suggestion_when_module_not_found/submodule2.rs @@ -0,0 +1 @@ +//@ ignore-auxiliary diff --git a/tests/ui/modules/module_suggestion_when_module_not_found/success.rs b/tests/ui/modules/module_suggestion_when_module_not_found/success.rs new file mode 100644 index 00000000000..888e6ab3f19 --- /dev/null +++ b/tests/ui/modules/module_suggestion_when_module_not_found/success.rs @@ -0,0 +1,4 @@ +//@ ignore-auxiliary + +use submodule3::ferris; // these modules are unresolved. +use submodule4::error; diff --git a/tests/ui/modules/module_suggestion_when_module_not_found/success/compiletest-ignore-dir b/tests/ui/modules/module_suggestion_when_module_not_found/success/compiletest-ignore-dir new file mode 100644 index 00000000000..e69de29bb2d --- /dev/null +++ b/tests/ui/modules/module_suggestion_when_module_not_found/success/compiletest-ignore-dir diff --git a/tests/ui/modules/module_suggestion_when_module_not_found/success/submodule3/mod.rs b/tests/ui/modules/module_suggestion_when_module_not_found/success/submodule3/mod.rs new file mode 100644 index 00000000000..8337712ea57 --- /dev/null +++ b/tests/ui/modules/module_suggestion_when_module_not_found/success/submodule3/mod.rs @@ -0,0 +1 @@ +// diff --git a/tests/ui/modules/module_suggestion_when_module_not_found/success/submodule4.rs b/tests/ui/modules/module_suggestion_when_module_not_found/success/submodule4.rs new file mode 100644 index 00000000000..8337712ea57 --- /dev/null +++ b/tests/ui/modules/module_suggestion_when_module_not_found/success/submodule4.rs @@ -0,0 +1 @@ +// diff --git a/tests/ui/modules/module_suggestion_when_module_not_found/suggestion.rs b/tests/ui/modules/module_suggestion_when_module_not_found/suggestion.rs new file mode 100644 index 00000000000..f4c24bff228 --- /dev/null +++ b/tests/ui/modules/module_suggestion_when_module_not_found/suggestion.rs @@ -0,0 +1,7 @@ +//@ edition:2024 +use submodule::cat; //~ ERROR unresolved import `submodule` +use submodule2::help; //~ ERROR unresolved import `submodule2` +mod success; +fn main() {} +//~? ERROR unresolved import `submodule3` +//~? ERROR unresolved import `submodule4` diff --git a/tests/ui/modules/module_suggestion_when_module_not_found/suggestion.stderr b/tests/ui/modules/module_suggestion_when_module_not_found/suggestion.stderr new file mode 100644 index 00000000000..6375d71c280 --- /dev/null +++ b/tests/ui/modules/module_suggestion_when_module_not_found/suggestion.stderr @@ -0,0 +1,49 @@ +error[E0432]: unresolved import `submodule` + --> $DIR/suggestion.rs:2:5 + | +LL | use submodule::cat; + | ^^^^^^^^^ use of unresolved module or unlinked crate `submodule` + | +help: to make use of source file $DIR/submodule/mod.rs, use `mod submodule` in this file to declare the module + | +LL + mod submodule; + | + +error[E0432]: unresolved import `submodule2` + --> $DIR/suggestion.rs:3:5 + | +LL | use submodule2::help; + | ^^^^^^^^^^ use of unresolved module or unlinked crate `submodule2` + | +help: to make use of source file $DIR/submodule2.rs, use `mod submodule2` in this file to declare the module + | +LL + mod submodule2; + | + +error[E0432]: unresolved import `submodule3` + --> $DIR/success.rs:3:5 + | +LL | use submodule3::ferris; // these modules are unresolved. + | ^^^^^^^^^^ use of unresolved module or unlinked crate `submodule3` + | +help: to make use of source file $DIR/success/submodule3/mod.rs, use `mod submodule3` in this file to declare the module + --> $DIR/suggestion.rs:2:1 + | +LL + mod submodule3; + | + +error[E0432]: unresolved import `submodule4` + --> $DIR/success.rs:4:5 + | +LL | use submodule4::error; + | ^^^^^^^^^^ use of unresolved module or unlinked crate `submodule4` + | +help: to make use of source file $DIR/success/submodule4.rs, use `mod submodule4` in this file to declare the module + --> $DIR/suggestion.rs:2:1 + | +LL + mod submodule4; + | + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/modules/nested-modules-basic.rs b/tests/ui/modules/nested-modules-basic.rs new file mode 100644 index 00000000000..12eccec2808 --- /dev/null +++ b/tests/ui/modules/nested-modules-basic.rs @@ -0,0 +1,19 @@ +//! Basic test for nested module functionality and path resolution + +//@ run-pass + +mod inner { + pub mod inner2 { + pub fn hello() { + println!("hello, modular world"); + } + } + pub fn hello() { + inner2::hello(); + } +} + +pub fn main() { + inner::hello(); + inner::inner2::hello(); +} diff --git a/tests/ui/modules_and_files_visibility/mod_file_disambig.stderr b/tests/ui/modules_and_files_visibility/mod_file_disambig.stderr index f82d613015f..e71a6de2fb9 100644 --- a/tests/ui/modules_and_files_visibility/mod_file_disambig.stderr +++ b/tests/ui/modules_and_files_visibility/mod_file_disambig.stderr @@ -12,7 +12,10 @@ error[E0433]: failed to resolve: use of unresolved module or unlinked crate `mod LL | assert_eq!(mod_file_aux::bar(), 10); | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `mod_file_aux` | - = help: you might be missing a crate named `mod_file_aux` +help: to make use of source file $DIR/mod_file_aux.rs, use `mod mod_file_aux` in this file to declare the module + | +LL + mod mod_file_aux; + | error: aborting due to 2 previous errors diff --git a/tests/ui/monomorphize-abi-alignment.rs b/tests/ui/monomorphize-abi-alignment.rs deleted file mode 100644 index 62df1aca357..00000000000 --- a/tests/ui/monomorphize-abi-alignment.rs +++ /dev/null @@ -1,35 +0,0 @@ -//@ run-pass - -#![allow(non_upper_case_globals)] -#![allow(dead_code)] -/*! - * On x86_64-linux-gnu and possibly other platforms, structs get 8-byte "preferred" alignment, - * but their "ABI" alignment (i.e., what actually matters for data layout) is the largest alignment - * of any field. (Also, `u64` has 8-byte ABI alignment; this is not always true). - * - * On such platforms, if monomorphize uses the "preferred" alignment, then it will unify - * `A` and `B`, even though `S<A>` and `S<B>` have the field `t` at different offsets, - * and apply the wrong instance of the method `unwrap`. - */ - -#[derive(Copy, Clone)] -struct S<T> { i:u8, t:T } - -impl<T> S<T> { - fn unwrap(self) -> T { - self.t - } -} - -#[derive(Copy, Clone, PartialEq, Debug)] -struct A((u32, u32)); - -#[derive(Copy, Clone, PartialEq, Debug)] -struct B(u64); - -pub fn main() { - static Ca: S<A> = S { i: 0, t: A((13, 104)) }; - static Cb: S<B> = S { i: 0, t: B(31337) }; - assert_eq!(Ca.unwrap(), A((13, 104))); - assert_eq!(Cb.unwrap(), B(31337)); -} diff --git a/tests/ui/moves/moves-based-on-type-capture-clause-bad.fixed b/tests/ui/moves/moves-based-on-type-capture-clause-bad.fixed new file mode 100644 index 00000000000..04a183ca96b --- /dev/null +++ b/tests/ui/moves/moves-based-on-type-capture-clause-bad.fixed @@ -0,0 +1,11 @@ +//@ run-rustfix +use std::thread; + +fn main() { + let x = "Hello world!".to_string(); + let value = x.clone(); + thread::spawn(move || { + println!("{}", value); + }); + println!("{}", x); //~ ERROR borrow of moved value +} diff --git a/tests/ui/moves/moves-based-on-type-capture-clause-bad.rs b/tests/ui/moves/moves-based-on-type-capture-clause-bad.rs index 9d7277c1c24..c9a7f2c8ed8 100644 --- a/tests/ui/moves/moves-based-on-type-capture-clause-bad.rs +++ b/tests/ui/moves/moves-based-on-type-capture-clause-bad.rs @@ -1,3 +1,4 @@ +//@ run-rustfix use std::thread; fn main() { diff --git a/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr b/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr index c2b9aeab237..17049fe6731 100644 --- a/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr +++ b/tests/ui/moves/moves-based-on-type-capture-clause-bad.stderr @@ -1,5 +1,5 @@ error[E0382]: borrow of moved value: `x` - --> $DIR/moves-based-on-type-capture-clause-bad.rs:8:20 + --> $DIR/moves-based-on-type-capture-clause-bad.rs:9:20 | LL | let x = "Hello world!".to_string(); | - move occurs because `x` has type `String`, which does not implement the `Copy` trait @@ -12,6 +12,12 @@ LL | println!("{}", x); | ^ value borrowed here after move | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) +help: consider cloning the value before moving it into the closure + | +LL ~ let value = x.clone(); +LL ~ thread::spawn(move || { +LL ~ println!("{}", value); + | error: aborting due to 1 previous error diff --git a/tests/ui/no-capture-arc.rs b/tests/ui/moves/no-capture-arc.rs index 9c957a4e01b..9c957a4e01b 100644 --- a/tests/ui/no-capture-arc.rs +++ b/tests/ui/moves/no-capture-arc.rs diff --git a/tests/ui/no-capture-arc.stderr b/tests/ui/moves/no-capture-arc.stderr index 9c1f5c65066..6d4a867fa88 100644 --- a/tests/ui/no-capture-arc.stderr +++ b/tests/ui/moves/no-capture-arc.stderr @@ -13,6 +13,12 @@ LL | assert_eq!((*arc_v)[2], 3); | ^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `Vec<i32>` +help: consider cloning the value before moving it into the closure + | +LL ~ let value = arc_v.clone(); +LL ~ thread::spawn(move|| { +LL ~ assert_eq!((*value)[3], 4); + | error: aborting due to 1 previous error diff --git a/tests/ui/moves/no-reuse-move-arc.fixed b/tests/ui/moves/no-reuse-move-arc.fixed new file mode 100644 index 00000000000..a5dac8cc14b --- /dev/null +++ b/tests/ui/moves/no-reuse-move-arc.fixed @@ -0,0 +1,17 @@ +//@ run-rustfix +use std::sync::Arc; +use std::thread; + +fn main() { + let v = vec![1, 2, 3, 4, 5, 6, 7, 8, 9, 10]; + let arc_v = Arc::new(v); + + let value = arc_v.clone(); + thread::spawn(move|| { + assert_eq!((*value)[3], 4); + }); + + assert_eq!((*arc_v)[2], 3); //~ ERROR borrow of moved value: `arc_v` + + println!("{:?}", *arc_v); +} diff --git a/tests/ui/no-reuse-move-arc.rs b/tests/ui/moves/no-reuse-move-arc.rs index 9c957a4e01b..0d67aa56489 100644 --- a/tests/ui/no-reuse-move-arc.rs +++ b/tests/ui/moves/no-reuse-move-arc.rs @@ -1,3 +1,4 @@ +//@ run-rustfix use std::sync::Arc; use std::thread; diff --git a/tests/ui/no-reuse-move-arc.stderr b/tests/ui/moves/no-reuse-move-arc.stderr index 61f4837dc0e..aff979af905 100644 --- a/tests/ui/no-reuse-move-arc.stderr +++ b/tests/ui/moves/no-reuse-move-arc.stderr @@ -1,5 +1,5 @@ error[E0382]: borrow of moved value: `arc_v` - --> $DIR/no-reuse-move-arc.rs:12:18 + --> $DIR/no-reuse-move-arc.rs:13:18 | LL | let arc_v = Arc::new(v); | ----- move occurs because `arc_v` has type `Arc<Vec<i32>>`, which does not implement the `Copy` trait @@ -13,6 +13,12 @@ LL | assert_eq!((*arc_v)[2], 3); | ^^^^^ value borrowed here after move | = note: borrow occurs due to deref coercion to `Vec<i32>` +help: consider cloning the value before moving it into the closure + | +LL ~ let value = arc_v.clone(); +LL ~ thread::spawn(move|| { +LL ~ assert_eq!((*value)[3], 4); + | error: aborting due to 1 previous error diff --git a/tests/ui/msvc-data-only.rs b/tests/ui/msvc-data-only.rs deleted file mode 100644 index 15d799085fe..00000000000 --- a/tests/ui/msvc-data-only.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -//@ aux-build:msvc-data-only-lib.rs - -extern crate msvc_data_only_lib; - -fn main() { - println!("The answer is {} !", msvc_data_only_lib::FOO); -} diff --git a/tests/ui/msvc-opt-minsize.rs b/tests/ui/msvc-opt-minsize.rs deleted file mode 100644 index c1be168a05d..00000000000 --- a/tests/ui/msvc-opt-minsize.rs +++ /dev/null @@ -1,31 +0,0 @@ -// A previously outdated version of LLVM caused compilation failures on Windows -// specifically with optimization level `z`. After the update to a more recent LLVM -// version, this test checks that compilation and execution both succeed. -// See https://github.com/rust-lang/rust/issues/45034 - -//@ ignore-cross-compile -// Reason: the compiled binary is executed -//@ only-windows -// Reason: the observed bug only occurs on Windows -//@ run-pass -//@ compile-flags: -C opt-level=z - -#![feature(test)] -extern crate test; - -fn foo(x: i32, y: i32) -> i64 { - (x + y) as i64 -} - -#[inline(never)] -fn bar() { - let _f = Box::new(0); - // This call used to trigger an LLVM bug in opt-level z where the base - // pointer gets corrupted, see issue #45034 - let y: fn(i32, i32) -> i64 = test::black_box(foo); - test::black_box(y(1, 2)); -} - -fn main() { - bar(); -} diff --git a/tests/ui/multibyte.rs b/tests/ui/multibyte.rs deleted file mode 100644 index d585a791fb9..00000000000 --- a/tests/ui/multibyte.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass -// - -// Test that multibyte characters don't crash the compiler -pub fn main() { - println!("마이너스 사인이 없으면"); -} diff --git a/tests/ui/multiline-comment.rs b/tests/ui/multiline-comment.rs deleted file mode 100644 index 98174882032..00000000000 --- a/tests/ui/multiline-comment.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-pass - -/* - * This is a multi-line oldcomment. - */ -pub fn main() { } diff --git a/tests/ui/mut-function-arguments.rs b/tests/ui/mut-function-arguments.rs deleted file mode 100644 index 01c264fce03..00000000000 --- a/tests/ui/mut-function-arguments.rs +++ /dev/null @@ -1,19 +0,0 @@ -//@ run-pass - -fn f(mut y: Box<isize>) { - *y = 5; - assert_eq!(*y, 5); -} - -fn g() { - let frob = |mut q: Box<isize>| { *q = 2; assert_eq!(*q, 2); }; - let w = Box::new(37); - frob(w); - -} - -pub fn main() { - let z = Box::new(17); - f(z); - g(); -} diff --git a/tests/ui/mutual-recursion-group.rs b/tests/ui/mutual-recursion-group.rs deleted file mode 100644 index f83150af7dc..00000000000 --- a/tests/ui/mutual-recursion-group.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] -#![allow(dead_code)] - - -enum colour { red, green, blue, } - -enum tree { children(Box<list>), leaf(colour), } - -enum list { cons(Box<tree>, Box<list>), nil, } - -enum small_list { kons(isize, Box<small_list>), neel, } - -pub fn main() { } diff --git a/tests/ui/myriad-closures.rs b/tests/ui/myriad-closures.rs deleted file mode 100644 index 541d27d5de4..00000000000 --- a/tests/ui/myriad-closures.rs +++ /dev/null @@ -1,39 +0,0 @@ -//@ run-pass -// This test case tests whether we can handle code bases that contain a high -// number of closures, something that needs special handling in the MingGW -// toolchain. -// See https://github.com/rust-lang/rust/issues/34793 for more information. - -// Make sure we don't optimize anything away: -//@ compile-flags: -C no-prepopulate-passes -Cpasses=name-anon-globals - -// Expand something exponentially -macro_rules! go_bacterial { - ($mac:ident) => ($mac!()); - ($mac:ident 1 $($t:tt)*) => ( - go_bacterial!($mac $($t)*); - go_bacterial!($mac $($t)*); - ) -} - -macro_rules! mk_closure { - () => ((move || {})()) -} - -macro_rules! mk_fn { - () => { - { - fn function() { - // Make 16 closures - go_bacterial!(mk_closure 1 1 1 1); - } - let _ = function(); - } - } -} - -fn main() { - // Make 2^8 functions, each containing 16 closures, - // resulting in 2^12 closures overall. - go_bacterial!(mk_fn 1 1 1 1 1 1 1 1); -} diff --git a/tests/ui/nested-block-comment.rs b/tests/ui/nested-block-comment.rs deleted file mode 100644 index 008df27e0e2..00000000000 --- a/tests/ui/nested-block-comment.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ run-pass - -/* This test checks that nested comments are supported - - /* - This should not panic - */ -*/ - -pub fn main() { -} diff --git a/tests/ui/nested-cfg-attrs.rs b/tests/ui/nested-cfg-attrs.rs deleted file mode 100644 index 941807a8431..00000000000 --- a/tests/ui/nested-cfg-attrs.rs +++ /dev/null @@ -1,4 +0,0 @@ -#[cfg_attr(all(), cfg_attr(all(), cfg(false)))] -fn f() {} - -fn main() { f() } //~ ERROR cannot find function `f` in this scope diff --git a/tests/ui/nested-class.rs b/tests/ui/nested-class.rs deleted file mode 100644 index f84ab40dd1d..00000000000 --- a/tests/ui/nested-class.rs +++ /dev/null @@ -1,25 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] - -pub fn main() { - struct b { - i: isize, - } - - impl b { - fn do_stuff(&self) -> isize { return 37; } - } - - fn b(i:isize) -> b { - b { - i: i - } - } - - // fn b(x:isize) -> isize { panic!(); } - - let z = b(42); - assert_eq!(z.i, 42); - assert_eq!(z.do_stuff(), 37); -} diff --git a/tests/ui/nested-ty-params.rs b/tests/ui/nested-ty-params.rs deleted file mode 100644 index c00c3bc3372..00000000000 --- a/tests/ui/nested-ty-params.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn hd<U>(v: Vec<U> ) -> U { - fn hd1(w: [U]) -> U { return w[0]; } - //~^ ERROR can't use generic parameters from outer item - //~| ERROR can't use generic parameters from outer item - - return hd1(v); -} - -fn main() {} diff --git a/tests/ui/never_type/never-type-fallback-option.rs b/tests/ui/never_type/never-type-fallback-option.rs new file mode 100644 index 00000000000..9c8103aa0a4 --- /dev/null +++ b/tests/ui/never_type/never-type-fallback-option.rs @@ -0,0 +1,22 @@ +//@ run-pass + +#![allow(warnings)] + +//! Tests type inference fallback to `!` (never type) in `Option` context. +//! +//! Regression test for issues: +//! - https://github.com/rust-lang/rust/issues/39808 +//! - https://github.com/rust-lang/rust/issues/39984 +//! +//! Here the type of `c` is `Option<?T>`, where `?T` is unconstrained. +//! Because there is data-flow from the `{ return; }` block, which +//! diverges and hence has type `!`, into `c`, we will default `?T` to +//! `!`, and hence this code compiles rather than failing and requiring +//! a type annotation. + +fn main() { + let c = Some({ + return; + }); + c.unwrap(); +} diff --git a/tests/ui/new-import-syntax.rs b/tests/ui/new-import-syntax.rs deleted file mode 100644 index 547900fab61..00000000000 --- a/tests/ui/new-import-syntax.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ run-pass - -pub fn main() { - println!("Hello world!"); -} diff --git a/tests/ui/new-style-constants.rs b/tests/ui/new-style-constants.rs deleted file mode 100644 index e33a2da3878..00000000000 --- a/tests/ui/new-style-constants.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass - -static FOO: isize = 3; - -pub fn main() { - println!("{}", FOO); -} diff --git a/tests/ui/newlambdas.rs b/tests/ui/newlambdas.rs deleted file mode 100644 index 75e851fb73a..00000000000 --- a/tests/ui/newlambdas.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ run-pass -// Tests for the new |args| expr lambda syntax - - -fn f<F>(i: isize, f: F) -> isize where F: FnOnce(isize) -> isize { f(i) } - -fn g<G>(_g: G) where G: FnOnce() { } - -pub fn main() { - assert_eq!(f(10, |a| a), 10); - g(||()); - assert_eq!(f(10, |a| a), 10); - g(||{}); -} diff --git a/tests/ui/newtype-polymorphic.rs b/tests/ui/newtype-polymorphic.rs deleted file mode 100644 index 146d49fdf68..00000000000 --- a/tests/ui/newtype-polymorphic.rs +++ /dev/null @@ -1,27 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] - - -#[derive(Clone)] -struct myvec<X>(Vec<X> ); - -fn myvec_deref<X:Clone>(mv: myvec<X>) -> Vec<X> { - let myvec(v) = mv; - return v.clone(); -} - -fn myvec_elt<X>(mv: myvec<X>) -> X { - let myvec(v) = mv; - return v.into_iter().next().unwrap(); -} - -pub fn main() { - let mv = myvec(vec![1, 2, 3]); - let mv_clone = mv.clone(); - let mv_clone = myvec_deref(mv_clone); - assert_eq!(mv_clone[1], 2); - assert_eq!(myvec_elt(mv.clone()), 1); - let myvec(v) = mv; - assert_eq!(v[2], 3); -} diff --git a/tests/ui/newtype.rs b/tests/ui/newtype.rs deleted file mode 100644 index 8a07c67eb4f..00000000000 --- a/tests/ui/newtype.rs +++ /dev/null @@ -1,23 +0,0 @@ -//@ run-pass - -#![allow(non_camel_case_types)] -#[derive(Copy, Clone)] -struct mytype(Mytype); - -#[derive(Copy, Clone)] -struct Mytype { - compute: fn(mytype) -> isize, - val: isize, -} - -fn compute(i: mytype) -> isize { - let mytype(m) = i; - return m.val + 20; -} - -pub fn main() { - let myval = mytype(Mytype{compute: compute, val: 30}); - println!("{}", compute(myval)); - let mytype(m) = myval; - assert_eq!((m.compute)(myval), 50); -} diff --git a/tests/ui/nll/ty-outlives/impl-trait-captures.stderr b/tests/ui/nll/ty-outlives/impl-trait-captures.stderr index 6fd41a761e9..6bf1e333327 100644 --- a/tests/ui/nll/ty-outlives/impl-trait-captures.stderr +++ b/tests/ui/nll/ty-outlives/impl-trait-captures.stderr @@ -4,14 +4,14 @@ error[E0700]: hidden type for `Opaque(DefId(0:11 ~ impl_trait_captures[aeb9]::fo LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> { | -- ------------ opaque type defined here | | - | hidden type `&ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), LateNamed(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::'_), '_)) T` captures the anonymous lifetime defined here + | hidden type `&ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), LateNamed(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::'_))) T` captures the anonymous lifetime defined here LL | x | ^ | -help: add a `use<...>` bound to explicitly capture `ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), LateNamed(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::'_), '_))` +help: add a `use<...>` bound to explicitly capture `ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), LateNamed(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::'_)))` | -LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + use<'a, ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), LateNamed(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::'_), '_)), T> { - | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +LL | fn foo<'a, T>(x: &T) -> impl Foo<'a> + use<'a, ReLateParam(DefId(0:8 ~ impl_trait_captures[aeb9]::foo), LateNamed(DefId(0:13 ~ impl_trait_captures[aeb9]::foo::'_))), T> { + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/nll/user-annotations/region-error-ice-109072.stderr b/tests/ui/nll/user-annotations/region-error-ice-109072.stderr index d90971bed25..42551b87f62 100644 --- a/tests/ui/nll/user-annotations/region-error-ice-109072.stderr +++ b/tests/ui/nll/user-annotations/region-error-ice-109072.stderr @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'missing` --> $DIR/region-error-ice-109072.rs:8:9 | LL | impl Lt<'missing> for () { - | - ^^^^^^^^ undeclared lifetime - | | - | help: consider introducing lifetime `'missing` here: `<'missing>` + | ^^^^^^^^ undeclared lifetime + | +help: consider introducing lifetime `'missing` here + | +LL | impl<'missing> Lt<'missing> for () { + | ++++++++++ error[E0261]: use of undeclared lifetime name `'missing` --> $DIR/region-error-ice-109072.rs:9:15 diff --git a/tests/ui/no-core-1.rs b/tests/ui/no-core-1.rs deleted file mode 100644 index d6d2ba60445..00000000000 --- a/tests/ui/no-core-1.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-pass - -#![allow(stable_features)] -#![feature(no_core, core)] -#![no_core] - -extern crate std; -extern crate core; - -use std::option::Option::Some; - -fn main() { - let a = Some("foo"); - a.unwrap(); -} diff --git a/tests/ui/no-core-2.rs b/tests/ui/no-core-2.rs deleted file mode 100644 index 2f55365bdd0..00000000000 --- a/tests/ui/no-core-2.rs +++ /dev/null @@ -1,20 +0,0 @@ -//@ run-pass - -#![allow(dead_code, unused_imports)] -#![feature(no_core)] -#![no_core] -//@ edition:2018 - -extern crate std; -extern crate core; -use core::{prelude::v1::*, *}; - -fn foo() { - for _ in &[()] {} -} - -fn bar() -> Option<()> { - None? -} - -fn main() {} diff --git a/tests/ui/no-warn-on-field-replace-issue-34101.rs b/tests/ui/no-warn-on-field-replace-issue-34101.rs deleted file mode 100644 index e1d5e9c5268..00000000000 --- a/tests/ui/no-warn-on-field-replace-issue-34101.rs +++ /dev/null @@ -1,46 +0,0 @@ -// Issue 34101: Circa 2016-06-05, `fn inline` below issued an -// erroneous warning from the elaborate_drops pass about moving out of -// a field in `Foo`, which has a destructor (and thus cannot have -// content moved out of it). The reason that the warning is erroneous -// in this case is that we are doing a *replace*, not a move, of the -// content in question, and it is okay to replace fields within `Foo`. -// -// Another more subtle problem was that the elaborate_drops was -// creating a separate drop flag for that internally replaced content, -// even though the compiler should enforce an invariant that any drop -// flag for such subcontent of `Foo` will always have the same value -// as the drop flag for `Foo` itself. - - - - - - - - -//@ check-pass - -struct Foo(String); - -impl Drop for Foo { - fn drop(&mut self) {} -} - -fn inline() { - // (dummy variable so `f` gets assigned `var1` in MIR for both fn's) - let _s = (); - let mut f = Foo(String::from("foo")); - f.0 = String::from("bar"); -} - -fn outline() { - let _s = String::from("foo"); - let mut f = Foo(_s); - f.0 = String::from("bar"); -} - - -fn main() { - inline(); - outline(); -} diff --git a/tests/ui/no_send-enum.rs b/tests/ui/no_send-enum.rs deleted file mode 100644 index bd560649b99..00000000000 --- a/tests/ui/no_send-enum.rs +++ /dev/null @@ -1,18 +0,0 @@ -#![feature(negative_impls)] - -use std::marker::Send; - -struct NoSend; -impl !Send for NoSend {} - -enum Foo { - A(NoSend) -} - -fn bar<T: Send>(_: T) {} - -fn main() { - let x = Foo::A(NoSend); - bar(x); - //~^ ERROR `NoSend` cannot be sent between threads safely -} diff --git a/tests/ui/no_send-enum.stderr b/tests/ui/no_send-enum.stderr deleted file mode 100644 index 3b66c7db545..00000000000 --- a/tests/ui/no_send-enum.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0277]: `NoSend` cannot be sent between threads safely - --> $DIR/no_send-enum.rs:16:9 - | -LL | bar(x); - | --- ^ `NoSend` cannot be sent between threads safely - | | - | required by a bound introduced by this call - | - = help: within `Foo`, the trait `Send` is not implemented for `NoSend` -note: required because it appears within the type `Foo` - --> $DIR/no_send-enum.rs:8:6 - | -LL | enum Foo { - | ^^^ -note: required by a bound in `bar` - --> $DIR/no_send-enum.rs:12:11 - | -LL | fn bar<T: Send>(_: T) {} - | ^^^^ required by this bound in `bar` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/no_send-rc.rs b/tests/ui/no_send-rc.rs deleted file mode 100644 index f31db15ef2e..00000000000 --- a/tests/ui/no_send-rc.rs +++ /dev/null @@ -1,9 +0,0 @@ -use std::rc::Rc; - -fn bar<T: Send>(_: T) {} - -fn main() { - let x = Rc::new(5); - bar(x); - //~^ ERROR `Rc<{integer}>` cannot be sent between threads safely -} diff --git a/tests/ui/no_send-rc.stderr b/tests/ui/no_send-rc.stderr deleted file mode 100644 index 1430a7a29ea..00000000000 --- a/tests/ui/no_send-rc.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error[E0277]: `Rc<{integer}>` cannot be sent between threads safely - --> $DIR/no_send-rc.rs:7:9 - | -LL | bar(x); - | --- ^ `Rc<{integer}>` cannot be sent between threads safely - | | - | required by a bound introduced by this call - | - = help: the trait `Send` is not implemented for `Rc<{integer}>` -note: required by a bound in `bar` - --> $DIR/no_send-rc.rs:3:11 - | -LL | fn bar<T: Send>(_: T) {} - | ^^^^ required by this bound in `bar` -help: consider dereferencing here - | -LL | bar(*x); - | + - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/no_share-enum.rs b/tests/ui/no_share-enum.rs deleted file mode 100644 index 44bf1913e7a..00000000000 --- a/tests/ui/no_share-enum.rs +++ /dev/null @@ -1,16 +0,0 @@ -#![feature(negative_impls)] - -use std::marker::Sync; - -struct NoSync; -impl !Sync for NoSync {} - -enum Foo { A(NoSync) } - -fn bar<T: Sync>(_: T) {} - -fn main() { - let x = Foo::A(NoSync); - bar(x); - //~^ ERROR `NoSync` cannot be shared between threads safely [E0277] -} diff --git a/tests/ui/no_share-enum.stderr b/tests/ui/no_share-enum.stderr deleted file mode 100644 index 89939216d5b..00000000000 --- a/tests/ui/no_share-enum.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0277]: `NoSync` cannot be shared between threads safely - --> $DIR/no_share-enum.rs:14:9 - | -LL | bar(x); - | --- ^ `NoSync` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = help: within `Foo`, the trait `Sync` is not implemented for `NoSync` -note: required because it appears within the type `Foo` - --> $DIR/no_share-enum.rs:8:6 - | -LL | enum Foo { A(NoSync) } - | ^^^ -note: required by a bound in `bar` - --> $DIR/no_share-enum.rs:10:11 - | -LL | fn bar<T: Sync>(_: T) {} - | ^^^^ required by this bound in `bar` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/no_share-struct.rs b/tests/ui/no_share-struct.rs deleted file mode 100644 index 7d8a36a76f2..00000000000 --- a/tests/ui/no_share-struct.rs +++ /dev/null @@ -1,14 +0,0 @@ -#![feature(negative_impls)] - -use std::marker::Sync; - -struct Foo { a: isize } -impl !Sync for Foo {} - -fn bar<T: Sync>(_: T) {} - -fn main() { - let x = Foo { a: 5 }; - bar(x); - //~^ ERROR `Foo` cannot be shared between threads safely [E0277] -} diff --git a/tests/ui/no_share-struct.stderr b/tests/ui/no_share-struct.stderr deleted file mode 100644 index 9c7a921b8d8..00000000000 --- a/tests/ui/no_share-struct.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0277]: `Foo` cannot be shared between threads safely - --> $DIR/no_share-struct.rs:12:9 - | -LL | bar(x); - | --- ^ `Foo` cannot be shared between threads safely - | | - | required by a bound introduced by this call - | - = help: the trait `Sync` is not implemented for `Foo` -note: required by a bound in `bar` - --> $DIR/no_share-struct.rs:8:11 - | -LL | fn bar<T: Sync>(_: T) {} - | ^^^^ required by this bound in `bar` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/no_std/no-core-edition2018-syntax.rs b/tests/ui/no_std/no-core-edition2018-syntax.rs new file mode 100644 index 00000000000..9a327e4c8e3 --- /dev/null +++ b/tests/ui/no_std/no-core-edition2018-syntax.rs @@ -0,0 +1,28 @@ +//! Test that `#![no_core]` doesn't break modern Rust syntax in edition 2018. +//! +//! When you use `#![no_core]`, you lose the automatic prelude, but you can still +//! get everything back by manually importing `use core::{prelude::v1::*, *}`. +//! This test makes sure that after doing that, things like `for` loops and the +//! `?` operator still work as expected. + +//@ run-pass +//@ edition:2018 + +#![allow(dead_code, unused_imports)] +#![feature(no_core)] +#![no_core] + +extern crate core; +extern crate std; +use core::prelude::v1::*; +use core::*; + +fn test_for_loop() { + for _ in &[()] {} +} + +fn test_question_mark_operator() -> Option<()> { + None? +} + +fn main() {} diff --git a/tests/ui/no_std/no-core-with-explicit-std-core.rs b/tests/ui/no_std/no-core-with-explicit-std-core.rs new file mode 100644 index 00000000000..3940bcb3aa4 --- /dev/null +++ b/tests/ui/no_std/no-core-with-explicit-std-core.rs @@ -0,0 +1,21 @@ +//! Test that you can use `#![no_core]` and still import std and core manually. +//! +//! The `#![no_core]` attribute disables the automatic core prelude, but you should +//! still be able to explicitly import both `std` and `core` crates and use types +//! like `Option` normally. + +//@ run-pass + +#![allow(stable_features)] +#![feature(no_core, core)] +#![no_core] + +extern crate core; +extern crate std; + +use std::option::Option::Some; + +fn main() { + let a = Some("foo"); + a.unwrap(); +} diff --git a/tests/ui/no_std/simple-runs.rs b/tests/ui/no_std/simple-runs.rs index 8931ac7ed11..af44dfec311 100644 --- a/tests/ui/no_std/simple-runs.rs +++ b/tests/ui/no_std/simple-runs.rs @@ -4,6 +4,7 @@ //@ compile-flags: -Cpanic=abort //@ ignore-wasm different `main` convention +#![feature(lang_items)] #![no_std] #![no_main] @@ -35,6 +36,17 @@ fn panic_handler(_info: &PanicInfo<'_>) -> ! { loop {} } +#[lang = "eh_personality"] +extern "C" fn rust_eh_personality( + _version: i32, + _actions: i32, + _exception_class: u64, + _exception_object: *mut (), + _context: *mut (), +) -> i32 { + loop {} +} + #[no_mangle] extern "C" fn main(_argc: c_int, _argv: *const *const c_char) -> c_int { 0 diff --git a/tests/ui/noexporttypeexe.stderr b/tests/ui/noexporttypeexe.stderr deleted file mode 100644 index 59759b696c7..00000000000 --- a/tests/ui/noexporttypeexe.stderr +++ /dev/null @@ -1,18 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/noexporttypeexe.rs:10:18 - | -LL | let x: isize = noexporttypelib::foo(); - | ----- ^^^^^^^^^^^^^^^^^^^^^^ expected `isize`, found `Option<isize>` - | | - | expected due to this - | - = note: expected type `isize` - found enum `Option<isize>` -help: consider using `Option::expect` to unwrap the `Option<isize>` value, panicking if the value is an `Option::None` - | -LL | let x: isize = noexporttypelib::foo().expect("REASON"); - | +++++++++++++++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/non-constant-expr-for-arr-len.rs b/tests/ui/non-constant-expr-for-arr-len.rs deleted file mode 100644 index 1b101d3233f..00000000000 --- a/tests/ui/non-constant-expr-for-arr-len.rs +++ /dev/null @@ -1,8 +0,0 @@ -// Check that non constant exprs fail for array repeat syntax - -fn main() { - fn bar(n: usize) { - let _x = [0; n]; - //~^ ERROR attempt to use a non-constant value in a constant [E0435] - } -} diff --git a/tests/ui/nonscalar-cast.fixed b/tests/ui/nonscalar-cast.fixed deleted file mode 100644 index cb5591dbb9d..00000000000 --- a/tests/ui/nonscalar-cast.fixed +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-rustfix - -#[derive(Debug)] -struct Foo { - x: isize -} - -impl From<Foo> for isize { - fn from(val: Foo) -> isize { - val.x - } -} - -fn main() { - println!("{}", isize::from(Foo { x: 1 })); //~ ERROR non-primitive cast: `Foo` as `isize` [E0605] -} diff --git a/tests/ui/nonscalar-cast.rs b/tests/ui/nonscalar-cast.rs deleted file mode 100644 index 27429b44cd0..00000000000 --- a/tests/ui/nonscalar-cast.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ run-rustfix - -#[derive(Debug)] -struct Foo { - x: isize -} - -impl From<Foo> for isize { - fn from(val: Foo) -> isize { - val.x - } -} - -fn main() { - println!("{}", Foo { x: 1 } as isize); //~ ERROR non-primitive cast: `Foo` as `isize` [E0605] -} diff --git a/tests/ui/nonscalar-cast.stderr b/tests/ui/nonscalar-cast.stderr deleted file mode 100644 index 834d4ea241c..00000000000 --- a/tests/ui/nonscalar-cast.stderr +++ /dev/null @@ -1,15 +0,0 @@ -error[E0605]: non-primitive cast: `Foo` as `isize` - --> $DIR/nonscalar-cast.rs:15:20 - | -LL | println!("{}", Foo { x: 1 } as isize); - | ^^^^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object - | -help: consider using the `From` trait instead - | -LL - println!("{}", Foo { x: 1 } as isize); -LL + println!("{}", isize::from(Foo { x: 1 })); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0605`. diff --git a/tests/ui/not-clone-closure.rs b/tests/ui/not-clone-closure.rs deleted file mode 100644 index 976e3b9e81c..00000000000 --- a/tests/ui/not-clone-closure.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@compile-flags: --diagnostic-width=300 -// Check that closures do not implement `Clone` if their environment is not `Clone`. - -struct S(i32); - -fn main() { - let a = S(5); - let hello = move || { - println!("Hello {}", a.0); - }; - - let hello = hello.clone(); //~ ERROR the trait bound `S: Clone` is not satisfied -} diff --git a/tests/ui/not-clone-closure.stderr b/tests/ui/not-clone-closure.stderr deleted file mode 100644 index 0c95a99d0c0..00000000000 --- a/tests/ui/not-clone-closure.stderr +++ /dev/null @@ -1,23 +0,0 @@ -error[E0277]: the trait bound `S: Clone` is not satisfied in `{closure@$DIR/not-clone-closure.rs:8:17: 8:24}` - --> $DIR/not-clone-closure.rs:12:23 - | -LL | let hello = move || { - | ------- within this `{closure@$DIR/not-clone-closure.rs:8:17: 8:24}` -... -LL | let hello = hello.clone(); - | ^^^^^ within `{closure@$DIR/not-clone-closure.rs:8:17: 8:24}`, the trait `Clone` is not implemented for `S` - | -note: required because it's used within this closure - --> $DIR/not-clone-closure.rs:8:17 - | -LL | let hello = move || { - | ^^^^^^^ -help: consider annotating `S` with `#[derive(Clone)]` - | -LL + #[derive(Clone)] -LL | struct S(i32); - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/occurs-check-2.rs b/tests/ui/occurs-check-2.rs deleted file mode 100644 index 9289a8e870a..00000000000 --- a/tests/ui/occurs-check-2.rs +++ /dev/null @@ -1,9 +0,0 @@ -fn main() { - - let f; - let g; - - g = f; - //~^ ERROR overflow assigning `Box<_>` to `_` - f = Box::new(g); -} diff --git a/tests/ui/occurs-check-3.rs b/tests/ui/occurs-check-3.rs deleted file mode 100644 index 377a043daf3..00000000000 --- a/tests/ui/occurs-check-3.rs +++ /dev/null @@ -1,11 +0,0 @@ -// From Issue #778 - -enum Clam<T> { A(T) } -fn main() { - let c; - c = Clam::A(c); - //~^ ERROR overflow assigning `Clam<_>` to `_` - match c { - Clam::A::<isize>(_) => { } - } -} diff --git a/tests/ui/occurs-check.rs b/tests/ui/occurs-check.rs deleted file mode 100644 index 638b9b6d7e4..00000000000 --- a/tests/ui/occurs-check.rs +++ /dev/null @@ -1,5 +0,0 @@ -fn main() { - let f; - f = Box::new(f); - //~^ ERROR overflow assigning `Box<_>` to `_` -} diff --git a/tests/ui/on-unimplemented/no-debug.stderr b/tests/ui/on-unimplemented/no-debug.stderr index 97d67dbd82e..5b0b060d40e 100644 --- a/tests/ui/on-unimplemented/no-debug.stderr +++ b/tests/ui/on-unimplemented/no-debug.stderr @@ -2,7 +2,9 @@ error[E0277]: `Foo` doesn't implement `Debug` --> $DIR/no-debug.rs:10:27 | LL | println!("{:?} {:?}", Foo, Bar); - | ^^^ `Foo` cannot be formatted using `{:?}` + | ---- ^^^ `Foo` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | | + | required by this formatting parameter | = help: the trait `Debug` is not implemented for `Foo` = note: add `#[derive(Debug)]` to `Foo` or manually `impl Debug for Foo` @@ -17,7 +19,9 @@ error[E0277]: `Bar` doesn't implement `Debug` --> $DIR/no-debug.rs:10:32 | LL | println!("{:?} {:?}", Foo, Bar); - | ^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ---- ^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | | + | required by this formatting parameter | = help: the trait `Debug` is not implemented for `Bar` = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) @@ -26,7 +30,9 @@ error[E0277]: `Foo` doesn't implement `std::fmt::Display` --> $DIR/no-debug.rs:11:23 | LL | println!("{} {}", Foo, Bar); - | ^^^ `Foo` cannot be formatted with the default formatter + | -- ^^^ `Foo` cannot be formatted with the default formatter + | | + | required by this formatting parameter | = help: the trait `std::fmt::Display` is not implemented for `Foo` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead @@ -36,7 +42,9 @@ error[E0277]: `Bar` doesn't implement `std::fmt::Display` --> $DIR/no-debug.rs:11:28 | LL | println!("{} {}", Foo, Bar); - | ^^^ `Bar` cannot be formatted with the default formatter + | -- ^^^ `Bar` cannot be formatted with the default formatter + | | + | required by this formatting parameter | = help: the trait `std::fmt::Display` is not implemented for `Bar` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead diff --git a/tests/ui/opeq.rs b/tests/ui/opeq.rs deleted file mode 100644 index 956ea0684fa..00000000000 --- a/tests/ui/opeq.rs +++ /dev/null @@ -1,17 +0,0 @@ -//@ run-pass - -pub fn main() { - let mut x: isize = 1; - x *= 2; - println!("{}", x); - assert_eq!(x, 2); - x += 3; - println!("{}", x); - assert_eq!(x, 5); - x *= x; - println!("{}", x); - assert_eq!(x, 25); - x /= 5; - println!("{}", x); - assert_eq!(x, 5); -} diff --git a/tests/ui/panic-runtime/auxiliary/depends.rs b/tests/ui/panic-runtime/auxiliary/depends.rs deleted file mode 100644 index 7a35619b681..00000000000 --- a/tests/ui/panic-runtime/auxiliary/depends.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ no-prefer-dynamic - -#![feature(panic_runtime)] -#![crate_type = "rlib"] -#![panic_runtime] -#![no_std] - -extern crate needs_panic_runtime; diff --git a/tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs b/tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs deleted file mode 100644 index fbafee0c241..00000000000 --- a/tests/ui/panic-runtime/auxiliary/needs-panic-runtime.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ no-prefer-dynamic - -#![feature(needs_panic_runtime)] -#![crate_type = "rlib"] -#![needs_panic_runtime] -#![no_std] diff --git a/tests/ui/panic-runtime/incompatible-type.rs b/tests/ui/panic-runtime/incompatible-type.rs index 4cbcfec11c9..f82c23d68c2 100644 --- a/tests/ui/panic-runtime/incompatible-type.rs +++ b/tests/ui/panic-runtime/incompatible-type.rs @@ -21,4 +21,12 @@ pub fn test(_: DropMe) { } #[rustc_std_internal_symbol] -pub unsafe extern "C" fn rust_eh_personality() {} +pub unsafe extern "C" fn rust_eh_personality( + _version: i32, + _actions: i32, + _exception_class: u64, + _exception_object: *mut (), + _context: *mut (), +) -> i32 { + loop {} +} diff --git a/tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs b/tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs deleted file mode 100644 index eb00c071702..00000000000 --- a/tests/ui/panic-runtime/runtime-depend-on-needs-runtime.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ dont-check-compiler-stderr -//@ aux-build:needs-panic-runtime.rs -//@ aux-build:depends.rs - -extern crate depends; - -fn main() {} - -//~? ERROR the crate `depends` cannot depend on a crate that needs a panic runtime, but it depends on `needs_panic_runtime` diff --git a/tests/ui/oom_unwind.rs b/tests/ui/panics/oom-panic-unwind.rs index be5e63d430b..5974ad91406 100644 --- a/tests/ui/oom_unwind.rs +++ b/tests/ui/panics/oom-panic-unwind.rs @@ -1,3 +1,5 @@ +//! Test that out-of-memory conditions trigger catchable panics with `-Z oom=panic`. + //@ compile-flags: -Z oom=panic //@ run-pass //@ no-prefer-dynamic diff --git a/tests/ui/parser/bad-lit-suffixes.rs b/tests/ui/parser/bad-lit-suffixes.rs index f29dc53d322..0a01bb84f01 100644 --- a/tests/ui/parser/bad-lit-suffixes.rs +++ b/tests/ui/parser/bad-lit-suffixes.rs @@ -42,4 +42,5 @@ extern "C" {} #[rustc_layout_scalar_valid_range_start(0suffix)] //~^ ERROR invalid suffix `suffix` for number literal +//~| ERROR malformed `rustc_layout_scalar_valid_range_start` attribute input struct S; diff --git a/tests/ui/parser/bad-lit-suffixes.stderr b/tests/ui/parser/bad-lit-suffixes.stderr index 86ef35bf783..7876d75c5a4 100644 --- a/tests/ui/parser/bad-lit-suffixes.stderr +++ b/tests/ui/parser/bad-lit-suffixes.stderr @@ -22,21 +22,6 @@ error: suffixes on string literals are invalid LL | #[must_use = "string"suffix] | ^^^^^^^^^^^^^^ invalid suffix `suffix` -error: malformed `must_use` attribute input - --> $DIR/bad-lit-suffixes.rs:34:1 - | -LL | #[must_use = "string"suffix] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -help: the following are the possible correct uses - | -LL - #[must_use = "string"suffix] -LL + #[must_use = "reason"] - | -LL - #[must_use = "string"suffix] -LL + #[must_use] - | - error: suffixes on string literals are invalid --> $DIR/bad-lit-suffixes.rs:39:15 | @@ -165,5 +150,33 @@ LL | 1.0e10suffix; | = help: valid suffixes are `f32` and `f64` -error: aborting due to 21 previous errors; 2 warnings emitted +error[E0539]: malformed `must_use` attribute input + --> $DIR/bad-lit-suffixes.rs:34:1 + | +LL | #[must_use = "string"suffix] + | ^^^^^^^^^^^^^--------------^ + | | + | expected a string literal here + | +help: try changing it to one of the following valid forms of the attribute + | +LL - #[must_use = "string"suffix] +LL + #[must_use = "reason"] + | +LL - #[must_use = "string"suffix] +LL + #[must_use] + | + +error[E0805]: malformed `rustc_layout_scalar_valid_range_start` attribute input + --> $DIR/bad-lit-suffixes.rs:43:1 + | +LL | #[rustc_layout_scalar_valid_range_start(0suffix)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^---------^ + | | | + | | expected a single argument here + | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` + +error: aborting due to 22 previous errors; 2 warnings emitted +Some errors have detailed explanations: E0539, E0805. +For more information about an error, try `rustc --explain E0539`. diff --git a/tests/ui/parser/bounds-type.rs b/tests/ui/parser/bounds-type.rs index ec0e83c314e..1bd67bbba6b 100644 --- a/tests/ui/parser/bounds-type.rs +++ b/tests/ui/parser/bounds-type.rs @@ -10,10 +10,10 @@ struct S< T: Tr +, // OK T: ?'a, //~ ERROR `?` may only modify trait bounds, not lifetime bounds - T: ~const Tr, // OK - T: ~const ?Tr, //~ ERROR `~const` trait not allowed with `?` trait polarity modifier - T: ~const Tr + 'a, // OK - T: ~const 'a, //~ ERROR `~const` may only modify trait bounds, not lifetime bounds + T: [const] Tr, // OK + T: [const] ?Tr, //~ ERROR `[const]` trait not allowed with `?` trait polarity modifier + T: [const] Tr + 'a, // OK + T: [const] 'a, //~ ERROR `[const]` may only modify trait bounds, not lifetime bounds T: const 'a, //~ ERROR `const` may only modify trait bounds, not lifetime bounds T: async Tr, // OK diff --git a/tests/ui/parser/bounds-type.stderr b/tests/ui/parser/bounds-type.stderr index 09c35c12b00..7c3e92a50da 100644 --- a/tests/ui/parser/bounds-type.stderr +++ b/tests/ui/parser/bounds-type.stderr @@ -12,19 +12,19 @@ error: `?` may only modify trait bounds, not lifetime bounds LL | T: ?'a, | ^ -error: `~const` trait not allowed with `?` trait polarity modifier - --> $DIR/bounds-type.rs:14:15 +error: `[const]` trait not allowed with `?` trait polarity modifier + --> $DIR/bounds-type.rs:14:16 | -LL | T: ~const ?Tr, - | ------ ^ +LL | T: [const] ?Tr, + | ------- ^ | | - | there is not a well-defined meaning for a `~const ?` trait + | there is not a well-defined meaning for a `[const] ?` trait -error: `~const` may only modify trait bounds, not lifetime bounds +error: `[const]` may only modify trait bounds, not lifetime bounds --> $DIR/bounds-type.rs:16:8 | -LL | T: ~const 'a, - | ^^^^^^ +LL | T: [const] 'a, + | ^^^^^^^ error: `const` may only modify trait bounds, not lifetime bounds --> $DIR/bounds-type.rs:17:8 diff --git a/tests/ui/parser/doc-comment-in-generic.rs b/tests/ui/parser/doc-comment-in-generic.rs new file mode 100644 index 00000000000..2596496763b --- /dev/null +++ b/tests/ui/parser/doc-comment-in-generic.rs @@ -0,0 +1,13 @@ +//! Tests correct parsing of doc comments on generic parameters in traits. +//! Checks that compiler doesn't panic when processing this. + +//@ check-pass + +#![crate_type = "lib"] + +pub trait Layer< + /// Documentation for generic parameter. + Input, +> +{ +} diff --git a/tests/ui/parser/issues/issue-7970b.rs b/tests/ui/parser/issues/issue-7970b.rs index 1c4abce3959..ae06aff7cef 100644 --- a/tests/ui/parser/issues/issue-7970b.rs +++ b/tests/ui/parser/issues/issue-7970b.rs @@ -1,4 +1,4 @@ fn main() {} macro_rules! test {} -//~^ ERROR unexpected end of macro invocation +//~^ ERROR macros must contain at least one rule diff --git a/tests/ui/parser/issues/issue-7970b.stderr b/tests/ui/parser/issues/issue-7970b.stderr index b23b09e752c..4715eb07c6d 100644 --- a/tests/ui/parser/issues/issue-7970b.stderr +++ b/tests/ui/parser/issues/issue-7970b.stderr @@ -1,8 +1,8 @@ -error: unexpected end of macro invocation +error: macros must contain at least one rule --> $DIR/issue-7970b.rs:3:1 | LL | macro_rules! test {} - | ^^^^^^^^^^^^^^^^^^^^ missing tokens in macro arguments + | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/parser/macro/bad-macro-definition.rs b/tests/ui/parser/macro/bad-macro-definition.rs new file mode 100644 index 00000000000..3c5c93ea3b3 --- /dev/null +++ b/tests/ui/parser/macro/bad-macro-definition.rs @@ -0,0 +1,22 @@ +#![crate_type = "lib"] + +macro_rules! a { {} => } +//~^ ERROR: macro definition ended unexpectedly + +macro_rules! b { 0 => } +//~^ ERROR: macro definition ended unexpectedly +//~| ERROR: invalid macro matcher + +macro_rules! c { x => } +//~^ ERROR: macro definition ended unexpectedly +//~| ERROR: invalid macro matcher + +macro_rules! d { _ => } +//~^ ERROR: macro definition ended unexpectedly +//~| ERROR: invalid macro matcher + +macro_rules! e { {} } +//~^ ERROR: expected `=>`, found end of macro arguments + +macro_rules! f {} +//~^ ERROR: macros must contain at least one rule diff --git a/tests/ui/parser/macro/bad-macro-definition.stderr b/tests/ui/parser/macro/bad-macro-definition.stderr new file mode 100644 index 00000000000..de6d9d6a38b --- /dev/null +++ b/tests/ui/parser/macro/bad-macro-definition.stderr @@ -0,0 +1,56 @@ +error: macro definition ended unexpectedly + --> $DIR/bad-macro-definition.rs:3:23 + | +LL | macro_rules! a { {} => } + | ^ expected right-hand side of macro rule + +error: invalid macro matcher; matchers must be contained in balanced delimiters + --> $DIR/bad-macro-definition.rs:6:18 + | +LL | macro_rules! b { 0 => } + | ^ + +error: macro definition ended unexpectedly + --> $DIR/bad-macro-definition.rs:6:22 + | +LL | macro_rules! b { 0 => } + | ^ expected right-hand side of macro rule + +error: invalid macro matcher; matchers must be contained in balanced delimiters + --> $DIR/bad-macro-definition.rs:10:18 + | +LL | macro_rules! c { x => } + | ^ + +error: macro definition ended unexpectedly + --> $DIR/bad-macro-definition.rs:10:22 + | +LL | macro_rules! c { x => } + | ^ expected right-hand side of macro rule + +error: invalid macro matcher; matchers must be contained in balanced delimiters + --> $DIR/bad-macro-definition.rs:14:18 + | +LL | macro_rules! d { _ => } + | ^ + +error: macro definition ended unexpectedly + --> $DIR/bad-macro-definition.rs:14:22 + | +LL | macro_rules! d { _ => } + | ^ expected right-hand side of macro rule + +error: expected `=>`, found end of macro arguments + --> $DIR/bad-macro-definition.rs:18:20 + | +LL | macro_rules! e { {} } + | ^ expected `=>` + +error: macros must contain at least one rule + --> $DIR/bad-macro-definition.rs:21:1 + | +LL | macro_rules! f {} + | ^^^^^^^^^^^^^^^^^ + +error: aborting due to 9 previous errors + diff --git a/tests/ui/parser/break-in-unlabeled-block-in-macro.rs b/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.rs index eecc0026b12..eecc0026b12 100644 --- a/tests/ui/parser/break-in-unlabeled-block-in-macro.rs +++ b/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.rs diff --git a/tests/ui/parser/break-in-unlabeled-block-in-macro.stderr b/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr index 2f46cb36750..2f46cb36750 100644 --- a/tests/ui/parser/break-in-unlabeled-block-in-macro.stderr +++ b/tests/ui/parser/macro/break-in-unlabeled-block-in-macro.stderr diff --git a/tests/ui/parser/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.rs b/tests/ui/parser/macro/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.rs index d6f7981813f..d6f7981813f 100644 --- a/tests/ui/parser/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.rs +++ b/tests/ui/parser/macro/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.rs diff --git a/tests/ui/parser/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.stderr b/tests/ui/parser/macro/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.stderr index 2796312f4ad..2796312f4ad 100644 --- a/tests/ui/parser/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.stderr +++ b/tests/ui/parser/macro/do-not-suggest-semicolon-between-macro-without-exclamation-mark-and-array.stderr diff --git a/tests/ui/parser/extern-abi-from-mac-literal-frag.rs b/tests/ui/parser/macro/extern-abi-from-mac-literal-frag.rs index 12b6c98705c..12b6c98705c 100644 --- a/tests/ui/parser/extern-abi-from-mac-literal-frag.rs +++ b/tests/ui/parser/macro/extern-abi-from-mac-literal-frag.rs diff --git a/tests/ui/parser/macro/issue-33569.rs b/tests/ui/parser/macro/issue-33569.rs index e0a5352ab06..7288fa858db 100644 --- a/tests/ui/parser/macro/issue-33569.rs +++ b/tests/ui/parser/macro/issue-33569.rs @@ -1,11 +1,10 @@ macro_rules! foo { { $+ } => { //~ ERROR expected identifier, found `+` //~^ ERROR missing fragment specifier - //~| ERROR missing fragment specifier $(x)(y) //~ ERROR expected one of: `*`, `+`, or `?` } } -foo!(); +foo!(); //~ ERROR unexpected end fn main() {} diff --git a/tests/ui/parser/macro/issue-33569.stderr b/tests/ui/parser/macro/issue-33569.stderr index 0d53c04c1c9..dd8e38f0d6e 100644 --- a/tests/ui/parser/macro/issue-33569.stderr +++ b/tests/ui/parser/macro/issue-33569.stderr @@ -4,12 +4,6 @@ error: expected identifier, found `+` LL | { $+ } => { | ^ -error: expected one of: `*`, `+`, or `?` - --> $DIR/issue-33569.rs:5:13 - | -LL | $(x)(y) - | ^^^ - error: missing fragment specifier --> $DIR/issue-33569.rs:2:8 | @@ -23,7 +17,22 @@ help: try adding a specifier here LL | { $+:spec } => { | +++++ -error: missing fragment specifier +error: expected one of: `*`, `+`, or `?` + --> $DIR/issue-33569.rs:4:13 + | +LL | $(x)(y) + | ^^^ + +error: unexpected end of macro invocation + --> $DIR/issue-33569.rs:8:1 + | +LL | macro_rules! foo { + | ---------------- when calling this macro +... +LL | foo!(); + | ^^^^^^ missing tokens in macro arguments + | +note: while trying to match meta-variable `$<!dummy!>:tt` --> $DIR/issue-33569.rs:2:8 | LL | { $+ } => { diff --git a/tests/ui/parser/lit-err-in-macro.rs b/tests/ui/parser/macro/lit-err-in-macro.rs index ca117ac4a15..ca117ac4a15 100644 --- a/tests/ui/parser/lit-err-in-macro.rs +++ b/tests/ui/parser/macro/lit-err-in-macro.rs diff --git a/tests/ui/parser/lit-err-in-macro.stderr b/tests/ui/parser/macro/lit-err-in-macro.stderr index 08fe58643d4..08fe58643d4 100644 --- a/tests/ui/parser/lit-err-in-macro.stderr +++ b/tests/ui/parser/macro/lit-err-in-macro.stderr diff --git a/tests/ui/parser/macro-bad-delimiter-ident.rs b/tests/ui/parser/macro/macro-bad-delimiter-ident.rs index f461f06b4dc..f461f06b4dc 100644 --- a/tests/ui/parser/macro-bad-delimiter-ident.rs +++ b/tests/ui/parser/macro/macro-bad-delimiter-ident.rs diff --git a/tests/ui/parser/macro-bad-delimiter-ident.stderr b/tests/ui/parser/macro/macro-bad-delimiter-ident.stderr index 06f72cdecf2..06f72cdecf2 100644 --- a/tests/ui/parser/macro-bad-delimiter-ident.stderr +++ b/tests/ui/parser/macro/macro-bad-delimiter-ident.stderr diff --git a/tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs b/tests/ui/parser/macro/macro-bare-trait-object-maybe-trait-bound.rs index 494e58c1ca5..494e58c1ca5 100644 --- a/tests/ui/parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs +++ b/tests/ui/parser/macro/macro-bare-trait-object-maybe-trait-bound.rs diff --git a/tests/ui/parser/macro-braces-dot-question.rs b/tests/ui/parser/macro/macro-braces-dot-question.rs index 9b070f201b5..9b070f201b5 100644 --- a/tests/ui/parser/macro-braces-dot-question.rs +++ b/tests/ui/parser/macro/macro-braces-dot-question.rs diff --git a/tests/ui/parser/macro/mbe-dotdotdot-may-not-begin-a-type.rs b/tests/ui/parser/macro/macro-dotdotdot-may-not-begin-a-type.rs index 8be99f22d2e..8be99f22d2e 100644 --- a/tests/ui/parser/macro/mbe-dotdotdot-may-not-begin-a-type.rs +++ b/tests/ui/parser/macro/macro-dotdotdot-may-not-begin-a-type.rs diff --git a/tests/ui/parser/macro-keyword.rs b/tests/ui/parser/macro/macro-keyword.rs index 58489fb2c51..58489fb2c51 100644 --- a/tests/ui/parser/macro-keyword.rs +++ b/tests/ui/parser/macro/macro-keyword.rs diff --git a/tests/ui/parser/macro-keyword.stderr b/tests/ui/parser/macro/macro-keyword.stderr index bfe89e320e0..bfe89e320e0 100644 --- a/tests/ui/parser/macro-keyword.stderr +++ b/tests/ui/parser/macro/macro-keyword.stderr diff --git a/tests/ui/parser/macro-mismatched-delim-brace-paren.rs b/tests/ui/parser/macro/macro-mismatched-delim-brace-paren.rs index 404aa7b806a..404aa7b806a 100644 --- a/tests/ui/parser/macro-mismatched-delim-brace-paren.rs +++ b/tests/ui/parser/macro/macro-mismatched-delim-brace-paren.rs diff --git a/tests/ui/parser/macro-mismatched-delim-brace-paren.stderr b/tests/ui/parser/macro/macro-mismatched-delim-brace-paren.stderr index f9a3072229f..f9a3072229f 100644 --- a/tests/ui/parser/macro-mismatched-delim-brace-paren.stderr +++ b/tests/ui/parser/macro/macro-mismatched-delim-brace-paren.stderr diff --git a/tests/ui/parser/macro-mismatched-delim-paren-brace.rs b/tests/ui/parser/macro/macro-mismatched-delim-paren-brace.rs index 1a1b9edfbcb..1a1b9edfbcb 100644 --- a/tests/ui/parser/macro-mismatched-delim-paren-brace.rs +++ b/tests/ui/parser/macro/macro-mismatched-delim-paren-brace.rs diff --git a/tests/ui/parser/macro-mismatched-delim-paren-brace.stderr b/tests/ui/parser/macro/macro-mismatched-delim-paren-brace.stderr index 34217e21ae9..34217e21ae9 100644 --- a/tests/ui/parser/macro-mismatched-delim-paren-brace.stderr +++ b/tests/ui/parser/macro/macro-mismatched-delim-paren-brace.stderr diff --git a/tests/ui/parser/mbe_missing_right_paren.rs b/tests/ui/parser/macro/macro-missing-right-paren.rs index 85191931664..85191931664 100644 --- a/tests/ui/parser/mbe_missing_right_paren.rs +++ b/tests/ui/parser/macro/macro-missing-right-paren.rs diff --git a/tests/ui/parser/mbe_missing_right_paren.stderr b/tests/ui/parser/macro/macro-missing-right-paren.stderr index d45a2e3ab52..285f14830ce 100644 --- a/tests/ui/parser/mbe_missing_right_paren.stderr +++ b/tests/ui/parser/macro/macro-missing-right-paren.stderr @@ -1,5 +1,5 @@ error: this file contains an unclosed delimiter - --> $DIR/mbe_missing_right_paren.rs:3:19 + --> $DIR/macro-missing-right-paren.rs:3:19 | LL | macro_rules! abc(ؼ | - ^ diff --git a/tests/ui/parser/macros-no-semicolon-items.rs b/tests/ui/parser/macro/macros-no-semicolon-items.rs index 3afc275d61a..86889279cea 100644 --- a/tests/ui/parser/macros-no-semicolon-items.rs +++ b/tests/ui/parser/macro/macros-no-semicolon-items.rs @@ -1,5 +1,5 @@ macro_rules! foo() //~ ERROR semicolon - //~| ERROR unexpected end of macro + //~| ERROR macros must contain at least one rule macro_rules! bar { ($($tokens:tt)*) => {} diff --git a/tests/ui/parser/macros-no-semicolon-items.stderr b/tests/ui/parser/macro/macros-no-semicolon-items.stderr index 07fa2439df5..f8f3ed83688 100644 --- a/tests/ui/parser/macros-no-semicolon-items.stderr +++ b/tests/ui/parser/macro/macros-no-semicolon-items.stderr @@ -38,11 +38,11 @@ help: add a semicolon LL | ); | + -error: unexpected end of macro invocation +error: macros must contain at least one rule --> $DIR/macros-no-semicolon-items.rs:1:1 | LL | macro_rules! foo() - | ^^^^^^^^^^^^^^^^^^ missing tokens in macro arguments + | ^^^^^^^^^^^^^^^^^^ error: aborting due to 3 previous errors diff --git a/tests/ui/parser/macros-no-semicolon.rs b/tests/ui/parser/macro/macros-no-semicolon.rs index 24d1ae9e623..24d1ae9e623 100644 --- a/tests/ui/parser/macros-no-semicolon.rs +++ b/tests/ui/parser/macro/macros-no-semicolon.rs diff --git a/tests/ui/parser/macros-no-semicolon.stderr b/tests/ui/parser/macro/macros-no-semicolon.stderr index f310662dbb0..f310662dbb0 100644 --- a/tests/ui/parser/macros-no-semicolon.stderr +++ b/tests/ui/parser/macro/macros-no-semicolon.stderr diff --git a/tests/ui/parser/misspelled-macro-rules.fixed b/tests/ui/parser/macro/misspelled-macro-rules.fixed index 7471a5641c2..7471a5641c2 100644 --- a/tests/ui/parser/misspelled-macro-rules.fixed +++ b/tests/ui/parser/macro/misspelled-macro-rules.fixed diff --git a/tests/ui/parser/misspelled-macro-rules.rs b/tests/ui/parser/macro/misspelled-macro-rules.rs index 8f63f37d3d3..8f63f37d3d3 100644 --- a/tests/ui/parser/misspelled-macro-rules.rs +++ b/tests/ui/parser/macro/misspelled-macro-rules.rs diff --git a/tests/ui/parser/misspelled-macro-rules.stderr b/tests/ui/parser/macro/misspelled-macro-rules.stderr index fc718d8556d..fc718d8556d 100644 --- a/tests/ui/parser/misspelled-macro-rules.stderr +++ b/tests/ui/parser/macro/misspelled-macro-rules.stderr diff --git a/tests/ui/parser/pub-method-macro.rs b/tests/ui/parser/macro/pub-method-macro.rs index 0183bdcf622..0183bdcf622 100644 --- a/tests/ui/parser/pub-method-macro.rs +++ b/tests/ui/parser/macro/pub-method-macro.rs diff --git a/tests/ui/parser/pub-method-macro.stderr b/tests/ui/parser/macro/pub-method-macro.stderr index 2e2c30dc6ad..2e2c30dc6ad 100644 --- a/tests/ui/parser/pub-method-macro.stderr +++ b/tests/ui/parser/macro/pub-method-macro.stderr diff --git a/tests/ui/parser/semi-after-closure-in-macro.rs b/tests/ui/parser/macro/semi-after-closure-in-macro.rs index 1eeb04b8833..1eeb04b8833 100644 --- a/tests/ui/parser/semi-after-closure-in-macro.rs +++ b/tests/ui/parser/macro/semi-after-closure-in-macro.rs diff --git a/tests/ui/parser/trailing-question-in-macro-type.rs b/tests/ui/parser/macro/trailing-question-in-macro-type.rs index e2a681ddd11..e2a681ddd11 100644 --- a/tests/ui/parser/trailing-question-in-macro-type.rs +++ b/tests/ui/parser/macro/trailing-question-in-macro-type.rs diff --git a/tests/ui/parser/trailing-question-in-macro-type.stderr b/tests/ui/parser/macro/trailing-question-in-macro-type.stderr index e3d33bf251d..e3d33bf251d 100644 --- a/tests/ui/parser/trailing-question-in-macro-type.stderr +++ b/tests/ui/parser/macro/trailing-question-in-macro-type.stderr diff --git a/tests/ui/parser/multiline-comments-basic.rs b/tests/ui/parser/multiline-comments-basic.rs new file mode 100644 index 00000000000..1aa2a531f5c --- /dev/null +++ b/tests/ui/parser/multiline-comments-basic.rs @@ -0,0 +1,10 @@ +//! Test that basic multiline comments are parsed correctly. +//! +//! Feature implementation test for <https://github.com/rust-lang/rust/issues/66>. + +//@ run-pass + +/* + * This is a multi-line comment. + */ +pub fn main() {} diff --git a/tests/ui/parser/nested-block-comments.rs b/tests/ui/parser/nested-block-comments.rs new file mode 100644 index 00000000000..8fe77896361 --- /dev/null +++ b/tests/ui/parser/nested-block-comments.rs @@ -0,0 +1,34 @@ +//! Test that nested block comments are properly supported by the parser. +//! +//! See <https://github.com/rust-lang/rust/issues/66>. + +//@ run-pass + +/* This test checks that nested comments are supported + + /* This is a nested comment + /* And this is even more deeply nested */ + Back to the first level of nesting + */ + + /* Another nested comment at the same level */ +*/ + +/* Additional test cases for nested comments */ + +#[rustfmt::skip] +/* + /* Level 1 + /* Level 2 + /* Level 3 */ + */ + */ +*/ + +pub fn main() { + // Check that code after nested comments works correctly + let _x = 42; + + /* Even inline /* nested */ comments work */ + let _y = /* nested /* comment */ test */ 100; +} diff --git a/tests/ui/parser/raw/raw-string-literals.rs b/tests/ui/parser/raw/raw-string-literals.rs new file mode 100644 index 00000000000..2272f268b36 --- /dev/null +++ b/tests/ui/parser/raw/raw-string-literals.rs Binary files differdiff --git a/tests/ui/parser/recover/recover-field-semi.rs b/tests/ui/parser/recover/recover-field-semi.rs index b703578860e..b6f235f8ad1 100644 --- a/tests/ui/parser/recover/recover-field-semi.rs +++ b/tests/ui/parser/recover/recover-field-semi.rs @@ -3,7 +3,7 @@ struct Foo { //~^ ERROR struct fields are separated by `,` } -union Bar { //~ ERROR +union Bar { foo: i32; //~^ ERROR union fields are separated by `,` } @@ -13,4 +13,6 @@ enum Baz { //~^ ERROR struct fields are separated by `,` } -fn main() {} +fn main() { + let _ = Foo { foo: "" }; //~ ERROR mismatched types +} diff --git a/tests/ui/parser/recover/recover-field-semi.stderr b/tests/ui/parser/recover/recover-field-semi.stderr index 3cf4847488c..9b1a34e134b 100644 --- a/tests/ui/parser/recover/recover-field-semi.stderr +++ b/tests/ui/parser/recover/recover-field-semi.stderr @@ -22,14 +22,12 @@ LL | Qux { foo: i32; } | | | while parsing this struct -error: unions cannot have zero fields - --> $DIR/recover-field-semi.rs:6:1 +error[E0308]: mismatched types + --> $DIR/recover-field-semi.rs:17:24 | -LL | / union Bar { -LL | | foo: i32; -LL | | -LL | | } - | |_^ +LL | let _ = Foo { foo: "" }; + | ^^ expected `i32`, found `&str` error: aborting due to 4 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/double-ref.rs b/tests/ui/parser/reference-whitespace-parsing.rs index eecf68ff209..7109c5911ae 100644 --- a/tests/ui/double-ref.rs +++ b/tests/ui/parser/reference-whitespace-parsing.rs @@ -1,3 +1,5 @@ +//! Test parsing of multiple references with various whitespace arrangements + //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/parser/trait-object-delimiters.rs b/tests/ui/parser/trait-object-delimiters.rs index 8f6221c1b94..2c75840bc0a 100644 --- a/tests/ui/parser/trait-object-delimiters.rs +++ b/tests/ui/parser/trait-object-delimiters.rs @@ -8,7 +8,7 @@ fn foo2(_: &dyn (Drop + AsRef<str>)) {} //~ ERROR incorrect parentheses around t fn foo2_no_space(_: &dyn(Drop + AsRef<str>)) {} //~ ERROR incorrect parentheses around trait bounds fn foo3(_: &dyn {Drop + AsRef<str>}) {} //~ ERROR expected parameter name, found `{` -//~^ ERROR expected one of `!`, `(`, `)`, `*`, `,`, `?`, `async`, `const`, `for`, `use`, `~`, lifetime, or path, found `{` +//~^ ERROR expected one of `!`, `(`, `)`, `,`, `?`, `[`, `async`, `const`, `for`, `use`, `~`, lifetime, or path, found `{` //~| ERROR at least one trait is required for an object type fn foo4(_: &dyn <Drop + AsRef<str>>) {} //~ ERROR expected identifier, found `<` diff --git a/tests/ui/parser/trait-object-delimiters.stderr b/tests/ui/parser/trait-object-delimiters.stderr index be130ac7ab2..a2c9161cfbe 100644 --- a/tests/ui/parser/trait-object-delimiters.stderr +++ b/tests/ui/parser/trait-object-delimiters.stderr @@ -39,7 +39,7 @@ error: expected parameter name, found `{` LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {} | ^ expected parameter name -error: expected one of `!`, `(`, `)`, `*`, `,`, `?`, `async`, `const`, `for`, `use`, `~`, lifetime, or path, found `{` +error: expected one of `!`, `(`, `)`, `,`, `?`, `[`, `async`, `const`, `for`, `use`, `~`, lifetime, or path, found `{` --> $DIR/trait-object-delimiters.rs:10:17 | LL | fn foo3(_: &dyn {Drop + AsRef<str>}) {} diff --git a/tests/ui/new-unicode-escapes.rs b/tests/ui/parser/unicode-escape-sequences.rs index 867a50da081..8b084866f19 100644 --- a/tests/ui/new-unicode-escapes.rs +++ b/tests/ui/parser/unicode-escape-sequences.rs @@ -1,6 +1,12 @@ +//! Test ES6-style Unicode escape sequences in string literals. +//! +//! Regression test for RFC 446 implementation. +//! See <https://github.com/rust-lang/rust/pull/19480>. + //@ run-pass pub fn main() { + // Basic Unicode escape - snowman character let s = "\u{2603}"; assert_eq!(s, "☃"); diff --git a/tests/ui/parser/unicode-multibyte-chars-no-ice.rs b/tests/ui/parser/unicode-multibyte-chars-no-ice.rs new file mode 100644 index 00000000000..b1bb0c66ae2 --- /dev/null +++ b/tests/ui/parser/unicode-multibyte-chars-no-ice.rs @@ -0,0 +1,9 @@ +//! Test that multibyte Unicode characters don't crash the compiler. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/4780>. + +//@ run-pass + +pub fn main() { + println!("마이너스 사인이 없으면"); +} diff --git a/tests/ui/pattern/move-ref-patterns/pattern-ref-bindings-reassignment.rs b/tests/ui/pattern/move-ref-patterns/pattern-ref-bindings-reassignment.rs new file mode 100644 index 00000000000..42b0b9ac44d --- /dev/null +++ b/tests/ui/pattern/move-ref-patterns/pattern-ref-bindings-reassignment.rs @@ -0,0 +1,24 @@ +//! Tests how we behave when the user attempts to mutate an immutable +//! binding that was introduced by either `ref` or `ref mut` +//! patterns. +//! +//! Such bindings cannot be made mutable via the mere addition of the +//! `mut` keyword, and thus we want to check that the compiler does not +//! suggest doing so. + +fn main() { + let (mut one_two, mut three_four) = ((1, 2), (3, 4)); + + // Bind via pattern: + // - `a` as immutable reference (`ref`) + // - `b` as mutable reference (`ref mut`) + let &mut (ref a, ref mut b) = &mut one_two; + + // Attempt to reassign immutable `ref`-bound variable + a = &three_four.0; + //~^ ERROR cannot assign twice to immutable variable `a` + + // Attempt to reassign mutable `ref mut`-bound variable + b = &mut three_four.1; + //~^ ERROR cannot assign twice to immutable variable `b` +} diff --git a/tests/ui/reassign-ref-mut.stderr b/tests/ui/pattern/move-ref-patterns/pattern-ref-bindings-reassignment.stderr index e623578e025..e04eb1dd25c 100644 --- a/tests/ui/reassign-ref-mut.stderr +++ b/tests/ui/pattern/move-ref-patterns/pattern-ref-bindings-reassignment.stderr @@ -1,13 +1,14 @@ error[E0384]: cannot assign twice to immutable variable `a` - --> $DIR/reassign-ref-mut.rs:12:5 + --> $DIR/pattern-ref-bindings-reassignment.rs:18:5 | LL | let &mut (ref a, ref mut b) = &mut one_two; | ----- first assignment to `a` +... LL | a = &three_four.0; | ^^^^^^^^^^^^^^^^^ cannot assign twice to immutable variable error[E0384]: cannot assign twice to immutable variable `b` - --> $DIR/reassign-ref-mut.rs:14:5 + --> $DIR/pattern-ref-bindings-reassignment.rs:22:5 | LL | let &mut (ref a, ref mut b) = &mut one_two; | --------- first assignment to `b` diff --git a/tests/ui/pattern/usefulness/conflicting_bindings.rs b/tests/ui/pattern/usefulness/conflicting_bindings.rs index 16737e0a894..883ce4333ca 100644 --- a/tests/ui/pattern/usefulness/conflicting_bindings.rs +++ b/tests/ui/pattern/usefulness/conflicting_bindings.rs @@ -1,4 +1,6 @@ -#![feature(if_let_guard, let_chains)] +//@ edition: 2024 + +#![feature(if_let_guard)] fn main() { let mut x = Some(String::new()); diff --git a/tests/ui/pattern/usefulness/conflicting_bindings.stderr b/tests/ui/pattern/usefulness/conflicting_bindings.stderr index 6f6504e6f64..7ab3393c8d1 100644 --- a/tests/ui/pattern/usefulness/conflicting_bindings.stderr +++ b/tests/ui/pattern/usefulness/conflicting_bindings.stderr @@ -1,5 +1,5 @@ error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:5:9 + --> $DIR/conflicting_bindings.rs:7:9 | LL | let ref mut y @ ref mut z = x; | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -7,7 +7,7 @@ LL | let ref mut y @ ref mut z = x; | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:7:14 + --> $DIR/conflicting_bindings.rs:9:14 | LL | let Some(ref mut y @ ref mut z) = x else { return }; | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -15,7 +15,7 @@ LL | let Some(ref mut y @ ref mut z) = x else { return }; | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:9:17 + --> $DIR/conflicting_bindings.rs:11:17 | LL | if let Some(ref mut y @ ref mut z) = x {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -23,7 +23,7 @@ LL | if let Some(ref mut y @ ref mut z) = x {} | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:11:17 + --> $DIR/conflicting_bindings.rs:13:17 | LL | if let Some(ref mut y @ ref mut z) = x && true {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -31,7 +31,7 @@ LL | if let Some(ref mut y @ ref mut z) = x && true {} | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:13:43 + --> $DIR/conflicting_bindings.rs:15:43 | LL | if let Some(_) = Some(()) && let Some(ref mut y @ ref mut z) = x && true {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -39,7 +39,7 @@ LL | if let Some(_) = Some(()) && let Some(ref mut y @ ref mut z) = x && tru | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:15:20 + --> $DIR/conflicting_bindings.rs:17:20 | LL | while let Some(ref mut y @ ref mut z) = x {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -47,7 +47,7 @@ LL | while let Some(ref mut y @ ref mut z) = x {} | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:17:20 + --> $DIR/conflicting_bindings.rs:19:20 | LL | while let Some(ref mut y @ ref mut z) = x && true {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -55,7 +55,7 @@ LL | while let Some(ref mut y @ ref mut z) = x && true {} | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:20:9 + --> $DIR/conflicting_bindings.rs:22:9 | LL | ref mut y @ ref mut z => {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here @@ -63,7 +63,7 @@ LL | ref mut y @ ref mut z => {} | value is mutably borrowed by `y` here error: cannot borrow value as mutable more than once at a time - --> $DIR/conflicting_bindings.rs:23:24 + --> $DIR/conflicting_bindings.rs:25:24 | LL | () if let Some(ref mut y @ ref mut z) = x => {} | ^^^^^^^^^ --------- value is mutably borrowed by `z` here diff --git a/tests/ui/pin-ergonomics/borrow-unpin.pinned.stderr b/tests/ui/pin-ergonomics/borrow-unpin.pinned.stderr new file mode 100644 index 00000000000..cc438461a5d --- /dev/null +++ b/tests/ui/pin-ergonomics/borrow-unpin.pinned.stderr @@ -0,0 +1,238 @@ +error[E0382]: use of moved value: `foo` + --> $DIR/borrow-unpin.rs:39:14 + | +LL | let foo = Foo::default(); + | --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait +LL | foo_pin_mut(&pin mut foo); + | --- value moved here +LL | foo_move(foo); + | ^^^ value used here after move + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:16:1 + | +LL | struct Foo(PhantomPinned); + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | foo_pin_mut(&pin mut foo); + | --- you could clone this value + +error[E0382]: use of moved value: `foo` + --> $DIR/borrow-unpin.rs:43:14 + | +LL | let foo = Foo::default(); + | --- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait +LL | let x = &pin mut foo; + | --- value moved here +LL | foo_move(foo); + | ^^^ value used here after move + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:16:1 + | +LL | struct Foo(PhantomPinned); + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | let x = &pin mut foo; + | --- you could clone this value + +error[E0382]: use of moved value: `foo` + --> $DIR/borrow-unpin.rs:52:14 + | +LL | let mut foo = Foo::default(); + | ------- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait +LL | foo_pin_mut(&pin mut foo); // ok + | --- value moved here +LL | foo_move(foo); + | ^^^ value used here after move + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:16:1 + | +LL | struct Foo(PhantomPinned); + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | foo_pin_mut(&pin mut foo); // ok + | --- you could clone this value + +error[E0382]: use of moved value: `foo` + --> $DIR/borrow-unpin.rs:56:14 + | +LL | let mut foo = Foo::default(); + | ------- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait +LL | let x = &pin mut foo; // ok + | --- value moved here +LL | foo_move(foo); + | ^^^ value used here after move + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:16:1 + | +LL | struct Foo(PhantomPinned); + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | let x = &pin mut foo; // ok + | --- you could clone this value + +error[E0505]: cannot move out of `foo` because it is borrowed + --> $DIR/borrow-unpin.rs:68:14 + | +LL | let foo = Foo::default(); + | --- binding `foo` declared here +LL | let x = &pin const foo; // ok + | -------------- borrow of `foo` occurs here +LL | foo_move(foo); + | ^^^ move out of `foo` occurs here +LL | +LL | foo_pin_ref(x); + | - borrow later used here + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:16:1 + | +LL | struct Foo(PhantomPinned); + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | let x = &pin const foo; // ok + | --- you could clone this value + +error[E0382]: borrow of moved value: `foo` + --> $DIR/borrow-unpin.rs:76:13 + | +LL | let mut foo = Foo::default(); + | ------- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait +LL | foo_pin_mut(&pin mut foo); // ok + | --- value moved here +LL | foo_ref(&foo); + | ^^^^ value borrowed here after move + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:16:1 + | +LL | struct Foo(PhantomPinned); + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | foo_pin_mut(&pin mut foo); // ok + | --- you could clone this value + +error[E0382]: borrow of moved value: `foo` + --> $DIR/borrow-unpin.rs:80:13 + | +LL | let mut foo = Foo::default(); + | ------- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait +LL | let x = &pin mut foo; // ok + | --- value moved here +LL | foo_ref(&foo); + | ^^^^ value borrowed here after move + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:16:1 + | +LL | struct Foo(PhantomPinned); + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | let x = &pin mut foo; // ok + | --- you could clone this value + +error[E0382]: use of moved value: `foo` + --> $DIR/borrow-unpin.rs:99:26 + | +LL | let mut foo = Foo::default(); + | ------- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait +LL | foo_pin_mut(&pin mut foo); // ok + | --- value moved here +LL | foo_pin_mut(&pin mut foo); + | ^^^ value used here after move + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:16:1 + | +LL | struct Foo(PhantomPinned); + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | foo_pin_mut(&pin mut foo); // ok + | --- you could clone this value + +error[E0382]: use of moved value: `foo` + --> $DIR/borrow-unpin.rs:103:26 + | +LL | let mut foo = Foo::default(); + | ------- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait +LL | let x = &pin mut foo; // ok + | --- value moved here +LL | foo_pin_mut(&pin mut foo); + | ^^^ value used here after move + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:16:1 + | +LL | struct Foo(PhantomPinned); + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | let x = &pin mut foo; // ok + | --- you could clone this value + +error[E0505]: cannot move out of `foo` because it is borrowed + --> $DIR/borrow-unpin.rs:115:26 + | +LL | let mut foo = Foo::default(); + | ------- binding `foo` declared here +LL | let x = &pin const foo; // ok + | -------------- borrow of `foo` occurs here +LL | foo_pin_mut(&pin mut foo); + | ^^^ move out of `foo` occurs here +LL | +LL | foo_pin_ref(x); + | - borrow later used here + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:16:1 + | +LL | struct Foo(PhantomPinned); + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | let x = &pin const foo; // ok + | --- you could clone this value + +error[E0382]: borrow of moved value: `foo` + --> $DIR/borrow-unpin.rs:123:17 + | +LL | let mut foo = Foo::default(); + | ------- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait +LL | foo_pin_mut(&pin mut foo); // ok + | --- value moved here +LL | foo_pin_ref(&pin const foo); + | ^^^^^^^^^^^^^^ value borrowed here after move + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:16:1 + | +LL | struct Foo(PhantomPinned); + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | foo_pin_mut(&pin mut foo); // ok + | --- you could clone this value + +error[E0382]: borrow of moved value: `foo` + --> $DIR/borrow-unpin.rs:127:17 + | +LL | let mut foo = Foo::default(); + | ------- move occurs because `foo` has type `Foo`, which does not implement the `Copy` trait +LL | let x = &pin mut foo; // ok + | --- value moved here +LL | foo_pin_ref(&pin const foo); + | ^^^^^^^^^^^^^^ value borrowed here after move + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:16:1 + | +LL | struct Foo(PhantomPinned); + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | let x = &pin mut foo; // ok + | --- you could clone this value + +error: aborting due to 12 previous errors + +Some errors have detailed explanations: E0382, E0505. +For more information about an error, try `rustc --explain E0382`. diff --git a/tests/ui/pin-ergonomics/borrow-unpin.rs b/tests/ui/pin-ergonomics/borrow-unpin.rs new file mode 100644 index 00000000000..61e69bab12b --- /dev/null +++ b/tests/ui/pin-ergonomics/borrow-unpin.rs @@ -0,0 +1,143 @@ +//@ revisions: unpin pinned +#![feature(pin_ergonomics)] +#![allow(dead_code, incomplete_features)] + +// For now, in order to ensure soundness, we move the place in `&pin mut place` +// if `place` is not `Unpin`. +// In the next step, we borrow the place instead of moving it, after that we +// have to makes sure `&pin mut place` and `&pin const place` cannot violate +// the mut-xor-share rules. + +use std::pin::Pin; +use std::marker::PhantomPinned; + +#[cfg(pinned)] +#[derive(Default)] +struct Foo(PhantomPinned); + +#[cfg(unpin)] +#[derive(Default)] +struct Foo; + +fn foo_mut(_: &mut Foo) { +} + +fn foo_ref(_: &Foo) { +} + +fn foo_pin_mut(_: Pin<&mut Foo>) { +} + +fn foo_pin_ref(_: Pin<&Foo>) { +} + +fn foo_move(_: Foo) {} + +fn immutable_pin_mut_then_move() { + let foo = Foo::default(); + foo_pin_mut(&pin mut foo); //[unpin]~ ERROR cannot borrow `foo` as mutable, as it is not declared as mutable + foo_move(foo); //[pinned]~ ERROR use of moved value: `foo` + + let foo = Foo::default(); + let x = &pin mut foo; //[unpin]~ ERROR cannot borrow `foo` as mutable, as it is not declared as mutable + foo_move(foo); //[pinned]~ ERROR use of moved value: `foo` + //[unpin]~^ ERROR cannot move out of `foo` because it is borrowed + foo_pin_mut(x); // +} + + +fn pin_mut_then_move() { + let mut foo = Foo::default(); + foo_pin_mut(&pin mut foo); // ok + foo_move(foo); //[pinned]~ ERROR use of moved value: `foo` + + let mut foo = Foo::default(); + let x = &pin mut foo; // ok + foo_move(foo); //[pinned]~ ERROR use of moved value: `foo` + //[unpin]~^ ERROR cannot move out of `foo` because it is borrowed + foo_pin_mut(x); // +} + +fn pin_ref_then_move() { + let foo = Foo::default(); + foo_pin_ref(&pin const foo); // ok + foo_move(foo); // ok + + let foo = Foo::default(); + let x = &pin const foo; // ok + foo_move(foo); //[pinned]~ ERROR cannot move out of `foo` because it is borrowed + //[unpin]~^ ERROR cannot move out of `foo` because it is borrowed + foo_pin_ref(x); +} + +fn pin_mut_then_ref() { + let mut foo = Foo::default(); + foo_pin_mut(&pin mut foo); // ok + foo_ref(&foo); //[pinned]~ ERROR borrow of moved value: `foo` + + let mut foo = Foo::default(); + let x = &pin mut foo; // ok + foo_ref(&foo); //[pinned]~ ERROR borrow of moved value: `foo` + //[unpin]~^ ERROR cannot borrow `foo` as immutable because it is also borrowed as mutable + foo_pin_mut(x); +} + +fn pin_ref_then_ref() { + let mut foo = Foo::default(); + foo_pin_ref(&pin const foo); // ok + foo_ref(&foo); // ok + + let mut foo = Foo::default(); + let x = &pin const foo; // ok + foo_ref(&foo); // ok + foo_pin_ref(x); +} + +fn pin_mut_then_pin_mut() { + let mut foo = Foo::default(); + foo_pin_mut(&pin mut foo); // ok + foo_pin_mut(&pin mut foo); //[pinned]~ ERROR use of moved value: `foo` + + let mut foo = Foo::default(); + let x = &pin mut foo; // ok + foo_pin_mut(&pin mut foo); //[pinned]~ ERROR use of moved value: `foo` + //[unpin]~^ ERROR cannot borrow `foo` as mutable more than once at a time + foo_pin_mut(x); +} + +fn pin_ref_then_pin_mut() { + let mut foo = Foo::default(); + foo_pin_ref(&pin const foo); // ok + foo_pin_mut(&pin mut foo); // ok + + let mut foo = Foo::default(); + let x = &pin const foo; // ok + foo_pin_mut(&pin mut foo); //[pinned]~ ERROR cannot move out of `foo` because it is borrowed + //[unpin]~^ ERROR cannot borrow `foo` as mutable because it is also borrowed as immutable + foo_pin_ref(x); +} + +fn pin_mut_then_pin_ref() { + let mut foo = Foo::default(); + foo_pin_mut(&pin mut foo); // ok + foo_pin_ref(&pin const foo); //[pinned]~ ERROR borrow of moved value: `foo` + + let mut foo = Foo::default(); + let x = &pin mut foo; // ok + foo_pin_ref(&pin const foo); //[pinned]~ ERROR borrow of moved value: `foo` + //[unpin]~^ ERROR cannot borrow `foo` as immutable because it is also borrowed as mutable + foo_pin_mut(x); +} + +fn pin_ref_then_pin_ref() { + let mut foo = Foo::default(); + foo_pin_ref(&pin const foo); // ok + foo_pin_ref(&pin const foo); // ok + + let mut foo = Foo::default(); + let x = &pin const foo; // ok + foo_pin_ref(&pin const foo); // ok + foo_pin_ref(x); +} + +fn main() {} diff --git a/tests/ui/pin-ergonomics/borrow-unpin.unpin.stderr b/tests/ui/pin-ergonomics/borrow-unpin.unpin.stderr new file mode 100644 index 00000000000..bf9921343ee --- /dev/null +++ b/tests/ui/pin-ergonomics/borrow-unpin.unpin.stderr @@ -0,0 +1,136 @@ +error[E0596]: cannot borrow `foo` as mutable, as it is not declared as mutable + --> $DIR/borrow-unpin.rs:38:17 + | +LL | foo_pin_mut(&pin mut foo); + | ^^^^^^^^^^^^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +LL | let mut foo = Foo::default(); + | +++ + +error[E0596]: cannot borrow `foo` as mutable, as it is not declared as mutable + --> $DIR/borrow-unpin.rs:42:13 + | +LL | let x = &pin mut foo; + | ^^^^^^^^^^^^ cannot borrow as mutable + | +help: consider changing this to be mutable + | +LL | let mut foo = Foo::default(); + | +++ + +error[E0505]: cannot move out of `foo` because it is borrowed + --> $DIR/borrow-unpin.rs:43:14 + | +LL | let foo = Foo::default(); + | --- binding `foo` declared here +LL | let x = &pin mut foo; + | ------------ borrow of `foo` occurs here +LL | foo_move(foo); + | ^^^ move out of `foo` occurs here +LL | +LL | foo_pin_mut(x); // + | - borrow later used here + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:20:1 + | +LL | struct Foo; + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | let x = &pin mut foo; + | --- you could clone this value + +error[E0505]: cannot move out of `foo` because it is borrowed + --> $DIR/borrow-unpin.rs:56:14 + | +LL | let mut foo = Foo::default(); + | ------- binding `foo` declared here +LL | let x = &pin mut foo; // ok + | ------------ borrow of `foo` occurs here +LL | foo_move(foo); + | ^^^ move out of `foo` occurs here +LL | +LL | foo_pin_mut(x); // + | - borrow later used here + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:20:1 + | +LL | struct Foo; + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | let x = &pin mut foo; // ok + | --- you could clone this value + +error[E0505]: cannot move out of `foo` because it is borrowed + --> $DIR/borrow-unpin.rs:68:14 + | +LL | let foo = Foo::default(); + | --- binding `foo` declared here +LL | let x = &pin const foo; // ok + | -------------- borrow of `foo` occurs here +LL | foo_move(foo); + | ^^^ move out of `foo` occurs here +LL | +LL | foo_pin_ref(x); + | - borrow later used here + | +note: if `Foo` implemented `Clone`, you could clone the value + --> $DIR/borrow-unpin.rs:20:1 + | +LL | struct Foo; + | ^^^^^^^^^^ consider implementing `Clone` for this type +... +LL | let x = &pin const foo; // ok + | --- you could clone this value + +error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable + --> $DIR/borrow-unpin.rs:80:13 + | +LL | let x = &pin mut foo; // ok + | ------------ mutable borrow occurs here +LL | foo_ref(&foo); + | ^^^^ immutable borrow occurs here +LL | +LL | foo_pin_mut(x); + | - mutable borrow later used here + +error[E0499]: cannot borrow `foo` as mutable more than once at a time + --> $DIR/borrow-unpin.rs:103:17 + | +LL | let x = &pin mut foo; // ok + | ------------ first mutable borrow occurs here +LL | foo_pin_mut(&pin mut foo); + | ^^^^^^^^^^^^ second mutable borrow occurs here +LL | +LL | foo_pin_mut(x); + | - first borrow later used here + +error[E0502]: cannot borrow `foo` as mutable because it is also borrowed as immutable + --> $DIR/borrow-unpin.rs:115:17 + | +LL | let x = &pin const foo; // ok + | -------------- immutable borrow occurs here +LL | foo_pin_mut(&pin mut foo); + | ^^^^^^^^^^^^ mutable borrow occurs here +LL | +LL | foo_pin_ref(x); + | - immutable borrow later used here + +error[E0502]: cannot borrow `foo` as immutable because it is also borrowed as mutable + --> $DIR/borrow-unpin.rs:127:17 + | +LL | let x = &pin mut foo; // ok + | ------------ mutable borrow occurs here +LL | foo_pin_ref(&pin const foo); + | ^^^^^^^^^^^^^^ immutable borrow occurs here +LL | +LL | foo_pin_mut(x); + | - mutable borrow later used here + +error: aborting due to 9 previous errors + +Some errors have detailed explanations: E0499, E0502, E0505, E0596. +For more information about an error, try `rustc --explain E0499`. diff --git a/tests/ui/pin-ergonomics/borrow.rs b/tests/ui/pin-ergonomics/borrow.rs new file mode 100644 index 00000000000..f221165848b --- /dev/null +++ b/tests/ui/pin-ergonomics/borrow.rs @@ -0,0 +1,38 @@ +//@ check-pass +#![feature(pin_ergonomics)] +#![allow(dead_code, incomplete_features)] + +// Makes sure we can handle `&pin mut place` and `&pin const place` as sugar for +// `std::pin::pin!(place)` and `Pin::new(&place)`. + +use std::pin::Pin; + +struct Foo; + +fn foo_pin_mut(_: Pin<&mut Foo>) { +} + +fn foo_pin_ref(_: Pin<&Foo>) { +} + +fn bar() { + let mut x: Pin<&mut _> = &pin mut Foo; + foo_pin_mut(x.as_mut()); + foo_pin_mut(x.as_mut()); + foo_pin_ref(x); + + let x: Pin<&_> = &pin const Foo; + + foo_pin_ref(x); + foo_pin_ref(x); +} + +fn baz(mut x: Foo, y: Foo) { + let _x = &pin mut x; + let _x = x; // ok because `Foo: Unpin` and thus `&pin mut x` doesn't move `x` + + let _y = &pin const y; + let _y = y; // ok because `&pin const y` dosn't move `y` +} + +fn main() {} diff --git a/tests/ui/async-await/pin-ergonomics/coerce-non-pointer-pin.rs b/tests/ui/pin-ergonomics/coerce-non-pointer-pin.rs index a95665f126d..a95665f126d 100644 --- a/tests/ui/async-await/pin-ergonomics/coerce-non-pointer-pin.rs +++ b/tests/ui/pin-ergonomics/coerce-non-pointer-pin.rs diff --git a/tests/ui/async-await/pin-ergonomics/coerce-non-pointer-pin.stderr b/tests/ui/pin-ergonomics/coerce-non-pointer-pin.stderr index 2deb5b09884..2deb5b09884 100644 --- a/tests/ui/async-await/pin-ergonomics/coerce-non-pointer-pin.stderr +++ b/tests/ui/pin-ergonomics/coerce-non-pointer-pin.stderr diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-arg.rs b/tests/ui/pin-ergonomics/reborrow-arg.rs index 2008bd1f52d..2008bd1f52d 100644 --- a/tests/ui/async-await/pin-ergonomics/reborrow-arg.rs +++ b/tests/ui/pin-ergonomics/reborrow-arg.rs diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-const-as-mut.rs b/tests/ui/pin-ergonomics/reborrow-const-as-mut.rs index 27c70a7b4df..27c70a7b4df 100644 --- a/tests/ui/async-await/pin-ergonomics/reborrow-const-as-mut.rs +++ b/tests/ui/pin-ergonomics/reborrow-const-as-mut.rs diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-const-as-mut.stderr b/tests/ui/pin-ergonomics/reborrow-const-as-mut.stderr index 36bbf1c493a..36bbf1c493a 100644 --- a/tests/ui/async-await/pin-ergonomics/reborrow-const-as-mut.stderr +++ b/tests/ui/pin-ergonomics/reborrow-const-as-mut.stderr diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-once.rs b/tests/ui/pin-ergonomics/reborrow-once.rs index 241efadef7d..241efadef7d 100644 --- a/tests/ui/async-await/pin-ergonomics/reborrow-once.rs +++ b/tests/ui/pin-ergonomics/reborrow-once.rs diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-once.stderr b/tests/ui/pin-ergonomics/reborrow-once.stderr index dc8e424ad2a..dc8e424ad2a 100644 --- a/tests/ui/async-await/pin-ergonomics/reborrow-once.stderr +++ b/tests/ui/pin-ergonomics/reborrow-once.stderr diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-self.rs b/tests/ui/pin-ergonomics/reborrow-self.rs index ee617617da0..ee617617da0 100644 --- a/tests/ui/async-await/pin-ergonomics/reborrow-self.rs +++ b/tests/ui/pin-ergonomics/reborrow-self.rs diff --git a/tests/ui/async-await/pin-ergonomics/reborrow-shorter.rs b/tests/ui/pin-ergonomics/reborrow-shorter.rs index 06c266e0035..06c266e0035 100644 --- a/tests/ui/async-await/pin-ergonomics/reborrow-shorter.rs +++ b/tests/ui/pin-ergonomics/reborrow-shorter.rs diff --git a/tests/ui/async-await/pin-ergonomics/sugar-ambiguity.rs b/tests/ui/pin-ergonomics/sugar-ambiguity.rs index d183000931e..d183000931e 100644 --- a/tests/ui/async-await/pin-ergonomics/sugar-ambiguity.rs +++ b/tests/ui/pin-ergonomics/sugar-ambiguity.rs diff --git a/tests/ui/async-await/pin-ergonomics/sugar-no-const.rs b/tests/ui/pin-ergonomics/sugar-no-const.rs index dd6456b6034..dd6456b6034 100644 --- a/tests/ui/async-await/pin-ergonomics/sugar-no-const.rs +++ b/tests/ui/pin-ergonomics/sugar-no-const.rs diff --git a/tests/ui/async-await/pin-ergonomics/sugar-no-const.stderr b/tests/ui/pin-ergonomics/sugar-no-const.stderr index 062b6d3f487..062b6d3f487 100644 --- a/tests/ui/async-await/pin-ergonomics/sugar-no-const.stderr +++ b/tests/ui/pin-ergonomics/sugar-no-const.stderr diff --git a/tests/ui/async-await/pin-ergonomics/sugar-self.rs b/tests/ui/pin-ergonomics/sugar-self.rs index 3d71b54b1ae..3d71b54b1ae 100644 --- a/tests/ui/async-await/pin-ergonomics/sugar-self.rs +++ b/tests/ui/pin-ergonomics/sugar-self.rs diff --git a/tests/ui/async-await/pin-ergonomics/sugar.rs b/tests/ui/pin-ergonomics/sugar.rs index 8dbdec418b1..8dbdec418b1 100644 --- a/tests/ui/async-await/pin-ergonomics/sugar.rs +++ b/tests/ui/pin-ergonomics/sugar.rs diff --git a/tests/ui/pptypedef.rs b/tests/ui/pptypedef.rs deleted file mode 100644 index d5f43df9d85..00000000000 --- a/tests/ui/pptypedef.rs +++ /dev/null @@ -1,13 +0,0 @@ -//@ dont-require-annotations: NOTE - -fn let_in<T, F>(x: T, f: F) where F: FnOnce(T) {} - -fn main() { - let_in(3u32, |i| { assert!(i == 3i32); }); - //~^ ERROR mismatched types - //~| NOTE expected `u32`, found `i32` - - let_in(3i32, |i| { assert!(i == 3u32); }); - //~^ ERROR mismatched types - //~| NOTE expected `i32`, found `u32` -} diff --git a/tests/ui/pptypedef.stderr b/tests/ui/pptypedef.stderr deleted file mode 100644 index a6d673e61c6..00000000000 --- a/tests/ui/pptypedef.stderr +++ /dev/null @@ -1,31 +0,0 @@ -error[E0308]: mismatched types - --> $DIR/pptypedef.rs:6:37 - | -LL | let_in(3u32, |i| { assert!(i == 3i32); }); - | - ^^^^ expected `u32`, found `i32` - | | - | expected because this is `u32` - | -help: change the type of the numeric literal from `i32` to `u32` - | -LL - let_in(3u32, |i| { assert!(i == 3i32); }); -LL + let_in(3u32, |i| { assert!(i == 3u32); }); - | - -error[E0308]: mismatched types - --> $DIR/pptypedef.rs:10:37 - | -LL | let_in(3i32, |i| { assert!(i == 3u32); }); - | - ^^^^ expected `i32`, found `u32` - | | - | expected because this is `i32` - | -help: change the type of the numeric literal from `u32` to `i32` - | -LL - let_in(3i32, |i| { assert!(i == 3u32); }); -LL + let_in(3i32, |i| { assert!(i == 3i32); }); - | - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/primitive-binop-lhs-mut.rs b/tests/ui/primitive-binop-lhs-mut.rs deleted file mode 100644 index d988e2ed14f..00000000000 --- a/tests/ui/primitive-binop-lhs-mut.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ run-pass - -fn main() { - let x = Box::new(0); - assert_eq!(0, *x + { drop(x); let _ = Box::new(main); 0 }); -} diff --git a/tests/ui/print-calling-conventions.rs b/tests/ui/print-calling-conventions.rs deleted file mode 100644 index 302ed088142..00000000000 --- a/tests/ui/print-calling-conventions.rs +++ /dev/null @@ -1,2 +0,0 @@ -//@ compile-flags: --print calling-conventions -//@ build-pass diff --git a/tests/ui/print-request/print-calling-conventions.rs b/tests/ui/print-request/print-calling-conventions.rs new file mode 100644 index 00000000000..cefaa0d9b6f --- /dev/null +++ b/tests/ui/print-request/print-calling-conventions.rs @@ -0,0 +1,4 @@ +//! Test that `--print calling-conventions` outputs all supported calling conventions. + +//@ compile-flags: --print calling-conventions +//@ build-pass diff --git a/tests/ui/print-calling-conventions.stdout b/tests/ui/print-request/print-calling-conventions.stdout index 7b5ae495660..b8b939e1c04 100644 --- a/tests/ui/print-calling-conventions.stdout +++ b/tests/ui/print-request/print-calling-conventions.stdout @@ -1,6 +1,4 @@ C -C-cmse-nonsecure-call -C-cmse-nonsecure-entry C-unwind Rust aapcs @@ -9,6 +7,8 @@ avr-interrupt avr-non-blocking-interrupt cdecl cdecl-unwind +cmse-nonsecure-call +cmse-nonsecure-entry custom efiapi fastcall @@ -20,6 +20,7 @@ riscv-interrupt-m riscv-interrupt-s rust-call rust-cold +rust-invalid stdcall stdcall-unwind system diff --git a/tests/ui/process/core-run-destroy.rs b/tests/ui/process/core-run-destroy.rs index b4815c9dfbb..f4be54da8fe 100644 --- a/tests/ui/process/core-run-destroy.rs +++ b/tests/ui/process/core-run-destroy.rs @@ -37,7 +37,7 @@ pub fn sleeper() -> Child { pub fn sleeper() -> Child { // There's a `timeout` command on windows, but it doesn't like having // its output piped, so instead just ping ourselves a few times with - // gaps in between so we're sure this process is alive for awhile + // gaps in between so we're sure this process is alive for a while t!(Command::new("ping").arg("127.0.0.1").arg("-n").arg("1000").spawn()) } diff --git a/tests/ui/project-cache-issue-31849.rs b/tests/ui/project-cache-issue-31849.rs deleted file mode 100644 index 29c278171a6..00000000000 --- a/tests/ui/project-cache-issue-31849.rs +++ /dev/null @@ -1,65 +0,0 @@ -//@ run-pass -// Regression test for #31849: the problem here was actually a performance -// cliff, but I'm adding the test for reference. - -pub trait Upcast<T> { - fn upcast(self) -> T; -} - -impl<S1, S2, T1, T2> Upcast<(T1, T2)> for (S1,S2) - where S1: Upcast<T1>, - S2: Upcast<T2>, -{ - fn upcast(self) -> (T1, T2) { (self.0.upcast(), self.1.upcast()) } -} - -impl Upcast<()> for () -{ - fn upcast(self) -> () { () } -} - -pub trait ToStatic { - type Static: 'static; - fn to_static(self) -> Self::Static where Self: Sized; -} - -impl<T, U> ToStatic for (T, U) - where T: ToStatic, - U: ToStatic -{ - type Static = (T::Static, U::Static); - fn to_static(self) -> Self::Static { (self.0.to_static(), self.1.to_static()) } -} - -impl ToStatic for () -{ - type Static = (); - fn to_static(self) -> () { () } -} - - -trait Factory { - type Output; - fn build(&self) -> Self::Output; -} - -impl<S,T> Factory for (S, T) - where S: Factory, - T: Factory, - S::Output: ToStatic, - <S::Output as ToStatic>::Static: Upcast<S::Output>, -{ - type Output = (S::Output, T::Output); - fn build(&self) -> Self::Output { (self.0.build().to_static().upcast(), self.1.build()) } -} - -impl Factory for () { - type Output = (); - fn build(&self) -> Self::Output { () } -} - -fn main() { - // More parens, more time. - let it = ((((((((((),()),()),()),()),()),()),()),()),()); - it.build(); -} diff --git a/tests/ui/ptr-coercion-rpass.rs b/tests/ui/ptr-coercion-rpass.rs deleted file mode 100644 index 8cc4120328e..00000000000 --- a/tests/ui/ptr-coercion-rpass.rs +++ /dev/null @@ -1,29 +0,0 @@ -//@ run-pass - -#![allow(unused_variables)] -// Test coercions between pointers which don't do anything fancy like unsizing. - - -pub fn main() { - // &mut -> & - let x: &mut isize = &mut 42; - let x: &isize = x; - - let x: &isize = &mut 42; - - // & -> *const - let x: &isize = &42; - let x: *const isize = x; - - let x: *const isize = &42; - - // &mut -> *const - let x: &mut isize = &mut 42; - let x: *const isize = x; - - let x: *const isize = &mut 42; - - // *mut -> *const - let x: *mut isize = &mut 42; - let x: *const isize = x; -} diff --git a/tests/ui/query-visibility.rs b/tests/ui/query-visibility.rs deleted file mode 100644 index 84abe875910..00000000000 --- a/tests/ui/query-visibility.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ check-pass -// Check that it doesn't panic when `Input` gets its visibility checked. - -#![crate_type = "lib"] - -pub trait Layer< - /// Hello. - Input, -> {} diff --git a/tests/ui/raw-str.rs b/tests/ui/raw-str.rs deleted file mode 100644 index 23018403295..00000000000 --- a/tests/ui/raw-str.rs +++ /dev/null Binary files differdiff --git a/tests/ui/reassign-ref-mut.rs b/tests/ui/reassign-ref-mut.rs deleted file mode 100644 index d6d41e959d9..00000000000 --- a/tests/ui/reassign-ref-mut.rs +++ /dev/null @@ -1,16 +0,0 @@ -// Tests how we behave when the user attempts to mutate an immutable -// binding that was introduced by either `ref` or `ref mut` -// patterns. -// -// Such bindings cannot be made mutable via the mere addition of the -// `mut` keyword, and thus we want to check that the compiler does not -// suggest doing so. - -fn main() { - let (mut one_two, mut three_four) = ((1, 2), (3, 4)); - let &mut (ref a, ref mut b) = &mut one_two; - a = &three_four.0; - //~^ ERROR cannot assign twice to immutable variable `a` [E0384] - b = &mut three_four.1; - //~^ ERROR cannot assign twice to immutable variable `b` [E0384] -} diff --git a/tests/ui/recursion/recursive-static-definition.rs b/tests/ui/recursion/recursive-static-definition.rs index 55db6a86bf1..4f0624eb162 100644 --- a/tests/ui/recursion/recursive-static-definition.rs +++ b/tests/ui/recursion/recursive-static-definition.rs @@ -1,5 +1,5 @@ pub static FOO: u32 = FOO; -//~^ ERROR encountered static that tried to initialize itself with itself +//~^ ERROR encountered static that tried to access itself during initialization #[derive(Copy, Clone)] pub union Foo { @@ -7,6 +7,6 @@ pub union Foo { } pub static BAR: Foo = BAR; -//~^ ERROR encountered static that tried to initialize itself with itself +//~^ ERROR encountered static that tried to access itself during initialization fn main() {} diff --git a/tests/ui/recursion/recursive-static-definition.stderr b/tests/ui/recursion/recursive-static-definition.stderr index ce93c41bc67..1e4005832cb 100644 --- a/tests/ui/recursion/recursive-static-definition.stderr +++ b/tests/ui/recursion/recursive-static-definition.stderr @@ -1,10 +1,10 @@ -error[E0080]: encountered static that tried to initialize itself with itself +error[E0080]: encountered static that tried to access itself during initialization --> $DIR/recursive-static-definition.rs:1:23 | LL | pub static FOO: u32 = FOO; | ^^^ evaluation of `FOO` failed here -error[E0080]: encountered static that tried to initialize itself with itself +error[E0080]: encountered static that tried to access itself during initialization --> $DIR/recursive-static-definition.rs:9:23 | LL | pub static BAR: Foo = BAR; diff --git a/tests/ui/regions/lifetime-not-long-enough-suggestion-regression-test-124563.stderr b/tests/ui/regions/lifetime-not-long-enough-suggestion-regression-test-124563.stderr index 9f1315070eb..e94074548e9 100644 --- a/tests/ui/regions/lifetime-not-long-enough-suggestion-regression-test-124563.stderr +++ b/tests/ui/regions/lifetime-not-long-enough-suggestion-regression-test-124563.stderr @@ -1,8 +1,8 @@ error[E0478]: lifetime bound not satisfied - --> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:19:16 + --> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:19:5 | LL | type Bar = BarImpl<'a, 'b, T>; - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | note: lifetime parameter instantiated with the lifetime `'a` as defined here --> $DIR/lifetime-not-long-enough-suggestion-regression-test-124563.rs:14:6 diff --git a/tests/ui/regions/region-bounds-on-objects-and-type-parameters.stderr b/tests/ui/regions/region-bounds-on-objects-and-type-parameters.stderr index b15d2affeea..e2a5027e710 100644 --- a/tests/ui/regions/region-bounds-on-objects-and-type-parameters.stderr +++ b/tests/ui/regions/region-bounds-on-objects-and-type-parameters.stderr @@ -4,6 +4,14 @@ error[E0226]: only a single explicit lifetime bound is permitted LL | z: Box<dyn Is<'a>+'b+'c>, | ^^ +error[E0392]: lifetime parameter `'c` is never used + --> $DIR/region-bounds-on-objects-and-type-parameters.rs:11:18 + | +LL | struct Foo<'a,'b,'c> { + | ^^ unused lifetime parameter + | + = help: consider removing `'c`, referring to it in a field, or using a marker such as `PhantomData` + error[E0478]: lifetime bound not satisfied --> $DIR/region-bounds-on-objects-and-type-parameters.rs:21:8 | @@ -21,14 +29,6 @@ note: but lifetime parameter must outlive the lifetime `'a` as defined here LL | struct Foo<'a,'b,'c> { | ^^ -error[E0392]: lifetime parameter `'c` is never used - --> $DIR/region-bounds-on-objects-and-type-parameters.rs:11:18 - | -LL | struct Foo<'a,'b,'c> { - | ^^ unused lifetime parameter - | - = help: consider removing `'c`, referring to it in a field, or using a marker such as `PhantomData` - error: aborting due to 3 previous errors Some errors have detailed explanations: E0226, E0392, E0478. diff --git a/tests/ui/regions/regions-in-enums.stderr b/tests/ui/regions/regions-in-enums.stderr index 66537653291..449763e8b59 100644 --- a/tests/ui/regions/regions-in-enums.stderr +++ b/tests/ui/regions/regions-in-enums.stderr @@ -1,18 +1,24 @@ error[E0261]: use of undeclared lifetime name `'foo` --> $DIR/regions-in-enums.rs:13:9 | -LL | enum No0 { - | - help: consider introducing lifetime `'foo` here: `<'foo>` LL | X5(&'foo usize) | ^^^^ undeclared lifetime + | +help: consider introducing lifetime `'foo` here + | +LL | enum No0<'foo> { + | ++++++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-in-enums.rs:17:9 | -LL | enum No1 { - | - help: consider introducing lifetime `'a` here: `<'a>` LL | X6(&'a usize) | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | enum No1<'a> { + | ++++ error: aborting due to 2 previous errors diff --git a/tests/ui/regions/regions-in-structs.stderr b/tests/ui/regions/regions-in-structs.stderr index 5dfdc2ee93b..c34b1ffca64 100644 --- a/tests/ui/regions/regions-in-structs.stderr +++ b/tests/ui/regions/regions-in-structs.stderr @@ -1,19 +1,24 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-in-structs.rs:10:9 | -LL | struct StructDecl { - | - help: consider introducing lifetime `'a` here: `<'a>` LL | a: &'a isize, | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | struct StructDecl<'a> { + | ++++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-in-structs.rs:11:9 | -LL | struct StructDecl { - | - help: consider introducing lifetime `'a` here: `<'a>` -LL | a: &'a isize, LL | b: &'a isize, | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | struct StructDecl<'a> { + | ++++ error: aborting due to 2 previous errors diff --git a/tests/ui/regions/regions-name-undeclared.stderr b/tests/ui/regions/regions-name-undeclared.stderr index 532603de5f7..06e6f4299de 100644 --- a/tests/ui/regions/regions-name-undeclared.stderr +++ b/tests/ui/regions/regions-name-undeclared.stderr @@ -50,9 +50,12 @@ LL | fn bar<'a>(x: &'a isize) { | -- lifetime parameter from outer item ... LL | type X = Option<&'a isize>; - | - ^^ use of generic parameter from outer item - | | - | help: consider introducing lifetime `'a` here: `<'a>` + | ^^ use of generic parameter from outer item + | +help: consider introducing lifetime `'a` here + | +LL | type X<'a> = Option<&'a isize>; + | ++++ error[E0401]: can't use generic parameters from outer item --> $DIR/regions-name-undeclared.rs:28:13 @@ -60,10 +63,13 @@ error[E0401]: can't use generic parameters from outer item LL | fn bar<'a>(x: &'a isize) { | -- lifetime parameter from outer item ... -LL | enum E { - | - help: consider introducing lifetime `'a` here: `<'a>` LL | E1(&'a isize) | ^^ use of generic parameter from outer item + | +help: consider introducing lifetime `'a` here + | +LL | enum E<'a> { + | ++++ error[E0401]: can't use generic parameters from outer item --> $DIR/regions-name-undeclared.rs:31:13 @@ -71,10 +77,13 @@ error[E0401]: can't use generic parameters from outer item LL | fn bar<'a>(x: &'a isize) { | -- lifetime parameter from outer item ... -LL | struct S { - | - help: consider introducing lifetime `'a` here: `<'a>` LL | f: &'a isize | ^^ use of generic parameter from outer item + | +help: consider introducing lifetime `'a` here + | +LL | struct S<'a> { + | ++++ error[E0401]: can't use generic parameters from outer item --> $DIR/regions-name-undeclared.rs:33:14 @@ -83,17 +92,23 @@ LL | fn bar<'a>(x: &'a isize) { | -- lifetime parameter from outer item ... LL | fn f(a: &'a isize) { } - | - ^^ use of generic parameter from outer item - | | - | help: consider introducing lifetime `'a` here: `<'a>` + | ^^ use of generic parameter from outer item + | +help: consider introducing lifetime `'a` here + | +LL | fn f<'a>(a: &'a isize) { } + | ++++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-name-undeclared.rs:41:17 | LL | fn fn_types(a: &'a isize, - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `<'a>` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn fn_types<'a>(a: &'a isize, + | ++++ error[E0261]: use of undeclared lifetime name `'b` --> $DIR/regions-name-undeclared.rs:43:36 @@ -129,11 +144,13 @@ LL | fn fn_types<'b>(a: &'a isize, error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-name-undeclared.rs:47:17 | -LL | fn fn_types(a: &'a isize, - | - help: consider introducing lifetime `'a` here: `<'a>` -... LL | c: &'a isize) | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn fn_types<'a>(a: &'a isize, + | ++++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-name-undeclared.rs:53:31 diff --git a/tests/ui/regions/regions-normalize-in-where-clause-list.rs b/tests/ui/regions/regions-normalize-in-where-clause-list.rs index 389f82e794b..9b046e6baed 100644 --- a/tests/ui/regions/regions-normalize-in-where-clause-list.rs +++ b/tests/ui/regions/regions-normalize-in-where-clause-list.rs @@ -22,9 +22,9 @@ where // Here we get an error: we need `'a: 'b`. fn bar<'a, 'b>() -//~^ ERROR cannot infer where <() as Project<'a, 'b>>::Item: Eq, + //~^ ERROR cannot infer { } diff --git a/tests/ui/regions/regions-normalize-in-where-clause-list.stderr b/tests/ui/regions/regions-normalize-in-where-clause-list.stderr index ca9ceeeeff3..9a5c9ae53de 100644 --- a/tests/ui/regions/regions-normalize-in-where-clause-list.stderr +++ b/tests/ui/regions/regions-normalize-in-where-clause-list.stderr @@ -1,8 +1,8 @@ error[E0803]: cannot infer an appropriate lifetime for lifetime parameter `'a` due to conflicting requirements - --> $DIR/regions-normalize-in-where-clause-list.rs:24:4 + --> $DIR/regions-normalize-in-where-clause-list.rs:26:36 | -LL | fn bar<'a, 'b>() - | ^^^ +LL | <() as Project<'a, 'b>>::Item: Eq, + | ^^ | note: first, the lifetime cannot outlive the lifetime `'a` as defined here... --> $DIR/regions-normalize-in-where-clause-list.rs:24:8 @@ -15,10 +15,10 @@ note: ...but the lifetime must also be valid for the lifetime `'b` as defined he LL | fn bar<'a, 'b>() | ^^ note: ...so that the types are compatible - --> $DIR/regions-normalize-in-where-clause-list.rs:24:4 + --> $DIR/regions-normalize-in-where-clause-list.rs:26:36 | -LL | fn bar<'a, 'b>() - | ^^^ +LL | <() as Project<'a, 'b>>::Item: Eq, + | ^^ = note: expected `Project<'a, 'b>` found `Project<'_, '_>` diff --git a/tests/ui/regions/regions-undeclared.stderr b/tests/ui/regions/regions-undeclared.stderr index 6bfde5524ac..2bc0f184803 100644 --- a/tests/ui/regions/regions-undeclared.stderr +++ b/tests/ui/regions/regions-undeclared.stderr @@ -7,35 +7,46 @@ LL | static c_x: &'blk isize = &22; error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-undeclared.rs:4:10 | -LL | enum EnumDecl { - | - help: consider introducing lifetime `'a` here: `<'a>` LL | Foo(&'a isize), | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | enum EnumDecl<'a> { + | ++++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-undeclared.rs:5:10 | -LL | enum EnumDecl { - | - help: consider introducing lifetime `'a` here: `<'a>` -LL | Foo(&'a isize), LL | Bar(&'a isize), | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | enum EnumDecl<'a> { + | ++++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-undeclared.rs:8:15 | LL | fn fnDecl(x: &'a isize, - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `<'a>` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn fnDecl<'a>(x: &'a isize, + | ++++ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/regions-undeclared.rs:9:15 | -LL | fn fnDecl(x: &'a isize, - | - help: consider introducing lifetime `'a` here: `<'a>` LL | y: &'a isize) | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn fnDecl<'a>(x: &'a isize, + | ++++ error: aborting due to 5 previous errors diff --git a/tests/ui/repr/repr-empty-packed.stderr b/tests/ui/repr/repr-empty-packed.stderr index c824c2998b4..6565b2e8c1d 100644 --- a/tests/ui/repr/repr-empty-packed.stderr +++ b/tests/ui/repr/repr-empty-packed.stderr @@ -1,27 +1,26 @@ +error[E0517]: attribute should be applied to a struct or union + --> $DIR/repr-empty-packed.rs:5:8 + | +LL | #[repr(packed)] + | ^^^^^^ +LL | / pub enum Foo { +LL | | Bar, +LL | | Baz(i32), +LL | | } + | |_- not a struct or union + error: unused attribute --> $DIR/repr-empty-packed.rs:4:1 | LL | #[repr()] | ^^^^^^^^^ help: remove this attribute | - = note: attribute `repr` with an empty list has no effect note: the lint level is defined here --> $DIR/repr-empty-packed.rs:2:9 | LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -error[E0517]: attribute should be applied to a struct or union - --> $DIR/repr-empty-packed.rs:5:8 - | -LL | #[repr(packed)] - | ^^^^^^ -LL | / pub enum Foo { -LL | | Bar, -LL | | Baz(i32), -LL | | } - | |_- not a struct or union - error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0517`. diff --git a/tests/ui/resolve/path-attr-in-const-block.rs b/tests/ui/resolve/path-attr-in-const-block.rs index 076511d26d6..69be65bda3f 100644 --- a/tests/ui/resolve/path-attr-in-const-block.rs +++ b/tests/ui/resolve/path-attr-in-const-block.rs @@ -5,5 +5,6 @@ fn main() { const { #![path = foo!()] //~^ ERROR: cannot find macro `foo` in this scope + //~| ERROR malformed `path` attribute input } } diff --git a/tests/ui/resolve/path-attr-in-const-block.stderr b/tests/ui/resolve/path-attr-in-const-block.stderr index 8f9e58157c8..0b5942a287d 100644 --- a/tests/ui/resolve/path-attr-in-const-block.stderr +++ b/tests/ui/resolve/path-attr-in-const-block.stderr @@ -4,5 +4,15 @@ error: cannot find macro `foo` in this scope LL | #![path = foo!()] | ^^^ -error: aborting due to 1 previous error +error[E0539]: malformed `path` attribute input + --> $DIR/path-attr-in-const-block.rs:6:9 + | +LL | #![path = foo!()] + | ^^^^^^^^^^------^ + | | | + | | expected a string literal here + | help: must be of the form: `#[path = "file"]` + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr b/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr index a9b45a18af3..f53e9e3b478 100644 --- a/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr +++ b/tests/ui/resolve/resolve-conflict-extern-crate-vs-extern-crate.stderr @@ -2,6 +2,7 @@ error[E0259]: the name `std` is defined multiple times | = note: `std` must be defined only once in the type namespace of this module help: you can use `as` to change the binding name of the import + --> $DIR/resolve-conflict-extern-crate-vs-extern-crate.rs:1:17 | LL | extern crate std as other_std; | ++++++++++++ diff --git a/tests/ui/resolve/resolve-same-name-struct.rs b/tests/ui/resolve/resolve-same-name-struct.rs new file mode 100644 index 00000000000..1bea0938e3d --- /dev/null +++ b/tests/ui/resolve/resolve-same-name-struct.rs @@ -0,0 +1,29 @@ +//! Test that name resolution works correctly when a struct and its constructor +//! function have the same name within a nested scope. This checks that the +//! compiler can distinguish between type names and value names in the same +//! namespace. + +//@ run-pass + +struct Point { + i: isize, +} + +impl Point { + fn get_value(&self) -> isize { + return 37; + } +} + +// Constructor function with the same name as the struct +#[allow(non_snake_case)] +fn Point(i: isize) -> Point { + Point { i } +} + +pub fn main() { + // Test that we can use the constructor function + let point = Point(42); + assert_eq!(point.i, 42); + assert_eq!(point.get_value(), 37); +} diff --git a/tests/ui/max-min-classes.rs b/tests/ui/resolve/struct-function-same-name.rs index 338a3156a9a..bb2837d7ca6 100644 --- a/tests/ui/max-min-classes.rs +++ b/tests/ui/resolve/struct-function-same-name.rs @@ -1,3 +1,5 @@ +//! Test that a struct and function can have the same name +//! //@ run-pass #![allow(non_snake_case)] @@ -23,7 +25,7 @@ impl Product for Foo { } fn Foo(x: isize, y: isize) -> Foo { - Foo { x: x, y: y } + Foo { x, y } } pub fn main() { diff --git a/tests/ui/lexical-scoping.rs b/tests/ui/resolve/type-param-local-var-shadowing.rs index f858369f7ce..e08379e2acf 100644 --- a/tests/ui/lexical-scoping.rs +++ b/tests/ui/resolve/type-param-local-var-shadowing.rs @@ -1,8 +1,13 @@ +//! Test that items in subscopes correctly shadow type parameters and local variables +//! +//! Regression test for https://github.com/rust-lang/rust/issues/23880 + //@ run-pass -// Tests that items in subscopes can shadow type parameters and local variables (see issue #23880). #![allow(unused)] -struct Foo<X> { x: Box<X> } +struct Foo<X> { + x: Box<X>, +} impl<Bar> Foo<Bar> { fn foo(&self) { type Bar = i32; diff --git a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr index 136cd763b05..1ac017aa08b 100644 --- a/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr +++ b/tests/ui/rfcs/rfc-2008-non-exhaustive/invalid-attribute.stderr @@ -1,8 +1,11 @@ -error: malformed `non_exhaustive` attribute input +error[E0565]: malformed `non_exhaustive` attribute input --> $DIR/invalid-attribute.rs:1:1 | LL | #[non_exhaustive(anything)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[non_exhaustive]` + | ^^^^^^^^^^^^^^^^----------^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[non_exhaustive]` error[E0701]: attribute should be applied to a struct or enum --> $DIR/invalid-attribute.rs:5:1 @@ -27,4 +30,5 @@ LL | | } error: aborting due to 3 previous errors -For more information about this error, try `rustc --explain E0701`. +Some errors have detailed explanations: E0565, E0701. +For more information about an error, try `rustc --explain E0565`. diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-odd-syntax.stderr b/tests/ui/rfcs/rfc-2091-track-caller/error-odd-syntax.stderr index e22d812c8b0..6088945b829 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/error-odd-syntax.stderr +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-odd-syntax.stderr @@ -1,8 +1,12 @@ -error: malformed `track_caller` attribute input +error[E0565]: malformed `track_caller` attribute input --> $DIR/error-odd-syntax.rs:1:1 | LL | #[track_caller(1)] - | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[track_caller]` + | ^^^^^^^^^^^^^^---^ + | | | + | | didn't expect any arguments here + | help: must be of the form: `#[track_caller]` error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0565`. diff --git a/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr index d3cafbc6350..30360806138 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr +++ b/tests/ui/rfcs/rfc-2091-track-caller/error-with-naked.stderr @@ -1,17 +1,17 @@ error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/error-with-naked.rs:5:1 + --> $DIR/error-with-naked.rs:5:3 | LL | #[track_caller] - | ^^^^^^^^^^^^^^^ the `track_caller` attribute is incompatible with `#[unsafe(naked)]` + | ^^^^^^^^^^^^ the `track_caller` attribute is incompatible with `#[unsafe(naked)]` LL | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here error[E0736]: attribute incompatible with `#[unsafe(naked)]` - --> $DIR/error-with-naked.rs:17:5 + --> $DIR/error-with-naked.rs:17:7 | LL | #[track_caller] - | ^^^^^^^^^^^^^^^ the `track_caller` attribute is incompatible with `#[unsafe(naked)]` + | ^^^^^^^^^^^^ the `track_caller` attribute is incompatible with `#[unsafe(naked)]` LL | LL | #[unsafe(naked)] | ---------------- function marked with `#[unsafe(naked)]` here diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr index 591585c88f5..01a3f528359 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region-rev.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-region-rev.rs:17:20 + --> $DIR/regions-outlives-nominal-type-region-rev.rs:17:9 | LL | type Out = &'a Foo<'b>; - | ^^^^^^^^^^^ + | ^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/regions-outlives-nominal-type-region-rev.rs:16:10 diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr index 0404b52d9ef..ff4c5f07284 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-region.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a Foo<'b>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-region.rs:17:20 + --> $DIR/regions-outlives-nominal-type-region.rs:17:9 | LL | type Out = &'a Foo<'b>; - | ^^^^^^^^^^^ + | ^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/regions-outlives-nominal-type-region.rs:16:10 diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr index 62415e250ec..a0ede2aeada 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type-rev.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-type-rev.rs:17:20 + --> $DIR/regions-outlives-nominal-type-type-rev.rs:17:9 | LL | type Out = &'a Foo<&'b i32>; - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/regions-outlives-nominal-type-type-rev.rs:16:10 diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr index 464d7968b74..23d3f4ac606 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-outlives-nominal-type-type.stderr @@ -1,8 +1,8 @@ error[E0491]: in type `&'a Foo<&'b i32>`, reference has a longer lifetime than the data it references - --> $DIR/regions-outlives-nominal-type-type.rs:17:20 + --> $DIR/regions-outlives-nominal-type-type.rs:17:9 | LL | type Out = &'a Foo<&'b i32>; - | ^^^^^^^^^^^^^^^^ + | ^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/regions-outlives-nominal-type-type.rs:16:10 diff --git a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.stderr b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.stderr index eb17ce736f7..73c0bbc44fb 100644 --- a/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.stderr +++ b/tests/ui/rfcs/rfc-2093-infer-outlives/regions-struct-not-wf.stderr @@ -1,10 +1,10 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:13:16 + --> $DIR/regions-struct-not-wf.rs:13:5 | LL | impl<'a, T> Trait<'a, T> for usize { | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | type Out = &'a T; - | ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at + | ^^^^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at | help: consider adding an explicit lifetime bound | @@ -12,12 +12,12 @@ LL | impl<'a, T: 'a> Trait<'a, T> for usize { | ++++ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/regions-struct-not-wf.rs:21:16 + --> $DIR/regions-struct-not-wf.rs:21:5 | LL | impl<'a, T> Trait<'a, T> for u32 { | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | type Out = RefOk<'a, T>; - | ^^^^^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... + | ^^^^^^^^ ...so that the type `T` will meet its required lifetime bounds... | note: ...that is required by this bound --> $DIR/regions-struct-not-wf.rs:16:20 @@ -30,10 +30,10 @@ LL | impl<'a, T: 'a> Trait<'a, T> for u32 { | ++++ error[E0491]: in type `&'a &'b T`, reference has a longer lifetime than the data it references - --> $DIR/regions-struct-not-wf.rs:25:16 + --> $DIR/regions-struct-not-wf.rs:25:5 | LL | type Out = &'a &'b T; - | ^^^^^^^^^ + | ^^^^^^^^ | note: the pointer is valid for the lifetime `'a` as defined here --> $DIR/regions-struct-not-wf.rs:24:6 diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope-let-chains.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope-let-chains.rs new file mode 100644 index 00000000000..4d2eac2ea2d --- /dev/null +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope-let-chains.rs @@ -0,0 +1,57 @@ +// Ensure that temporaries in if-let guards live for the arm +// regression test for #118593 + +//@ check-pass +//@ edition: 2024 + +#![feature(if_let_guard)] + +fn get_temp() -> Option<String> { + None +} + +fn let_let_chain_guard(num: u8) { + match num { + 5 | 6 + if let Some(ref a) = get_temp() + && let Some(ref b) = get_temp() => + { + let _x = a; + let _y = b; + } + _ => {} + } + match num { + 7 | 8 + if let Some(ref mut c) = get_temp() + && let Some(ref mut d) = get_temp() => + { + let _w = c; + let _z = d; + } + _ => {} + } +} + +fn let_cond_chain_guard(num: u8) { + match num { + 9 | 10 + if let Some(ref a) = get_temp() + && true => + { + let _x = a; + } + _ => {} + } + match num { + 11 | 12 + if let Some(ref mut b) = get_temp() + && true => + { + let _w = b; + } + _ => {} + } +} + +fn main() {} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope.rs index 0578b827a47..59e33bb6af8 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/drop-scope.rs @@ -4,7 +4,6 @@ //@ check-pass #![feature(if_let_guard)] -#![feature(let_chains)] fn get_temp() -> Option<String> { None @@ -25,48 +24,4 @@ fn let_guard(num: u8) { } } -fn let_let_chain_guard(num: u8) { - match num { - 5 | 6 - if let Some(ref a) = get_temp() - && let Some(ref b) = get_temp() => - { - let _x = a; - let _y = b; - } - _ => {} - } - match num { - 7 | 8 - if let Some(ref mut c) = get_temp() - && let Some(ref mut d) = get_temp() => - { - let _w = c; - let _z = d; - } - _ => {} - } -} - -fn let_cond_chain_guard(num: u8) { - match num { - 9 | 10 - if let Some(ref a) = get_temp() - && true => - { - let _x = a; - } - _ => {} - } - match num { - 11 | 12 - if let Some(ref mut b) = get_temp() - && true => - { - let _w = b; - } - _ => {} - } -} - fn main() {} diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/partially-macro-expanded.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/partially-macro-expanded.rs index e836b0b88ff..294a0d02770 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/partially-macro-expanded.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/partially-macro-expanded.rs @@ -2,7 +2,6 @@ //@ check-pass #![feature(if_let_guard)] -#![feature(let_chains)] macro_rules! m { (pattern $i:ident) => { Some($i) }; diff --git a/tests/ui/rfcs/rfc-2294-if-let-guard/scope.rs b/tests/ui/rfcs/rfc-2294-if-let-guard/scope.rs index 56a6fb5bfa3..47cc7a64bd1 100644 --- a/tests/ui/rfcs/rfc-2294-if-let-guard/scope.rs +++ b/tests/ui/rfcs/rfc-2294-if-let-guard/scope.rs @@ -3,7 +3,6 @@ //@run-pass #![feature(if_let_guard)] -#![feature(let_chains)] #![allow(irrefutable_let_patterns)] fn lhs_let(opt: Option<bool>) { diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-ref-impl.rs b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-ref-impl.rs new file mode 100644 index 00000000000..c6e38c0758d --- /dev/null +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-ref-impl.rs @@ -0,0 +1,17 @@ +/// Check that only `&X: Debug` is required, not `X: Debug` +//@check-pass + +use std::fmt::Debug; +use std::fmt::Formatter; + +struct X; + +impl Debug for &X { + fn fmt(&self, f: &mut Formatter<'_>) -> Result<(), std::fmt::Error> { + f.write_str("X") + } +} + +fn main() { + dbg!(X); +} diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs index f2fb62d76f3..fe71f106fdf 100644 --- a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.rs @@ -1,4 +1,7 @@ // Test ensuring that `dbg!(expr)` requires the passed type to implement `Debug`. +// +// `dbg!` shouldn't tell the user about format literal syntax; the user didn't write one. +//@ forbid-output: cannot be formatted using struct NotDebug; diff --git a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr index 7ec018a95cc..4e0ae918415 100644 --- a/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr +++ b/tests/ui/rfcs/rfc-2361-dbg-macro/dbg-macro-requires-debug.stderr @@ -1,12 +1,11 @@ error[E0277]: `NotDebug` doesn't implement `Debug` - --> $DIR/dbg-macro-requires-debug.rs:6:23 + --> $DIR/dbg-macro-requires-debug.rs:9:23 | LL | let _: NotDebug = dbg!(NotDebug); - | ^^^^^^^^^^^^^^ `NotDebug` cannot be formatted using `{:?}` + | ^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `NotDebug` | - = help: the trait `Debug` is not implemented for `NotDebug` = note: add `#[derive(Debug)]` to `NotDebug` or manually `impl Debug for NotDebug` - = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) + = note: this error originates in the macro `dbg` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider annotating `NotDebug` with `#[derive(Debug)]` | LL + #[derive(Debug)] diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.no_feature.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.e2021.stderr index dda09de4c53..15e7be8c65f 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.no_feature.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.e2021.stderr @@ -1,239 +1,263 @@ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:33:9 + --> $DIR/disallowed-positions.rs:32:9 | LL | if (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:33:9 + --> $DIR/disallowed-positions.rs:32:9 | LL | if (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:36:11 + --> $DIR/disallowed-positions.rs:35:11 | LL | if (((let 0 = 1))) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:36:11 + --> $DIR/disallowed-positions.rs:35:11 | LL | if (((let 0 = 1))) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:39:9 + --> $DIR/disallowed-positions.rs:38:9 | LL | if (let 0 = 1) && true {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:39:9 + --> $DIR/disallowed-positions.rs:38:9 | LL | if (let 0 = 1) && true {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:42:17 + --> $DIR/disallowed-positions.rs:41:17 | LL | if true && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:42:17 + --> $DIR/disallowed-positions.rs:41:17 | LL | if true && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:45:9 + --> $DIR/disallowed-positions.rs:44:9 | LL | if (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:45:9 + --> $DIR/disallowed-positions.rs:44:9 | LL | if (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:45:24 + --> $DIR/disallowed-positions.rs:44:24 | LL | if (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:45:24 + --> $DIR/disallowed-positions.rs:44:24 | LL | if (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ +error: let chains are only allowed in Rust 2024 or later + --> $DIR/disallowed-positions.rs:48:8 + | +LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^ + +error: let chains are only allowed in Rust 2024 or later + --> $DIR/disallowed-positions.rs:48:21 + | +LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^ + error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:49:35 + --> $DIR/disallowed-positions.rs:48:35 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:49:35 + --> $DIR/disallowed-positions.rs:48:35 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:49:48 + --> $DIR/disallowed-positions.rs:48:48 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:49:35 + --> $DIR/disallowed-positions.rs:48:35 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:49:61 + --> $DIR/disallowed-positions.rs:48:61 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:49:35 + --> $DIR/disallowed-positions.rs:48:35 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:59:12 + --> $DIR/disallowed-positions.rs:58:12 | LL | while (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:59:12 + --> $DIR/disallowed-positions.rs:58:12 | LL | while (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:62:14 + --> $DIR/disallowed-positions.rs:61:14 | LL | while (((let 0 = 1))) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:62:14 + --> $DIR/disallowed-positions.rs:61:14 | LL | while (((let 0 = 1))) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:65:12 + --> $DIR/disallowed-positions.rs:64:12 | LL | while (let 0 = 1) && true {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:65:12 + --> $DIR/disallowed-positions.rs:64:12 | LL | while (let 0 = 1) && true {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:68:20 + --> $DIR/disallowed-positions.rs:67:20 | LL | while true && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:68:20 + --> $DIR/disallowed-positions.rs:67:20 | LL | while true && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:71:12 + --> $DIR/disallowed-positions.rs:70:12 | LL | while (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:71:12 + --> $DIR/disallowed-positions.rs:70:12 | LL | while (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:71:27 + --> $DIR/disallowed-positions.rs:70:27 | LL | while (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:71:27 + --> $DIR/disallowed-positions.rs:70:27 | LL | while (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ +error: let chains are only allowed in Rust 2024 or later + --> $DIR/disallowed-positions.rs:74:11 + | +LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^ + +error: let chains are only allowed in Rust 2024 or later + --> $DIR/disallowed-positions.rs:74:24 + | +LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} + | ^^^^^^^^^ + error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:75:38 + --> $DIR/disallowed-positions.rs:74:38 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:75:38 + --> $DIR/disallowed-positions.rs:74:38 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:75:51 + --> $DIR/disallowed-positions.rs:74:51 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:75:38 + --> $DIR/disallowed-positions.rs:74:38 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:75:64 + --> $DIR/disallowed-positions.rs:74:64 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:75:38 + --> $DIR/disallowed-positions.rs:74:38 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:103:9 + --> $DIR/disallowed-positions.rs:102:9 | LL | if &let 0 = 0 {} | ^^^^^^^^^ @@ -241,7 +265,7 @@ LL | if &let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:106:9 + --> $DIR/disallowed-positions.rs:105:9 | LL | if !let 0 = 0 {} | ^^^^^^^^^ @@ -249,7 +273,7 @@ LL | if !let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:108:9 + --> $DIR/disallowed-positions.rs:107:9 | LL | if *let 0 = 0 {} | ^^^^^^^^^ @@ -257,7 +281,7 @@ LL | if *let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:110:9 + --> $DIR/disallowed-positions.rs:109:9 | LL | if -let 0 = 0 {} | ^^^^^^^^^ @@ -265,7 +289,7 @@ LL | if -let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:118:9 + --> $DIR/disallowed-positions.rs:117:9 | LL | if (let 0 = 0)? {} | ^^^^^^^^^ @@ -273,13 +297,13 @@ LL | if (let 0 = 0)? {} = note: only supported directly in conditions of `if` and `while` expressions error: `||` operators are not supported in let chain conditions - --> $DIR/disallowed-positions.rs:121:13 + --> $DIR/disallowed-positions.rs:120:13 | LL | if true || let 0 = 0 {} | ^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:123:17 + --> $DIR/disallowed-positions.rs:122:17 | LL | if (true || let 0 = 0) {} | ^^^^^^^^^ @@ -287,7 +311,7 @@ LL | if (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:125:25 + --> $DIR/disallowed-positions.rs:124:25 | LL | if true && (true || let 0 = 0) {} | ^^^^^^^^^ @@ -295,7 +319,7 @@ LL | if true && (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:127:25 + --> $DIR/disallowed-positions.rs:126:25 | LL | if true || (true && let 0 = 0) {} | ^^^^^^^^^ @@ -303,7 +327,7 @@ LL | if true || (true && let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:131:12 + --> $DIR/disallowed-positions.rs:130:12 | LL | if x = let 0 = 0 {} | ^^^ @@ -311,7 +335,7 @@ LL | if x = let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:134:15 + --> $DIR/disallowed-positions.rs:133:15 | LL | if true..(let 0 = 0) {} | ^^^^^^^^^ @@ -319,7 +343,7 @@ LL | if true..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:137:11 + --> $DIR/disallowed-positions.rs:136:11 | LL | if ..(let 0 = 0) {} | ^^^^^^^^^ @@ -327,7 +351,7 @@ LL | if ..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:139:9 + --> $DIR/disallowed-positions.rs:138:9 | LL | if (let 0 = 0).. {} | ^^^^^^^^^ @@ -335,7 +359,7 @@ LL | if (let 0 = 0).. {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:143:8 + --> $DIR/disallowed-positions.rs:142:8 | LL | if let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -343,7 +367,7 @@ LL | if let Range { start: _, end: _ } = true..true && false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:146:8 + --> $DIR/disallowed-positions.rs:145:8 | LL | if let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -351,7 +375,7 @@ LL | if let Range { start: _, end: _ } = true..true || false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:152:8 + --> $DIR/disallowed-positions.rs:151:8 | LL | if let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -359,7 +383,7 @@ LL | if let Range { start: F, end } = F..|| true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:158:8 + --> $DIR/disallowed-positions.rs:157:8 | LL | if let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -367,7 +391,7 @@ LL | if let Range { start: true, end } = t..&&false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:162:19 + --> $DIR/disallowed-positions.rs:161:19 | LL | if let true = let true = true {} | ^^^ @@ -375,7 +399,7 @@ LL | if let true = let true = true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:165:15 + --> $DIR/disallowed-positions.rs:164:15 | LL | if return let 0 = 0 {} | ^^^ @@ -383,7 +407,7 @@ LL | if return let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:168:21 + --> $DIR/disallowed-positions.rs:167:21 | LL | loop { if break let 0 = 0 {} } | ^^^ @@ -391,7 +415,7 @@ LL | loop { if break let 0 = 0 {} } = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:171:15 + --> $DIR/disallowed-positions.rs:170:15 | LL | if (match let 0 = 0 { _ => { false } }) {} | ^^^ @@ -399,7 +423,7 @@ LL | if (match let 0 = 0 { _ => { false } }) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:174:9 + --> $DIR/disallowed-positions.rs:173:9 | LL | if (let 0 = 0, false).1 {} | ^^^^^^^^^ @@ -407,7 +431,7 @@ LL | if (let 0 = 0, false).1 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:177:9 + --> $DIR/disallowed-positions.rs:176:9 | LL | if (let 0 = 0,) {} | ^^^^^^^^^ @@ -415,7 +439,7 @@ LL | if (let 0 = 0,) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:181:13 + --> $DIR/disallowed-positions.rs:180:13 | LL | if (let 0 = 0).await {} | ^^^^^^^^^ @@ -423,7 +447,7 @@ LL | if (let 0 = 0).await {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:185:12 + --> $DIR/disallowed-positions.rs:184:12 | LL | if (|| let 0 = 0) {} | ^^^ @@ -431,7 +455,7 @@ LL | if (|| let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:188:9 + --> $DIR/disallowed-positions.rs:187:9 | LL | if (let 0 = 0)() {} | ^^^^^^^^^ @@ -439,7 +463,7 @@ LL | if (let 0 = 0)() {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:194:12 + --> $DIR/disallowed-positions.rs:193:12 | LL | while &let 0 = 0 {} | ^^^^^^^^^ @@ -447,7 +471,7 @@ LL | while &let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:197:12 + --> $DIR/disallowed-positions.rs:196:12 | LL | while !let 0 = 0 {} | ^^^^^^^^^ @@ -455,7 +479,7 @@ LL | while !let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:199:12 + --> $DIR/disallowed-positions.rs:198:12 | LL | while *let 0 = 0 {} | ^^^^^^^^^ @@ -463,7 +487,7 @@ LL | while *let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:201:12 + --> $DIR/disallowed-positions.rs:200:12 | LL | while -let 0 = 0 {} | ^^^^^^^^^ @@ -471,7 +495,7 @@ LL | while -let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:209:12 + --> $DIR/disallowed-positions.rs:208:12 | LL | while (let 0 = 0)? {} | ^^^^^^^^^ @@ -479,13 +503,13 @@ LL | while (let 0 = 0)? {} = note: only supported directly in conditions of `if` and `while` expressions error: `||` operators are not supported in let chain conditions - --> $DIR/disallowed-positions.rs:212:16 + --> $DIR/disallowed-positions.rs:211:16 | LL | while true || let 0 = 0 {} | ^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:214:20 + --> $DIR/disallowed-positions.rs:213:20 | LL | while (true || let 0 = 0) {} | ^^^^^^^^^ @@ -493,7 +517,7 @@ LL | while (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:216:28 + --> $DIR/disallowed-positions.rs:215:28 | LL | while true && (true || let 0 = 0) {} | ^^^^^^^^^ @@ -501,7 +525,7 @@ LL | while true && (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:218:28 + --> $DIR/disallowed-positions.rs:217:28 | LL | while true || (true && let 0 = 0) {} | ^^^^^^^^^ @@ -509,7 +533,7 @@ LL | while true || (true && let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:222:15 + --> $DIR/disallowed-positions.rs:221:15 | LL | while x = let 0 = 0 {} | ^^^ @@ -517,7 +541,7 @@ LL | while x = let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:225:18 + --> $DIR/disallowed-positions.rs:224:18 | LL | while true..(let 0 = 0) {} | ^^^^^^^^^ @@ -525,7 +549,7 @@ LL | while true..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:228:14 + --> $DIR/disallowed-positions.rs:227:14 | LL | while ..(let 0 = 0) {} | ^^^^^^^^^ @@ -533,7 +557,7 @@ LL | while ..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:230:12 + --> $DIR/disallowed-positions.rs:229:12 | LL | while (let 0 = 0).. {} | ^^^^^^^^^ @@ -541,7 +565,7 @@ LL | while (let 0 = 0).. {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:234:11 + --> $DIR/disallowed-positions.rs:233:11 | LL | while let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -549,7 +573,7 @@ LL | while let Range { start: _, end: _ } = true..true && false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:237:11 + --> $DIR/disallowed-positions.rs:236:11 | LL | while let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -557,7 +581,7 @@ LL | while let Range { start: _, end: _ } = true..true || false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:243:11 + --> $DIR/disallowed-positions.rs:242:11 | LL | while let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -565,7 +589,7 @@ LL | while let Range { start: F, end } = F..|| true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:249:11 + --> $DIR/disallowed-positions.rs:248:11 | LL | while let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -573,7 +597,7 @@ LL | while let Range { start: true, end } = t..&&false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:253:22 + --> $DIR/disallowed-positions.rs:252:22 | LL | while let true = let true = true {} | ^^^ @@ -581,7 +605,7 @@ LL | while let true = let true = true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:256:18 + --> $DIR/disallowed-positions.rs:255:18 | LL | while return let 0 = 0 {} | ^^^ @@ -589,7 +613,7 @@ LL | while return let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:259:39 + --> $DIR/disallowed-positions.rs:258:39 | LL | 'outer: loop { while break 'outer let 0 = 0 {} } | ^^^ @@ -597,7 +621,7 @@ LL | 'outer: loop { while break 'outer let 0 = 0 {} } = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:262:18 + --> $DIR/disallowed-positions.rs:261:18 | LL | while (match let 0 = 0 { _ => { false } }) {} | ^^^ @@ -605,7 +629,7 @@ LL | while (match let 0 = 0 { _ => { false } }) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:265:12 + --> $DIR/disallowed-positions.rs:264:12 | LL | while (let 0 = 0, false).1 {} | ^^^^^^^^^ @@ -613,7 +637,7 @@ LL | while (let 0 = 0, false).1 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:268:12 + --> $DIR/disallowed-positions.rs:267:12 | LL | while (let 0 = 0,) {} | ^^^^^^^^^ @@ -621,7 +645,7 @@ LL | while (let 0 = 0,) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:272:16 + --> $DIR/disallowed-positions.rs:271:16 | LL | while (let 0 = 0).await {} | ^^^^^^^^^ @@ -629,7 +653,7 @@ LL | while (let 0 = 0).await {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:276:15 + --> $DIR/disallowed-positions.rs:275:15 | LL | while (|| let 0 = 0) {} | ^^^ @@ -637,7 +661,7 @@ LL | while (|| let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:279:12 + --> $DIR/disallowed-positions.rs:278:12 | LL | while (let 0 = 0)() {} | ^^^^^^^^^ @@ -645,7 +669,7 @@ LL | while (let 0 = 0)() {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:296:6 + --> $DIR/disallowed-positions.rs:295:6 | LL | &let 0 = 0; | ^^^ @@ -653,7 +677,7 @@ LL | &let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:299:6 + --> $DIR/disallowed-positions.rs:298:6 | LL | !let 0 = 0; | ^^^ @@ -661,7 +685,7 @@ LL | !let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:301:6 + --> $DIR/disallowed-positions.rs:300:6 | LL | *let 0 = 0; | ^^^ @@ -669,7 +693,7 @@ LL | *let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:303:6 + --> $DIR/disallowed-positions.rs:302:6 | LL | -let 0 = 0; | ^^^ @@ -677,7 +701,7 @@ LL | -let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:305:13 + --> $DIR/disallowed-positions.rs:304:13 | LL | let _ = let _ = 3; | ^^^ @@ -685,7 +709,7 @@ LL | let _ = let _ = 3; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:313:6 + --> $DIR/disallowed-positions.rs:312:6 | LL | (let 0 = 0)?; | ^^^ @@ -693,7 +717,7 @@ LL | (let 0 = 0)?; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:316:13 + --> $DIR/disallowed-positions.rs:315:13 | LL | true || let 0 = 0; | ^^^ @@ -701,7 +725,7 @@ LL | true || let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:318:14 + --> $DIR/disallowed-positions.rs:317:14 | LL | (true || let 0 = 0); | ^^^ @@ -709,7 +733,7 @@ LL | (true || let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:320:22 + --> $DIR/disallowed-positions.rs:319:22 | LL | true && (true || let 0 = 0); | ^^^ @@ -717,7 +741,7 @@ LL | true && (true || let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:324:9 + --> $DIR/disallowed-positions.rs:323:9 | LL | x = let 0 = 0; | ^^^ @@ -725,7 +749,7 @@ LL | x = let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:327:12 + --> $DIR/disallowed-positions.rs:326:12 | LL | true..(let 0 = 0); | ^^^ @@ -733,7 +757,7 @@ LL | true..(let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:329:8 + --> $DIR/disallowed-positions.rs:328:8 | LL | ..(let 0 = 0); | ^^^ @@ -741,7 +765,7 @@ LL | ..(let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:331:6 + --> $DIR/disallowed-positions.rs:330:6 | LL | (let 0 = 0)..; | ^^^ @@ -749,7 +773,7 @@ LL | (let 0 = 0)..; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:334:6 + --> $DIR/disallowed-positions.rs:333:6 | LL | (let Range { start: _, end: _ } = true..true || false); | ^^^ @@ -757,7 +781,7 @@ LL | (let Range { start: _, end: _ } = true..true || false); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:338:6 + --> $DIR/disallowed-positions.rs:337:6 | LL | (let true = let true = true); | ^^^ @@ -765,7 +789,7 @@ LL | (let true = let true = true); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:338:17 + --> $DIR/disallowed-positions.rs:337:17 | LL | (let true = let true = true); | ^^^ @@ -773,7 +797,7 @@ LL | (let true = let true = true); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:344:25 + --> $DIR/disallowed-positions.rs:343:25 | LL | let x = true && let y = 1; | ^^^ @@ -781,7 +805,7 @@ LL | let x = true && let y = 1; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:350:19 + --> $DIR/disallowed-positions.rs:349:19 | LL | [1, 2, 3][let _ = ()] | ^^^ @@ -789,7 +813,7 @@ LL | [1, 2, 3][let _ = ()] = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:355:6 + --> $DIR/disallowed-positions.rs:354:6 | LL | &let 0 = 0 | ^^^ @@ -797,7 +821,7 @@ LL | &let 0 = 0 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:366:17 + --> $DIR/disallowed-positions.rs:365:17 | LL | true && let 1 = 1 | ^^^ @@ -805,7 +829,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:371:17 + --> $DIR/disallowed-positions.rs:370:17 | LL | true && let 1 = 1 | ^^^ @@ -813,7 +837,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:376:17 + --> $DIR/disallowed-positions.rs:375:17 | LL | true && let 1 = 1 | ^^^ @@ -821,7 +845,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:387:17 + --> $DIR/disallowed-positions.rs:386:17 | LL | true && let 1 = 1 | ^^^ @@ -829,7 +853,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/disallowed-positions.rs:387:9 + --> $DIR/disallowed-positions.rs:386:9 | LL | true && let 1 = 1 | ^^^^^^^^^^^^^^^^^ @@ -840,124 +864,154 @@ LL | { true && let 1 = 1 } | + + error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:397:9 + --> $DIR/disallowed-positions.rs:396:9 | LL | if (let Some(a) = opt && true) { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:397:9 + --> $DIR/disallowed-positions.rs:396:9 | LL | if (let Some(a) = opt && true) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:401:9 + --> $DIR/disallowed-positions.rs:400:9 | LL | if (let Some(a) = opt) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:401:9 + --> $DIR/disallowed-positions.rs:400:9 | LL | if (let Some(a) = opt) && true { | ^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:404:9 + --> $DIR/disallowed-positions.rs:403:9 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:404:9 + --> $DIR/disallowed-positions.rs:403:9 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:404:32 + --> $DIR/disallowed-positions.rs:403:32 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:404:32 + --> $DIR/disallowed-positions.rs:403:32 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^ +error: let chains are only allowed in Rust 2024 or later + --> $DIR/disallowed-positions.rs:407:8 + | +LL | if let Some(a) = opt && (true && true) { + | ^^^^^^^^^^^^^^^^^ + error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:412:9 + --> $DIR/disallowed-positions.rs:411:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:412:9 + --> $DIR/disallowed-positions.rs:411:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:412:31 + --> $DIR/disallowed-positions.rs:411:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:412:31 + --> $DIR/disallowed-positions.rs:411:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:416:9 + --> $DIR/disallowed-positions.rs:415:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:416:9 + --> $DIR/disallowed-positions.rs:415:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:416:31 + --> $DIR/disallowed-positions.rs:415:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:416:31 + --> $DIR/disallowed-positions.rs:415:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:420:9 + --> $DIR/disallowed-positions.rs:419:9 | LL | if (let Some(a) = opt && (true)) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:420:9 + --> $DIR/disallowed-positions.rs:419:9 | LL | if (let Some(a) = opt && (true)) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ +error: let chains are only allowed in Rust 2024 or later + --> $DIR/disallowed-positions.rs:423:28 + | +LL | if (true && (true)) && let Some(a) = opt { + | ^^^^^^^^^^^^^^^^^ + +error: let chains are only allowed in Rust 2024 or later + --> $DIR/disallowed-positions.rs:426:18 + | +LL | if (true) && let Some(a) = opt { + | ^^^^^^^^^^^^^^^^^ + +error: let chains are only allowed in Rust 2024 or later + --> $DIR/disallowed-positions.rs:429:16 + | +LL | if true && let Some(a) = opt { + | ^^^^^^^^^^^^^^^^^ + +error: let chains are only allowed in Rust 2024 or later + --> $DIR/disallowed-positions.rs:434:8 + | +LL | if let true = (true && fun()) && (true) { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:440:22 + --> $DIR/disallowed-positions.rs:439:22 | LL | let x = (true && let y = 1); | ^^^ @@ -965,7 +1019,7 @@ LL | let x = (true && let y = 1); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:445:20 + --> $DIR/disallowed-positions.rs:444:20 | LL | ([1, 2, 3][let _ = ()]) | ^^^ @@ -973,7 +1027,7 @@ LL | ([1, 2, 3][let _ = ()]) = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:91:16 + --> $DIR/disallowed-positions.rs:90:16 | LL | use_expr!((let 0 = 1 && 0 == 0)); | ^^^ @@ -981,7 +1035,7 @@ LL | use_expr!((let 0 = 1 && 0 == 0)); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:91:16 + --> $DIR/disallowed-positions.rs:90:16 | LL | use_expr!((let 0 = 1 && 0 == 0)); | ^^^ @@ -990,7 +1044,7 @@ LL | use_expr!((let 0 = 1 && 0 == 0)); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:91:16 + --> $DIR/disallowed-positions.rs:90:16 | LL | use_expr!((let 0 = 1 && 0 == 0)); | ^^^ @@ -999,7 +1053,7 @@ LL | use_expr!((let 0 = 1 && 0 == 0)); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:95:16 + --> $DIR/disallowed-positions.rs:94:16 | LL | use_expr!((let 0 = 1)); | ^^^ @@ -1007,7 +1061,7 @@ LL | use_expr!((let 0 = 1)); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:95:16 + --> $DIR/disallowed-positions.rs:94:16 | LL | use_expr!((let 0 = 1)); | ^^^ @@ -1016,7 +1070,7 @@ LL | use_expr!((let 0 = 1)); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:95:16 + --> $DIR/disallowed-positions.rs:94:16 | LL | use_expr!((let 0 = 1)); | ^^^ @@ -1024,98 +1078,8 @@ LL | use_expr!((let 0 = 1)); = note: only supported directly in conditions of `if` and `while` expressions = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0658]: `let` expressions in this position are unstable - --> $DIR/disallowed-positions.rs:49:8 - | -LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/disallowed-positions.rs:49:21 - | -LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/disallowed-positions.rs:75:11 - | -LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/disallowed-positions.rs:75:24 - | -LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} - | ^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/disallowed-positions.rs:408:8 - | -LL | if let Some(a) = opt && (true && true) { - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/disallowed-positions.rs:424:28 - | -LL | if (true && (true)) && let Some(a) = opt { - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/disallowed-positions.rs:427:18 - | -LL | if (true) && let Some(a) = opt { - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/disallowed-positions.rs:430:16 - | -LL | if true && let Some(a) = opt { - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/disallowed-positions.rs:435:8 - | -LL | if let true = (true && fun()) && (true) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:134:8 + --> $DIR/disallowed-positions.rs:133:8 | LL | if true..(let 0 = 0) {} | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range<bool>` @@ -1124,7 +1088,7 @@ LL | if true..(let 0 = 0) {} found struct `std::ops::Range<bool>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:143:12 + --> $DIR/disallowed-positions.rs:142:12 | LL | if let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -1135,7 +1099,7 @@ LL | if let Range { start: _, end: _ } = true..true && false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:146:12 + --> $DIR/disallowed-positions.rs:145:12 | LL | if let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -1146,7 +1110,7 @@ LL | if let Range { start: _, end: _ } = true..true || false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:152:12 + --> $DIR/disallowed-positions.rs:151:12 | LL | if let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` @@ -1157,7 +1121,7 @@ LL | if let Range { start: F, end } = F..|| true {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:158:12 + --> $DIR/disallowed-positions.rs:157:12 | LL | if let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` @@ -1168,7 +1132,7 @@ LL | if let Range { start: true, end } = t..&&false {} found struct `std::ops::Range<_>` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:114:20 + --> $DIR/disallowed-positions.rs:113:20 | LL | if let 0 = 0? {} | ^^ the `?` operator cannot be applied to type `{integer}` @@ -1176,7 +1140,7 @@ LL | if let 0 = 0? {} = help: the trait `Try` is not implemented for `{integer}` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:225:11 + --> $DIR/disallowed-positions.rs:224:11 | LL | while true..(let 0 = 0) {} | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range<bool>` @@ -1185,7 +1149,7 @@ LL | while true..(let 0 = 0) {} found struct `std::ops::Range<bool>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:234:15 + --> $DIR/disallowed-positions.rs:233:15 | LL | while let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -1196,7 +1160,7 @@ LL | while let Range { start: _, end: _ } = true..true && false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:237:15 + --> $DIR/disallowed-positions.rs:236:15 | LL | while let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -1207,7 +1171,7 @@ LL | while let Range { start: _, end: _ } = true..true || false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:243:15 + --> $DIR/disallowed-positions.rs:242:15 | LL | while let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` @@ -1218,7 +1182,7 @@ LL | while let Range { start: F, end } = F..|| true {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:249:15 + --> $DIR/disallowed-positions.rs:248:15 | LL | while let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` @@ -1229,7 +1193,7 @@ LL | while let Range { start: true, end } = t..&&false {} found struct `std::ops::Range<_>` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:205:23 + --> $DIR/disallowed-positions.rs:204:23 | LL | while let 0 = 0? {} | ^^ the `?` operator cannot be applied to type `{integer}` @@ -1237,7 +1201,7 @@ LL | while let 0 = 0? {} = help: the trait `Try` is not implemented for `{integer}` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:334:10 + --> $DIR/disallowed-positions.rs:333:10 | LL | (let Range { start: _, end: _ } = true..true || false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -1248,7 +1212,7 @@ LL | (let Range { start: _, end: _ } = true..true || false); found struct `std::ops::Range<_>` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:309:17 + --> $DIR/disallowed-positions.rs:308:17 | LL | let 0 = 0?; | ^^ the `?` operator cannot be applied to type `{integer}` @@ -1257,5 +1221,5 @@ LL | let 0 = 0?; error: aborting due to 134 previous errors -Some errors have detailed explanations: E0277, E0308, E0658. +Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.feature.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.e2024.stderr index 141a6d255d0..20af65cf89a 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.feature.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.e2024.stderr @@ -1,239 +1,239 @@ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:33:9 + --> $DIR/disallowed-positions.rs:32:9 | LL | if (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:33:9 + --> $DIR/disallowed-positions.rs:32:9 | LL | if (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:36:11 + --> $DIR/disallowed-positions.rs:35:11 | LL | if (((let 0 = 1))) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:36:11 + --> $DIR/disallowed-positions.rs:35:11 | LL | if (((let 0 = 1))) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:39:9 + --> $DIR/disallowed-positions.rs:38:9 | LL | if (let 0 = 1) && true {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:39:9 + --> $DIR/disallowed-positions.rs:38:9 | LL | if (let 0 = 1) && true {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:42:17 + --> $DIR/disallowed-positions.rs:41:17 | LL | if true && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:42:17 + --> $DIR/disallowed-positions.rs:41:17 | LL | if true && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:45:9 + --> $DIR/disallowed-positions.rs:44:9 | LL | if (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:45:9 + --> $DIR/disallowed-positions.rs:44:9 | LL | if (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:45:24 + --> $DIR/disallowed-positions.rs:44:24 | LL | if (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:45:24 + --> $DIR/disallowed-positions.rs:44:24 | LL | if (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:49:35 + --> $DIR/disallowed-positions.rs:48:35 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:49:35 + --> $DIR/disallowed-positions.rs:48:35 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:49:48 + --> $DIR/disallowed-positions.rs:48:48 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:49:35 + --> $DIR/disallowed-positions.rs:48:35 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:49:61 + --> $DIR/disallowed-positions.rs:48:61 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:49:35 + --> $DIR/disallowed-positions.rs:48:35 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:59:12 + --> $DIR/disallowed-positions.rs:58:12 | LL | while (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:59:12 + --> $DIR/disallowed-positions.rs:58:12 | LL | while (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:62:14 + --> $DIR/disallowed-positions.rs:61:14 | LL | while (((let 0 = 1))) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:62:14 + --> $DIR/disallowed-positions.rs:61:14 | LL | while (((let 0 = 1))) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:65:12 + --> $DIR/disallowed-positions.rs:64:12 | LL | while (let 0 = 1) && true {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:65:12 + --> $DIR/disallowed-positions.rs:64:12 | LL | while (let 0 = 1) && true {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:68:20 + --> $DIR/disallowed-positions.rs:67:20 | LL | while true && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:68:20 + --> $DIR/disallowed-positions.rs:67:20 | LL | while true && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:71:12 + --> $DIR/disallowed-positions.rs:70:12 | LL | while (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:71:12 + --> $DIR/disallowed-positions.rs:70:12 | LL | while (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:71:27 + --> $DIR/disallowed-positions.rs:70:27 | LL | while (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:71:27 + --> $DIR/disallowed-positions.rs:70:27 | LL | while (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:75:38 + --> $DIR/disallowed-positions.rs:74:38 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:75:38 + --> $DIR/disallowed-positions.rs:74:38 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:75:51 + --> $DIR/disallowed-positions.rs:74:51 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:75:38 + --> $DIR/disallowed-positions.rs:74:38 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:75:64 + --> $DIR/disallowed-positions.rs:74:64 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:75:38 + --> $DIR/disallowed-positions.rs:74:38 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:103:9 + --> $DIR/disallowed-positions.rs:102:9 | LL | if &let 0 = 0 {} | ^^^^^^^^^ @@ -241,7 +241,7 @@ LL | if &let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:106:9 + --> $DIR/disallowed-positions.rs:105:9 | LL | if !let 0 = 0 {} | ^^^^^^^^^ @@ -249,7 +249,7 @@ LL | if !let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:108:9 + --> $DIR/disallowed-positions.rs:107:9 | LL | if *let 0 = 0 {} | ^^^^^^^^^ @@ -257,7 +257,7 @@ LL | if *let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:110:9 + --> $DIR/disallowed-positions.rs:109:9 | LL | if -let 0 = 0 {} | ^^^^^^^^^ @@ -265,7 +265,7 @@ LL | if -let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:118:9 + --> $DIR/disallowed-positions.rs:117:9 | LL | if (let 0 = 0)? {} | ^^^^^^^^^ @@ -273,13 +273,13 @@ LL | if (let 0 = 0)? {} = note: only supported directly in conditions of `if` and `while` expressions error: `||` operators are not supported in let chain conditions - --> $DIR/disallowed-positions.rs:121:13 + --> $DIR/disallowed-positions.rs:120:13 | LL | if true || let 0 = 0 {} | ^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:123:17 + --> $DIR/disallowed-positions.rs:122:17 | LL | if (true || let 0 = 0) {} | ^^^^^^^^^ @@ -287,7 +287,7 @@ LL | if (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:125:25 + --> $DIR/disallowed-positions.rs:124:25 | LL | if true && (true || let 0 = 0) {} | ^^^^^^^^^ @@ -295,7 +295,7 @@ LL | if true && (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:127:25 + --> $DIR/disallowed-positions.rs:126:25 | LL | if true || (true && let 0 = 0) {} | ^^^^^^^^^ @@ -303,7 +303,7 @@ LL | if true || (true && let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:131:12 + --> $DIR/disallowed-positions.rs:130:12 | LL | if x = let 0 = 0 {} | ^^^ @@ -311,7 +311,7 @@ LL | if x = let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:134:15 + --> $DIR/disallowed-positions.rs:133:15 | LL | if true..(let 0 = 0) {} | ^^^^^^^^^ @@ -319,7 +319,7 @@ LL | if true..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:137:11 + --> $DIR/disallowed-positions.rs:136:11 | LL | if ..(let 0 = 0) {} | ^^^^^^^^^ @@ -327,7 +327,7 @@ LL | if ..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:139:9 + --> $DIR/disallowed-positions.rs:138:9 | LL | if (let 0 = 0).. {} | ^^^^^^^^^ @@ -335,7 +335,7 @@ LL | if (let 0 = 0).. {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:143:8 + --> $DIR/disallowed-positions.rs:142:8 | LL | if let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -343,7 +343,7 @@ LL | if let Range { start: _, end: _ } = true..true && false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:146:8 + --> $DIR/disallowed-positions.rs:145:8 | LL | if let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -351,7 +351,7 @@ LL | if let Range { start: _, end: _ } = true..true || false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:152:8 + --> $DIR/disallowed-positions.rs:151:8 | LL | if let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -359,7 +359,7 @@ LL | if let Range { start: F, end } = F..|| true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:158:8 + --> $DIR/disallowed-positions.rs:157:8 | LL | if let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -367,7 +367,7 @@ LL | if let Range { start: true, end } = t..&&false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:162:19 + --> $DIR/disallowed-positions.rs:161:19 | LL | if let true = let true = true {} | ^^^ @@ -375,7 +375,7 @@ LL | if let true = let true = true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:165:15 + --> $DIR/disallowed-positions.rs:164:15 | LL | if return let 0 = 0 {} | ^^^ @@ -383,7 +383,7 @@ LL | if return let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:168:21 + --> $DIR/disallowed-positions.rs:167:21 | LL | loop { if break let 0 = 0 {} } | ^^^ @@ -391,7 +391,7 @@ LL | loop { if break let 0 = 0 {} } = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:171:15 + --> $DIR/disallowed-positions.rs:170:15 | LL | if (match let 0 = 0 { _ => { false } }) {} | ^^^ @@ -399,7 +399,7 @@ LL | if (match let 0 = 0 { _ => { false } }) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:174:9 + --> $DIR/disallowed-positions.rs:173:9 | LL | if (let 0 = 0, false).1 {} | ^^^^^^^^^ @@ -407,7 +407,7 @@ LL | if (let 0 = 0, false).1 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:177:9 + --> $DIR/disallowed-positions.rs:176:9 | LL | if (let 0 = 0,) {} | ^^^^^^^^^ @@ -415,7 +415,7 @@ LL | if (let 0 = 0,) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:181:13 + --> $DIR/disallowed-positions.rs:180:13 | LL | if (let 0 = 0).await {} | ^^^^^^^^^ @@ -423,7 +423,7 @@ LL | if (let 0 = 0).await {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:185:12 + --> $DIR/disallowed-positions.rs:184:12 | LL | if (|| let 0 = 0) {} | ^^^ @@ -431,7 +431,7 @@ LL | if (|| let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:188:9 + --> $DIR/disallowed-positions.rs:187:9 | LL | if (let 0 = 0)() {} | ^^^^^^^^^ @@ -439,7 +439,7 @@ LL | if (let 0 = 0)() {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:194:12 + --> $DIR/disallowed-positions.rs:193:12 | LL | while &let 0 = 0 {} | ^^^^^^^^^ @@ -447,7 +447,7 @@ LL | while &let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:197:12 + --> $DIR/disallowed-positions.rs:196:12 | LL | while !let 0 = 0 {} | ^^^^^^^^^ @@ -455,7 +455,7 @@ LL | while !let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:199:12 + --> $DIR/disallowed-positions.rs:198:12 | LL | while *let 0 = 0 {} | ^^^^^^^^^ @@ -463,7 +463,7 @@ LL | while *let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:201:12 + --> $DIR/disallowed-positions.rs:200:12 | LL | while -let 0 = 0 {} | ^^^^^^^^^ @@ -471,7 +471,7 @@ LL | while -let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:209:12 + --> $DIR/disallowed-positions.rs:208:12 | LL | while (let 0 = 0)? {} | ^^^^^^^^^ @@ -479,13 +479,13 @@ LL | while (let 0 = 0)? {} = note: only supported directly in conditions of `if` and `while` expressions error: `||` operators are not supported in let chain conditions - --> $DIR/disallowed-positions.rs:212:16 + --> $DIR/disallowed-positions.rs:211:16 | LL | while true || let 0 = 0 {} | ^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:214:20 + --> $DIR/disallowed-positions.rs:213:20 | LL | while (true || let 0 = 0) {} | ^^^^^^^^^ @@ -493,7 +493,7 @@ LL | while (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:216:28 + --> $DIR/disallowed-positions.rs:215:28 | LL | while true && (true || let 0 = 0) {} | ^^^^^^^^^ @@ -501,7 +501,7 @@ LL | while true && (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:218:28 + --> $DIR/disallowed-positions.rs:217:28 | LL | while true || (true && let 0 = 0) {} | ^^^^^^^^^ @@ -509,7 +509,7 @@ LL | while true || (true && let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:222:15 + --> $DIR/disallowed-positions.rs:221:15 | LL | while x = let 0 = 0 {} | ^^^ @@ -517,7 +517,7 @@ LL | while x = let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:225:18 + --> $DIR/disallowed-positions.rs:224:18 | LL | while true..(let 0 = 0) {} | ^^^^^^^^^ @@ -525,7 +525,7 @@ LL | while true..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:228:14 + --> $DIR/disallowed-positions.rs:227:14 | LL | while ..(let 0 = 0) {} | ^^^^^^^^^ @@ -533,7 +533,7 @@ LL | while ..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:230:12 + --> $DIR/disallowed-positions.rs:229:12 | LL | while (let 0 = 0).. {} | ^^^^^^^^^ @@ -541,7 +541,7 @@ LL | while (let 0 = 0).. {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:234:11 + --> $DIR/disallowed-positions.rs:233:11 | LL | while let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -549,7 +549,7 @@ LL | while let Range { start: _, end: _ } = true..true && false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:237:11 + --> $DIR/disallowed-positions.rs:236:11 | LL | while let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -557,7 +557,7 @@ LL | while let Range { start: _, end: _ } = true..true || false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:243:11 + --> $DIR/disallowed-positions.rs:242:11 | LL | while let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -565,7 +565,7 @@ LL | while let Range { start: F, end } = F..|| true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:249:11 + --> $DIR/disallowed-positions.rs:248:11 | LL | while let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -573,7 +573,7 @@ LL | while let Range { start: true, end } = t..&&false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:253:22 + --> $DIR/disallowed-positions.rs:252:22 | LL | while let true = let true = true {} | ^^^ @@ -581,7 +581,7 @@ LL | while let true = let true = true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:256:18 + --> $DIR/disallowed-positions.rs:255:18 | LL | while return let 0 = 0 {} | ^^^ @@ -589,7 +589,7 @@ LL | while return let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:259:39 + --> $DIR/disallowed-positions.rs:258:39 | LL | 'outer: loop { while break 'outer let 0 = 0 {} } | ^^^ @@ -597,7 +597,7 @@ LL | 'outer: loop { while break 'outer let 0 = 0 {} } = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:262:18 + --> $DIR/disallowed-positions.rs:261:18 | LL | while (match let 0 = 0 { _ => { false } }) {} | ^^^ @@ -605,7 +605,7 @@ LL | while (match let 0 = 0 { _ => { false } }) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:265:12 + --> $DIR/disallowed-positions.rs:264:12 | LL | while (let 0 = 0, false).1 {} | ^^^^^^^^^ @@ -613,7 +613,7 @@ LL | while (let 0 = 0, false).1 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:268:12 + --> $DIR/disallowed-positions.rs:267:12 | LL | while (let 0 = 0,) {} | ^^^^^^^^^ @@ -621,7 +621,7 @@ LL | while (let 0 = 0,) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:272:16 + --> $DIR/disallowed-positions.rs:271:16 | LL | while (let 0 = 0).await {} | ^^^^^^^^^ @@ -629,7 +629,7 @@ LL | while (let 0 = 0).await {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:276:15 + --> $DIR/disallowed-positions.rs:275:15 | LL | while (|| let 0 = 0) {} | ^^^ @@ -637,7 +637,7 @@ LL | while (|| let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:279:12 + --> $DIR/disallowed-positions.rs:278:12 | LL | while (let 0 = 0)() {} | ^^^^^^^^^ @@ -645,7 +645,7 @@ LL | while (let 0 = 0)() {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:296:6 + --> $DIR/disallowed-positions.rs:295:6 | LL | &let 0 = 0; | ^^^ @@ -653,7 +653,7 @@ LL | &let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:299:6 + --> $DIR/disallowed-positions.rs:298:6 | LL | !let 0 = 0; | ^^^ @@ -661,7 +661,7 @@ LL | !let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:301:6 + --> $DIR/disallowed-positions.rs:300:6 | LL | *let 0 = 0; | ^^^ @@ -669,7 +669,7 @@ LL | *let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:303:6 + --> $DIR/disallowed-positions.rs:302:6 | LL | -let 0 = 0; | ^^^ @@ -677,7 +677,7 @@ LL | -let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:305:13 + --> $DIR/disallowed-positions.rs:304:13 | LL | let _ = let _ = 3; | ^^^ @@ -685,7 +685,7 @@ LL | let _ = let _ = 3; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:313:6 + --> $DIR/disallowed-positions.rs:312:6 | LL | (let 0 = 0)?; | ^^^ @@ -693,7 +693,7 @@ LL | (let 0 = 0)?; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:316:13 + --> $DIR/disallowed-positions.rs:315:13 | LL | true || let 0 = 0; | ^^^ @@ -701,7 +701,7 @@ LL | true || let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:318:14 + --> $DIR/disallowed-positions.rs:317:14 | LL | (true || let 0 = 0); | ^^^ @@ -709,7 +709,7 @@ LL | (true || let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:320:22 + --> $DIR/disallowed-positions.rs:319:22 | LL | true && (true || let 0 = 0); | ^^^ @@ -717,7 +717,7 @@ LL | true && (true || let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:324:9 + --> $DIR/disallowed-positions.rs:323:9 | LL | x = let 0 = 0; | ^^^ @@ -725,7 +725,7 @@ LL | x = let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:327:12 + --> $DIR/disallowed-positions.rs:326:12 | LL | true..(let 0 = 0); | ^^^ @@ -733,7 +733,7 @@ LL | true..(let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:329:8 + --> $DIR/disallowed-positions.rs:328:8 | LL | ..(let 0 = 0); | ^^^ @@ -741,7 +741,7 @@ LL | ..(let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:331:6 + --> $DIR/disallowed-positions.rs:330:6 | LL | (let 0 = 0)..; | ^^^ @@ -749,7 +749,7 @@ LL | (let 0 = 0)..; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:334:6 + --> $DIR/disallowed-positions.rs:333:6 | LL | (let Range { start: _, end: _ } = true..true || false); | ^^^ @@ -757,7 +757,7 @@ LL | (let Range { start: _, end: _ } = true..true || false); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:338:6 + --> $DIR/disallowed-positions.rs:337:6 | LL | (let true = let true = true); | ^^^ @@ -765,7 +765,7 @@ LL | (let true = let true = true); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:338:17 + --> $DIR/disallowed-positions.rs:337:17 | LL | (let true = let true = true); | ^^^ @@ -773,7 +773,7 @@ LL | (let true = let true = true); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:344:25 + --> $DIR/disallowed-positions.rs:343:25 | LL | let x = true && let y = 1; | ^^^ @@ -781,7 +781,7 @@ LL | let x = true && let y = 1; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:350:19 + --> $DIR/disallowed-positions.rs:349:19 | LL | [1, 2, 3][let _ = ()] | ^^^ @@ -789,7 +789,7 @@ LL | [1, 2, 3][let _ = ()] = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:355:6 + --> $DIR/disallowed-positions.rs:354:6 | LL | &let 0 = 0 | ^^^ @@ -797,7 +797,7 @@ LL | &let 0 = 0 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:366:17 + --> $DIR/disallowed-positions.rs:365:17 | LL | true && let 1 = 1 | ^^^ @@ -805,7 +805,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:371:17 + --> $DIR/disallowed-positions.rs:370:17 | LL | true && let 1 = 1 | ^^^ @@ -813,7 +813,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:376:17 + --> $DIR/disallowed-positions.rs:375:17 | LL | true && let 1 = 1 | ^^^ @@ -821,7 +821,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:387:17 + --> $DIR/disallowed-positions.rs:386:17 | LL | true && let 1 = 1 | ^^^ @@ -829,7 +829,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/disallowed-positions.rs:387:9 + --> $DIR/disallowed-positions.rs:386:9 | LL | true && let 1 = 1 | ^^^^^^^^^^^^^^^^^ @@ -840,124 +840,124 @@ LL | { true && let 1 = 1 } | + + error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:397:9 + --> $DIR/disallowed-positions.rs:396:9 | LL | if (let Some(a) = opt && true) { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:397:9 + --> $DIR/disallowed-positions.rs:396:9 | LL | if (let Some(a) = opt && true) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:401:9 + --> $DIR/disallowed-positions.rs:400:9 | LL | if (let Some(a) = opt) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:401:9 + --> $DIR/disallowed-positions.rs:400:9 | LL | if (let Some(a) = opt) && true { | ^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:404:9 + --> $DIR/disallowed-positions.rs:403:9 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:404:9 + --> $DIR/disallowed-positions.rs:403:9 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:404:32 + --> $DIR/disallowed-positions.rs:403:32 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:404:32 + --> $DIR/disallowed-positions.rs:403:32 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:412:9 + --> $DIR/disallowed-positions.rs:411:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:412:9 + --> $DIR/disallowed-positions.rs:411:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:412:31 + --> $DIR/disallowed-positions.rs:411:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:412:31 + --> $DIR/disallowed-positions.rs:411:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:416:9 + --> $DIR/disallowed-positions.rs:415:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:416:9 + --> $DIR/disallowed-positions.rs:415:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:416:31 + --> $DIR/disallowed-positions.rs:415:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:416:31 + --> $DIR/disallowed-positions.rs:415:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:420:9 + --> $DIR/disallowed-positions.rs:419:9 | LL | if (let Some(a) = opt && (true)) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:420:9 + --> $DIR/disallowed-positions.rs:419:9 | LL | if (let Some(a) = opt && (true)) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:440:22 + --> $DIR/disallowed-positions.rs:439:22 | LL | let x = (true && let y = 1); | ^^^ @@ -965,7 +965,7 @@ LL | let x = (true && let y = 1); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:445:20 + --> $DIR/disallowed-positions.rs:444:20 | LL | ([1, 2, 3][let _ = ()]) | ^^^ @@ -973,7 +973,7 @@ LL | ([1, 2, 3][let _ = ()]) = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:91:16 + --> $DIR/disallowed-positions.rs:90:16 | LL | use_expr!((let 0 = 1 && 0 == 0)); | ^^^ @@ -981,7 +981,7 @@ LL | use_expr!((let 0 = 1 && 0 == 0)); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:91:16 + --> $DIR/disallowed-positions.rs:90:16 | LL | use_expr!((let 0 = 1 && 0 == 0)); | ^^^ @@ -990,7 +990,7 @@ LL | use_expr!((let 0 = 1 && 0 == 0)); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:91:16 + --> $DIR/disallowed-positions.rs:90:16 | LL | use_expr!((let 0 = 1 && 0 == 0)); | ^^^ @@ -999,7 +999,7 @@ LL | use_expr!((let 0 = 1 && 0 == 0)); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:95:16 + --> $DIR/disallowed-positions.rs:94:16 | LL | use_expr!((let 0 = 1)); | ^^^ @@ -1007,7 +1007,7 @@ LL | use_expr!((let 0 = 1)); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:95:16 + --> $DIR/disallowed-positions.rs:94:16 | LL | use_expr!((let 0 = 1)); | ^^^ @@ -1016,7 +1016,7 @@ LL | use_expr!((let 0 = 1)); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:95:16 + --> $DIR/disallowed-positions.rs:94:16 | LL | use_expr!((let 0 = 1)); | ^^^ @@ -1025,7 +1025,7 @@ LL | use_expr!((let 0 = 1)); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:134:8 + --> $DIR/disallowed-positions.rs:133:8 | LL | if true..(let 0 = 0) {} | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range<bool>` @@ -1034,7 +1034,7 @@ LL | if true..(let 0 = 0) {} found struct `std::ops::Range<bool>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:143:12 + --> $DIR/disallowed-positions.rs:142:12 | LL | if let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -1045,7 +1045,7 @@ LL | if let Range { start: _, end: _ } = true..true && false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:146:12 + --> $DIR/disallowed-positions.rs:145:12 | LL | if let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -1056,7 +1056,7 @@ LL | if let Range { start: _, end: _ } = true..true || false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:152:12 + --> $DIR/disallowed-positions.rs:151:12 | LL | if let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` @@ -1067,7 +1067,7 @@ LL | if let Range { start: F, end } = F..|| true {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:158:12 + --> $DIR/disallowed-positions.rs:157:12 | LL | if let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` @@ -1078,7 +1078,7 @@ LL | if let Range { start: true, end } = t..&&false {} found struct `std::ops::Range<_>` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:114:20 + --> $DIR/disallowed-positions.rs:113:20 | LL | if let 0 = 0? {} | ^^ the `?` operator cannot be applied to type `{integer}` @@ -1086,7 +1086,7 @@ LL | if let 0 = 0? {} = help: the trait `Try` is not implemented for `{integer}` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:225:11 + --> $DIR/disallowed-positions.rs:224:11 | LL | while true..(let 0 = 0) {} | ^^^^^^^^^^^^^^^^^ expected `bool`, found `Range<bool>` @@ -1095,7 +1095,7 @@ LL | while true..(let 0 = 0) {} found struct `std::ops::Range<bool>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:234:15 + --> $DIR/disallowed-positions.rs:233:15 | LL | while let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -1106,7 +1106,7 @@ LL | while let Range { start: _, end: _ } = true..true && false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:237:15 + --> $DIR/disallowed-positions.rs:236:15 | LL | while let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -1117,7 +1117,7 @@ LL | while let Range { start: _, end: _ } = true..true || false {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:243:15 + --> $DIR/disallowed-positions.rs:242:15 | LL | while let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `fn() -> bool` @@ -1128,7 +1128,7 @@ LL | while let Range { start: F, end } = F..|| true {} found struct `std::ops::Range<_>` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:249:15 + --> $DIR/disallowed-positions.rs:248:15 | LL | while let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - this expression has type `&&bool` @@ -1139,7 +1139,7 @@ LL | while let Range { start: true, end } = t..&&false {} found struct `std::ops::Range<_>` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:205:23 + --> $DIR/disallowed-positions.rs:204:23 | LL | while let 0 = 0? {} | ^^ the `?` operator cannot be applied to type `{integer}` @@ -1147,7 +1147,7 @@ LL | while let 0 = 0? {} = help: the trait `Try` is not implemented for `{integer}` error[E0308]: mismatched types - --> $DIR/disallowed-positions.rs:334:10 + --> $DIR/disallowed-positions.rs:333:10 | LL | (let Range { start: _, end: _ } = true..true || false); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ ---- this expression has type `bool` @@ -1158,7 +1158,7 @@ LL | (let Range { start: _, end: _ } = true..true || false); found struct `std::ops::Range<_>` error[E0277]: the `?` operator can only be applied to values that implement `Try` - --> $DIR/disallowed-positions.rs:309:17 + --> $DIR/disallowed-positions.rs:308:17 | LL | let 0 = 0?; | ^^ the `?` operator cannot be applied to type `{integer}` diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.nothing.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.nothing.stderr index 5b53691cbf5..f69c18ff0d9 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.nothing.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.nothing.stderr @@ -1,239 +1,239 @@ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:33:9 + --> $DIR/disallowed-positions.rs:32:9 | LL | if (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:33:9 + --> $DIR/disallowed-positions.rs:32:9 | LL | if (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:36:11 + --> $DIR/disallowed-positions.rs:35:11 | LL | if (((let 0 = 1))) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:36:11 + --> $DIR/disallowed-positions.rs:35:11 | LL | if (((let 0 = 1))) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:39:9 + --> $DIR/disallowed-positions.rs:38:9 | LL | if (let 0 = 1) && true {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:39:9 + --> $DIR/disallowed-positions.rs:38:9 | LL | if (let 0 = 1) && true {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:42:17 + --> $DIR/disallowed-positions.rs:41:17 | LL | if true && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:42:17 + --> $DIR/disallowed-positions.rs:41:17 | LL | if true && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:45:9 + --> $DIR/disallowed-positions.rs:44:9 | LL | if (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:45:9 + --> $DIR/disallowed-positions.rs:44:9 | LL | if (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:45:24 + --> $DIR/disallowed-positions.rs:44:24 | LL | if (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:45:24 + --> $DIR/disallowed-positions.rs:44:24 | LL | if (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:49:35 + --> $DIR/disallowed-positions.rs:48:35 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:49:35 + --> $DIR/disallowed-positions.rs:48:35 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:49:48 + --> $DIR/disallowed-positions.rs:48:48 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:49:35 + --> $DIR/disallowed-positions.rs:48:35 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:49:61 + --> $DIR/disallowed-positions.rs:48:61 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:49:35 + --> $DIR/disallowed-positions.rs:48:35 | LL | if let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:59:12 + --> $DIR/disallowed-positions.rs:58:12 | LL | while (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:59:12 + --> $DIR/disallowed-positions.rs:58:12 | LL | while (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:62:14 + --> $DIR/disallowed-positions.rs:61:14 | LL | while (((let 0 = 1))) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:62:14 + --> $DIR/disallowed-positions.rs:61:14 | LL | while (((let 0 = 1))) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:65:12 + --> $DIR/disallowed-positions.rs:64:12 | LL | while (let 0 = 1) && true {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:65:12 + --> $DIR/disallowed-positions.rs:64:12 | LL | while (let 0 = 1) && true {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:68:20 + --> $DIR/disallowed-positions.rs:67:20 | LL | while true && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:68:20 + --> $DIR/disallowed-positions.rs:67:20 | LL | while true && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:71:12 + --> $DIR/disallowed-positions.rs:70:12 | LL | while (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:71:12 + --> $DIR/disallowed-positions.rs:70:12 | LL | while (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:71:27 + --> $DIR/disallowed-positions.rs:70:27 | LL | while (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:71:27 + --> $DIR/disallowed-positions.rs:70:27 | LL | while (let 0 = 1) && (let 0 = 1) {} | ^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:75:38 + --> $DIR/disallowed-positions.rs:74:38 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:75:38 + --> $DIR/disallowed-positions.rs:74:38 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:75:51 + --> $DIR/disallowed-positions.rs:74:51 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:75:38 + --> $DIR/disallowed-positions.rs:74:38 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:75:64 + --> $DIR/disallowed-positions.rs:74:64 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:75:38 + --> $DIR/disallowed-positions.rs:74:38 | LL | while let 0 = 1 && let 1 = 2 && (let 2 = 3 && let 3 = 4 && let 4 = 5) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:103:9 + --> $DIR/disallowed-positions.rs:102:9 | LL | if &let 0 = 0 {} | ^^^^^^^^^ @@ -241,7 +241,7 @@ LL | if &let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:106:9 + --> $DIR/disallowed-positions.rs:105:9 | LL | if !let 0 = 0 {} | ^^^^^^^^^ @@ -249,7 +249,7 @@ LL | if !let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:108:9 + --> $DIR/disallowed-positions.rs:107:9 | LL | if *let 0 = 0 {} | ^^^^^^^^^ @@ -257,7 +257,7 @@ LL | if *let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:110:9 + --> $DIR/disallowed-positions.rs:109:9 | LL | if -let 0 = 0 {} | ^^^^^^^^^ @@ -265,7 +265,7 @@ LL | if -let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:118:9 + --> $DIR/disallowed-positions.rs:117:9 | LL | if (let 0 = 0)? {} | ^^^^^^^^^ @@ -273,13 +273,13 @@ LL | if (let 0 = 0)? {} = note: only supported directly in conditions of `if` and `while` expressions error: `||` operators are not supported in let chain conditions - --> $DIR/disallowed-positions.rs:121:13 + --> $DIR/disallowed-positions.rs:120:13 | LL | if true || let 0 = 0 {} | ^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:123:17 + --> $DIR/disallowed-positions.rs:122:17 | LL | if (true || let 0 = 0) {} | ^^^^^^^^^ @@ -287,7 +287,7 @@ LL | if (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:125:25 + --> $DIR/disallowed-positions.rs:124:25 | LL | if true && (true || let 0 = 0) {} | ^^^^^^^^^ @@ -295,7 +295,7 @@ LL | if true && (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:127:25 + --> $DIR/disallowed-positions.rs:126:25 | LL | if true || (true && let 0 = 0) {} | ^^^^^^^^^ @@ -303,7 +303,7 @@ LL | if true || (true && let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:131:12 + --> $DIR/disallowed-positions.rs:130:12 | LL | if x = let 0 = 0 {} | ^^^ @@ -311,7 +311,7 @@ LL | if x = let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:134:15 + --> $DIR/disallowed-positions.rs:133:15 | LL | if true..(let 0 = 0) {} | ^^^^^^^^^ @@ -319,7 +319,7 @@ LL | if true..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:137:11 + --> $DIR/disallowed-positions.rs:136:11 | LL | if ..(let 0 = 0) {} | ^^^^^^^^^ @@ -327,7 +327,7 @@ LL | if ..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:139:9 + --> $DIR/disallowed-positions.rs:138:9 | LL | if (let 0 = 0).. {} | ^^^^^^^^^ @@ -335,7 +335,7 @@ LL | if (let 0 = 0).. {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:143:8 + --> $DIR/disallowed-positions.rs:142:8 | LL | if let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -343,7 +343,7 @@ LL | if let Range { start: _, end: _ } = true..true && false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:146:8 + --> $DIR/disallowed-positions.rs:145:8 | LL | if let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -351,7 +351,7 @@ LL | if let Range { start: _, end: _ } = true..true || false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:152:8 + --> $DIR/disallowed-positions.rs:151:8 | LL | if let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -359,7 +359,7 @@ LL | if let Range { start: F, end } = F..|| true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:158:8 + --> $DIR/disallowed-positions.rs:157:8 | LL | if let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -367,7 +367,7 @@ LL | if let Range { start: true, end } = t..&&false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:162:19 + --> $DIR/disallowed-positions.rs:161:19 | LL | if let true = let true = true {} | ^^^ @@ -375,7 +375,7 @@ LL | if let true = let true = true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:165:15 + --> $DIR/disallowed-positions.rs:164:15 | LL | if return let 0 = 0 {} | ^^^ @@ -383,7 +383,7 @@ LL | if return let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:168:21 + --> $DIR/disallowed-positions.rs:167:21 | LL | loop { if break let 0 = 0 {} } | ^^^ @@ -391,7 +391,7 @@ LL | loop { if break let 0 = 0 {} } = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:171:15 + --> $DIR/disallowed-positions.rs:170:15 | LL | if (match let 0 = 0 { _ => { false } }) {} | ^^^ @@ -399,7 +399,7 @@ LL | if (match let 0 = 0 { _ => { false } }) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:174:9 + --> $DIR/disallowed-positions.rs:173:9 | LL | if (let 0 = 0, false).1 {} | ^^^^^^^^^ @@ -407,7 +407,7 @@ LL | if (let 0 = 0, false).1 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:177:9 + --> $DIR/disallowed-positions.rs:176:9 | LL | if (let 0 = 0,) {} | ^^^^^^^^^ @@ -415,7 +415,7 @@ LL | if (let 0 = 0,) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:181:13 + --> $DIR/disallowed-positions.rs:180:13 | LL | if (let 0 = 0).await {} | ^^^^^^^^^ @@ -423,7 +423,7 @@ LL | if (let 0 = 0).await {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:185:12 + --> $DIR/disallowed-positions.rs:184:12 | LL | if (|| let 0 = 0) {} | ^^^ @@ -431,7 +431,7 @@ LL | if (|| let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:188:9 + --> $DIR/disallowed-positions.rs:187:9 | LL | if (let 0 = 0)() {} | ^^^^^^^^^ @@ -439,7 +439,7 @@ LL | if (let 0 = 0)() {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:194:12 + --> $DIR/disallowed-positions.rs:193:12 | LL | while &let 0 = 0 {} | ^^^^^^^^^ @@ -447,7 +447,7 @@ LL | while &let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:197:12 + --> $DIR/disallowed-positions.rs:196:12 | LL | while !let 0 = 0 {} | ^^^^^^^^^ @@ -455,7 +455,7 @@ LL | while !let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:199:12 + --> $DIR/disallowed-positions.rs:198:12 | LL | while *let 0 = 0 {} | ^^^^^^^^^ @@ -463,7 +463,7 @@ LL | while *let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:201:12 + --> $DIR/disallowed-positions.rs:200:12 | LL | while -let 0 = 0 {} | ^^^^^^^^^ @@ -471,7 +471,7 @@ LL | while -let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:209:12 + --> $DIR/disallowed-positions.rs:208:12 | LL | while (let 0 = 0)? {} | ^^^^^^^^^ @@ -479,13 +479,13 @@ LL | while (let 0 = 0)? {} = note: only supported directly in conditions of `if` and `while` expressions error: `||` operators are not supported in let chain conditions - --> $DIR/disallowed-positions.rs:212:16 + --> $DIR/disallowed-positions.rs:211:16 | LL | while true || let 0 = 0 {} | ^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:214:20 + --> $DIR/disallowed-positions.rs:213:20 | LL | while (true || let 0 = 0) {} | ^^^^^^^^^ @@ -493,7 +493,7 @@ LL | while (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:216:28 + --> $DIR/disallowed-positions.rs:215:28 | LL | while true && (true || let 0 = 0) {} | ^^^^^^^^^ @@ -501,7 +501,7 @@ LL | while true && (true || let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:218:28 + --> $DIR/disallowed-positions.rs:217:28 | LL | while true || (true && let 0 = 0) {} | ^^^^^^^^^ @@ -509,7 +509,7 @@ LL | while true || (true && let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:222:15 + --> $DIR/disallowed-positions.rs:221:15 | LL | while x = let 0 = 0 {} | ^^^ @@ -517,7 +517,7 @@ LL | while x = let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:225:18 + --> $DIR/disallowed-positions.rs:224:18 | LL | while true..(let 0 = 0) {} | ^^^^^^^^^ @@ -525,7 +525,7 @@ LL | while true..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:228:14 + --> $DIR/disallowed-positions.rs:227:14 | LL | while ..(let 0 = 0) {} | ^^^^^^^^^ @@ -533,7 +533,7 @@ LL | while ..(let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:230:12 + --> $DIR/disallowed-positions.rs:229:12 | LL | while (let 0 = 0).. {} | ^^^^^^^^^ @@ -541,7 +541,7 @@ LL | while (let 0 = 0).. {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:234:11 + --> $DIR/disallowed-positions.rs:233:11 | LL | while let Range { start: _, end: _ } = true..true && false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -549,7 +549,7 @@ LL | while let Range { start: _, end: _ } = true..true && false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:237:11 + --> $DIR/disallowed-positions.rs:236:11 | LL | while let Range { start: _, end: _ } = true..true || false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -557,7 +557,7 @@ LL | while let Range { start: _, end: _ } = true..true || false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:243:11 + --> $DIR/disallowed-positions.rs:242:11 | LL | while let Range { start: F, end } = F..|| true {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -565,7 +565,7 @@ LL | while let Range { start: F, end } = F..|| true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:249:11 + --> $DIR/disallowed-positions.rs:248:11 | LL | while let Range { start: true, end } = t..&&false {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -573,7 +573,7 @@ LL | while let Range { start: true, end } = t..&&false {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:253:22 + --> $DIR/disallowed-positions.rs:252:22 | LL | while let true = let true = true {} | ^^^ @@ -581,7 +581,7 @@ LL | while let true = let true = true {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:256:18 + --> $DIR/disallowed-positions.rs:255:18 | LL | while return let 0 = 0 {} | ^^^ @@ -589,7 +589,7 @@ LL | while return let 0 = 0 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:259:39 + --> $DIR/disallowed-positions.rs:258:39 | LL | 'outer: loop { while break 'outer let 0 = 0 {} } | ^^^ @@ -597,7 +597,7 @@ LL | 'outer: loop { while break 'outer let 0 = 0 {} } = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:262:18 + --> $DIR/disallowed-positions.rs:261:18 | LL | while (match let 0 = 0 { _ => { false } }) {} | ^^^ @@ -605,7 +605,7 @@ LL | while (match let 0 = 0 { _ => { false } }) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:265:12 + --> $DIR/disallowed-positions.rs:264:12 | LL | while (let 0 = 0, false).1 {} | ^^^^^^^^^ @@ -613,7 +613,7 @@ LL | while (let 0 = 0, false).1 {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:268:12 + --> $DIR/disallowed-positions.rs:267:12 | LL | while (let 0 = 0,) {} | ^^^^^^^^^ @@ -621,7 +621,7 @@ LL | while (let 0 = 0,) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:272:16 + --> $DIR/disallowed-positions.rs:271:16 | LL | while (let 0 = 0).await {} | ^^^^^^^^^ @@ -629,7 +629,7 @@ LL | while (let 0 = 0).await {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:276:15 + --> $DIR/disallowed-positions.rs:275:15 | LL | while (|| let 0 = 0) {} | ^^^ @@ -637,7 +637,7 @@ LL | while (|| let 0 = 0) {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:279:12 + --> $DIR/disallowed-positions.rs:278:12 | LL | while (let 0 = 0)() {} | ^^^^^^^^^ @@ -645,7 +645,7 @@ LL | while (let 0 = 0)() {} = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:296:6 + --> $DIR/disallowed-positions.rs:295:6 | LL | &let 0 = 0; | ^^^ @@ -653,7 +653,7 @@ LL | &let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:299:6 + --> $DIR/disallowed-positions.rs:298:6 | LL | !let 0 = 0; | ^^^ @@ -661,7 +661,7 @@ LL | !let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:301:6 + --> $DIR/disallowed-positions.rs:300:6 | LL | *let 0 = 0; | ^^^ @@ -669,7 +669,7 @@ LL | *let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:303:6 + --> $DIR/disallowed-positions.rs:302:6 | LL | -let 0 = 0; | ^^^ @@ -677,7 +677,7 @@ LL | -let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:305:13 + --> $DIR/disallowed-positions.rs:304:13 | LL | let _ = let _ = 3; | ^^^ @@ -685,7 +685,7 @@ LL | let _ = let _ = 3; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:313:6 + --> $DIR/disallowed-positions.rs:312:6 | LL | (let 0 = 0)?; | ^^^ @@ -693,7 +693,7 @@ LL | (let 0 = 0)?; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:316:13 + --> $DIR/disallowed-positions.rs:315:13 | LL | true || let 0 = 0; | ^^^ @@ -701,7 +701,7 @@ LL | true || let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:318:14 + --> $DIR/disallowed-positions.rs:317:14 | LL | (true || let 0 = 0); | ^^^ @@ -709,7 +709,7 @@ LL | (true || let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:320:22 + --> $DIR/disallowed-positions.rs:319:22 | LL | true && (true || let 0 = 0); | ^^^ @@ -717,7 +717,7 @@ LL | true && (true || let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:324:9 + --> $DIR/disallowed-positions.rs:323:9 | LL | x = let 0 = 0; | ^^^ @@ -725,7 +725,7 @@ LL | x = let 0 = 0; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:327:12 + --> $DIR/disallowed-positions.rs:326:12 | LL | true..(let 0 = 0); | ^^^ @@ -733,7 +733,7 @@ LL | true..(let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:329:8 + --> $DIR/disallowed-positions.rs:328:8 | LL | ..(let 0 = 0); | ^^^ @@ -741,7 +741,7 @@ LL | ..(let 0 = 0); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:331:6 + --> $DIR/disallowed-positions.rs:330:6 | LL | (let 0 = 0)..; | ^^^ @@ -749,7 +749,7 @@ LL | (let 0 = 0)..; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:334:6 + --> $DIR/disallowed-positions.rs:333:6 | LL | (let Range { start: _, end: _ } = true..true || false); | ^^^ @@ -757,7 +757,7 @@ LL | (let Range { start: _, end: _ } = true..true || false); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:338:6 + --> $DIR/disallowed-positions.rs:337:6 | LL | (let true = let true = true); | ^^^ @@ -765,7 +765,7 @@ LL | (let true = let true = true); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:338:17 + --> $DIR/disallowed-positions.rs:337:17 | LL | (let true = let true = true); | ^^^ @@ -773,7 +773,7 @@ LL | (let true = let true = true); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:344:25 + --> $DIR/disallowed-positions.rs:343:25 | LL | let x = true && let y = 1; | ^^^ @@ -781,7 +781,7 @@ LL | let x = true && let y = 1; = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:350:19 + --> $DIR/disallowed-positions.rs:349:19 | LL | [1, 2, 3][let _ = ()] | ^^^ @@ -789,7 +789,7 @@ LL | [1, 2, 3][let _ = ()] = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:355:6 + --> $DIR/disallowed-positions.rs:354:6 | LL | &let 0 = 0 | ^^^ @@ -797,7 +797,7 @@ LL | &let 0 = 0 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:366:17 + --> $DIR/disallowed-positions.rs:365:17 | LL | true && let 1 = 1 | ^^^ @@ -805,7 +805,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:371:17 + --> $DIR/disallowed-positions.rs:370:17 | LL | true && let 1 = 1 | ^^^ @@ -813,7 +813,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:376:17 + --> $DIR/disallowed-positions.rs:375:17 | LL | true && let 1 = 1 | ^^^ @@ -821,7 +821,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:387:17 + --> $DIR/disallowed-positions.rs:386:17 | LL | true && let 1 = 1 | ^^^ @@ -829,7 +829,7 @@ LL | true && let 1 = 1 = note: only supported directly in conditions of `if` and `while` expressions error: expressions must be enclosed in braces to be used as const generic arguments - --> $DIR/disallowed-positions.rs:387:9 + --> $DIR/disallowed-positions.rs:386:9 | LL | true && let 1 = 1 | ^^^^^^^^^^^^^^^^^ @@ -840,124 +840,124 @@ LL | { true && let 1 = 1 } | + + error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:397:9 + --> $DIR/disallowed-positions.rs:396:9 | LL | if (let Some(a) = opt && true) { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:397:9 + --> $DIR/disallowed-positions.rs:396:9 | LL | if (let Some(a) = opt && true) { | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:401:9 + --> $DIR/disallowed-positions.rs:400:9 | LL | if (let Some(a) = opt) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:401:9 + --> $DIR/disallowed-positions.rs:400:9 | LL | if (let Some(a) = opt) && true { | ^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:404:9 + --> $DIR/disallowed-positions.rs:403:9 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:404:9 + --> $DIR/disallowed-positions.rs:403:9 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:404:32 + --> $DIR/disallowed-positions.rs:403:32 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:404:32 + --> $DIR/disallowed-positions.rs:403:32 | LL | if (let Some(a) = opt) && (let Some(b) = a) { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:412:9 + --> $DIR/disallowed-positions.rs:411:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:412:9 + --> $DIR/disallowed-positions.rs:411:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:412:31 + --> $DIR/disallowed-positions.rs:411:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:412:31 + --> $DIR/disallowed-positions.rs:411:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:416:9 + --> $DIR/disallowed-positions.rs:415:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:416:9 + --> $DIR/disallowed-positions.rs:415:9 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:416:31 + --> $DIR/disallowed-positions.rs:415:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:416:31 + --> $DIR/disallowed-positions.rs:415:31 | LL | if (let Some(a) = opt && (let Some(b) = a)) && true { | ^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:420:9 + --> $DIR/disallowed-positions.rs:419:9 | LL | if (let Some(a) = opt && (true)) && true { | ^^^^^^^^^^^^^^^^^ | = note: only supported directly in conditions of `if` and `while` expressions note: `let`s wrapped in parentheses are not supported in a context with let chains - --> $DIR/disallowed-positions.rs:420:9 + --> $DIR/disallowed-positions.rs:419:9 | LL | if (let Some(a) = opt && (true)) && true { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:440:22 + --> $DIR/disallowed-positions.rs:439:22 | LL | let x = (true && let y = 1); | ^^^ @@ -965,7 +965,7 @@ LL | let x = (true && let y = 1); = note: only supported directly in conditions of `if` and `while` expressions error: expected expression, found `let` statement - --> $DIR/disallowed-positions.rs:445:20 + --> $DIR/disallowed-positions.rs:444:20 | LL | ([1, 2, 3][let _ = ()]) | ^^^ diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs index 65beccf2214..142ea6b4ea8 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/disallowed-positions.rs @@ -1,5 +1,7 @@ -//@ revisions: no_feature feature nothing -//@ edition: 2021 +//@ revisions: e2021 e2024 nothing +//@ [e2021] edition: 2021 +//@ [e2024] edition: 2024 +//@ [nothing] edition: 2024 // Here we test that `lowering` behaves correctly wrt. `let $pats = $expr` expressions. // // We want to make sure that `let` is banned in situations other than: @@ -19,9 +21,6 @@ // // To that end, we check some positions which is not part of the language above. -// Avoid inflating `.stderr` with overzealous gates (or test what happens if you disable the gate) -#![cfg_attr(not(no_feature), feature(let_chains))] - #![allow(irrefutable_let_patterns)] use std::ops::Range; @@ -50,8 +49,8 @@ fn _if() { //~^ ERROR expected expression, found `let` statement //~| ERROR expected expression, found `let` statement //~| ERROR expected expression, found `let` statement - //[no_feature]~| ERROR `let` expressions in this position are unstable - //[no_feature]~| ERROR `let` expressions in this position are unstable + //[e2021]~| ERROR let chains are only allowed in Rust 2024 or later + //[e2021]~| ERROR let chains are only allowed in Rust 2024 or later } #[cfg(not(nothing))] @@ -76,8 +75,8 @@ fn _while() { //~^ ERROR expected expression, found `let` statement //~| ERROR expected expression, found `let` statement //~| ERROR expected expression, found `let` statement - //[no_feature]~| ERROR `let` expressions in this position are unstable - //[no_feature]~| ERROR `let` expressions in this position are unstable + //[e2021]~| ERROR let chains are only allowed in Rust 2024 or later + //[e2021]~| ERROR let chains are only allowed in Rust 2024 or later } #[cfg(not(nothing))] @@ -89,13 +88,13 @@ fn _macros() { } } use_expr!((let 0 = 1 && 0 == 0)); - //[feature,no_feature]~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR expected expression, found `let` statement + //[e2021,e2024]~^ ERROR expected expression, found `let` statement + //[e2021,e2024]~| ERROR expected expression, found `let` statement + //[e2021,e2024]~| ERROR expected expression, found `let` statement use_expr!((let 0 = 1)); - //[feature,no_feature]~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR expected expression, found `let` statement + //[e2021,e2024]~^ ERROR expected expression, found `let` statement + //[e2021,e2024]~| ERROR expected expression, found `let` statement + //[e2021,e2024]~| ERROR expected expression, found `let` statement } #[cfg(not(nothing))] @@ -112,7 +111,7 @@ fn nested_within_if_expr() { fn _check_try_binds_tighter() -> Result<(), ()> { if let 0 = 0? {} - //[feature,no_feature]~^ ERROR the `?` operator can only be applied to values that implement `Try` + //[e2021,e2024]~^ ERROR the `?` operator can only be applied to values that implement `Try` Ok(()) } if (let 0 = 0)? {} @@ -133,7 +132,7 @@ fn nested_within_if_expr() { if true..(let 0 = 0) {} //~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR mismatched types + //[e2021,e2024]~| ERROR mismatched types if ..(let 0 = 0) {} //~^ ERROR expected expression, found `let` statement if (let 0 = 0).. {} @@ -142,22 +141,22 @@ fn nested_within_if_expr() { // Binds as `(let ... = true)..true &&/|| false`. if let Range { start: _, end: _ } = true..true && false {} //~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR mismatched types + //[e2021,e2024]~| ERROR mismatched types if let Range { start: _, end: _ } = true..true || false {} //~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR mismatched types + //[e2021,e2024]~| ERROR mismatched types // Binds as `(let Range { start: F, end } = F)..(|| true)`. const F: fn() -> bool = || true; if let Range { start: F, end } = F..|| true {} //~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR mismatched types + //[e2021,e2024]~| ERROR mismatched types // Binds as `(let Range { start: true, end } = t)..(&&false)`. let t = &&true; if let Range { start: true, end } = t..&&false {} //~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR mismatched types + //[e2021,e2024]~| ERROR mismatched types if let true = let true = true {} //~^ ERROR expected expression, found `let` statement @@ -203,7 +202,7 @@ fn nested_within_while_expr() { fn _check_try_binds_tighter() -> Result<(), ()> { while let 0 = 0? {} - //[feature,no_feature]~^ ERROR the `?` operator can only be applied to values that implement `Try` + //[e2021,e2024]~^ ERROR the `?` operator can only be applied to values that implement `Try` Ok(()) } while (let 0 = 0)? {} @@ -224,7 +223,7 @@ fn nested_within_while_expr() { while true..(let 0 = 0) {} //~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR mismatched types + //[e2021,e2024]~| ERROR mismatched types while ..(let 0 = 0) {} //~^ ERROR expected expression, found `let` statement while (let 0 = 0).. {} @@ -233,22 +232,22 @@ fn nested_within_while_expr() { // Binds as `(let ... = true)..true &&/|| false`. while let Range { start: _, end: _ } = true..true && false {} //~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR mismatched types + //[e2021,e2024]~| ERROR mismatched types while let Range { start: _, end: _ } = true..true || false {} //~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR mismatched types + //[e2021,e2024]~| ERROR mismatched types // Binds as `(let Range { start: F, end } = F)..(|| true)`. const F: fn() -> bool = || true; while let Range { start: F, end } = F..|| true {} //~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR mismatched types + //[e2021,e2024]~| ERROR mismatched types // Binds as `(let Range { start: true, end } = t)..(&&false)`. let t = &&true; while let Range { start: true, end } = t..&&false {} //~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR mismatched types + //[e2021,e2024]~| ERROR mismatched types while let true = let true = true {} //~^ ERROR expected expression, found `let` statement @@ -307,7 +306,7 @@ fn outside_if_and_while_expr() { fn _check_try_binds_tighter() -> Result<(), ()> { let 0 = 0?; - //[feature,no_feature]~^ ERROR the `?` operator can only be applied to values that implement `Try` + //[e2021,e2024]~^ ERROR the `?` operator can only be applied to values that implement `Try` Ok(()) } (let 0 = 0)?; @@ -333,7 +332,7 @@ fn outside_if_and_while_expr() { (let Range { start: _, end: _ } = true..true || false); //~^ ERROR expected expression, found `let` statement - //[feature,no_feature]~| ERROR mismatched types + //[e2021,e2024]~| ERROR mismatched types (let true = let true = true); //~^ ERROR expected expression, found `let` statement @@ -406,7 +405,7 @@ fn with_parenthesis() { //~| ERROR expected expression, found `let` statement } if let Some(a) = opt && (true && true) { - //[no_feature]~^ ERROR `let` expressions in this position are unstable + //[e2021]~^ ERROR let chains are only allowed in Rust 2024 or later } if (let Some(a) = opt && (let Some(b) = a)) && b == 1 { @@ -422,18 +421,18 @@ fn with_parenthesis() { } if (true && (true)) && let Some(a) = opt { - //[no_feature]~^ ERROR `let` expressions in this position are unstable + //[e2021]~^ ERROR let chains are only allowed in Rust 2024 or later } if (true) && let Some(a) = opt { - //[no_feature]~^ ERROR `let` expressions in this position are unstable + //[e2021]~^ ERROR let chains are only allowed in Rust 2024 or later } if true && let Some(a) = opt { - //[no_feature]~^ ERROR `let` expressions in this position are unstable + //[e2021]~^ ERROR let chains are only allowed in Rust 2024 or later } let fun = || true; if let true = (true && fun()) && (true) { - //[no_feature]~^ ERROR `let` expressions in this position are unstable + //[e2021]~^ ERROR let chains are only allowed in Rust 2024 or later } #[cfg(false)] diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro-error.edition2021.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro-error.edition2021.stderr index 23700f89f10..7fc91e9d980 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro-error.edition2021.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro-error.edition2021.stderr @@ -1,65 +1,42 @@ -error[E0658]: `let` expressions in this position are unstable +error: let chains are only allowed in Rust 2024 or later --> $DIR/edition-gate-macro-error.rs:19:30 | LL | macro_in_2021::make_if!((let Some(0) = None && let Some(0) = None) { never!() } { never!() }); | ^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable +error: let chains are only allowed in Rust 2024 or later --> $DIR/edition-gate-macro-error.rs:19:52 | LL | macro_in_2021::make_if!((let Some(0) = None && let Some(0) = None) { never!() } { never!() }); | ^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable +error: let chains are only allowed in Rust 2024 or later --> $DIR/edition-gate-macro-error.rs:22:5 | LL | macro_in_2021::make_if!(let (Some(0)) let (Some(0)) { never!() } { never!() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - = 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 `macro_in_2021::make_if` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0658]: `let` expressions in this position are unstable +error: let chains are only allowed in Rust 2024 or later --> $DIR/edition-gate-macro-error.rs:22:5 | LL | macro_in_2021::make_if!(let (Some(0)) let (Some(0)) { never!() } { never!() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - = 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 `macro_in_2021::make_if` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0658]: `let` expressions in this position are unstable +error: let chains are only allowed in Rust 2024 or later --> $DIR/edition-gate-macro-error.rs:26:30 | LL | macro_in_2024::make_if!((let Some(0) = None && let Some(0) = None) { never!() } { never!() }); | ^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable +error: let chains are only allowed in Rust 2024 or later --> $DIR/edition-gate-macro-error.rs:26:52 | LL | macro_in_2024::make_if!((let Some(0) = None && let Some(0) = None) { never!() } { never!() }); | ^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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 6 previous errors -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro-error.edition2024.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro-error.edition2024.stderr index 3af844f4f96..35ac848561c 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro-error.edition2024.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro-error.edition2024.stderr @@ -1,45 +1,30 @@ -error[E0658]: `let` expressions in this position are unstable +error: let chains are only allowed in Rust 2024 or later --> $DIR/edition-gate-macro-error.rs:19:30 | LL | macro_in_2021::make_if!((let Some(0) = None && let Some(0) = None) { never!() } { never!() }); | ^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable +error: let chains are only allowed in Rust 2024 or later --> $DIR/edition-gate-macro-error.rs:19:52 | LL | macro_in_2021::make_if!((let Some(0) = None && let Some(0) = None) { never!() } { never!() }); | ^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable +error: let chains are only allowed in Rust 2024 or later --> $DIR/edition-gate-macro-error.rs:22:5 | LL | macro_in_2021::make_if!(let (Some(0)) let (Some(0)) { never!() } { never!() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - = 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 `macro_in_2021::make_if` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0658]: `let` expressions in this position are unstable +error: let chains are only allowed in Rust 2024 or later --> $DIR/edition-gate-macro-error.rs:22:5 | LL | macro_in_2021::make_if!(let (Some(0)) let (Some(0)) { never!() } { never!() }); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` to the crate attributes to enable - = 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 `macro_in_2021::make_if` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 4 previous errors -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro-error.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro-error.rs index 89b555d2c50..a56c11264c1 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro-error.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate-macro-error.rs @@ -17,14 +17,14 @@ fn main() { // No gating if both the `if` and the chain are from a 2024 macro macro_in_2021::make_if!((let Some(0) = None && let Some(0) = None) { never!() } { never!() }); - //~^ ERROR `let` expressions in this position are unstable - //~| ERROR `let` expressions in this position are unstable + //~^ ERROR let chains are only allowed in Rust 2024 or later + //~| ERROR let chains are only allowed in Rust 2024 or later macro_in_2021::make_if!(let (Some(0)) let (Some(0)) { never!() } { never!() }); - //~^ ERROR `let` expressions in this position are unstable - //~| ERROR `let` expressions in this position are unstable + //~^ ERROR let chains are only allowed in Rust 2024 or later + //~| ERROR let chains are only allowed in Rust 2024 or later macro_in_2024::make_if!((let Some(0) = None && let Some(0) = None) { never!() } { never!() }); - //[edition2021]~^ ERROR `let` expressions in this position are unstable - //[edition2021]~| ERROR `let` expressions in this position are unstable + //[edition2021]~^ ERROR let chains are only allowed in Rust 2024 or later + //[edition2021]~| ERROR let chains are only allowed in Rust 2024 or later macro_in_2024::make_if!(let (Some(0)) let (Some(0)) { never!() } { never!() }); } diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate.rs index dad02b7f106..0096e6985d3 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate.rs @@ -1,6 +1,4 @@ -// gate-test-let_chains - -// Here we test feature gating for ´let_chains`. +// Here we test Rust 2024 edition gating for ´let_chains`. // See `disallowed-positions.rs` for the grammar // defining the language for gated allowed positions. @@ -12,17 +10,17 @@ fn _if() { if let 0 = 1 {} // Stable! if true && let 0 = 1 {} - //~^ ERROR `let` expressions in this position are unstable [E0658] + //~^ ERROR let chains are only allowed in Rust 2024 or later if let 0 = 1 && true {} - //~^ ERROR `let` expressions in this position are unstable [E0658] + //~^ ERROR let chains are only allowed in Rust 2024 or later if let Range { start: _, end: _ } = (true..true) && false {} - //~^ ERROR `let` expressions in this position are unstable [E0658] + //~^ ERROR let chains are only allowed in Rust 2024 or later if let 1 = 1 && let true = { true } && false { - //~^ ERROR `let` expressions in this position are unstable [E0658] - //~| ERROR `let` expressions in this position are unstable [E0658] + //~^ ERROR let chains are only allowed in Rust 2024 or later + //~| ERROR let chains are only allowed in Rust 2024 or later } } @@ -30,13 +28,13 @@ fn _while() { while let 0 = 1 {} // Stable! while true && let 0 = 1 {} - //~^ ERROR `let` expressions in this position are unstable [E0658] + //~^ ERROR let chains are only allowed in Rust 2024 or later while let 0 = 1 && true {} - //~^ ERROR `let` expressions in this position are unstable [E0658] + //~^ ERROR let chains are only allowed in Rust 2024 or later while let Range { start: _, end: _ } = (true..true) && false {} - //~^ ERROR `let` expressions in this position are unstable [E0658] + //~^ ERROR let chains are only allowed in Rust 2024 or later } fn _macros() { diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate.stderr new file mode 100644 index 00000000000..f75dd858941 --- /dev/null +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/edition-gate.stderr @@ -0,0 +1,81 @@ +error: let chains are only allowed in Rust 2024 or later + --> $DIR/edition-gate.rs:12:16 + | +LL | if true && let 0 = 1 {} + | ^^^^^^^^^ + +error: let chains are only allowed in Rust 2024 or later + --> $DIR/edition-gate.rs:15:8 + | +LL | if let 0 = 1 && true {} + | ^^^^^^^^^ + +error: let chains are only allowed in Rust 2024 or later + --> $DIR/edition-gate.rs:18:8 + | +LL | if let Range { start: _, end: _ } = (true..true) && false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: let chains are only allowed in Rust 2024 or later + --> $DIR/edition-gate.rs:21:8 + | +LL | if let 1 = 1 && let true = { true } && false { + | ^^^^^^^^^ + +error: let chains are only allowed in Rust 2024 or later + --> $DIR/edition-gate.rs:21:21 + | +LL | if let 1 = 1 && let true = { true } && false { + | ^^^^^^^^^^^^^^^^^^^ + +error: let chains are only allowed in Rust 2024 or later + --> $DIR/edition-gate.rs:30:19 + | +LL | while true && let 0 = 1 {} + | ^^^^^^^^^ + +error: let chains are only allowed in Rust 2024 or later + --> $DIR/edition-gate.rs:33:11 + | +LL | while let 0 = 1 && true {} + | ^^^^^^^^^ + +error: let chains are only allowed in Rust 2024 or later + --> $DIR/edition-gate.rs:36:11 + | +LL | while let Range { start: _, end: _ } = (true..true) && false {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: expected expression, found `let` statement + --> $DIR/edition-gate.rs:52:20 + | +LL | #[cfg(false)] (let 0 = 1); + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: expected expression, found `let` statement + --> $DIR/edition-gate.rs:43:17 + | +LL | noop_expr!((let 0 = 1)); + | ^^^ + | + = note: only supported directly in conditions of `if` and `while` expressions + +error: no rules expected keyword `let` + --> $DIR/edition-gate.rs:54:15 + | +LL | macro_rules! use_expr { + | --------------------- when calling this macro +... +LL | use_expr!(let 0 = 1); + | ^^^ no rules expected this token in macro call + | +note: while trying to match meta-variable `$e:expr` + --> $DIR/edition-gate.rs:47:10 + | +LL | ($e:expr) => { + | ^^^^^^^ + +error: aborting due to 11 previous errors + diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.stderr deleted file mode 100644 index b9dac472dca..00000000000 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/feature-gate.stderr +++ /dev/null @@ -1,114 +0,0 @@ -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:54:20 - | -LL | #[cfg(false)] (let 0 = 1); - | ^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: expected expression, found `let` statement - --> $DIR/feature-gate.rs:45:17 - | -LL | noop_expr!((let 0 = 1)); - | ^^^ - | - = note: only supported directly in conditions of `if` and `while` expressions - -error: no rules expected keyword `let` - --> $DIR/feature-gate.rs:56:15 - | -LL | macro_rules! use_expr { - | --------------------- when calling this macro -... -LL | use_expr!(let 0 = 1); - | ^^^ no rules expected this token in macro call - | -note: while trying to match meta-variable `$e:expr` - --> $DIR/feature-gate.rs:49:10 - | -LL | ($e:expr) => { - | ^^^^^^^ - -error[E0658]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:14:16 - | -LL | if true && let 0 = 1 {} - | ^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:17:8 - | -LL | if let 0 = 1 && true {} - | ^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:20:8 - | -LL | if let Range { start: _, end: _ } = (true..true) && false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:23:8 - | -LL | if let 1 = 1 && let true = { true } && false { - | ^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:23:21 - | -LL | if let 1 = 1 && let true = { true } && false { - | ^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:32:19 - | -LL | while true && let 0 = 1 {} - | ^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:35:11 - | -LL | while let 0 = 1 && true {} - | ^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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]: `let` expressions in this position are unstable - --> $DIR/feature-gate.rs:38:11 - | -LL | while let Range { start: _, end: _ } = (true..true) && false {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #53667 <https://github.com/rust-lang/rust/issues/53667> for more information - = help: add `#![feature(let_chains)]` 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 11 previous errors - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs index ae525aed414..3711dd5abb2 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/invalid-let-in-a-valid-let-context.rs @@ -1,4 +1,4 @@ -#![feature(let_chains)] +//@ edition: 2024 fn main() { let _opt = Some(1i32); diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr index 130d0296c5e..008e769cf0b 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.disallowed.stderr @@ -1,19 +1,19 @@ error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:13:8 + --> $DIR/irrefutable-lets.rs:14:8 | -LL | if let first = &opt && let Some(ref second) = first && let None = second.start {} +LL | if let first = &opt && let Some(second) = first && let None = second.start {} | ^^^^^^^^^^^^^^^^ | = note: this pattern will always match = help: consider moving it outside of the construct note: the lint level is defined here - --> $DIR/irrefutable-lets.rs:6:30 + --> $DIR/irrefutable-lets.rs:7:30 | LL | #![cfg_attr(disallowed, deny(irrefutable_let_patterns))] | ^^^^^^^^^^^^^^^^^^^^^^^^ error: irrefutable `if let` patterns - --> $DIR/irrefutable-lets.rs:19:8 + --> $DIR/irrefutable-lets.rs:20:8 | LL | if let first = &opt && let (a, b) = (1, 2) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -22,25 +22,25 @@ LL | if let first = &opt && let (a, b) = (1, 2) {} = help: consider replacing the `if let` with a `let` error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:22:8 + --> $DIR/irrefutable-lets.rs:23:8 | -LL | if let first = &opt && let Some(ref second) = first && let None = second.start && let v = 0 {} +LL | if let first = &opt && let Some(second) = first && let None = second.start && let v = 0 {} | ^^^^^^^^^^^^^^^^ | = note: this pattern will always match = help: consider moving it outside of the construct error: trailing irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:22:87 + --> $DIR/irrefutable-lets.rs:23:83 | -LL | if let first = &opt && let Some(ref second) = first && let None = second.start && let v = 0 {} - | ^^^^^^^^^ +LL | if let first = &opt && let Some(second) = first && let None = second.start && let v = 0 {} + | ^^^^^^^^^ | = note: this pattern will always match = help: consider moving it into the body error: trailing irrefutable patterns in let chain - --> $DIR/irrefutable-lets.rs:26:37 + --> $DIR/irrefutable-lets.rs:27:37 | LL | if let Some(ref first) = opt && let second = first && let _third = second {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -49,7 +49,7 @@ LL | if let Some(ref first) = opt && let second = first && let _third = seco = help: consider moving them into the body error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:29:8 + --> $DIR/irrefutable-lets.rs:30:8 | LL | if let Range { start: local_start, end: _ } = (None..Some(1)) && let None = local_start {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -58,7 +58,7 @@ LL | if let Range { start: local_start, end: _ } = (None..Some(1)) && let No = help: consider moving it outside of the construct error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:32:8 + --> $DIR/irrefutable-lets.rs:33:8 | LL | if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -67,7 +67,7 @@ LL | if let (a, b, c) = (Some(1), Some(1), Some(1)) && let None = Some(1) {} = help: consider moving it outside of the construct error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:35:8 + --> $DIR/irrefutable-lets.rs:36:8 | LL | if let first = &opt && let None = Some(1) {} | ^^^^^^^^^^^^^^^^ @@ -76,7 +76,7 @@ LL | if let first = &opt && let None = Some(1) {} = help: consider moving it outside of the construct error: irrefutable `if let` guard patterns - --> $DIR/irrefutable-lets.rs:44:28 + --> $DIR/irrefutable-lets.rs:45:28 | LL | Some(ref first) if let second = first && let _third = second && let v = 4 + 4 => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -85,7 +85,7 @@ LL | Some(ref first) if let second = first && let _third = second && let = help: consider removing the guard and adding a `let` inside the match arm error: trailing irrefutable patterns in let chain - --> $DIR/irrefutable-lets.rs:59:16 + --> $DIR/irrefutable-lets.rs:60:16 | LL | && let v = local_end && let w = v => {}, | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -94,7 +94,7 @@ LL | && let v = local_end && let w = v => {}, = help: consider moving them into the body error: irrefutable `while let` patterns - --> $DIR/irrefutable-lets.rs:68:11 + --> $DIR/irrefutable-lets.rs:69:11 | LL | while let first = &opt && let (a, b) = (1, 2) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -103,7 +103,7 @@ LL | while let first = &opt && let (a, b) = (1, 2) {} = help: consider instead using a `loop { ... }` with a `let` inside it error: trailing irrefutable patterns in let chain - --> $DIR/irrefutable-lets.rs:71:40 + --> $DIR/irrefutable-lets.rs:72:40 | LL | while let Some(ref first) = opt && let second = first && let _third = second {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -112,7 +112,7 @@ LL | while let Some(ref first) = opt && let second = first && let _third = s = help: consider moving them into the body error: trailing irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:87:12 + --> $DIR/irrefutable-lets.rs:88:12 | LL | && let x = &opt | ^^^^^^^^^^^^ @@ -121,7 +121,7 @@ LL | && let x = &opt = help: consider moving it into the body error: leading irrefutable pattern in let chain - --> $DIR/irrefutable-lets.rs:93:12 + --> $DIR/irrefutable-lets.rs:94:12 | LL | if let x = opt.clone().map(|_| 1) | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs index e7d69f89773..c8b9ac313ba 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/irrefutable-lets.rs @@ -1,7 +1,8 @@ //@ revisions: allowed disallowed //@[allowed] check-pass +//@ edition: 2024 -#![feature(if_let_guard, let_chains)] +#![feature(if_let_guard)] #![cfg_attr(allowed, allow(irrefutable_let_patterns))] #![cfg_attr(disallowed, deny(irrefutable_let_patterns))] @@ -10,16 +11,16 @@ use std::ops::Range; fn main() { let opt = Some(None..Some(1)); - if let first = &opt && let Some(ref second) = first && let None = second.start {} + if let first = &opt && let Some(second) = first && let None = second.start {} //[disallowed]~^ ERROR leading irrefutable pattern in let chain // No lint as the irrefutable pattern is surrounded by other stuff - if 4 * 2 == 0 && let first = &opt && let Some(ref second) = first && let None = second.start {} + if 4 * 2 == 0 && let first = &opt && let Some(second) = first && let None = second.start {} if let first = &opt && let (a, b) = (1, 2) {} //[disallowed]~^ ERROR irrefutable `if let` patterns - if let first = &opt && let Some(ref second) = first && let None = second.start && let v = 0 {} + if let first = &opt && let Some(second) = first && let None = second.start && let v = 0 {} //[disallowed]~^ ERROR leading irrefutable pattern in let chain //[disallowed]~^^ ERROR trailing irrefutable pattern in let chain @@ -63,7 +64,7 @@ fn main() { // No error, despite the prefix being irrefutable: moving out could change the behaviour, // due to possible side effects of the operation. - while let first = &opt && let Some(ref second) = first && let None = second.start {} + while let first = &opt && let Some(second) = first && let None = second.start {} while let first = &opt && let (a, b) = (1, 2) {} //[disallowed]~^ ERROR irrefutable `while let` patterns diff --git a/tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs b/tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs index 6d307be90c1..287c73b41e9 100644 --- a/tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs +++ b/tests/ui/rfcs/rfc-2497-if-let-chains/then-else-blocks.rs @@ -1,6 +1,7 @@ //@ run-pass +//@ edition: 2024 -#![feature(if_let_guard, let_chains)] +#![feature(if_let_guard)] fn check_if_let(opt: Option<Option<Option<i32>>>, value: i32) -> bool { if let Some(first) = opt diff --git a/tests/ui/rustdoc/renamed-features-rustdoc_internals.rs b/tests/ui/rustdoc/renamed-features-rustdoc_internals.rs index 2257130280d..739c624d0c6 100644 --- a/tests/ui/rustdoc/renamed-features-rustdoc_internals.rs +++ b/tests/ui/rustdoc/renamed-features-rustdoc_internals.rs @@ -1,5 +1,3 @@ -//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION" - #![feature(doc_keyword)] //~ ERROR #![feature(doc_primitive)] //~ ERROR #![crate_type = "lib"] diff --git a/tests/ui/rustdoc/renamed-features-rustdoc_internals.stderr b/tests/ui/rustdoc/renamed-features-rustdoc_internals.stderr index 9c664da8ee6..0608a8b58a2 100644 --- a/tests/ui/rustdoc/renamed-features-rustdoc_internals.stderr +++ b/tests/ui/rustdoc/renamed-features-rustdoc_internals.stderr @@ -1,19 +1,19 @@ error[E0557]: feature has been removed - --> $DIR/renamed-features-rustdoc_internals.rs:3:12 + --> $DIR/renamed-features-rustdoc_internals.rs:1:12 | LL | #![feature(doc_keyword)] | ^^^^^^^^^^^ feature has been removed | - = note: removed in 1.58.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/90420> for more information + = note: removed in 1.58.0; see <https://github.com/rust-lang/rust/pull/90420> for more information = note: merged into `#![feature(rustdoc_internals)]` error[E0557]: feature has been removed - --> $DIR/renamed-features-rustdoc_internals.rs:4:12 + --> $DIR/renamed-features-rustdoc_internals.rs:2:12 | LL | #![feature(doc_primitive)] | ^^^^^^^^^^^^^ feature has been removed | - = note: removed in 1.58.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/90420> for more information + = note: removed in 1.58.0; see <https://github.com/rust-lang/rust/pull/90420> for more information = note: merged into `#![feature(rustdoc_internals)]` error: aborting due to 2 previous errors diff --git a/tests/ui/sanitizer/cfi/closures.rs b/tests/ui/sanitizer/cfi/closures.rs index 9f9002da674..424e70560db 100644 --- a/tests/ui/sanitizer/cfi/closures.rs +++ b/tests/ui/sanitizer/cfi/closures.rs @@ -31,7 +31,7 @@ fn dyn_fn_with_params() { #[test] fn call_fn_trait() { - let f: &(dyn Fn()) = &(|| {}) as _; + let f: &dyn Fn() = &(|| {}) as _; f.call(()); } @@ -47,7 +47,7 @@ fn use_fnmut<F: FnMut()>(mut f: F) { #[test] fn fn_to_fnmut() { - let f: &(dyn Fn()) = &(|| {}) as _; + let f: &dyn Fn() = &(|| {}) as _; use_fnmut(f); } diff --git a/tests/ui/sanitizer/cfi/invalid-attr-encoding.rs b/tests/ui/sanitizer/cfi/invalid-attr-encoding.rs index 7ef6bd2f0ac..23ffabad62f 100644 --- a/tests/ui/sanitizer/cfi/invalid-attr-encoding.rs +++ b/tests/ui/sanitizer/cfi/invalid-attr-encoding.rs @@ -7,5 +7,5 @@ #![no_core] #![no_main] -#[cfi_encoding] //~ERROR 10:1: 10:16: malformed `cfi_encoding` attribute input +#[cfi_encoding] //~ ERROR malformed `cfi_encoding` attribute input pub struct Type1(i32); diff --git a/tests/ui/sanitizer/memory-eager.rs b/tests/ui/sanitizer/memory-eager.rs index 532d7b308f6..709299f87d4 100644 --- a/tests/ui/sanitizer/memory-eager.rs +++ b/tests/ui/sanitizer/memory-eager.rs @@ -8,8 +8,14 @@ // //@ run-fail //@ error-pattern: MemorySanitizer: use-of-uninitialized-value -//@ error-pattern: Uninitialized value was created by an allocation -//@ error-pattern: in the stack frame +//@ [optimized]error-pattern: Uninitialized value was created by an allocation +//@ [optimized]error-pattern: in the stack frame +// +// FIXME the unoptimized case actually has that text in the output too, per +// <https://github.com/rust-lang/rust/pull/138759#issuecomment-3037186707> +// but doesn't seem to be getting picked up for some reason. For now we don't +// check for that part, since it's still testing that memory sanitizer reported +// a use of an uninitialized value, which is the critical part. // // This test case intentionally limits the usage of the std, // since it will be linked with an uninstrumented version of it. diff --git a/tests/ui/self/self-infer.rs b/tests/ui/self/self-infer.rs index 9839b8880e9..d6f6d8bfa06 100644 --- a/tests/ui/self/self-infer.rs +++ b/tests/ui/self/self-infer.rs @@ -1,8 +1,8 @@ struct S; impl S { - fn f(self: _) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for functions - fn g(self: &_) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for functions + fn f(self: _) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for methods + fn g(self: &_) {} //~ERROR the placeholder `_` is not allowed within types on item signatures for methods } fn main() {} diff --git a/tests/ui/self/self-infer.stderr b/tests/ui/self/self-infer.stderr index c6bdff22b69..13d803d9559 100644 --- a/tests/ui/self/self-infer.stderr +++ b/tests/ui/self/self-infer.stderr @@ -1,26 +1,14 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/self-infer.rs:4:16 | LL | fn f(self: _) {} | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn f(self: _) {} -LL + fn f<T>(self: T) {} - | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/self-infer.rs:5:17 | LL | fn g(self: &_) {} | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn g(self: &_) {} -LL + fn g<T>(self: &T) {} - | error: aborting due to 2 previous errors diff --git a/tests/ui/shadow-bool.rs b/tests/ui/shadowed/primitive-type-shadowing.rs index 8cba2c1710b..fdcb4246a82 100644 --- a/tests/ui/shadow-bool.rs +++ b/tests/ui/shadowed/primitive-type-shadowing.rs @@ -1,3 +1,6 @@ +//! Check that a primitive type can be shadowed by a user-defined type, and the primitive type +//! can still be referenced using its fully qualified path (e.g., `core::primitive::bool`). + //@ check-pass mod bar { diff --git a/tests/ui/shadowed-use-visibility.rs b/tests/ui/shadowed/use-shadows-reexport.rs index 5ce4103b559..d220e4b406b 100644 --- a/tests/ui/shadowed-use-visibility.rs +++ b/tests/ui/shadowed/use-shadows-reexport.rs @@ -1,3 +1,5 @@ +//! Check that a local `use` declaration can shadow a re-exported item within the same module. + //@ run-pass #![allow(unused_imports)] diff --git a/tests/ui/short-error-format.stderr b/tests/ui/short-error-format.stderr deleted file mode 100644 index 1a4a6d4df88..00000000000 --- a/tests/ui/short-error-format.stderr +++ /dev/null @@ -1,3 +0,0 @@ -$DIR/short-error-format.rs:6:9: error[E0308]: mismatched types: expected `u32`, found `String` -$DIR/short-error-format.rs:8:7: error[E0599]: no method named `salut` found for type `u32` in the current scope: method not found in `u32` -error: aborting due to 2 previous errors diff --git a/tests/ui/simd/array-trait.stderr b/tests/ui/simd/array-trait.stderr index 299f0ad96ae..47f395044ff 100644 --- a/tests/ui/simd/array-trait.stderr +++ b/tests/ui/simd/array-trait.stderr @@ -1,3 +1,9 @@ +error[E0077]: SIMD vector element type should be a primitive scalar (integer/float/pointer) type + --> $DIR/array-trait.rs:22:1 + | +LL | pub struct T<S: Simd>([S::Lane; S::SIZE]); + | ^^^^^^^^^^^^^^^^^^^^^ + error: unconstrained generic constant --> $DIR/array-trait.rs:22:23 | @@ -9,12 +15,6 @@ help: try adding a `where` bound LL | pub struct T<S: Simd>([S::Lane; S::SIZE]) where [(); S::SIZE]:; | ++++++++++++++++++++ -error[E0077]: SIMD vector element type should be a primitive scalar (integer/float/pointer) type - --> $DIR/array-trait.rs:22:1 - | -LL | pub struct T<S: Simd>([S::Lane; S::SIZE]); - | ^^^^^^^^^^^^^^^^^^^^^ - error: unconstrained generic constant --> $DIR/array-trait.rs:22:23 | diff --git a/tests/ui/simd/intrinsic/float-math-pass.rs b/tests/ui/simd/intrinsic/float-math-pass.rs index 4c28568a739..01fed8537d0 100644 --- a/tests/ui/simd/intrinsic/float-math-pass.rs +++ b/tests/ui/simd/intrinsic/float-math-pass.rs @@ -85,6 +85,9 @@ fn main() { let r = simd_round(h); assert_eq!(x, r); + let r = simd_round_ties_even(h); + assert_eq!(z, r); + let r = simd_trunc(h); assert_eq!(z, r); } diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs index fdf06b7882e..caec607d6fe 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs @@ -43,6 +43,10 @@ fn main() { simd_shl(y, y); simd_shr(x, x); simd_shr(y, y); + simd_funnel_shl(x, x, x); + simd_funnel_shl(y, y, y); + simd_funnel_shr(x, x, x); + simd_funnel_shr(y, y, y); simd_and(x, x); simd_and(y, y); simd_or(x, x); @@ -73,6 +77,10 @@ fn main() { //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_shr(0, 0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_funnel_shl(0, 0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` + simd_funnel_shr(0, 0, 0); + //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_and(0, 0); //~^ ERROR expected SIMD input type, found non-SIMD `i32` simd_or(0, 0); @@ -95,6 +103,10 @@ fn main() { //~^ ERROR unsupported operation on `f32x4` with element `f32` simd_shr(z, z); //~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_funnel_shl(z, z, z); + //~^ ERROR unsupported operation on `f32x4` with element `f32` + simd_funnel_shr(z, z, z); + //~^ ERROR unsupported operation on `f32x4` with element `f32` simd_and(z, z); //~^ ERROR unsupported operation on `f32x4` with element `f32` simd_or(z, z); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr index 76db6d5328f..a27a8d721fb 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr @@ -1,147 +1,171 @@ error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:64:9 + --> $DIR/generic-arithmetic-2.rs:68:9 | LL | simd_add(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_sub` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:66:9 + --> $DIR/generic-arithmetic-2.rs:70:9 | LL | simd_sub(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_mul` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:68:9 + --> $DIR/generic-arithmetic-2.rs:72:9 | LL | simd_mul(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_div` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:70:9 + --> $DIR/generic-arithmetic-2.rs:74:9 | LL | simd_div(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:72:9 + --> $DIR/generic-arithmetic-2.rs:76:9 | LL | simd_shl(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:74:9 + --> $DIR/generic-arithmetic-2.rs:78:9 | LL | simd_shr(0, 0); | ^^^^^^^^^^^^^^ +error[E0511]: invalid monomorphization of `simd_funnel_shl` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:80:9 + | +LL | simd_funnel_shl(0, 0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_funnel_shr` intrinsic: expected SIMD input type, found non-SIMD `i32` + --> $DIR/generic-arithmetic-2.rs:82:9 + | +LL | simd_funnel_shr(0, 0, 0); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0511]: invalid monomorphization of `simd_and` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:76:9 + --> $DIR/generic-arithmetic-2.rs:84:9 | LL | simd_and(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:78:9 + --> $DIR/generic-arithmetic-2.rs:86:9 | LL | simd_or(0, 0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:80:9 + --> $DIR/generic-arithmetic-2.rs:88:9 | LL | simd_xor(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_neg` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:83:9 + --> $DIR/generic-arithmetic-2.rs:91:9 | LL | simd_neg(0); | ^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:85:9 + --> $DIR/generic-arithmetic-2.rs:93:9 | LL | simd_bswap(0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:87:9 + --> $DIR/generic-arithmetic-2.rs:95:9 | LL | simd_bitreverse(0); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:89:9 + --> $DIR/generic-arithmetic-2.rs:97:9 | LL | simd_ctlz(0); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:91:9 + --> $DIR/generic-arithmetic-2.rs:99:9 | LL | simd_cttz(0); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:94:9 + --> $DIR/generic-arithmetic-2.rs:102:9 | LL | simd_shl(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:96:9 + --> $DIR/generic-arithmetic-2.rs:104:9 | LL | simd_shr(z, z); | ^^^^^^^^^^^^^^ +error[E0511]: invalid monomorphization of `simd_funnel_shl` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:106:9 + | +LL | simd_funnel_shl(z, z, z); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0511]: invalid monomorphization of `simd_funnel_shr` intrinsic: unsupported operation on `f32x4` with element `f32` + --> $DIR/generic-arithmetic-2.rs:108:9 + | +LL | simd_funnel_shr(z, z, z); + | ^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0511]: invalid monomorphization of `simd_and` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:98:9 + --> $DIR/generic-arithmetic-2.rs:110:9 | LL | simd_and(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:100:9 + --> $DIR/generic-arithmetic-2.rs:112:9 | LL | simd_or(z, z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:102:9 + --> $DIR/generic-arithmetic-2.rs:114:9 | LL | simd_xor(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:104:9 + --> $DIR/generic-arithmetic-2.rs:116:9 | LL | simd_bswap(z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:106:9 + --> $DIR/generic-arithmetic-2.rs:118:9 | LL | simd_bitreverse(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:108:9 + --> $DIR/generic-arithmetic-2.rs:120:9 | LL | simd_ctlz(z); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctpop` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:110:9 + --> $DIR/generic-arithmetic-2.rs:122:9 | LL | simd_ctpop(z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:112:9 + --> $DIR/generic-arithmetic-2.rs:124:9 | LL | simd_cttz(z); | ^^^^^^^^^^^^ -error: aborting due to 24 previous errors +error: aborting due to 28 previous errors For more information about this error, try `rustc --explain E0511`. diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs index 3f0325d690b..4c97fb2141d 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs @@ -83,6 +83,80 @@ fn main() { all_eq!(simd_shr(simd_shl(y1, y2), y2), y1); all_eq!(simd_shr(simd_shl(y2, y1), y1), y2); + all_eq!( + simd_funnel_shl(x1, x2, x1), + i32x4([ + (1 << 1) | (2 >> 31), + (2 << 2) | (3 >> 30), + (3 << 3) | (4 >> 29), + (4 << 4) | (5 >> 28) + ]) + ); + all_eq!( + simd_funnel_shl(x2, x1, x1), + i32x4([ + (2 << 1) | (1 >> 31), + (3 << 2) | (2 >> 30), + (4 << 3) | (3 >> 29), + (5 << 4) | (4 >> 28) + ]) + ); + all_eq!( + simd_funnel_shl(y1, y2, y1), + U32::<4>([ + (1 << 1) | (2 >> 31), + (2 << 2) | (3 >> 30), + (3 << 3) | (4 >> 29), + (4 << 4) | (5 >> 28) + ]) + ); + all_eq!( + simd_funnel_shl(y2, y1, y1), + U32::<4>([ + (2 << 1) | (1 >> 31), + (3 << 2) | (2 >> 30), + (4 << 3) | (3 >> 29), + (5 << 4) | (4 >> 28) + ]) + ); + + all_eq!( + simd_funnel_shr(x1, x2, x1), + i32x4([ + (1 << 31) | (2 >> 1), + (2 << 30) | (3 >> 2), + (3 << 29) | (4 >> 3), + (4 << 28) | (5 >> 4) + ]) + ); + all_eq!( + simd_funnel_shr(x2, x1, x1), + i32x4([ + (2 << 31) | (1 >> 1), + (3 << 30) | (2 >> 2), + (4 << 29) | (3 >> 3), + (5 << 28) | (4 >> 4) + ]) + ); + all_eq!( + simd_funnel_shr(y1, y2, y1), + U32::<4>([ + (1 << 31) | (2 >> 1), + (2 << 30) | (3 >> 2), + (3 << 29) | (4 >> 3), + (4 << 28) | (5 >> 4) + ]) + ); + all_eq!( + simd_funnel_shr(y2, y1, y1), + U32::<4>([ + (2 << 31) | (1 >> 1), + (3 << 30) | (2 >> 2), + (4 << 29) | (3 >> 3), + (5 << 28) | (4 >> 4) + ]) + ); + // ensure we get logical vs. arithmetic shifts correct let (a, b, c, d) = (-12, -123, -1234, -12345); all_eq!(simd_shr(i32x4([a, b, c, d]), x1), i32x4([a >> 1, b >> 2, c >> 3, d >> 4])); diff --git a/tests/ui/sized-borrowed-pointer.rs b/tests/ui/sized-borrowed-pointer.rs deleted file mode 100644 index bd213c067db..00000000000 --- a/tests/ui/sized-borrowed-pointer.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -// Possibly-dynamic size of typaram should be cleared at pointer boundary. - - -fn bar<T: Sized>() { } -fn foo<T>() { bar::<&T>() } -pub fn main() { } diff --git a/tests/ui/sized-cycle-note.rs b/tests/ui/sized-cycle-note.rs deleted file mode 100644 index 766a5fa0de3..00000000000 --- a/tests/ui/sized-cycle-note.rs +++ /dev/null @@ -1,7 +0,0 @@ -struct Baz { q: Option<Foo> } -//~^ ERROR recursive types `Baz` and `Foo` have infinite size -struct Foo { q: Option<Baz> } - -impl Foo { fn bar(&self) {} } - -fn main() {} diff --git a/tests/ui/sized-cycle-note.stderr b/tests/ui/sized-cycle-note.stderr deleted file mode 100644 index 21e54c12fed..00000000000 --- a/tests/ui/sized-cycle-note.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error[E0072]: recursive types `Baz` and `Foo` have infinite size - --> $DIR/sized-cycle-note.rs:1:1 - | -LL | struct Baz { q: Option<Foo> } - | ^^^^^^^^^^ --- recursive without indirection -LL | -LL | struct Foo { q: Option<Baz> } - | ^^^^^^^^^^ --- recursive without indirection - | -help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle - | -LL ~ struct Baz { q: Option<Box<Foo>> } -LL | -LL ~ struct Foo { q: Option<Box<Baz>> } - | - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0072`. diff --git a/tests/ui/sized-hierarchy/impls.rs b/tests/ui/sized-hierarchy/impls.rs index 46697e47c4b..643f7bc7c46 100644 --- a/tests/ui/sized-hierarchy/impls.rs +++ b/tests/ui/sized-hierarchy/impls.rs @@ -3,7 +3,7 @@ #![allow(incomplete_features, internal_features)] #![feature(sized_hierarchy)] -#![feature(coroutines, dyn_star, extern_types, f16, never_type, unsized_fn_params)] +#![feature(coroutines, extern_types, f16, never_type, unsized_fn_params)] use std::fmt::Debug; use std::marker::{MetaSized, PointeeSized}; @@ -151,11 +151,6 @@ fn main() { needs_metasized::<!>(); needs_pointeesized::<!>(); - // `dyn*` - needs_sized::<dyn* Debug>(); - needs_metasized::<dyn* Debug>(); - needs_pointeesized::<dyn* Debug>(); - // `str` needs_sized::<str>(); //~^ ERROR the size for values of type `str` cannot be known at compilation time diff --git a/tests/ui/sized-hierarchy/impls.stderr b/tests/ui/sized-hierarchy/impls.stderr index eebe4e0d706..ca70822aad2 100644 --- a/tests/ui/sized-hierarchy/impls.stderr +++ b/tests/ui/sized-hierarchy/impls.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:240:42 + --> $DIR/impls.rs:235:42 | LL | struct StructAllFieldsMetaSized { x: [u8], y: [u8] } | ^^^^ doesn't have a size known at compile-time @@ -17,7 +17,7 @@ LL | struct StructAllFieldsMetaSized { x: Box<[u8]>, y: [u8] } | ++++ + error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:248:40 + --> $DIR/impls.rs:243:40 | LL | struct StructAllFieldsUnsized { x: Foo, y: Foo } | ^^^ doesn't have a size known at compile-time @@ -35,7 +35,7 @@ LL | struct StructAllFieldsUnsized { x: Box<Foo>, y: Foo } | ++++ + error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:284:44 + --> $DIR/impls.rs:279:44 | LL | enum EnumAllFieldsMetaSized { Qux { x: [u8], y: [u8] } } | ^^^^ doesn't have a size known at compile-time @@ -53,7 +53,7 @@ LL | enum EnumAllFieldsMetaSized { Qux { x: Box<[u8]>, y: [u8] } } | ++++ + error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:291:42 + --> $DIR/impls.rs:286:42 | LL | enum EnumAllFieldsUnsized { Qux { x: Foo, y: Foo } } | ^^^ doesn't have a size known at compile-time @@ -71,7 +71,7 @@ LL | enum EnumAllFieldsUnsized { Qux { x: Box<Foo>, y: Foo } } | ++++ + error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:298:52 + --> $DIR/impls.rs:293:52 | LL | enum EnumLastFieldMetaSized { Qux { x: u32, y: [u8] } } | ^^^^ doesn't have a size known at compile-time @@ -89,7 +89,7 @@ LL | enum EnumLastFieldMetaSized { Qux { x: u32, y: Box<[u8]> } } | ++++ + error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:305:50 + --> $DIR/impls.rs:300:50 | LL | enum EnumLastFieldUnsized { Qux { x: u32, y: Foo } } | ^^^ doesn't have a size known at compile-time @@ -107,7 +107,7 @@ LL | enum EnumLastFieldUnsized { Qux { x: u32, y: Box<Foo> } } | ++++ + error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/impls.rs:160:19 + --> $DIR/impls.rs:155:19 | LL | needs_sized::<str>(); | ^^^ doesn't have a size known at compile-time @@ -120,7 +120,7 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:166:19 + --> $DIR/impls.rs:161:19 | LL | needs_sized::<[u8]>(); | ^^^^ doesn't have a size known at compile-time @@ -133,7 +133,7 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `dyn Debug` cannot be known at compilation time - --> $DIR/impls.rs:172:19 + --> $DIR/impls.rs:167:19 | LL | needs_sized::<dyn Debug>(); | ^^^^^^^^^ doesn't have a size known at compile-time @@ -146,7 +146,7 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:181:19 + --> $DIR/impls.rs:176:19 | LL | needs_sized::<Foo>(); | ^^^ doesn't have a size known at compile-time @@ -159,7 +159,7 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known - --> $DIR/impls.rs:183:23 + --> $DIR/impls.rs:178:23 | LL | needs_metasized::<Foo>(); | ^^^ doesn't have a known size @@ -172,7 +172,7 @@ LL | fn needs_metasized<T: MetaSized>() { } | ^^^^^^^^^ required by this bound in `needs_metasized` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:198:19 + --> $DIR/impls.rs:193:19 | LL | needs_sized::<([u8], [u8])>(); | ^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -181,7 +181,7 @@ LL | needs_sized::<([u8], [u8])>(); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:200:23 + --> $DIR/impls.rs:195:23 | LL | needs_metasized::<([u8], [u8])>(); | ^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -190,7 +190,7 @@ LL | needs_metasized::<([u8], [u8])>(); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:202:26 + --> $DIR/impls.rs:197:26 | LL | needs_pointeesized::<([u8], [u8])>(); | ^^^^^^^^^^^^ doesn't have a size known at compile-time @@ -199,7 +199,7 @@ LL | needs_pointeesized::<([u8], [u8])>(); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:206:19 + --> $DIR/impls.rs:201:19 | LL | needs_sized::<(Foo, Foo)>(); | ^^^^^^^^^^ doesn't have a size known at compile-time @@ -208,7 +208,7 @@ LL | needs_sized::<(Foo, Foo)>(); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:208:23 + --> $DIR/impls.rs:203:23 | LL | needs_metasized::<(Foo, Foo)>(); | ^^^^^^^^^^ doesn't have a size known at compile-time @@ -217,7 +217,7 @@ LL | needs_metasized::<(Foo, Foo)>(); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `main::Foo` cannot be known - --> $DIR/impls.rs:208:23 + --> $DIR/impls.rs:203:23 | LL | needs_metasized::<(Foo, Foo)>(); | ^^^^^^^^^^ doesn't have a known size @@ -231,7 +231,7 @@ LL | fn needs_metasized<T: MetaSized>() { } | ^^^^^^^^^ required by this bound in `needs_metasized` error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:211:26 + --> $DIR/impls.rs:206:26 | LL | needs_pointeesized::<(Foo, Foo)>(); | ^^^^^^^^^^ doesn't have a size known at compile-time @@ -240,7 +240,7 @@ LL | needs_pointeesized::<(Foo, Foo)>(); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:215:19 + --> $DIR/impls.rs:210:19 | LL | needs_sized::<(u32, [u8])>(); | ^^^^^^^^^^^ doesn't have a size known at compile-time @@ -254,7 +254,7 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:221:19 + --> $DIR/impls.rs:216:19 | LL | needs_sized::<(u32, Foo)>(); | ^^^^^^^^^^ doesn't have a size known at compile-time @@ -268,7 +268,7 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known - --> $DIR/impls.rs:223:23 + --> $DIR/impls.rs:218:23 | LL | needs_metasized::<(u32, Foo)>(); | ^^^^^^^^^^ doesn't have a known size @@ -282,14 +282,14 @@ LL | fn needs_metasized<T: MetaSized>() { } | ^^^^^^^^^ required by this bound in `needs_metasized` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:242:19 + --> $DIR/impls.rs:237:19 | LL | needs_sized::<StructAllFieldsMetaSized>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `StructAllFieldsMetaSized`, the trait `Sized` is not implemented for `[u8]` note: required because it appears within the type `StructAllFieldsMetaSized` - --> $DIR/impls.rs:240:12 + --> $DIR/impls.rs:235:12 | LL | struct StructAllFieldsMetaSized { x: [u8], y: [u8] } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -300,14 +300,14 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:250:19 + --> $DIR/impls.rs:245:19 | LL | needs_sized::<StructAllFieldsUnsized>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `StructAllFieldsUnsized`, the trait `Sized` is not implemented for `main::Foo` note: required because it appears within the type `StructAllFieldsUnsized` - --> $DIR/impls.rs:248:12 + --> $DIR/impls.rs:243:12 | LL | struct StructAllFieldsUnsized { x: Foo, y: Foo } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -318,14 +318,14 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known - --> $DIR/impls.rs:252:23 + --> $DIR/impls.rs:247:23 | LL | needs_metasized::<StructAllFieldsUnsized>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a known size | = help: within `StructAllFieldsUnsized`, the trait `MetaSized` is not implemented for `main::Foo` note: required because it appears within the type `StructAllFieldsUnsized` - --> $DIR/impls.rs:248:12 + --> $DIR/impls.rs:243:12 | LL | struct StructAllFieldsUnsized { x: Foo, y: Foo } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -336,14 +336,14 @@ LL | fn needs_metasized<T: MetaSized>() { } | ^^^^^^^^^ required by this bound in `needs_metasized` error[E0277]: the size for values of type `[u8]` cannot be known at compilation time - --> $DIR/impls.rs:258:19 + --> $DIR/impls.rs:253:19 | LL | needs_sized::<StructLastFieldMetaSized>(); | ^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `StructLastFieldMetaSized`, the trait `Sized` is not implemented for `[u8]` note: required because it appears within the type `StructLastFieldMetaSized` - --> $DIR/impls.rs:257:12 + --> $DIR/impls.rs:252:12 | LL | struct StructLastFieldMetaSized { x: u32, y: [u8] } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -354,14 +354,14 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known at compilation time - --> $DIR/impls.rs:265:19 + --> $DIR/impls.rs:260:19 | LL | needs_sized::<StructLastFieldUnsized>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `StructLastFieldUnsized`, the trait `Sized` is not implemented for `main::Foo` note: required because it appears within the type `StructLastFieldUnsized` - --> $DIR/impls.rs:264:12 + --> $DIR/impls.rs:259:12 | LL | struct StructLastFieldUnsized { x: u32, y: Foo } | ^^^^^^^^^^^^^^^^^^^^^^ @@ -372,14 +372,14 @@ LL | fn needs_sized<T: Sized>() { } | ^^^^^ required by this bound in `needs_sized` error[E0277]: the size for values of type `main::Foo` cannot be known - --> $DIR/impls.rs:267:23 + --> $DIR/impls.rs:262:23 | LL | needs_metasized::<StructLastFieldUnsized>(); | ^^^^^^^^^^^^^^^^^^^^^^ doesn't have a known size | = help: within `StructLastFieldUnsized`, the trait `MetaSized` is not implemented for `main::Foo` note: required because it appears within the type `StructLastFieldUnsized` - --> $DIR/impls.rs:264:12 + --> $DIR/impls.rs:259:12 | LL | struct StructLastFieldUnsized { x: u32, y: Foo } | ^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/sized-hierarchy/reject-dyn-pointeesized.rs b/tests/ui/sized-hierarchy/reject-dyn-pointeesized.rs new file mode 100644 index 00000000000..ece1702679d --- /dev/null +++ b/tests/ui/sized-hierarchy/reject-dyn-pointeesized.rs @@ -0,0 +1,16 @@ +#![feature(sized_hierarchy)] + +use std::marker::PointeeSized; + +type Foo = dyn PointeeSized; +//~^ ERROR `PointeeSized` cannot be used with trait objects + +fn foo(f: &Foo) {} + +fn main() { + foo(&()); + + let x = main; + let y: Box<dyn PointeeSized> = x; +//~^ ERROR `PointeeSized` cannot be used with trait objects +} diff --git a/tests/ui/sized-hierarchy/reject-dyn-pointeesized.stderr b/tests/ui/sized-hierarchy/reject-dyn-pointeesized.stderr new file mode 100644 index 00000000000..a833c6952fd --- /dev/null +++ b/tests/ui/sized-hierarchy/reject-dyn-pointeesized.stderr @@ -0,0 +1,14 @@ +error: `PointeeSized` cannot be used with trait objects + --> $DIR/reject-dyn-pointeesized.rs:5:12 + | +LL | type Foo = dyn PointeeSized; + | ^^^^^^^^^^^^^^^^ + +error: `PointeeSized` cannot be used with trait objects + --> $DIR/reject-dyn-pointeesized.rs:14:16 + | +LL | let y: Box<dyn PointeeSized> = x; + | ^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/sized-owned-pointer.rs b/tests/ui/sized-owned-pointer.rs deleted file mode 100644 index b35c0f91abd..00000000000 --- a/tests/ui/sized-owned-pointer.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ run-pass - -#![allow(dead_code)] -// Possibly-dynamic size of typaram should be cleared at pointer boundary. - - - -fn bar<T: Sized>() { } -fn foo<T>() { bar::<Box<T>>() } -pub fn main() { } diff --git a/tests/ui/sized/recursive-type-infinite-size.rs b/tests/ui/sized/recursive-type-infinite-size.rs new file mode 100644 index 00000000000..5cd8e895573 --- /dev/null +++ b/tests/ui/sized/recursive-type-infinite-size.rs @@ -0,0 +1,16 @@ +//! Check for compilation errors when recursive types are defined in a way +//! that leads to an infinite size. + +struct Baz { + //~^ ERROR recursive types `Baz` and `Foo` have infinite size + q: Option<Foo>, +} +struct Foo { + q: Option<Baz>, +} + +impl Foo { + fn bar(&self) {} +} + +fn main() {} diff --git a/tests/ui/sized/recursive-type-infinite-size.stderr b/tests/ui/sized/recursive-type-infinite-size.stderr new file mode 100644 index 00000000000..98ac36c4bb6 --- /dev/null +++ b/tests/ui/sized/recursive-type-infinite-size.stderr @@ -0,0 +1,25 @@ +error[E0072]: recursive types `Baz` and `Foo` have infinite size + --> $DIR/recursive-type-infinite-size.rs:4:1 + | +LL | struct Baz { + | ^^^^^^^^^^ +LL | +LL | q: Option<Foo>, + | --- recursive without indirection +LL | } +LL | struct Foo { + | ^^^^^^^^^^ +LL | q: Option<Baz>, + | --- recursive without indirection + | +help: insert some indirection (e.g., a `Box`, `Rc`, or `&`) to break the cycle + | +LL ~ q: Option<Box<Foo>>, +LL | } +LL | struct Foo { +LL ~ q: Option<Box<Baz>>, + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0072`. diff --git a/tests/ui/sized/sized-box-unsized-content.rs b/tests/ui/sized/sized-box-unsized-content.rs new file mode 100644 index 00000000000..9cc202a1582 --- /dev/null +++ b/tests/ui/sized/sized-box-unsized-content.rs @@ -0,0 +1,11 @@ +//! Check that `Box<T>` is `Sized`, even when `T` is a dynamically sized type. + +//@ run-pass + +#![allow(dead_code)] + +fn bar<T: Sized>() {} +fn foo<T>() { + bar::<Box<T>>() +} +pub fn main() {} diff --git a/tests/ui/sized/sized-reference-to-unsized.rs b/tests/ui/sized/sized-reference-to-unsized.rs new file mode 100644 index 00000000000..ac2934d8fe6 --- /dev/null +++ b/tests/ui/sized/sized-reference-to-unsized.rs @@ -0,0 +1,11 @@ +//! Check that a reference to a potentially unsized type (`&T`) is itself considered `Sized`. + +//@ run-pass + +#![allow(dead_code)] + +fn bar<T: Sized>() {} +fn foo<T>() { + bar::<&T>() +} +pub fn main() {} diff --git a/tests/ui/span/issue-71363.stderr b/tests/ui/span/issue-71363.stderr index 90b623e89cf..31069914daa 100644 --- a/tests/ui/span/issue-71363.stderr +++ b/tests/ui/span/issue-71363.stderr @@ -2,10 +2,8 @@ error[E0277]: `MyError` doesn't implement `std::fmt::Display` --> $DIR/issue-71363.rs:4:28 | 4 | impl std::error::Error for MyError {} - | ^^^^^^^ `MyError` cannot be formatted with the default formatter + | ^^^^^^^ the trait `std::fmt::Display` is not implemented for `MyError` | - = help: the trait `std::fmt::Display` is not implemented for `MyError` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `std::error::Error` --> $SRC_DIR/core/src/error.rs:LL:COL @@ -13,9 +11,8 @@ error[E0277]: `MyError` doesn't implement `Debug` --> $DIR/issue-71363.rs:4:28 | 4 | impl std::error::Error for MyError {} - | ^^^^^^^ `MyError` cannot be formatted using `{:?}` + | ^^^^^^^ the trait `Debug` is not implemented for `MyError` | - = help: the trait `Debug` is not implemented for `MyError` = note: add `#[derive(Debug)]` to `MyError` or manually `impl Debug for MyError` note: required by a bound in `std::error::Error` --> $SRC_DIR/core/src/error.rs:LL:COL diff --git a/tests/ui/specialization/const_trait_impl.rs b/tests/ui/specialization/const_trait_impl.rs index d842601a6b7..2df92dfad3b 100644 --- a/tests/ui/specialization/const_trait_impl.rs +++ b/tests/ui/specialization/const_trait_impl.rs @@ -10,7 +10,7 @@ pub unsafe trait Sup { #[rustc_specialization_trait] #[const_trait] -pub unsafe trait Sub: ~const Sup {} +pub unsafe trait Sub: [const] Sup {} unsafe impl const Sup for u8 { default fn foo() -> u32 { @@ -31,19 +31,19 @@ pub trait A { fn a() -> u32; } -impl<T: ~const Default> const A for T { +impl<T: [const] Default> const A for T { default fn a() -> u32 { 2 } } -impl<T: ~const Default + ~const Sup> const A for T { +impl<T: [const] Default + [const] Sup> const A for T { default fn a() -> u32 { 3 } } -impl<T: ~const Default + ~const Sub> const A for T { +impl<T: [const] Default + [const] Sub> const A for T { fn a() -> u32 { T::foo() } diff --git a/tests/ui/specialization/const_trait_impl.stderr b/tests/ui/specialization/const_trait_impl.stderr index 3e1260ff09c..ea3ec16ac1e 100644 --- a/tests/ui/specialization/const_trait_impl.stderr +++ b/tests/ui/specialization/const_trait_impl.stderr @@ -1,57 +1,57 @@ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const_trait_impl.rs:34:9 | -LL | impl<T: ~const Default> const A for T { - | ^^^^^^ can't be applied to `Default` +LL | impl<T: [const] Default> const A for T { + | ^^^^^^^ can't be applied to `Default` | -note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/default.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const_trait_impl.rs:40:9 | -LL | impl<T: ~const Default + ~const Sup> const A for T { - | ^^^^^^ can't be applied to `Default` +LL | impl<T: [const] Default + [const] Sup> const A for T { + | ^^^^^^^ can't be applied to `Default` | -note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/default.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const_trait_impl.rs:46:9 | -LL | impl<T: ~const Default + ~const Sub> const A for T { - | ^^^^^^ can't be applied to `Default` +LL | impl<T: [const] Default + [const] Sub> const A for T { + | ^^^^^^^ can't be applied to `Default` | -note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/default.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const_trait_impl.rs:40:9 | -LL | impl<T: ~const Default + ~const Sup> const A for T { - | ^^^^^^ can't be applied to `Default` +LL | impl<T: [const] Default + [const] Sup> const A for T { + | ^^^^^^^ can't be applied to `Default` | -note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/default.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const_trait_impl.rs:34:9 | -LL | impl<T: ~const Default> const A for T { - | ^^^^^^ can't be applied to `Default` +LL | impl<T: [const] Default> const A for T { + | ^^^^^^^ can't be applied to `Default` | -note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/default.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const_trait_impl.rs:46:9 | -LL | impl<T: ~const Default + ~const Sub> const A for T { - | ^^^^^^ can't be applied to `Default` +LL | impl<T: [const] Default + [const] Sub> const A for T { + | ^^^^^^^ can't be applied to `Default` | -note: `Default` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Default` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/default.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/specialization/defaultimpl/validation.stderr b/tests/ui/specialization/defaultimpl/validation.stderr index d034386b842..82a33bf9cdc 100644 --- a/tests/ui/specialization/defaultimpl/validation.stderr +++ b/tests/ui/specialization/defaultimpl/validation.stderr @@ -18,14 +18,6 @@ LL | #![feature(specialization)] = help: consider using `min_specialization` instead, which is more stable and complete = note: `#[warn(incomplete_features)]` on by default -error: impls of auto traits cannot be default - --> $DIR/validation.rs:9:21 - | -LL | default unsafe impl Send for S {} - | ------- ^^^^ auto trait - | | - | default because of this - error[E0367]: `!Send` impl requires `Z: Send` but the struct it is implemented for does not --> $DIR/validation.rs:12:1 | @@ -39,6 +31,14 @@ LL | struct Z; | ^^^^^^^^ error: impls of auto traits cannot be default + --> $DIR/validation.rs:9:21 + | +LL | default unsafe impl Send for S {} + | ------- ^^^^ auto trait + | | + | default because of this + +error: impls of auto traits cannot be default --> $DIR/validation.rs:12:15 | LL | default impl !Send for Z {} diff --git a/tests/ui/specialization/issue-51892.stderr b/tests/ui/specialization/issue-51892.stderr index b1cabc0ac0e..f327f10438d 100644 --- a/tests/ui/specialization/issue-51892.stderr +++ b/tests/ui/specialization/issue-51892.stderr @@ -1,8 +1,8 @@ error: unconstrained generic constant - --> $DIR/issue-51892.rs:14:17 + --> $DIR/issue-51892.rs:14:5 | LL | type Type = [u8; std::mem::size_of::<<T as Trait>::Type>()]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^ | help: try adding a `where` bound | diff --git a/tests/ui/specialization/min_specialization/issue-79224.stderr b/tests/ui/specialization/min_specialization/issue-79224.stderr index 2ed614f1857..9b6c931f909 100644 --- a/tests/ui/specialization/min_specialization/issue-79224.stderr +++ b/tests/ui/specialization/min_specialization/issue-79224.stderr @@ -1,8 +1,8 @@ error[E0277]: the trait bound `B: Clone` is not satisfied - --> $DIR/issue-79224.rs:28:29 + --> $DIR/issue-79224.rs:30:5 | -LL | impl<B: ?Sized> Display for Cow<'_, B> { - | ^^^^^^^^^^ the trait `Clone` is not implemented for `B` +LL | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `B` | = note: required for `B` to implement `ToOwned` help: consider further restricting type parameter `B` with trait `Clone` @@ -11,10 +11,10 @@ LL | impl<B: ?Sized + std::clone::Clone> Display for Cow<'_, B> { | +++++++++++++++++++ error[E0277]: the trait bound `B: Clone` is not satisfied - --> $DIR/issue-79224.rs:30:5 + --> $DIR/issue-79224.rs:28:29 | -LL | fn fmt(&self, f: &mut fmt::Formatter<'_>) -> fmt::Result { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `Clone` is not implemented for `B` +LL | impl<B: ?Sized> Display for Cow<'_, B> { + | ^^^^^^^^^^ the trait `Clone` is not implemented for `B` | = note: required for `B` to implement `ToOwned` help: consider further restricting type parameter `B` with trait `Clone` diff --git a/tests/ui/stable-addr-of.rs b/tests/ui/stable-addr-of.rs deleted file mode 100644 index e330a4853ce..00000000000 --- a/tests/ui/stable-addr-of.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ run-pass -// Issue #2040 - - -pub fn main() { - let foo: isize = 1; - assert_eq!(&foo as *const isize, &foo as *const isize); -} diff --git a/tests/ui/stable-mir-print/async-closure.rs b/tests/ui/stable-mir-print/async-closure.rs index 7da532a359f..80f96e09cfc 100644 --- a/tests/ui/stable-mir-print/async-closure.rs +++ b/tests/ui/stable-mir-print/async-closure.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z unpretty=stable-mir --crate-type lib -C panic=abort +//@ compile-flags: -Z unpretty=stable-mir --crate-type lib -C panic=abort -Zmir-opt-level=0 //@ check-pass //@ only-x86_64 //@ edition: 2024 diff --git a/tests/ui/stable-mir-print/async-closure.stdout b/tests/ui/stable-mir-print/async-closure.stdout index 12e7a5530ac..31811299722 100644 --- a/tests/ui/stable-mir-print/async-closure.stdout +++ b/tests/ui/stable-mir-print/async-closure.stdout @@ -8,19 +8,30 @@ fn foo() -> () { debug y => _1; debug x => _2; bb0: { + StorageLive(_1); _1 = 0_i32; + StorageLive(_2); + StorageLive(_3); _3 = &_1; _2 = {coroutine-closure@$DIR/async-closure.rs:9:13: 9:21}(move _3); + StorageDead(_3); + _0 = (); + StorageDead(_2); + StorageDead(_1); return; } } fn foo::{closure#0}(_1: &{async closure@$DIR/async-closure.rs:9:13: 9:21}) -> {async closure body@$DIR/async-closure.rs:9:22: 11:6} { let mut _0: {async closure body@$DIR/async-closure.rs:9:22: 11:6}; let mut _2: &i32; + let mut _3: &i32; debug y => (*((*_1).0: &i32)); bb0: { - _2 = CopyForDeref(((*_1).0: &i32)); - _0 = {coroutine@$DIR/async-closure.rs:9:22: 11:6}(_2); + StorageLive(_2); + _3 = CopyForDeref(((*_1).0: &i32)); + _2 = &(*_3); + _0 = {coroutine@$DIR/async-closure.rs:9:22: 11:6}(move _2); + StorageDead(_2); return; } } @@ -28,25 +39,31 @@ fn foo::{closure#0}::{closure#0}(_1: Pin<&mut {async closure body@$DIR/async-clo let mut _0: Poll<()>; let _3: i32; let mut _4: &i32; - let mut _5: u32; - let mut _6: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}; - let mut _7: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}; + let mut _5: (); + let mut _6: &mut Context<'_>; + let mut _7: u32; let mut _8: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}; - debug _task_context => _2; + let mut _9: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}; + let mut _10: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}; + debug _task_context => _6; debug y => (*((*(_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})).0: &i32)); debug y => _3; bb0: { - _6 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); - _5 = discriminant((*_6)); - switchInt(move _5) -> [0: bb1, 1: bb2, otherwise: bb3]; + _8 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); + _7 = discriminant((*_8)); + switchInt(move _7) -> [0: bb1, 1: bb2, otherwise: bb3]; } bb1: { - _7 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); - _4 = CopyForDeref(((*_7).0: &i32)); + _6 = move _2; + StorageLive(_3); + _9 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); + _4 = CopyForDeref(((*_9).0: &i32)); _3 = (*_4); - _0 = std::task::Poll::Ready(()); - _8 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); - discriminant((*_8) = 1; + _5 = (); + StorageDead(_3); + _0 = std::task::Poll::Ready(move _5); + _10 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); + discriminant((*_10) = 1; return; } bb2: { @@ -60,25 +77,31 @@ fn foo::{closure#0}::{synthetic#0}(_1: Pin<&mut {async closure body@$DIR/async-c let mut _0: Poll<()>; let _3: i32; let mut _4: &i32; - let mut _5: u32; - let mut _6: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}; - let mut _7: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}; + let mut _5: (); + let mut _6: &mut Context<'_>; + let mut _7: u32; let mut _8: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}; - debug _task_context => _2; + let mut _9: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}; + let mut _10: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6}; + debug _task_context => _6; debug y => (*((*(_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})).0: &i32)); debug y => _3; bb0: { - _6 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); - _5 = discriminant((*_6)); - switchInt(move _5) -> [0: bb1, 1: bb2, otherwise: bb3]; + _8 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); + _7 = discriminant((*_8)); + switchInt(move _7) -> [0: bb1, 1: bb2, otherwise: bb3]; } bb1: { - _7 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); - _4 = CopyForDeref(((*_7).0: &i32)); + _6 = move _2; + StorageLive(_3); + _9 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); + _4 = CopyForDeref(((*_9).0: &i32)); _3 = (*_4); - _0 = std::task::Poll::Ready(()); - _8 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); - discriminant((*_8) = 1; + _5 = (); + StorageDead(_3); + _0 = std::task::Poll::Ready(move _5); + _10 = CopyForDeref((_1.0: &mut {async closure body@$DIR/async-closure.rs:9:22: 11:6})); + discriminant((*_10) = 1; return; } bb2: { diff --git a/tests/ui/stable-mir-print/basic_function.rs b/tests/ui/stable-mir-print/basic_function.rs index 5f582ece6fb..21469c61f72 100644 --- a/tests/ui/stable-mir-print/basic_function.rs +++ b/tests/ui/stable-mir-print/basic_function.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z unpretty=stable-mir -Z mir-opt-level=3 +//@ compile-flags: -Z unpretty=stable-mir -Zmir-opt-level=0 //@ check-pass //@ only-x86_64 //@ needs-unwind unwind edges are different with panic=abort diff --git a/tests/ui/stable-mir-print/basic_function.stdout b/tests/ui/stable-mir-print/basic_function.stdout index 76288c2aa49..319d9c1dc69 100644 --- a/tests/ui/stable-mir-print/basic_function.stdout +++ b/tests/ui/stable-mir-print/basic_function.stdout @@ -2,14 +2,18 @@ // If you find a bug or want to improve the output open a issue at https://github.com/rust-lang/project-stable-mir. fn foo(_1: i32) -> i32 { let mut _0: i32; - let mut _2: (i32, bool); + let mut _2: i32; + let mut _3: (i32, bool); debug i => _1; bb0: { - _2 = CheckedAdd(_1, 1_i32); - assert(!move (_2.1: bool), "attempt to compute `{} + {}`, which would overflow", _1, 1_i32) -> [success: bb1, unwind continue]; + StorageLive(_2); + _2 = _1; + _3 = CheckedAdd(_2, 1_i32); + assert(!move (_3.1: bool), "attempt to compute `{} + {}`, which would overflow", move _2, 1_i32) -> [success: bb1, unwind continue]; } bb1: { - _0 = move (_2.0: i32); + _0 = move (_3.0: i32); + StorageDead(_2); return; } } @@ -22,15 +26,23 @@ fn bar(_1: &mut Vec<i32>) -> Vec<i32> { debug vec => _1; debug new_vec => _2; bb0: { + StorageLive(_2); + StorageLive(_3); _3 = &(*_1); _2 = <Vec<i32> as Clone>::clone(move _3) -> [return: bb1, unwind continue]; } bb1: { + StorageDead(_3); + StorageLive(_4); + StorageLive(_5); _5 = &mut _2; _4 = Vec::<i32>::push(move _5, 1_i32) -> [return: bb2, unwind: bb3]; } bb2: { + StorageDead(_5); + StorageDead(_4); _0 = move _2; + StorageDead(_2); return; } bb3: { @@ -69,6 +81,7 @@ fn demux(_1: u8) -> u8 { fn main() -> () { let mut _0: (); bb0: { + _0 = (); return; } } diff --git a/tests/ui/stable-mir-print/operands.rs b/tests/ui/stable-mir-print/operands.rs index 34a74e2287e..484ad07cf04 100644 --- a/tests/ui/stable-mir-print/operands.rs +++ b/tests/ui/stable-mir-print/operands.rs @@ -1,4 +1,4 @@ -//@ compile-flags: -Z unpretty=stable-mir --crate-type lib -C panic=abort +//@ compile-flags: -Z unpretty=stable-mir --crate-type lib -C panic=abort -Zmir-opt-level=0 //@ check-pass //@ only-x86_64 //@ needs-unwind unwind edges are different with panic=abort diff --git a/tests/ui/stable-mir-print/operands.stdout b/tests/ui/stable-mir-print/operands.stdout index c3b1151ae24..37c5ec1a95e 100644 --- a/tests/ui/stable-mir-print/operands.stdout +++ b/tests/ui/stable-mir-print/operands.stdout @@ -3,185 +3,398 @@ fn operands(_1: u8) -> () { let mut _0: (); let _2: [u8; 10]; - let _3: u8; - let _4: usize; - let mut _5: bool; - let _6: u8; - let _7: usize; - let mut _8: (usize, bool); - let mut _9: bool; - let mut _10: (&u8, &u8); - let mut _11: &u8; - let mut _12: &u8; - let _13: &u8; - let _14: &u8; - let mut _15: bool; - let mut _16: u8; - let mut _17: u8; - let _18: core::panicking::AssertKind; - let _19: !; - let mut _20: Option<Arguments<'_>>; - let _21: &u8; - let _22: u8; - let mut _23: (&u8, &u8); + let mut _3: u8; + let _4: u8; + let _5: usize; + let mut _6: bool; + let _7: u8; + let _8: usize; + let mut _9: (usize, bool); + let mut _10: bool; + let _11: (); + let mut _12: (&u8, &u8); + let mut _13: &u8; + let mut _14: &u8; + let _15: &u8; + let _16: &u8; + let mut _17: bool; + let mut _18: u8; + let mut _19: u8; + let mut _20: !; + let _21: core::panicking::AssertKind; + let _22: !; + let mut _23: core::panicking::AssertKind; let mut _24: &u8; - let mut _25: &u8; - let _26: &u8; + let _25: &u8; + let mut _26: &u8; let _27: &u8; - let mut _28: bool; - let mut _29: u8; - let mut _30: u8; - let _31: core::panicking::AssertKind; - let _32: !; - let mut _33: Option<Arguments<'_>>; - let _34: (u8, u8); - let _35: u8; - let _36: u8; - let mut _37: (&u8, &u8); - let mut _38: &u8; - let mut _39: &u8; - let _40: &u8; - let _41: &u8; - let mut _42: bool; - let mut _43: u8; - let mut _44: u8; - let _45: core::panicking::AssertKind; - let _46: !; - let mut _47: Option<Arguments<'_>>; - let _48: usize; - let mut _49: &[u8]; - let mut _50: &[u8; 10]; - let _51: usize; - let _52: &usize; - let mut _53: (&usize, &usize); - let mut _54: &usize; - let mut _55: &usize; - let _56: &usize; - let _57: &usize; - let mut _58: bool; - let mut _59: usize; - let mut _60: usize; - let _61: core::panicking::AssertKind; - let _62: !; - let mut _63: Option<Arguments<'_>>; + let mut _28: Option<Arguments<'_>>; + let _29: &u8; + let _30: u8; + let _31: (); + let mut _32: (&u8, &u8); + let mut _33: &u8; + let mut _34: &u8; + let _35: &u8; + let _36: &u8; + let mut _37: bool; + let mut _38: u8; + let mut _39: u8; + let mut _40: !; + let _41: core::panicking::AssertKind; + let _42: !; + let mut _43: core::panicking::AssertKind; + let mut _44: &u8; + let _45: &u8; + let mut _46: &u8; + let _47: &u8; + let mut _48: Option<Arguments<'_>>; + let _49: (u8, u8); + let mut _50: u8; + let mut _51: u8; + let _52: u8; + let _53: u8; + let _54: (); + let mut _55: (&u8, &u8); + let mut _56: &u8; + let mut _57: &u8; + let _58: &u8; + let _59: &u8; + let mut _60: bool; + let mut _61: u8; + let mut _62: u8; + let mut _63: !; + let _64: core::panicking::AssertKind; + let _65: !; + let mut _66: core::panicking::AssertKind; + let mut _67: &u8; + let _68: &u8; + let mut _69: &u8; + let _70: &u8; + let mut _71: Option<Arguments<'_>>; + let _72: usize; + let mut _73: &[u8]; + let mut _74: &[u8; 10]; + let _75: usize; + let mut _76: &usize; + let _77: &usize; + let _78: (); + let mut _79: (&usize, &usize); + let mut _80: &usize; + let mut _81: &usize; + let _82: &usize; + let _83: &usize; + let mut _84: bool; + let mut _85: usize; + let mut _86: usize; + let mut _87: !; + let _88: core::panicking::AssertKind; + let _89: !; + let mut _90: core::panicking::AssertKind; + let mut _91: &usize; + let _92: &usize; + let mut _93: &usize; + let _94: &usize; + let mut _95: Option<Arguments<'_>>; debug val => _1; debug array => _2; - debug first => _3; - debug last => _6; - debug left_val => _13; - debug right_val => _14; - debug kind => _18; - debug reference => _21; - debug dereferenced => _22; - debug left_val => _26; - debug right_val => _27; - debug kind => _31; - debug tuple => _34; - debug first_again => _35; - debug first_again_again => _36; - debug left_val => _40; - debug right_val => _41; - debug kind => _45; - debug length => _48; - debug size_of => _51; - debug left_val => _56; - debug right_val => _57; - debug kind => _61; + debug first => _4; + debug last => _7; + debug left_val => _15; + debug right_val => _16; + debug kind => _21; + debug reference => _29; + debug dereferenced => _30; + debug left_val => _35; + debug right_val => _36; + debug kind => _41; + debug tuple => _49; + debug first_again => _52; + debug first_again_again => _53; + debug left_val => _58; + debug right_val => _59; + debug kind => _64; + debug length => _72; + debug size_of => _75; + debug left_val => _82; + debug right_val => _83; + debug kind => _88; bb0: { - _2 = [_1; 10]; - _4 = 0_usize; - _5 = Lt(_4, 10_usize); - assert(move _5, "index out of bounds: the length is {} but the index is {}", 10_usize, _4) -> [success: bb1, unwind unreachable]; + StorageLive(_2); + StorageLive(_3); + _3 = _1; + _2 = [move _3; 10]; + StorageDead(_3); + StorageLive(_4); + StorageLive(_5); + _5 = 0_usize; + _6 = Lt(_5, 10_usize); + assert(move _6, "index out of bounds: the length is {} but the index is {}", 10_usize, _5) -> [success: bb1, unwind unreachable]; } bb1: { - _3 = _2[_4]; - _8 = CheckedSub(10_usize, 1_usize); - assert(!move (_8.1: bool), "attempt to compute `{} - {}`, which would overflow", 10_usize, 1_usize) -> [success: bb2, unwind unreachable]; + _4 = _2[_5]; + StorageDead(_5); + StorageLive(_7); + StorageLive(_8); + _9 = CheckedSub(10_usize, 1_usize); + assert(!move (_9.1: bool), "attempt to compute `{} - {}`, which would overflow", 10_usize, 1_usize) -> [success: bb2, unwind unreachable]; } bb2: { - _7 = move (_8.0: usize); - _9 = Lt(_7, 10_usize); - assert(move _9, "index out of bounds: the length is {} but the index is {}", 10_usize, _7) -> [success: bb3, unwind unreachable]; + _8 = move (_9.0: usize); + _10 = Lt(_8, 10_usize); + assert(move _10, "index out of bounds: the length is {} but the index is {}", 10_usize, _8) -> [success: bb3, unwind unreachable]; } bb3: { - _6 = _2[_7]; - _11 = &_3; - _12 = &_6; - _10 = (move _11, move _12); - _13 = (_10.0: &u8); - _14 = (_10.1: &u8); - _16 = (*_13); - _17 = (*_14); - _15 = Eq(move _16, move _17); - switchInt(move _15) -> [0: bb5, otherwise: bb4]; + _7 = _2[_8]; + StorageDead(_8); + StorageLive(_11); + StorageLive(_12); + StorageLive(_13); + _13 = &_4; + StorageLive(_14); + _14 = &_7; + _12 = (move _13, move _14); + StorageDead(_14); + StorageDead(_13); + StorageLive(_15); + _15 = (_12.0: &u8); + StorageLive(_16); + _16 = (_12.1: &u8); + StorageLive(_17); + StorageLive(_18); + _18 = (*_15); + StorageLive(_19); + _19 = (*_16); + _17 = Eq(move _18, move _19); + switchInt(move _17) -> [0: bb5, otherwise: bb4]; } bb4: { - _21 = &_3; - _22 = (*_21); - _24 = &_22; - _25 = &_3; - _23 = (move _24, move _25); - _26 = (_23.0: &u8); - _27 = (_23.1: &u8); - _29 = (*_26); - _30 = (*_27); - _28 = Eq(move _29, move _30); - switchInt(move _28) -> [0: bb7, otherwise: bb6]; + StorageDead(_19); + StorageDead(_18); + _11 = (); + StorageDead(_17); + StorageDead(_16); + StorageDead(_15); + StorageDead(_12); + StorageDead(_11); + StorageLive(_29); + _29 = &_4; + StorageLive(_30); + _30 = (*_29); + StorageLive(_31); + StorageLive(_32); + StorageLive(_33); + _33 = &_30; + StorageLive(_34); + _34 = &_4; + _32 = (move _33, move _34); + StorageDead(_34); + StorageDead(_33); + StorageLive(_35); + _35 = (_32.0: &u8); + StorageLive(_36); + _36 = (_32.1: &u8); + StorageLive(_37); + StorageLive(_38); + _38 = (*_35); + StorageLive(_39); + _39 = (*_36); + _37 = Eq(move _38, move _39); + switchInt(move _37) -> [0: bb7, otherwise: bb6]; } bb5: { - _18 = core::panicking::AssertKind::Eq; - _20 = std::option::Option::None; - _19 = core::panicking::assert_failed::<u8, u8>(move _18, _13, _14, move _20) -> unwind unreachable; + StorageDead(_19); + StorageDead(_18); + StorageLive(_21); + _21 = core::panicking::AssertKind::Eq; + StorageLive(_22); + StorageLive(_23); + _23 = move _21; + StorageLive(_24); + StorageLive(_25); + _25 = &(*_15); + _24 = &(*_25); + StorageLive(_26); + StorageLive(_27); + _27 = &(*_16); + _26 = &(*_27); + StorageLive(_28); + _28 = std::option::Option::None; + _22 = core::panicking::assert_failed::<u8, u8>(move _23, move _24, move _26, move _28) -> unwind unreachable; } bb6: { - _34 = (_3, _6); - _35 = (_34.0: u8); - _36 = (_34.0: u8); - _38 = &_35; - _39 = &_36; - _37 = (move _38, move _39); - _40 = (_37.0: &u8); - _41 = (_37.1: &u8); - _43 = (*_40); - _44 = (*_41); - _42 = Eq(move _43, move _44); - switchInt(move _42) -> [0: bb9, otherwise: bb8]; + StorageDead(_39); + StorageDead(_38); + _31 = (); + StorageDead(_37); + StorageDead(_36); + StorageDead(_35); + StorageDead(_32); + StorageDead(_31); + StorageLive(_49); + StorageLive(_50); + _50 = _4; + StorageLive(_51); + _51 = _7; + _49 = (move _50, move _51); + StorageDead(_51); + StorageDead(_50); + StorageLive(_52); + _52 = (_49.0: u8); + StorageLive(_53); + _53 = (_49.0: u8); + StorageLive(_54); + StorageLive(_55); + StorageLive(_56); + _56 = &_52; + StorageLive(_57); + _57 = &_53; + _55 = (move _56, move _57); + StorageDead(_57); + StorageDead(_56); + StorageLive(_58); + _58 = (_55.0: &u8); + StorageLive(_59); + _59 = (_55.1: &u8); + StorageLive(_60); + StorageLive(_61); + _61 = (*_58); + StorageLive(_62); + _62 = (*_59); + _60 = Eq(move _61, move _62); + switchInt(move _60) -> [0: bb9, otherwise: bb8]; } bb7: { - _31 = core::panicking::AssertKind::Eq; - _33 = std::option::Option::None; - _32 = core::panicking::assert_failed::<u8, u8>(move _31, _26, _27, move _33) -> unwind unreachable; + StorageDead(_39); + StorageDead(_38); + StorageLive(_41); + _41 = core::panicking::AssertKind::Eq; + StorageLive(_42); + StorageLive(_43); + _43 = move _41; + StorageLive(_44); + StorageLive(_45); + _45 = &(*_35); + _44 = &(*_45); + StorageLive(_46); + StorageLive(_47); + _47 = &(*_36); + _46 = &(*_47); + StorageLive(_48); + _48 = std::option::Option::None; + _42 = core::panicking::assert_failed::<u8, u8>(move _43, move _44, move _46, move _48) -> unwind unreachable; } bb8: { - _50 = &_2; - _49 = move _50 as &[u8]; - _48 = PtrMetadata(move _49); - _52 = &_48; - _51 = std::mem::size_of_val::<usize>(_52) -> [return: bb10, unwind unreachable]; + StorageDead(_62); + StorageDead(_61); + _54 = (); + StorageDead(_60); + StorageDead(_59); + StorageDead(_58); + StorageDead(_55); + StorageDead(_54); + StorageLive(_72); + StorageLive(_73); + StorageLive(_74); + _74 = &_2; + _73 = move _74 as &[u8]; + StorageDead(_74); + _72 = core::slice::<impl [u8]>::len(move _73) -> [return: bb10, unwind unreachable]; } bb9: { - _45 = core::panicking::AssertKind::Eq; - _47 = std::option::Option::None; - _46 = core::panicking::assert_failed::<u8, u8>(move _45, _40, _41, move _47) -> unwind unreachable; + StorageDead(_62); + StorageDead(_61); + StorageLive(_64); + _64 = core::panicking::AssertKind::Eq; + StorageLive(_65); + StorageLive(_66); + _66 = move _64; + StorageLive(_67); + StorageLive(_68); + _68 = &(*_58); + _67 = &(*_68); + StorageLive(_69); + StorageLive(_70); + _70 = &(*_59); + _69 = &(*_70); + StorageLive(_71); + _71 = std::option::Option::None; + _65 = core::panicking::assert_failed::<u8, u8>(move _66, move _67, move _69, move _71) -> unwind unreachable; } bb10: { - _54 = &_48; - _55 = &_51; - _53 = (move _54, move _55); - _56 = (_53.0: &usize); - _57 = (_53.1: &usize); - _59 = (*_56); - _60 = (*_57); - _58 = Eq(move _59, move _60); - switchInt(move _58) -> [0: bb12, otherwise: bb11]; + StorageDead(_73); + StorageLive(_75); + StorageLive(_76); + StorageLive(_77); + _77 = &_72; + _76 = &(*_77); + _75 = std::mem::size_of_val::<usize>(move _76) -> [return: bb11, unwind unreachable]; } bb11: { - return; + StorageDead(_76); + StorageDead(_77); + StorageLive(_78); + StorageLive(_79); + StorageLive(_80); + _80 = &_72; + StorageLive(_81); + _81 = &_75; + _79 = (move _80, move _81); + StorageDead(_81); + StorageDead(_80); + StorageLive(_82); + _82 = (_79.0: &usize); + StorageLive(_83); + _83 = (_79.1: &usize); + StorageLive(_84); + StorageLive(_85); + _85 = (*_82); + StorageLive(_86); + _86 = (*_83); + _84 = Eq(move _85, move _86); + switchInt(move _84) -> [0: bb13, otherwise: bb12]; } bb12: { - _61 = core::panicking::AssertKind::Eq; - _63 = std::option::Option::None; - _62 = core::panicking::assert_failed::<usize, usize>(move _61, _56, _57, move _63) -> unwind unreachable; + StorageDead(_86); + StorageDead(_85); + _78 = (); + StorageDead(_84); + StorageDead(_83); + StorageDead(_82); + StorageDead(_79); + StorageDead(_78); + _0 = (); + StorageDead(_75); + StorageDead(_72); + StorageDead(_53); + StorageDead(_52); + StorageDead(_49); + StorageDead(_30); + StorageDead(_29); + StorageDead(_7); + StorageDead(_4); + StorageDead(_2); + return; + } + bb13: { + StorageDead(_86); + StorageDead(_85); + StorageLive(_88); + _88 = core::panicking::AssertKind::Eq; + StorageLive(_89); + StorageLive(_90); + _90 = move _88; + StorageLive(_91); + StorageLive(_92); + _92 = &(*_82); + _91 = &(*_92); + StorageLive(_93); + StorageLive(_94); + _94 = &(*_83); + _93 = &(*_94); + StorageLive(_95); + _95 = std::option::Option::None; + _89 = core::panicking::assert_failed::<usize, usize>(move _90, move _91, move _93, move _95) -> unwind unreachable; } } fn operands::{constant#0}() -> usize { @@ -196,17 +409,41 @@ fn more_operands() -> [Ctors; 3] { let _1: Dummy; let _2: Ctors; let _3: Ctors; - let _4: Ctors; + let mut _4: Dummy; + let _5: Ctors; + let mut _6: Ctors; + let mut _7: Ctors; + let mut _8: Ctors; debug dummy => _1; debug unit => _2; debug struct_like => _3; - debug tup_like => _4; + debug tup_like => _5; bb0: { + StorageLive(_1); _1 = Dummy('a', core::num::<impl i32>::MIN); + StorageLive(_2); _2 = Ctors::Unit; - _3 = Ctors::StructLike(move _1); - _4 = Ctors::TupLike(false); - _0 = [move _2, move _3, move _4]; + StorageLive(_3); + StorageLive(_4); + _4 = move _1; + _3 = Ctors::StructLike(move _4); + StorageDead(_4); + StorageLive(_5); + _5 = Ctors::TupLike(false); + StorageLive(_6); + _6 = move _2; + StorageLive(_7); + _7 = move _3; + StorageLive(_8); + _8 = move _5; + _0 = [move _6, move _7, move _8]; + StorageDead(_8); + StorageDead(_7); + StorageDead(_6); + StorageDead(_5); + StorageDead(_3); + StorageDead(_2); + StorageDead(_1); return; } } @@ -230,23 +467,33 @@ fn closures::{closure#0}(_1: {closure@$DIR/operands.rs:47:5: 47:19}, _2: bool) - let mut _0: bool; let mut _3: bool; let mut _4: bool; + let mut _5: bool; debug y => _2; debug x => (_1.0: bool); debug z => (_1.1: bool); bb0: { + StorageLive(_3); + StorageLive(_4); _4 = (_1.0: bool); - _3 = BitXor(move _4, _2); + StorageLive(_5); + _5 = _2; + _3 = BitXor(move _4, move _5); switchInt(move _3) -> [0: bb2, otherwise: bb1]; } bb1: { + StorageDead(_5); + StorageDead(_4); _0 = true; goto -> bb3; } bb2: { + StorageDead(_5); + StorageDead(_4); _0 = (_1.1: bool); goto -> bb3; } bb3: { + StorageDead(_3); return; } } diff --git a/tests/ui/static/issue-24446.stderr b/tests/ui/static/issue-24446.stderr index 0e6e338c5ef..ed195634f12 100644 --- a/tests/ui/static/issue-24446.stderr +++ b/tests/ui/static/issue-24446.stderr @@ -8,10 +8,10 @@ LL | static foo: dyn Fn() -> u32 = || -> u32 { = note: shared static variables must have a type that implements `Sync` error[E0277]: the size for values of type `(dyn Fn() -> u32 + 'static)` cannot be known at compilation time - --> $DIR/issue-24446.rs:2:17 + --> $DIR/issue-24446.rs:2:5 | LL | static foo: dyn Fn() -> u32 = || -> u32 { - | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)` = note: statics and constants must have a statically known size diff --git a/tests/ui/statics/check-immutable-mut-slices.rs b/tests/ui/statics/check-immutable-mut-slices.rs index 8f9680778aa..19545a1c925 100644 --- a/tests/ui/statics/check-immutable-mut-slices.rs +++ b/tests/ui/statics/check-immutable-mut-slices.rs @@ -1,6 +1,6 @@ // Checks that immutable static items can't have mutable slices static TEST: &'static mut [isize] = &mut []; -//~^ ERROR mutable references are not allowed +//~^ ERROR mutable borrows of temporaries pub fn main() { } diff --git a/tests/ui/statics/check-immutable-mut-slices.stderr b/tests/ui/statics/check-immutable-mut-slices.stderr index 5cb35a7c21e..a9486fc9d78 100644 --- a/tests/ui/statics/check-immutable-mut-slices.stderr +++ b/tests/ui/statics/check-immutable-mut-slices.stderr @@ -1,8 +1,12 @@ -error[E0764]: mutable references are not allowed in the final value of statics +error[E0764]: mutable borrows of temporaries that have their lifetime extended until the end of the program are not allowed --> $DIR/check-immutable-mut-slices.rs:3:37 | LL | static TEST: &'static mut [isize] = &mut []; - | ^^^^^^^ + | ^^^^^^^ this mutable borrow refers to such a temporary + | + = note: Temporaries in constants and statics can have their lifetime extended until the end of the program + = note: To avoid accidentally creating global mutable state, such temporaries must be immutable + = help: If you really want global mutable state, try replacing the temporary by an interior mutable `static` or a `static mut` error: aborting due to 1 previous error diff --git a/tests/ui/statics/missing_lifetime.stderr b/tests/ui/statics/missing_lifetime.stderr index e23b27f7a6a..102670c3642 100644 --- a/tests/ui/statics/missing_lifetime.stderr +++ b/tests/ui/statics/missing_lifetime.stderr @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'reborrow` --> $DIR/missing_lifetime.rs:4:15 | LL | struct Slice(&'reborrow [&'static [u8]]); - | - ^^^^^^^^^ undeclared lifetime - | | - | help: consider introducing lifetime `'reborrow` here: `<'reborrow>` + | ^^^^^^^^^ undeclared lifetime + | +help: consider introducing lifetime `'reborrow` here + | +LL | struct Slice<'reborrow>(&'reborrow [&'static [u8]]); + | +++++++++++ error: aborting due to 1 previous error diff --git a/tests/ui/statics/read_before_init.rs b/tests/ui/statics/read_before_init.rs index d779ef6dffa..32cc2554e1a 100644 --- a/tests/ui/statics/read_before_init.rs +++ b/tests/ui/statics/read_before_init.rs @@ -8,13 +8,15 @@ use std::mem::MaybeUninit; -pub static X: (i32, MaybeUninit<i32>) = (1, foo(&X.0)); -//~^ ERROR: encountered static that tried to initialize itself with itself +pub static X: (i32, MaybeUninit<i32>) = (1, foo(&X.0, 1)); +//~^ ERROR: encountered static that tried to access itself during initialization +pub static Y: (i32, MaybeUninit<i32>) = (1, foo(&Y.0, 0)); +//~^ ERROR: encountered static that tried to access itself during initialization -const fn foo(x: &i32) -> MaybeUninit<i32> { +const fn foo(x: &i32, num: usize) -> MaybeUninit<i32> { let mut temp = MaybeUninit::<i32>::uninit(); unsafe { - std::ptr::copy(x, temp.as_mut_ptr(), 1); + std::ptr::copy(x, temp.as_mut_ptr(), num); } temp } diff --git a/tests/ui/statics/read_before_init.stderr b/tests/ui/statics/read_before_init.stderr index aeebcf7d9ce..239568c1205 100644 --- a/tests/ui/statics/read_before_init.stderr +++ b/tests/ui/statics/read_before_init.stderr @@ -1,17 +1,31 @@ -error[E0080]: encountered static that tried to initialize itself with itself +error[E0080]: encountered static that tried to access itself during initialization --> $DIR/read_before_init.rs:11:45 | -LL | pub static X: (i32, MaybeUninit<i32>) = (1, foo(&X.0)); - | ^^^^^^^^^ evaluation of `X` failed inside this call +LL | pub static X: (i32, MaybeUninit<i32>) = (1, foo(&X.0, 1)); + | ^^^^^^^^^^^^ evaluation of `X` failed inside this call | note: inside `foo` - --> $DIR/read_before_init.rs:17:9 + --> $DIR/read_before_init.rs:19:9 | -LL | std::ptr::copy(x, temp.as_mut_ptr(), 1); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | std::ptr::copy(x, temp.as_mut_ptr(), num); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ note: inside `std::ptr::copy::<i32>` --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL -error: aborting due to 1 previous error +error[E0080]: encountered static that tried to access itself during initialization + --> $DIR/read_before_init.rs:13:45 + | +LL | pub static Y: (i32, MaybeUninit<i32>) = (1, foo(&Y.0, 0)); + | ^^^^^^^^^^^^ evaluation of `Y` failed inside this call + | +note: inside `foo` + --> $DIR/read_before_init.rs:19:9 + | +LL | std::ptr::copy(x, temp.as_mut_ptr(), num); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +note: inside `std::ptr::copy::<i32>` + --> $SRC_DIR/core/src/ptr/mod.rs:LL:COL + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0080`. diff --git a/tests/ui/statics/static-generic-param-soundness.rs b/tests/ui/statics/static-generic-param-soundness.rs new file mode 100644 index 00000000000..aabcca514d3 --- /dev/null +++ b/tests/ui/statics/static-generic-param-soundness.rs @@ -0,0 +1,20 @@ +//! Originally, inner statics in generic functions were generated only once, causing the same +//! static to be shared across all generic instantiations. This created a soundness hole where +//! different types could be coerced through thread-local storage in safe code. +//! +//! This test checks that generic parameters from outer scopes cannot be used in inner statics, +//! preventing this soundness issue. +//! +//! See https://github.com/rust-lang/rust/issues/9186 + +enum Bar<T> { + //~^ ERROR parameter `T` is never used + What, +} + +fn foo<T>() { + static a: Bar<T> = Bar::What; + //~^ ERROR can't use generic parameters from outer item +} + +fn main() {} diff --git a/tests/ui/inner-static-type-parameter.stderr b/tests/ui/statics/static-generic-param-soundness.stderr index 88d33b44c59..47554c7fcb0 100644 --- a/tests/ui/inner-static-type-parameter.stderr +++ b/tests/ui/statics/static-generic-param-soundness.stderr @@ -1,5 +1,5 @@ error[E0401]: can't use generic parameters from outer item - --> $DIR/inner-static-type-parameter.rs:6:19 + --> $DIR/static-generic-param-soundness.rs:16:19 | LL | fn foo<T>() { | - type parameter from outer item @@ -9,9 +9,9 @@ LL | static a: Bar<T> = Bar::What; = note: a `static` is a separate item from the item that contains it error[E0392]: type parameter `T` is never used - --> $DIR/inner-static-type-parameter.rs:3:10 + --> $DIR/static-generic-param-soundness.rs:10:10 | -LL | enum Bar<T> { What } +LL | enum Bar<T> { | ^ unused type parameter | = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` diff --git a/tests/ui/statics/uninhabited-static.stderr b/tests/ui/statics/uninhabited-static.stderr index f799a82f139..a0f9ad6772d 100644 --- a/tests/ui/statics/uninhabited-static.stderr +++ b/tests/ui/statics/uninhabited-static.stderr @@ -1,8 +1,8 @@ error: static of uninhabited type - --> $DIR/uninhabited-static.rs:6:5 + --> $DIR/uninhabited-static.rs:12:1 | -LL | static VOID: Void; - | ^^^^^^^^^^^^^^^^^ +LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; + | ^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> @@ -14,30 +14,30 @@ LL | #![deny(uninhabited_static)] | ^^^^^^^^^^^^^^^^^^ error: static of uninhabited type - --> $DIR/uninhabited-static.rs:8:5 + --> $DIR/uninhabited-static.rs:15:1 | -LL | static NEVER: !; - | ^^^^^^^^^^^^^^^ +LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; + | ^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> = note: uninhabited statics cannot be initialized, and any access would be an immediate error error: static of uninhabited type - --> $DIR/uninhabited-static.rs:12:1 + --> $DIR/uninhabited-static.rs:6:5 | -LL | static VOID2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^ +LL | static VOID: Void; + | ^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> = note: uninhabited statics cannot be initialized, and any access would be an immediate error error: static of uninhabited type - --> $DIR/uninhabited-static.rs:15:1 + --> $DIR/uninhabited-static.rs:8:5 | -LL | static NEVER2: Void = unsafe { std::mem::transmute(()) }; - | ^^^^^^^^^^^^^^^^^^^ +LL | static NEVER: !; + | ^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = note: for more information, see issue #74840 <https://github.com/rust-lang/rust/issues/74840> diff --git a/tests/ui/statics/unsized_type2.stderr b/tests/ui/statics/unsized_type2.stderr index 3f9b0879c16..293df7554e9 100644 --- a/tests/ui/statics/unsized_type2.stderr +++ b/tests/ui/statics/unsized_type2.stderr @@ -1,8 +1,8 @@ error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/unsized_type2.rs:14:24 + --> $DIR/unsized_type2.rs:14:1 | LL | pub static WITH_ERROR: Foo = Foo { version: 0 }; - | ^^^ doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `Foo`, the trait `Sized` is not implemented for `str` note: required because it appears within the type `Foo` diff --git a/tests/ui/stats/input-stats.rs b/tests/ui/stats/input-stats.rs index e760e2894e3..4e8e25eb736 100644 --- a/tests/ui/stats/input-stats.rs +++ b/tests/ui/stats/input-stats.rs @@ -1,6 +1,7 @@ //@ check-pass //@ compile-flags: -Zinput-stats //@ only-64bit +//@ needs-asm-support // layout randomization affects the hir stat output //@ needs-deterministic-layouts // @@ -49,5 +50,7 @@ fn main() { _ => {} } - unsafe { asm!("mov rdi, 1"); } + // NOTE(workingjubilee): do GPUs support NOPs? remove this cfg if they do + #[cfg(not(any(target_arch = "nvptx64", target_arch = "amdgpu")))] + unsafe { asm!("nop"); } } diff --git a/tests/ui/stats/input-stats.stderr b/tests/ui/stats/input-stats.stderr index 88f91bef30b..eb038bbcaf1 100644 --- a/tests/ui/stats/input-stats.stderr +++ b/tests/ui/stats/input-stats.stderr @@ -1,52 +1,7 @@ -ast-stats POST EXPANSION AST STATS +ast-stats ================================================================ +ast-stats POST EXPANSION AST STATS: input_stats ast-stats Name Accumulated Size Count Item Size ast-stats ---------------------------------------------------------------- -ast-stats Crate 40 (NN.N%) 1 40 -ast-stats GenericArgs 40 (NN.N%) 1 40 -ast-stats - AngleBracketed 40 (NN.N%) 1 -ast-stats ExprField 48 (NN.N%) 1 48 -ast-stats WherePredicate 72 (NN.N%) 1 72 -ast-stats - BoundPredicate 72 (NN.N%) 1 -ast-stats ForeignItem 80 (NN.N%) 1 80 -ast-stats - Fn 80 (NN.N%) 1 -ast-stats Arm 96 (NN.N%) 2 48 -ast-stats Local 96 (NN.N%) 1 96 -ast-stats FnDecl 120 (NN.N%) 5 24 -ast-stats InlineAsm 120 (NN.N%) 1 120 -ast-stats Attribute 128 (NN.N%) 4 32 -ast-stats - DocComment 32 (NN.N%) 1 -ast-stats - Normal 96 (NN.N%) 3 -ast-stats Param 160 (NN.N%) 4 40 -ast-stats Stmt 160 (NN.N%) 5 32 -ast-stats - Let 32 (NN.N%) 1 -ast-stats - Semi 32 (NN.N%) 1 -ast-stats - Expr 96 (NN.N%) 3 -ast-stats Block 192 (NN.N%) 6 32 -ast-stats FieldDef 208 (NN.N%) 2 104 -ast-stats Variant 208 (NN.N%) 2 104 -ast-stats AssocItem 320 (NN.N%) 4 80 -ast-stats - Fn 160 (NN.N%) 2 -ast-stats - Type 160 (NN.N%) 2 -ast-stats GenericBound 352 (NN.N%) 4 88 -ast-stats - Trait 352 (NN.N%) 4 -ast-stats GenericParam 480 (NN.N%) 5 96 -ast-stats Pat 504 (NN.N%) 7 72 -ast-stats - Struct 72 (NN.N%) 1 -ast-stats - Wild 72 (NN.N%) 1 -ast-stats - Ident 360 (NN.N%) 5 -ast-stats Expr 648 (NN.N%) 9 72 -ast-stats - InlineAsm 72 (NN.N%) 1 -ast-stats - Match 72 (NN.N%) 1 -ast-stats - Path 72 (NN.N%) 1 -ast-stats - Struct 72 (NN.N%) 1 -ast-stats - Lit 144 (NN.N%) 2 -ast-stats - Block 216 (NN.N%) 3 -ast-stats PathSegment 864 (NN.N%) 36 24 -ast-stats Ty 896 (NN.N%) 14 64 -ast-stats - Ptr 64 (NN.N%) 1 -ast-stats - Ref 64 (NN.N%) 1 -ast-stats - ImplicitSelf 128 (NN.N%) 2 -ast-stats - Path 640 (NN.N%) 10 ast-stats Item 1_584 (NN.N%) 11 144 ast-stats - Enum 144 (NN.N%) 1 ast-stats - ExternCrate 144 (NN.N%) 1 @@ -55,57 +10,61 @@ ast-stats - Impl 144 (NN.N%) 1 ast-stats - Trait 144 (NN.N%) 1 ast-stats - Fn 288 (NN.N%) 2 ast-stats - Use 576 (NN.N%) 4 +ast-stats Ty 896 (NN.N%) 14 64 +ast-stats - Ptr 64 (NN.N%) 1 +ast-stats - Ref 64 (NN.N%) 1 +ast-stats - ImplicitSelf 128 (NN.N%) 2 +ast-stats - Path 640 (NN.N%) 10 +ast-stats PathSegment 888 (NN.N%) 37 24 +ast-stats Expr 648 (NN.N%) 9 72 +ast-stats - InlineAsm 72 (NN.N%) 1 +ast-stats - Match 72 (NN.N%) 1 +ast-stats - Path 72 (NN.N%) 1 +ast-stats - Struct 72 (NN.N%) 1 +ast-stats - Lit 144 (NN.N%) 2 +ast-stats - Block 216 (NN.N%) 3 +ast-stats Pat 504 (NN.N%) 7 72 +ast-stats - Struct 72 (NN.N%) 1 +ast-stats - Wild 72 (NN.N%) 1 +ast-stats - Ident 360 (NN.N%) 5 +ast-stats GenericParam 480 (NN.N%) 5 96 +ast-stats GenericBound 352 (NN.N%) 4 88 +ast-stats - Trait 352 (NN.N%) 4 +ast-stats AssocItem 320 (NN.N%) 4 80 +ast-stats - Fn 160 (NN.N%) 2 +ast-stats - Type 160 (NN.N%) 2 +ast-stats Variant 208 (NN.N%) 2 104 +ast-stats FieldDef 208 (NN.N%) 2 104 +ast-stats Block 192 (NN.N%) 6 32 +ast-stats Stmt 160 (NN.N%) 5 32 +ast-stats - Let 32 (NN.N%) 1 +ast-stats - Semi 32 (NN.N%) 1 +ast-stats - Expr 96 (NN.N%) 3 +ast-stats Param 160 (NN.N%) 4 40 +ast-stats Attribute 160 (NN.N%) 5 32 +ast-stats - DocComment 32 (NN.N%) 1 +ast-stats - Normal 128 (NN.N%) 4 +ast-stats InlineAsm 120 (NN.N%) 1 120 +ast-stats FnDecl 120 (NN.N%) 5 24 +ast-stats Local 96 (NN.N%) 1 96 +ast-stats Arm 96 (NN.N%) 2 48 +ast-stats ForeignItem 80 (NN.N%) 1 80 +ast-stats - Fn 80 (NN.N%) 1 +ast-stats WherePredicate 72 (NN.N%) 1 72 +ast-stats - BoundPredicate 72 (NN.N%) 1 +ast-stats ExprField 48 (NN.N%) 1 48 +ast-stats GenericArgs 40 (NN.N%) 1 40 +ast-stats - AngleBracketed 40 (NN.N%) 1 +ast-stats Crate 40 (NN.N%) 1 40 ast-stats ---------------------------------------------------------------- -ast-stats Total 7_416 127 -ast-stats -hir-stats HIR STATS +ast-stats Total 7_472 129 +ast-stats ================================================================ +hir-stats ================================================================ +hir-stats HIR STATS: input_stats hir-stats Name Accumulated Size Count Item Size hir-stats ---------------------------------------------------------------- -hir-stats ForeignItemRef 24 (NN.N%) 1 24 -hir-stats Lifetime 28 (NN.N%) 1 28 -hir-stats Mod 32 (NN.N%) 1 32 -hir-stats ExprField 40 (NN.N%) 1 40 -hir-stats TraitItemRef 56 (NN.N%) 2 28 -hir-stats GenericArg 64 (NN.N%) 4 16 -hir-stats - Type 16 (NN.N%) 1 -hir-stats - Lifetime 48 (NN.N%) 3 -hir-stats Param 64 (NN.N%) 2 32 -hir-stats Body 72 (NN.N%) 3 24 -hir-stats ImplItemRef 72 (NN.N%) 2 36 -hir-stats InlineAsm 72 (NN.N%) 1 72 -hir-stats Local 72 (NN.N%) 1 72 -hir-stats WherePredicate 72 (NN.N%) 3 24 -hir-stats - BoundPredicate 72 (NN.N%) 3 -hir-stats Arm 80 (NN.N%) 2 40 -hir-stats Stmt 96 (NN.N%) 3 32 -hir-stats - Expr 32 (NN.N%) 1 -hir-stats - Let 32 (NN.N%) 1 -hir-stats - Semi 32 (NN.N%) 1 -hir-stats FnDecl 120 (NN.N%) 3 40 -hir-stats FieldDef 128 (NN.N%) 2 64 -hir-stats GenericArgs 144 (NN.N%) 3 48 -hir-stats Variant 144 (NN.N%) 2 72 -hir-stats Attribute 160 (NN.N%) 4 40 -hir-stats GenericBound 256 (NN.N%) 4 64 -hir-stats - Trait 256 (NN.N%) 4 -hir-stats Block 288 (NN.N%) 6 48 -hir-stats Pat 360 (NN.N%) 5 72 -hir-stats - Struct 72 (NN.N%) 1 -hir-stats - Wild 72 (NN.N%) 1 -hir-stats - Binding 216 (NN.N%) 3 -hir-stats GenericParam 400 (NN.N%) 5 80 -hir-stats Generics 560 (NN.N%) 10 56 -hir-stats Ty 720 (NN.N%) 15 48 -hir-stats - Ptr 48 (NN.N%) 1 -hir-stats - Ref 48 (NN.N%) 1 -hir-stats - Path 624 (NN.N%) 13 -hir-stats Expr 768 (NN.N%) 12 64 -hir-stats - InlineAsm 64 (NN.N%) 1 -hir-stats - Match 64 (NN.N%) 1 -hir-stats - Path 64 (NN.N%) 1 -hir-stats - Struct 64 (NN.N%) 1 -hir-stats - Lit 128 (NN.N%) 2 -hir-stats - Block 384 (NN.N%) 6 +hir-stats PathSegment 1_776 (NN.N%) 37 48 +hir-stats Path 1_040 (NN.N%) 26 40 hir-stats Item 968 (NN.N%) 11 88 hir-stats - Enum 88 (NN.N%) 1 hir-stats - ExternCrate 88 (NN.N%) 1 @@ -114,8 +73,51 @@ hir-stats - Impl 88 (NN.N%) 1 hir-stats - Trait 88 (NN.N%) 1 hir-stats - Fn 176 (NN.N%) 2 hir-stats - Use 352 (NN.N%) 4 -hir-stats Path 1_040 (NN.N%) 26 40 -hir-stats PathSegment 1_776 (NN.N%) 37 48 +hir-stats Expr 768 (NN.N%) 12 64 +hir-stats - InlineAsm 64 (NN.N%) 1 +hir-stats - Match 64 (NN.N%) 1 +hir-stats - Path 64 (NN.N%) 1 +hir-stats - Struct 64 (NN.N%) 1 +hir-stats - Lit 128 (NN.N%) 2 +hir-stats - Block 384 (NN.N%) 6 +hir-stats Ty 720 (NN.N%) 15 48 +hir-stats - Ptr 48 (NN.N%) 1 +hir-stats - Ref 48 (NN.N%) 1 +hir-stats - Path 624 (NN.N%) 13 +hir-stats Generics 560 (NN.N%) 10 56 +hir-stats GenericParam 400 (NN.N%) 5 80 +hir-stats Pat 360 (NN.N%) 5 72 +hir-stats - Struct 72 (NN.N%) 1 +hir-stats - Wild 72 (NN.N%) 1 +hir-stats - Binding 216 (NN.N%) 3 +hir-stats Block 288 (NN.N%) 6 48 +hir-stats GenericBound 256 (NN.N%) 4 64 +hir-stats - Trait 256 (NN.N%) 4 +hir-stats Attribute 200 (NN.N%) 5 40 +hir-stats Variant 144 (NN.N%) 2 72 +hir-stats GenericArgs 144 (NN.N%) 3 48 +hir-stats FieldDef 128 (NN.N%) 2 64 +hir-stats FnDecl 120 (NN.N%) 3 40 +hir-stats Stmt 96 (NN.N%) 3 32 +hir-stats - Expr 32 (NN.N%) 1 +hir-stats - Let 32 (NN.N%) 1 +hir-stats - Semi 32 (NN.N%) 1 +hir-stats Arm 80 (NN.N%) 2 40 +hir-stats WherePredicate 72 (NN.N%) 3 24 +hir-stats - BoundPredicate 72 (NN.N%) 3 +hir-stats Local 72 (NN.N%) 1 72 +hir-stats InlineAsm 72 (NN.N%) 1 72 +hir-stats ImplItemRef 72 (NN.N%) 2 36 +hir-stats Body 72 (NN.N%) 3 24 +hir-stats Param 64 (NN.N%) 2 32 +hir-stats GenericArg 64 (NN.N%) 4 16 +hir-stats - Type 16 (NN.N%) 1 +hir-stats - Lifetime 48 (NN.N%) 3 +hir-stats TraitItemRef 56 (NN.N%) 2 28 +hir-stats ExprField 40 (NN.N%) 1 40 +hir-stats Mod 32 (NN.N%) 1 32 +hir-stats Lifetime 28 (NN.N%) 1 28 +hir-stats ForeignItemRef 24 (NN.N%) 1 24 hir-stats ---------------------------------------------------------------- -hir-stats Total 8_676 172 -hir-stats +hir-stats Total 8_716 173 +hir-stats ================================================================ diff --git a/tests/ui/stats/macro-stats.rs b/tests/ui/stats/macro-stats.rs index ee265d682fd..d986904ddd6 100644 --- a/tests/ui/stats/macro-stats.rs +++ b/tests/ui/stats/macro-stats.rs @@ -49,12 +49,17 @@ fn opt(x: Option<u32>) { } } -macro_rules! this_is_a_really_really_long_macro_name { +macro_rules! long_name_that_fits_on_a_single_line { + () => {} +} +long_name_that_fits_on_a_single_line!(); + +macro_rules! long_name_that_doesnt_fit_on_one_line { ($t:ty) => { fn f(_: $t) {} } } -this_is_a_really_really_long_macro_name!(u32!()); // AstFragmentKind::{Items,Ty} +long_name_that_doesnt_fit_on_one_line!(u32!()); // AstFragmentKind::{Items,Ty} macro_rules! trait_tys { () => { diff --git a/tests/ui/stats/macro-stats.stderr b/tests/ui/stats/macro-stats.stderr index f87e34622b9..8d0fdb8958a 100644 --- a/tests/ui/stats/macro-stats.stderr +++ b/tests/ui/stats/macro-stats.stderr @@ -2,25 +2,26 @@ macro-stats ==================================================================== macro-stats MACRO EXPANSION STATS: macro_stats macro-stats Macro Name Uses Lines Avg Lines Bytes Avg Bytes macro-stats ----------------------------------------------------------------------------------- -macro-stats #[derive(Clone)] 8 56 7.0 1_660 207.5 -macro-stats #[derive(PartialOrd)] 1 16 16.0 654 654.0 -macro-stats #[derive(Hash)] 2 15 7.5 547 273.5 -macro-stats #[derive(Ord)] 1 14 14.0 489 489.0 -macro-stats q! 1 24 24.0 435 435.0 -macro-stats #[derive(Default)] 2 14 7.0 367 183.5 -macro-stats #[derive(Eq)] 1 10 10.0 312 312.0 -macro-stats #[derive(Debug)] 1 7 7.0 261 261.0 -macro-stats #[derive(PartialEq)] 1 8 8.0 247 247.0 -macro-stats #[derive(Copy)] 1 1 1.0 46 46.0 -macro-stats p! 1 2 2.0 28 28.0 -macro-stats trait_impl_tys! 1 1 1.0 11 11.0 -macro-stats foreign_item! 1 0 0.0 6 6.0 -macro-stats impl_const! 1 0 0.0 4 4.0 -macro-stats trait_tys! 1 1 1.0 3 3.0 -macro-stats u32! 1 0 0.0 -3 -3.0 -macro-stats none! 1 0 0.0 -3 -3.0 -macro-stats n99! 2 0 0.0 -8 -4.0 -macro-stats this_is_a_really_really_long_macro_name! -macro-stats 1 0 0.0 -30 -30.0 -macro-stats #[test] 1 -6 -6.0 -158 -158.0 +macro-stats #[derive(Clone)] 8 64 8.0 1_788 223.5 +macro-stats #[derive(PartialOrd)] 1 17 17.0 675 675.0 +macro-stats #[derive(Hash)] 2 17 8.5 577 288.5 +macro-stats q! 1 26 26.0 519 519.0 +macro-stats #[derive(Ord)] 1 15 15.0 503 503.0 +macro-stats #[derive(Default)] 2 16 8.0 403 201.5 +macro-stats #[derive(Eq)] 1 11 11.0 325 325.0 +macro-stats #[derive(Debug)] 1 8 8.0 277 277.0 +macro-stats #[derive(PartialEq)] 1 9 9.0 267 267.0 +macro-stats #[derive(Copy)] 1 2 2.0 61 61.0 +macro-stats p! 1 3 3.0 32 32.0 +macro-stats trait_impl_tys! 1 2 2.0 28 28.0 +macro-stats foreign_item! 1 1 1.0 21 21.0 +macro-stats long_name_that_doesnt_fit_on_one_line! +macro-stats 1 1 1.0 18 18.0 +macro-stats impl_const! 1 1 1.0 17 17.0 +macro-stats trait_tys! 1 2 2.0 15 15.0 +macro-stats n99! 2 2 1.0 4 2.0 +macro-stats none! 1 1 1.0 4 4.0 +macro-stats u32! 1 1 1.0 3 3.0 +macro-stats long_name_that_fits_on_a_single_line! 1 1 1.0 0 0.0 +macro-stats #[test] 1 1 1.0 0 0.0 macro-stats =================================================================================== diff --git a/tests/ui/paths-containing-nul.rs b/tests/ui/std/fs-nul-byte-paths.rs index 5c37980127d..79012362347 100644 --- a/tests/ui/paths-containing-nul.rs +++ b/tests/ui/std/fs-nul-byte-paths.rs @@ -1,18 +1,22 @@ -//@ run-pass +//! Test that `std::fs` functions properly reject paths containing NUL bytes. +//@ run-pass #![allow(deprecated)] //@ ignore-wasm32 no cwd //@ ignore-sgx no files -use std::fs; -use std::io; +use std::{fs, io}; fn assert_invalid_input<T>(on: &str, result: io::Result<T>) { fn inner(on: &str, result: io::Result<()>) { match result { Ok(()) => panic!("{} didn't return an error on a path with NUL", on), - Err(e) => assert!(e.kind() == io::ErrorKind::InvalidInput, - "{} returned a strange {:?} on a path with NUL", on, e.kind()), + Err(e) => assert!( + e.kind() == io::ErrorKind::InvalidInput, + "{} returned a strange {:?} on a path with NUL", + on, + e.kind() + ), } } inner(on, result.map(drop)) @@ -43,6 +47,8 @@ fn main() { assert_invalid_input("remove_dir", fs::remove_dir("\0")); assert_invalid_input("remove_dir_all", fs::remove_dir_all("\0")); assert_invalid_input("read_dir", fs::read_dir("\0")); - assert_invalid_input("set_permissions", - fs::set_permissions("\0", fs::metadata(".").unwrap().permissions())); + assert_invalid_input( + "set_permissions", + fs::set_permissions("\0", fs::metadata(".").unwrap().permissions()), + ); } diff --git a/tests/ui/nul-characters.rs b/tests/ui/str/nul-char-equivalence.rs index eb83f440d3e..2d4110de681 100644 --- a/tests/ui/nul-characters.rs +++ b/tests/ui/str/nul-char-equivalence.rs @@ -1,7 +1,8 @@ +//! Checks that different NUL character representations are equivalent in strings and chars. + //@ run-pass -pub fn main() -{ +pub fn main() { let all_nuls1 = "\0\x00\u{0}\u{0}"; let all_nuls2 = "\u{0}\u{0}\x00\0"; let all_nuls3 = "\u{0}\u{0}\x00\0"; @@ -17,11 +18,9 @@ pub fn main() assert_eq!(all_nuls3, all_nuls4); // all extracted characters in all_nuls are equivalent to each other - for c1 in all_nuls1.chars() - { - for c2 in all_nuls1.chars() - { - assert_eq!(c1,c2); + for c1 in all_nuls1.chars() { + for c2 in all_nuls1.chars() { + assert_eq!(c1, c2); } } diff --git a/tests/ui/structs-enums/recover-enum-with-bad-where.rs b/tests/ui/structs-enums/recover-enum-with-bad-where.rs new file mode 100644 index 00000000000..cf7747d710b --- /dev/null +++ b/tests/ui/structs-enums/recover-enum-with-bad-where.rs @@ -0,0 +1,8 @@ +pub enum Foo<T> +where: +//~^ ERROR unexpected colon after `where` + T: Missing, {} +//~^ ERROR cannot find trait `Missing` in this scope +// (evidence that we continue parsing after the erroneous colon) + +fn main() {} diff --git a/tests/ui/structs-enums/recover-enum-with-bad-where.stderr b/tests/ui/structs-enums/recover-enum-with-bad-where.stderr new file mode 100644 index 00000000000..30b73f59e8c --- /dev/null +++ b/tests/ui/structs-enums/recover-enum-with-bad-where.stderr @@ -0,0 +1,15 @@ +error: unexpected colon after `where` + --> $DIR/recover-enum-with-bad-where.rs:2:6 + | +LL | where: + | ^ help: remove the colon + +error[E0405]: cannot find trait `Missing` in this scope + --> $DIR/recover-enum-with-bad-where.rs:4:8 + | +LL | T: Missing, {} + | ^^^^^^^ not found in this scope + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0405`. diff --git a/tests/ui/structs/basic-newtype-pattern.rs b/tests/ui/structs/basic-newtype-pattern.rs new file mode 100644 index 00000000000..38ccd0ea8e0 --- /dev/null +++ b/tests/ui/structs/basic-newtype-pattern.rs @@ -0,0 +1,25 @@ +//! Test basic newtype pattern functionality. + +//@ run-pass + +#[derive(Copy, Clone)] +struct Counter(CounterData); + +#[derive(Copy, Clone)] +struct CounterData { + compute: fn(Counter) -> isize, + val: isize, +} + +fn compute_value(counter: Counter) -> isize { + let Counter(data) = counter; + data.val + 20 +} + +pub fn main() { + let my_counter = Counter(CounterData { compute: compute_value, val: 30 }); + + // Test destructuring and function pointer call + let Counter(data) = my_counter; + assert_eq!((data.compute)(my_counter), 50); +} diff --git a/tests/ui/suggestions/bad-infer-in-trait-impl.rs b/tests/ui/suggestions/bad-infer-in-trait-impl.rs index f38b168037b..db6fc9319e1 100644 --- a/tests/ui/suggestions/bad-infer-in-trait-impl.rs +++ b/tests/ui/suggestions/bad-infer-in-trait-impl.rs @@ -4,7 +4,7 @@ trait Foo { impl Foo for () { fn bar(s: _) {} - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions //~| ERROR has 1 parameter but the declaration in trait `Foo::bar` has 0 } diff --git a/tests/ui/suggestions/bad-infer-in-trait-impl.stderr b/tests/ui/suggestions/bad-infer-in-trait-impl.stderr index 68d8f5402e4..5aa46545943 100644 --- a/tests/ui/suggestions/bad-infer-in-trait-impl.stderr +++ b/tests/ui/suggestions/bad-infer-in-trait-impl.stderr @@ -1,14 +1,8 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/bad-infer-in-trait-impl.rs:6:15 | LL | fn bar(s: _) {} | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn bar(s: _) {} -LL + fn bar<T>(s: T) {} - | error[E0050]: method `bar` has 1 parameter but the declaration in trait `Foo::bar` has 0 --> $DIR/bad-infer-in-trait-impl.rs:6:15 diff --git a/tests/ui/suggestions/bound-suggestions.stderr b/tests/ui/suggestions/bound-suggestions.stderr index f23e086afe4..ec1d23fac45 100644 --- a/tests/ui/suggestions/bound-suggestions.stderr +++ b/tests/ui/suggestions/bound-suggestions.stderr @@ -2,7 +2,9 @@ error[E0277]: `impl Sized` doesn't implement `Debug` --> $DIR/bound-suggestions.rs:9:22 | LL | println!("{:?}", t); - | ^ `impl Sized` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ---- ^ `impl Sized` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | | + | required by this formatting parameter | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting opaque type `impl Sized` with trait `Debug` @@ -14,7 +16,9 @@ error[E0277]: `T` doesn't implement `Debug` --> $DIR/bound-suggestions.rs:15:22 | LL | println!("{:?}", t); - | ^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ---- ^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | | + | required by this formatting parameter | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider restricting type parameter `T` with trait `Debug` @@ -26,7 +30,9 @@ error[E0277]: `T` doesn't implement `Debug` --> $DIR/bound-suggestions.rs:21:22 | LL | println!("{:?}", t); - | ^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ---- ^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | | + | required by this formatting parameter | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting type parameter `T` with trait `Debug` @@ -38,7 +44,9 @@ error[E0277]: `Y` doesn't implement `Debug` --> $DIR/bound-suggestions.rs:27:30 | LL | println!("{:?} {:?}", x, y); - | ^ `Y` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ---- ^ `Y` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | | + | required by this formatting parameter | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting type parameter `Y` with trait `Debug` @@ -50,7 +58,9 @@ error[E0277]: `X` doesn't implement `Debug` --> $DIR/bound-suggestions.rs:33:22 | LL | println!("{:?}", x); - | ^ `X` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ---- ^ `X` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | | + | required by this formatting parameter | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting type parameter `X` with trait `Debug` @@ -62,7 +72,9 @@ error[E0277]: `X` doesn't implement `Debug` --> $DIR/bound-suggestions.rs:39:22 | LL | println!("{:?}", x); - | ^ `X` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ---- ^ `X` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | | + | required by this formatting parameter | = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) help: consider further restricting type parameter `X` with trait `Debug` diff --git a/tests/ui/suggestions/derive-macro-missing-bounds.stderr b/tests/ui/suggestions/derive-macro-missing-bounds.stderr index 68c8204d1e1..b28f39ced54 100644 --- a/tests/ui/suggestions/derive-macro-missing-bounds.stderr +++ b/tests/ui/suggestions/derive-macro-missing-bounds.stderr @@ -4,9 +4,8 @@ error[E0277]: `a::Inner<T>` doesn't implement `Debug` LL | #[derive(Debug)] | ----- in this derive macro expansion LL | struct Outer<T>(Inner<T>); - | ^^^^^^^^ `a::Inner<T>` cannot be formatted using `{:?}` + | ^^^^^^^^ the trait `Debug` is not implemented for `a::Inner<T>` | - = help: the trait `Debug` is not implemented for `a::Inner<T>` = note: add `#[derive(Debug)]` to `a::Inner<T>` or manually `impl Debug for a::Inner<T>` help: consider annotating `a::Inner<T>` with `#[derive(Debug)]` | diff --git a/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.fixed b/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.fixed new file mode 100644 index 00000000000..95fd920dec2 --- /dev/null +++ b/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.fixed @@ -0,0 +1,17 @@ +//@ run-rustfix + +struct S; +trait Trait { + fn foo() {} +} +impl Trait for &S {} +impl Trait for &mut S {} +fn main() { + let _ = <&str>::from("value"); + //~^ ERROR the trait bound `str: From<_>` is not satisfied + //~| ERROR the size for values of type `str` cannot be known at compilation time + let _ = <&mut S>::foo(); + //~^ ERROR the trait bound `S: Trait` is not satisfied + let _ = <&S>::foo(); + //~^ ERROR the trait bound `S: Trait` is not satisfied +} diff --git a/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.rs b/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.rs new file mode 100644 index 00000000000..f79d2465062 --- /dev/null +++ b/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.rs @@ -0,0 +1,17 @@ +//@ run-rustfix + +struct S; +trait Trait { + fn foo() {} +} +impl Trait for &S {} +impl Trait for &mut S {} +fn main() { + let _ = &str::from("value"); + //~^ ERROR the trait bound `str: From<_>` is not satisfied + //~| ERROR the size for values of type `str` cannot be known at compilation time + let _ = &mut S::foo(); + //~^ ERROR the trait bound `S: Trait` is not satisfied + let _ = &S::foo(); + //~^ ERROR the trait bound `S: Trait` is not satisfied +} diff --git a/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.stderr b/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.stderr new file mode 100644 index 00000000000..ac96ec76da7 --- /dev/null +++ b/tests/ui/suggestions/dont-suggest-borrowing-existing-borrow.stderr @@ -0,0 +1,58 @@ +error[E0277]: the trait bound `str: From<_>` is not satisfied + --> $DIR/dont-suggest-borrowing-existing-borrow.rs:10:14 + | +LL | let _ = &str::from("value"); + | ^^^ the trait `From<_>` is not implemented for `str` + | + = help: the following other types implement trait `From<T>`: + `String` implements `From<&String>` + `String` implements `From<&mut str>` + `String` implements `From<&str>` + `String` implements `From<Box<str>>` + `String` implements `From<Cow<'_, str>>` + `String` implements `From<char>` +help: you likely meant to call the associated function `from` for type `&str`, but the code as written calls associated function `from` on type `str` + | +LL | let _ = <&str>::from("value"); + | + + + +error[E0277]: the trait bound `S: Trait` is not satisfied + --> $DIR/dont-suggest-borrowing-existing-borrow.rs:13:18 + | +LL | let _ = &mut S::foo(); + | ^ the trait `Trait` is not implemented for `S` + | + = help: the following other types implement trait `Trait`: + &S + &mut S +help: you likely meant to call the associated function `foo` for type `&mut S`, but the code as written calls associated function `foo` on type `S` + | +LL | let _ = <&mut S>::foo(); + | + + + +error[E0277]: the trait bound `S: Trait` is not satisfied + --> $DIR/dont-suggest-borrowing-existing-borrow.rs:15:14 + | +LL | let _ = &S::foo(); + | ^ the trait `Trait` is not implemented for `S` + | + = help: the following other types implement trait `Trait`: + &S + &mut S +help: you likely meant to call the associated function `foo` for type `&S`, but the code as written calls associated function `foo` on type `S` + | +LL | let _ = <&S>::foo(); + | + + + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/dont-suggest-borrowing-existing-borrow.rs:10:14 + | +LL | let _ = &str::from("value"); + | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: the return type of a function must have a statically known size + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs index 10b4781eb04..97a0e005f86 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs @@ -4,19 +4,16 @@ trait A: Sized { fn f(a: A) -> A; //~^ ERROR expected a type, found a trait //~| ERROR expected a type, found a trait - //~| ERROR associated item referring to unboxed trait object for its own trait } trait B { fn f(b: B) -> B; //~^ ERROR expected a type, found a trait //~| ERROR expected a type, found a trait - //~| ERROR associated item referring to unboxed trait object for its own trait } trait C { fn f(&self, c: C) -> C; //~^ ERROR expected a type, found a trait //~| ERROR expected a type, found a trait - //~| ERROR associated item referring to unboxed trait object for its own trait } fn main() {} diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021-without-dyn.stderr b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021-without-dyn.stderr index e189012d15c..c4dab4691f4 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021-without-dyn.stderr +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021-without-dyn.stderr @@ -26,22 +26,8 @@ help: `A` is dyn-incompatible, use `impl A` to return an opaque type, as long as LL | fn f(a: A) -> impl A; | ++++ -error: associated item referring to unboxed trait object for its own trait - --> $DIR/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs:4:13 - | -LL | trait A: Sized { - | - in this trait -LL | fn f(a: A) -> A; - | ^ ^ - | -help: you might have meant to use `Self` to refer to the implementing type - | -LL - fn f(a: A) -> A; -LL + fn f(a: Self) -> Self; - | - error[E0782]: expected a type, found a trait - --> $DIR/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs:10:13 + --> $DIR/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs:9:13 | LL | fn f(b: B) -> B; | ^ @@ -58,7 +44,7 @@ LL | fn f(b: impl B) -> B; | ++++ error[E0782]: expected a type, found a trait - --> $DIR/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs:10:19 + --> $DIR/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs:9:19 | LL | fn f(b: B) -> B; | ^ @@ -68,22 +54,8 @@ help: `B` is dyn-incompatible, use `impl B` to return an opaque type, as long as LL | fn f(b: B) -> impl B; | ++++ -error: associated item referring to unboxed trait object for its own trait - --> $DIR/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs:10:13 - | -LL | trait B { - | - in this trait -LL | fn f(b: B) -> B; - | ^ ^ - | -help: you might have meant to use `Self` to refer to the implementing type - | -LL - fn f(b: B) -> B; -LL + fn f(b: Self) -> Self; - | - error[E0782]: expected a type, found a trait - --> $DIR/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs:16:20 + --> $DIR/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs:14:20 | LL | fn f(&self, c: C) -> C; | ^ @@ -100,7 +72,7 @@ LL | fn f(&self, c: impl C) -> C; | ++++ error[E0782]: expected a type, found a trait - --> $DIR/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs:16:26 + --> $DIR/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs:14:26 | LL | fn f(&self, c: C) -> C; | ^ @@ -110,20 +82,6 @@ help: `C` is dyn-incompatible, use `impl C` to return an opaque type, as long as LL | fn f(&self, c: C) -> impl C; | ++++ -error: associated item referring to unboxed trait object for its own trait - --> $DIR/dyn-incompatible-trait-should-use-self-2021-without-dyn.rs:16:20 - | -LL | trait C { - | - in this trait -LL | fn f(&self, c: C) -> C; - | ^ ^ - | -help: you might have meant to use `Self` to refer to the implementing type - | -LL - fn f(&self, c: C) -> C; -LL + fn f(&self, c: Self) -> Self; - | - -error: aborting due to 9 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0782`. diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.rs b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.rs index 747926c400a..a798b1bd578 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.rs +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.rs @@ -2,13 +2,11 @@ #![allow(bare_trait_objects)] trait A: Sized { fn f(a: dyn A) -> dyn A; - //~^ ERROR associated item referring to unboxed trait object for its own trait - //~| ERROR the trait `A` is not dyn compatible + //~^ ERROR the trait `A` is not dyn compatible } trait B { fn f(a: dyn B) -> dyn B; - //~^ ERROR associated item referring to unboxed trait object for its own trait - //~| ERROR the trait `B` is not dyn compatible + //~^ ERROR the trait `B` is not dyn compatible } trait C { fn f(&self, a: dyn C) -> dyn C; diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.stderr b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.stderr index 2e3919db1b7..4ccf65b68bf 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.stderr +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self-2021.stderr @@ -1,17 +1,3 @@ -error: associated item referring to unboxed trait object for its own trait - --> $DIR/dyn-incompatible-trait-should-use-self-2021.rs:4:13 - | -LL | trait A: Sized { - | - in this trait -LL | fn f(a: dyn A) -> dyn A; - | ^^^^^ ^^^^^ - | -help: you might have meant to use `Self` to refer to the implementing type - | -LL - fn f(a: dyn A) -> dyn A; -LL + fn f(a: Self) -> Self; - | - error[E0038]: the trait `A` is not dyn compatible --> $DIR/dyn-incompatible-trait-should-use-self-2021.rs:4:13 | @@ -26,30 +12,21 @@ LL | trait A: Sized { | - ^^^^^ ...because it requires `Self: Sized` | | | this trait is not dyn compatible... - -error: associated item referring to unboxed trait object for its own trait - --> $DIR/dyn-incompatible-trait-should-use-self-2021.rs:9:13 - | -LL | trait B { - | - in this trait -LL | fn f(a: dyn B) -> dyn B; - | ^^^^^ ^^^^^ - | help: you might have meant to use `Self` to refer to the implementing type | -LL - fn f(a: dyn B) -> dyn B; -LL + fn f(a: Self) -> Self; +LL - fn f(a: dyn A) -> dyn A; +LL + fn f(a: Self) -> dyn A; | error[E0038]: the trait `B` is not dyn compatible - --> $DIR/dyn-incompatible-trait-should-use-self-2021.rs:9:13 + --> $DIR/dyn-incompatible-trait-should-use-self-2021.rs:8:13 | LL | fn f(a: dyn B) -> dyn B; | ^^^^^ `B` 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/dyn-incompatible-trait-should-use-self-2021.rs:9:8 + --> $DIR/dyn-incompatible-trait-should-use-self-2021.rs:8:8 | LL | trait B { | - this trait is not dyn compatible... @@ -63,7 +40,12 @@ help: alternatively, consider constraining `f` so it does not apply to trait obj | LL | fn f(a: dyn B) -> dyn B where Self: Sized; | +++++++++++++++++ +help: you might have meant to use `Self` to refer to the implementing type + | +LL - fn f(a: dyn B) -> dyn B; +LL + fn f(a: Self) -> dyn B; + | -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.rs b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.rs index 63fe5ebaea4..d8e9d381dbd 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.rs +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.rs @@ -1,12 +1,10 @@ trait A: Sized { fn f(a: dyn A) -> dyn A; - //~^ ERROR associated item referring to unboxed trait object for its own trait - //~| ERROR the trait `A` is not dyn compatible + //~^ ERROR the trait `A` is not dyn compatible } trait B { fn f(a: dyn B) -> dyn B; - //~^ ERROR associated item referring to unboxed trait object for its own trait - //~| ERROR the trait `B` is not dyn compatible + //~^ ERROR the trait `B` is not dyn compatible } trait C { fn f(&self, a: dyn C) -> dyn C; diff --git a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr index e8384afed7a..bda1d01e23f 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr +++ b/tests/ui/suggestions/dyn-incompatible-trait-should-use-self.stderr @@ -1,17 +1,3 @@ -error: associated item referring to unboxed trait object for its own trait - --> $DIR/dyn-incompatible-trait-should-use-self.rs:2:13 - | -LL | trait A: Sized { - | - in this trait -LL | fn f(a: dyn A) -> dyn A; - | ^^^^^ ^^^^^ - | -help: you might have meant to use `Self` to refer to the implementing type - | -LL - fn f(a: dyn A) -> dyn A; -LL + fn f(a: Self) -> Self; - | - error[E0038]: the trait `A` is not dyn compatible --> $DIR/dyn-incompatible-trait-should-use-self.rs:2:13 | @@ -26,30 +12,21 @@ LL | trait A: Sized { | - ^^^^^ ...because it requires `Self: Sized` | | | this trait is not dyn compatible... - -error: associated item referring to unboxed trait object for its own trait - --> $DIR/dyn-incompatible-trait-should-use-self.rs:7:13 - | -LL | trait B { - | - in this trait -LL | fn f(a: dyn B) -> dyn B; - | ^^^^^ ^^^^^ - | help: you might have meant to use `Self` to refer to the implementing type | -LL - fn f(a: dyn B) -> dyn B; -LL + fn f(a: Self) -> Self; +LL - fn f(a: dyn A) -> dyn A; +LL + fn f(a: Self) -> dyn A; | error[E0038]: the trait `B` is not dyn compatible - --> $DIR/dyn-incompatible-trait-should-use-self.rs:7:13 + --> $DIR/dyn-incompatible-trait-should-use-self.rs:6:13 | LL | fn f(a: dyn B) -> dyn B; | ^^^^^ `B` 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/dyn-incompatible-trait-should-use-self.rs:7:8 + --> $DIR/dyn-incompatible-trait-should-use-self.rs:6:8 | LL | trait B { | - this trait is not dyn compatible... @@ -63,7 +40,12 @@ help: alternatively, consider constraining `f` so it does not apply to trait obj | LL | fn f(a: dyn B) -> dyn B where Self: Sized; | +++++++++++++++++ +help: you might have meant to use `Self` to refer to the implementing type + | +LL - fn f(a: dyn B) -> dyn B; +LL + fn f(a: Self) -> dyn B; + | -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0038`. diff --git a/tests/ui/suggestions/impl-trait-with-missing-bounds.stderr b/tests/ui/suggestions/impl-trait-with-missing-bounds.stderr index d0ce7c9ed4e..b3f1865dd30 100644 --- a/tests/ui/suggestions/impl-trait-with-missing-bounds.stderr +++ b/tests/ui/suggestions/impl-trait-with-missing-bounds.stderr @@ -2,11 +2,10 @@ error[E0277]: `<impl Iterator as Iterator>::Item` doesn't implement `Debug` --> $DIR/impl-trait-with-missing-bounds.rs:6:13 | LL | qux(constraint); - | --- ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | --- ^^^^^^^^^^ the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item` | | | required by a bound introduced by this call | - = help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item` note: required by a bound in `qux` --> $DIR/impl-trait-with-missing-bounds.rs:50:16 | @@ -22,11 +21,10 @@ error[E0277]: `<impl Iterator as Iterator>::Item` doesn't implement `Debug` --> $DIR/impl-trait-with-missing-bounds.rs:14:13 | LL | qux(constraint); - | --- ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | --- ^^^^^^^^^^ the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item` | | | required by a bound introduced by this call | - = help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item` note: required by a bound in `qux` --> $DIR/impl-trait-with-missing-bounds.rs:50:16 | @@ -42,11 +40,10 @@ error[E0277]: `<impl Iterator as Iterator>::Item` doesn't implement `Debug` --> $DIR/impl-trait-with-missing-bounds.rs:22:13 | LL | qux(constraint); - | --- ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | --- ^^^^^^^^^^ the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item` | | | required by a bound introduced by this call | - = help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item` note: required by a bound in `qux` --> $DIR/impl-trait-with-missing-bounds.rs:50:16 | @@ -62,11 +59,10 @@ error[E0277]: `<impl Iterator as Iterator>::Item` doesn't implement `Debug` --> $DIR/impl-trait-with-missing-bounds.rs:30:13 | LL | qux(constraint); - | --- ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | --- ^^^^^^^^^^ the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item` | | | required by a bound introduced by this call | - = help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item` note: required by a bound in `qux` --> $DIR/impl-trait-with-missing-bounds.rs:50:16 | @@ -82,11 +78,10 @@ error[E0277]: `<impl Iterator + std::fmt::Debug as Iterator>::Item` doesn't impl --> $DIR/impl-trait-with-missing-bounds.rs:37:13 | LL | qux(constraint); - | --- ^^^^^^^^^^ `<impl Iterator + std::fmt::Debug as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | --- ^^^^^^^^^^ the trait `Debug` is not implemented for `<impl Iterator + std::fmt::Debug as Iterator>::Item` | | | required by a bound introduced by this call | - = help: the trait `Debug` is not implemented for `<impl Iterator + std::fmt::Debug as Iterator>::Item` note: required by a bound in `qux` --> $DIR/impl-trait-with-missing-bounds.rs:50:16 | @@ -102,11 +97,10 @@ error[E0277]: `<impl Iterator as Iterator>::Item` doesn't implement `Debug` --> $DIR/impl-trait-with-missing-bounds.rs:45:13 | LL | qux(constraint); - | --- ^^^^^^^^^^ `<impl Iterator as Iterator>::Item` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | --- ^^^^^^^^^^ the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item` | | | required by a bound introduced by this call | - = help: the trait `Debug` is not implemented for `<impl Iterator as Iterator>::Item` note: required by a bound in `qux` --> $DIR/impl-trait-with-missing-bounds.rs:50:16 | diff --git a/tests/ui/suggestions/issue-105645.rs b/tests/ui/suggestions/issue-105645.rs index 681ce1c6e37..f3ca8ccbb3c 100644 --- a/tests/ui/suggestions/issue-105645.rs +++ b/tests/ui/suggestions/issue-105645.rs @@ -2,7 +2,7 @@ fn main() { let mut buf = [0u8; 50]; let mut bref = buf.as_slice(); foo(&mut bref); - //~^ ERROR 4:9: 4:18: the trait bound `&[u8]: std::io::Write` is not satisfied [E0277] + //~^ ERROR the trait bound `&[u8]: std::io::Write` is not satisfied [E0277] } fn foo(_: &mut impl std::io::Write) {} diff --git a/tests/ui/suggestions/issue-116434-2015.rs b/tests/ui/suggestions/issue-116434-2015.rs index bad9d02321c..e0438cdef25 100644 --- a/tests/ui/suggestions/issue-116434-2015.rs +++ b/tests/ui/suggestions/issue-116434-2015.rs @@ -11,6 +11,7 @@ trait Foo { //~| HELP if this is a dyn-compatible trait, use `dyn` //~| ERROR the trait `Clone` is not dyn compatible [E0038] //~| HELP there is an associated type with the same name + //~| HELP use `Self` to refer to the implementing type } trait DbHandle: Sized {} @@ -26,6 +27,7 @@ trait DbInterface { //~| HELP if this is a dyn-compatible trait, use `dyn` //~| ERROR the trait `DbHandle` is not dyn compatible [E0038] //~| HELP there is an associated type with the same name + //~| HELP use `Self` to refer to the implementing type } fn main() {} diff --git a/tests/ui/suggestions/issue-116434-2015.stderr b/tests/ui/suggestions/issue-116434-2015.stderr index a0a99cc560d..cad5812da66 100644 --- a/tests/ui/suggestions/issue-116434-2015.stderr +++ b/tests/ui/suggestions/issue-116434-2015.stderr @@ -35,13 +35,18 @@ LL | fn foo() -> Clone; = note: the trait is not dyn compatible because it requires `Self: Sized` = 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> +help: you might have meant to use `Self` to refer to the implementing type + | +LL - fn foo() -> Clone; +LL + fn foo() -> Self; + | help: there is an associated type with the same name | LL | fn foo() -> Self::Clone; | ++++++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/issue-116434-2015.rs:20:20 + --> $DIR/issue-116434-2015.rs:21:20 | LL | fn handle() -> DbHandle; | ^^^^^^^^ @@ -54,7 +59,7 @@ LL | fn handle() -> dyn DbHandle; | +++ warning: trait objects without an explicit `dyn` are deprecated - --> $DIR/issue-116434-2015.rs:20:20 + --> $DIR/issue-116434-2015.rs:21:20 | LL | fn handle() -> DbHandle; | ^^^^^^^^ @@ -68,19 +73,24 @@ LL | fn handle() -> dyn DbHandle; | +++ error[E0038]: the trait `DbHandle` is not dyn compatible - --> $DIR/issue-116434-2015.rs:20:20 + --> $DIR/issue-116434-2015.rs:21:20 | LL | fn handle() -> DbHandle; | ^^^^^^^^ `DbHandle` 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/issue-116434-2015.rs:16:17 + --> $DIR/issue-116434-2015.rs:17:17 | LL | trait DbHandle: Sized {} | -------- ^^^^^ ...because it requires `Self: Sized` | | | this trait is not dyn compatible... +help: you might have meant to use `Self` to refer to the implementing type + | +LL - fn handle() -> DbHandle; +LL + fn handle() -> Self; + | help: there is an associated type with the same name | LL | fn handle() -> Self::DbHandle; diff --git a/tests/ui/suggestions/issue-81098.stderr b/tests/ui/suggestions/issue-81098.stderr index 4dc47a20282..36948469a31 100644 --- a/tests/ui/suggestions/issue-81098.stderr +++ b/tests/ui/suggestions/issue-81098.stderr @@ -2,23 +2,17 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/issue-81098.rs:3:13 | LL | fn wat() -> impl core::fmt::Display { - | ^^^^^^^^^^^^^^^^^^^^^^^ `()` cannot be formatted with the default formatter - | - = help: the trait `std::fmt::Display` is not implemented for `()` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::fmt::Display` is not implemented for `()` error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/issue-81098.rs:9:12 | LL | fn ok() -> impl core::fmt::Display { - | ^^^^^^^^^^^^^^^^^^^^^^^ `()` cannot be formatted with the default formatter + | ^^^^^^^^^^^^^^^^^^^^^^^ the trait `std::fmt::Display` is not implemented for `()` LL | 1; | -- help: remove this semicolon | | | this expression has type `{integer}`, which implements `std::fmt::Display` - | - = help: the trait `std::fmt::Display` is not implemented for `()` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead error: aborting due to 2 previous errors diff --git a/tests/ui/suggestions/issue-97760.stderr b/tests/ui/suggestions/issue-97760.stderr index ddd143b967c..1084ea7c9e0 100644 --- a/tests/ui/suggestions/issue-97760.stderr +++ b/tests/ui/suggestions/issue-97760.stderr @@ -2,7 +2,10 @@ error[E0277]: `<impl IntoIterator as IntoIterator>::Item` doesn't implement `std --> $DIR/issue-97760.rs:4:20 | LL | println!("{x}"); - | ^ `<impl IntoIterator as IntoIterator>::Item` cannot be formatted with the default formatter + | -^- + | || + | |`<impl IntoIterator as IntoIterator>::Item` cannot be formatted with the default formatter + | required by this formatting parameter | = help: the trait `std::fmt::Display` is not implemented for `<impl IntoIterator as IntoIterator>::Item` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead diff --git a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr index 0aa33d3b6fb..ab067f2439c 100644 --- a/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr +++ b/tests/ui/suggestions/lifetimes/missing-lifetimes-in-signature.stderr @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'a` --> $DIR/missing-lifetimes-in-signature.rs:37:11 | LL | fn baz<G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'a` here: `'a,` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'a` here + | +LL | fn baz<'a, G: 'a, T>(g: G, dest: &mut T) -> impl FnOnce() + '_ + | +++ error[E0700]: hidden type for `impl FnOnce()` captures lifetime that does not appear in bounds --> $DIR/missing-lifetimes-in-signature.rs:19:5 diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr index 3f8b6f93e1f..e3375b67c86 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl-3.stderr @@ -21,7 +21,7 @@ error[E0277]: `K` doesn't implement `Debug` --> $DIR/missing-bound-in-derive-copy-impl-3.rs:12:14 | LL | pub loc: Vector2<K>, - | ^^^^^^^^^^ `K` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^ the trait `Debug` is not implemented for `K` | note: required by a bound in `Vector2` --> $DIR/missing-bound-in-derive-copy-impl-3.rs:5:23 @@ -40,7 +40,7 @@ LL | #[derive(Debug, Copy, Clone)] | ----- in this derive macro expansion LL | pub struct AABB<K: Copy>{ LL | pub loc: Vector2<K>, - | ^^^^^^^^^^^^^^^^^^^ `K` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `K` | help: consider further restricting type parameter `K` with trait `Debug` | @@ -54,7 +54,7 @@ LL | #[derive(Debug, Copy, Clone)] | ----- in this derive macro expansion ... LL | pub size: Vector2<K> - | ^^^^^^^^^^^^^^^^^^^^ `K` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `K` | help: consider further restricting type parameter `K` with trait `Debug` | diff --git a/tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr b/tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr index 3766e3e2c7b..645d6ebb396 100644 --- a/tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr +++ b/tests/ui/suggestions/missing-bound-in-derive-copy-impl.stderr @@ -21,7 +21,7 @@ error[E0277]: `K` doesn't implement `Debug` --> $DIR/missing-bound-in-derive-copy-impl.rs:11:14 | LL | pub loc: Vector2<K>, - | ^^^^^^^^^^ `K` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^ the trait `Debug` is not implemented for `K` | note: required by a bound in `Vector2` --> $DIR/missing-bound-in-derive-copy-impl.rs:4:23 @@ -78,7 +78,7 @@ LL | #[derive(Debug, Copy, Clone)] | ----- in this derive macro expansion LL | pub struct AABB<K> { LL | pub loc: Vector2<K>, - | ^^^^^^^^^^^^^^^^^^^ `K` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `K` | help: consider restricting type parameter `K` with trait `Debug` | @@ -111,7 +111,7 @@ LL | #[derive(Debug, Copy, Clone)] | ----- in this derive macro expansion ... LL | pub size: Vector2<K>, - | ^^^^^^^^^^^^^^^^^^^^ `K` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `K` | help: consider restricting type parameter `K` with trait `Debug` | diff --git a/tests/ui/suggestions/option-content-move3.stderr b/tests/ui/suggestions/option-content-move3.stderr index a20dcce1ee3..faaf8a9df9d 100644 --- a/tests/ui/suggestions/option-content-move3.stderr +++ b/tests/ui/suggestions/option-content-move3.stderr @@ -79,7 +79,7 @@ LL | let x = var; | variable moved due to use in closure | move occurs because `var` has type `NotCopyableButCloneable`, which does not implement the `Copy` trait | -help: clone the value before moving it into the closure +help: consider cloning the value before moving it into the closure | LL ~ { LL + let value = var.clone(); diff --git a/tests/ui/suggestions/path-display.stderr b/tests/ui/suggestions/path-display.stderr index 46d0b35825b..0c7271b3c1c 100644 --- a/tests/ui/suggestions/path-display.stderr +++ b/tests/ui/suggestions/path-display.stderr @@ -2,18 +2,23 @@ error[E0277]: `Path` doesn't implement `std::fmt::Display` --> $DIR/path-display.rs:5:20 | LL | println!("{}", path); - | ^^^^ `Path` cannot be formatted with the default formatter; call `.display()` on it + | -- ^^^^ `Path` cannot be formatted with the default formatter; call `.display()` on it + | | + | required by this formatting parameter | = help: the trait `std::fmt::Display` is not implemented for `Path` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = note: call `.display()` or `.to_string_lossy()` to safely print paths, as they may contain non-Unicode data + = note: required for `&Path` to implement `std::fmt::Display` = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0277]: `PathBuf` doesn't implement `std::fmt::Display` --> $DIR/path-display.rs:9:20 | LL | println!("{}", path); - | ^^^^ `PathBuf` cannot be formatted with the default formatter; call `.display()` on it + | -- ^^^^ `PathBuf` cannot be formatted with the default formatter; call `.display()` on it + | | + | required by this formatting parameter | = help: the trait `std::fmt::Display` is not implemented for `PathBuf` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead diff --git a/tests/ui/suggestions/return-bindings.stderr b/tests/ui/suggestions/return-bindings.stderr index 8e396d17dc0..651998043e1 100644 --- a/tests/ui/suggestions/return-bindings.stderr +++ b/tests/ui/suggestions/return-bindings.stderr @@ -62,12 +62,16 @@ LL ~ error[E0308]: `if` and `else` have incompatible types --> $DIR/return-bindings.rs:30:9 | -LL | let s = if let Some(s) = opt_str { - | ______________________________________- -LL | | } else { - | |_____- expected because of this -LL | String::new() - | ^^^^^^^^^^^^^ expected `()`, found `String` +LL | let s = if let Some(s) = opt_str { + | ______________- - + | | ______________________________________| +LL | || } else { + | ||_____- expected because of this +LL | | String::new() + | | ^^^^^^^^^^^^^ expected `()`, found `String` +LL | | +LL | | }; + | |______- `if` and `else` have incompatible types | help: consider returning the local binding `s` | diff --git a/tests/ui/suggestions/suggest-full-enum-variant-for-local-module.rs b/tests/ui/suggestions/suggest-full-enum-variant-for-local-module.rs index 1dfc0786668..807fba0ab7e 100644 --- a/tests/ui/suggestions/suggest-full-enum-variant-for-local-module.rs +++ b/tests/ui/suggestions/suggest-full-enum-variant-for-local-module.rs @@ -6,5 +6,5 @@ mod option { } fn main() { - let _: option::O<()> = (); //~ ERROR 9:28: 9:30: mismatched types [E0308] + let _: option::O<()> = (); //~ ERROR mismatched types [E0308] } diff --git a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs index 6a273997ee6..2ee6ad91056 100644 --- a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs +++ b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.rs @@ -1,5 +1,3 @@ -#![feature(dyn_star)] //~ WARNING the feature `dyn_star` is incomplete - use std::future::Future; pub fn dyn_func<T>( @@ -8,12 +6,6 @@ pub fn dyn_func<T>( Box::new(executor) //~ ERROR may not live long enough } -pub fn dyn_star_func<T>( - executor: impl FnOnce(T) -> dyn* Future<Output = ()>, -) -> Box<dyn FnOnce(T) -> dyn* Future<Output = ()>> { - Box::new(executor) //~ ERROR may not live long enough -} - trait Trait { fn method(&self) {} } diff --git a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr index 1fb3e7d211e..62943616e3a 100644 --- a/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr +++ b/tests/ui/suggestions/wrap-dyn-in-suggestion-issue-120223.stderr @@ -1,14 +1,5 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:1:12 - | -LL | #![feature(dyn_star)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0599]: no method named `method` found for type parameter `T` in the current scope - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:24:7 + --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:16:7 | LL | pub fn in_ty_param<T: Fn() -> dyn std::fmt::Debug> (t: T) { | - method `method` not found for this type parameter @@ -22,7 +13,7 @@ LL | pub fn in_ty_param<T: Fn() -> (dyn std::fmt::Debug) + Trait> (t: T) { | + +++++++++ error[E0277]: the size for values of type `T` cannot be known at compilation time - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:29:21 + --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:21:21 | LL | fn with_sized<T: Fn() -> &'static (dyn std::fmt::Debug) + ?Sized>() { | - this type parameter needs to be `Sized` @@ -30,7 +21,7 @@ LL | without_sized::<T>(); | ^ doesn't have a size known at compile-time | note: required by an implicit `Sized` bound in `without_sized` - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:33:18 + --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:25:18 | LL | fn without_sized<T: Fn() -> &'static dyn std::fmt::Debug>() {} | ^ required by the implicit `Sized` requirement on this type parameter in `without_sized` @@ -45,7 +36,7 @@ LL | fn without_sized<T: Fn() -> &'static (dyn std::fmt::Debug) + ?Sized>() {} | + ++++++++++ error[E0310]: the parameter type `impl FnOnce(T) -> dyn Future<Output = ()>` may not live long enough - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:8:5 + --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:6:5 | LL | Box::new(executor) | ^^^^^^^^^^^^^^^^^^ @@ -58,21 +49,7 @@ help: consider adding an explicit lifetime bound LL | executor: impl FnOnce(T) -> (dyn Future<Output = ()>) + 'static, | + +++++++++++ -error[E0310]: the parameter type `impl FnOnce(T) -> dyn* Future<Output = ()>` may not live long enough - --> $DIR/wrap-dyn-in-suggestion-issue-120223.rs:14:5 - | -LL | Box::new(executor) - | ^^^^^^^^^^^^^^^^^^ - | | - | the parameter type `impl FnOnce(T) -> dyn* Future<Output = ()>` must be valid for the static lifetime... - | ...so that the type `impl FnOnce(T) -> dyn* Future<Output = ()>` will meet its required lifetime bounds - | -help: consider adding an explicit lifetime bound - | -LL | executor: impl FnOnce(T) -> (dyn* Future<Output = ()>) + 'static, - | + +++++++++++ - -error: aborting due to 4 previous errors; 1 warning emitted +error: aborting due to 3 previous errors Some errors have detailed explanations: E0277, E0310, E0599. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/std-uncopyable-atomics.rs b/tests/ui/sync/atomic-types-not-copyable.rs index d85864ecac2..d96414676ee 100644 --- a/tests/ui/std-uncopyable-atomics.rs +++ b/tests/ui/sync/atomic-types-not-copyable.rs @@ -1,8 +1,10 @@ -// Issue #8380 +//! Check that atomic types from `std::sync::atomic` are not `Copy` +//! and cannot be moved out of a shared reference. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/8380>. - -use std::sync::atomic::*; use std::ptr; +use std::sync::atomic::*; fn main() { let x = AtomicBool::new(false); diff --git a/tests/ui/std-uncopyable-atomics.stderr b/tests/ui/sync/atomic-types-not-copyable.stderr index 8c5d0b96096..05103f5d8f2 100644 --- a/tests/ui/std-uncopyable-atomics.stderr +++ b/tests/ui/sync/atomic-types-not-copyable.stderr @@ -1,5 +1,5 @@ error[E0507]: cannot move out of a shared reference - --> $DIR/std-uncopyable-atomics.rs:9:13 + --> $DIR/atomic-types-not-copyable.rs:11:13 | LL | let x = *&x; | ^^^ move occurs because value has type `std::sync::atomic::AtomicBool`, which does not implement the `Copy` trait @@ -11,7 +11,7 @@ LL + let x = &x; | error[E0507]: cannot move out of a shared reference - --> $DIR/std-uncopyable-atomics.rs:11:13 + --> $DIR/atomic-types-not-copyable.rs:13:13 | LL | let x = *&x; | ^^^ move occurs because value has type `std::sync::atomic::AtomicIsize`, which does not implement the `Copy` trait @@ -23,7 +23,7 @@ LL + let x = &x; | error[E0507]: cannot move out of a shared reference - --> $DIR/std-uncopyable-atomics.rs:13:13 + --> $DIR/atomic-types-not-copyable.rs:15:13 | LL | let x = *&x; | ^^^ move occurs because value has type `std::sync::atomic::AtomicUsize`, which does not implement the `Copy` trait @@ -35,7 +35,7 @@ LL + let x = &x; | error[E0507]: cannot move out of a shared reference - --> $DIR/std-uncopyable-atomics.rs:15:13 + --> $DIR/atomic-types-not-copyable.rs:17:13 | LL | let x = *&x; | ^^^ move occurs because value has type `std::sync::atomic::AtomicPtr<usize>`, which does not implement the `Copy` trait diff --git a/tests/ui/syntax-extension-minor.rs b/tests/ui/syntax-extension-minor.rs deleted file mode 100644 index 826990a89a5..00000000000 --- a/tests/ui/syntax-extension-minor.rs +++ /dev/null @@ -1,15 +0,0 @@ -//@ run-pass - -#![feature(concat_idents)] -#![expect(deprecated)] // concat_idents is deprecated - -pub fn main() { - struct Foo; - let _: concat_idents!(F, oo) = Foo; // Test that `concat_idents!` can be used in type positions - - let asdf_fdsa = "<.<".to_string(); - // concat_idents should have call-site hygiene. - assert!(concat_idents!(asd, f_f, dsa) == "<.<".to_string()); - - assert_eq!(stringify!(use_mention_distinction), "use_mention_distinction"); -} diff --git a/tests/ui/target-feature/invalid-attribute.rs b/tests/ui/target-feature/invalid-attribute.rs index 9ef7a686d25..d13098c3a6a 100644 --- a/tests/ui/target-feature/invalid-attribute.rs +++ b/tests/ui/target-feature/invalid-attribute.rs @@ -19,13 +19,16 @@ extern "Rust" {} #[target_feature = "+sse2"] //~^ ERROR malformed `target_feature` attribute +//~| NOTE expected this to be a list #[target_feature(enable = "foo")] //~^ ERROR not valid for this target //~| NOTE `foo` is not valid for this target #[target_feature(bar)] //~^ ERROR malformed `target_feature` attribute +//~| NOTE expected this to be of the form `enable = "..."` #[target_feature(disable = "baz")] //~^ ERROR malformed `target_feature` attribute +//~| NOTE expected this to be of the form `enable = "..."` unsafe fn foo() {} #[target_feature(enable = "sse2")] @@ -117,3 +120,8 @@ fn main() { || {}; //~^ NOTE not a function } + +#[target_feature(enable = "+sse2")] +//~^ ERROR `+sse2` is not valid for this target +//~| NOTE `+sse2` is not valid for this target +unsafe fn hey() {} diff --git a/tests/ui/target-feature/invalid-attribute.stderr b/tests/ui/target-feature/invalid-attribute.stderr index 05ae49d6b0d..113c0c3695a 100644 --- a/tests/ui/target-feature/invalid-attribute.stderr +++ b/tests/ui/target-feature/invalid-attribute.stderr @@ -1,8 +1,29 @@ -error: malformed `target_feature` attribute input +error[E0539]: malformed `target_feature` attribute input --> $DIR/invalid-attribute.rs:20:1 | LL | #[target_feature = "+sse2"] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[target_feature(enable = "name")]` + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | | + | expected this to be a list + | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]` + +error[E0539]: malformed `target_feature` attribute input + --> $DIR/invalid-attribute.rs:26:1 + | +LL | #[target_feature(bar)] + | ^^^^^^^^^^^^^^^^^---^^ + | | | + | | expected this to be of the form `enable = "..."` + | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]` + +error[E0539]: malformed `target_feature` attribute input + --> $DIR/invalid-attribute.rs:29:1 + | +LL | #[target_feature(disable = "baz")] + | ^^^^^^^^^^^^^^^^^-------^^^^^^^^^^ + | | | + | | expected this to be of the form `enable = "..."` + | help: must be of the form: `#[target_feature(enable = "feat1, feat2")]` error: attribute should be applied to a function definition --> $DIR/invalid-attribute.rs:5:1 @@ -32,7 +53,7 @@ LL | extern "Rust" {} | ---------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:31:1 + --> $DIR/invalid-attribute.rs:34:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -41,7 +62,7 @@ LL | mod another {} | -------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:36:1 + --> $DIR/invalid-attribute.rs:39:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -50,7 +71,7 @@ LL | const FOO: usize = 7; | --------------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:41:1 + --> $DIR/invalid-attribute.rs:44:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -59,7 +80,7 @@ LL | struct Foo; | ----------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:46:1 + --> $DIR/invalid-attribute.rs:49:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -68,7 +89,7 @@ LL | enum Bar {} | ----------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:51:1 + --> $DIR/invalid-attribute.rs:54:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -81,7 +102,7 @@ LL | | } | |_- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:59:1 + --> $DIR/invalid-attribute.rs:62:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -90,7 +111,7 @@ LL | type Uwu = (); | -------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:64:1 + --> $DIR/invalid-attribute.rs:67:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -99,13 +120,13 @@ LL | trait Baz {} | ------------ not a function definition error: cannot use `#[inline(always)]` with `#[target_feature]` - --> $DIR/invalid-attribute.rs:69:1 + --> $DIR/invalid-attribute.rs:72:1 | LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^ error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:74:1 + --> $DIR/invalid-attribute.rs:77:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +135,7 @@ LL | static A: () = (); | ------------------ not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:79:1 + --> $DIR/invalid-attribute.rs:82:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -123,7 +144,7 @@ LL | impl Quux for u8 {} | ------------------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:86:1 + --> $DIR/invalid-attribute.rs:89:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -132,7 +153,7 @@ LL | impl Foo {} | ----------- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:108:5 + --> $DIR/invalid-attribute.rs:111:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -143,7 +164,7 @@ LL | | } | |_____- not a function definition error: attribute should be applied to a function definition - --> $DIR/invalid-attribute.rs:115:5 + --> $DIR/invalid-attribute.rs:118:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -152,25 +173,13 @@ LL | || {}; | ----- not a function definition error: the feature named `foo` is not valid for this target - --> $DIR/invalid-attribute.rs:22:18 + --> $DIR/invalid-attribute.rs:23:18 | LL | #[target_feature(enable = "foo")] | ^^^^^^^^^^^^^^ `foo` is not valid for this target -error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:25:18 - | -LL | #[target_feature(bar)] - | ^^^ help: must be of the form: `enable = ".."` - -error: malformed `target_feature` attribute input - --> $DIR/invalid-attribute.rs:27:18 - | -LL | #[target_feature(disable = "baz")] - | ^^^^^^^^^^^^^^^ help: must be of the form: `enable = ".."` - error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/invalid-attribute.rs:81:1 + --> $DIR/invalid-attribute.rs:84:1 | LL | impl Quux for u8 {} | ^^^^^^^^^^^^^^^^ missing `foo` in implementation @@ -179,7 +188,7 @@ LL | fn foo(); | --------- `foo` from trait error: `#[target_feature(..)]` cannot be applied to safe trait method - --> $DIR/invalid-attribute.rs:97:5 + --> $DIR/invalid-attribute.rs:100:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method @@ -188,20 +197,28 @@ LL | fn foo() {} | -------- not an `unsafe` function error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/invalid-attribute.rs:100:5 + --> $DIR/invalid-attribute.rs:103:5 | LL | fn foo() {} | ^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait - --> $DIR/invalid-attribute.rs:92:5 + --> $DIR/invalid-attribute.rs:95:5 | LL | fn foo(); | ^^^^^^^^^ = note: expected signature `fn()` found signature `#[target_features] fn()` -error: aborting due to 23 previous errors +error: the feature named `+sse2` is not valid for this target + --> $DIR/invalid-attribute.rs:124:18 + | +LL | #[target_feature(enable = "+sse2")] + | ^^^^^^^^^^^^^^^^ `+sse2` is not valid for this target + | + = help: consider removing the leading `+` in the feature name + +error: aborting due to 24 previous errors -Some errors have detailed explanations: E0046, E0053. +Some errors have detailed explanations: E0046, E0053, E0539. For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/sse2.rs b/tests/ui/target-feature/target-feature-detection.rs index a1894cc03db..3404bfbe782 100644 --- a/tests/ui/sse2.rs +++ b/tests/ui/target-feature/target-feature-detection.rs @@ -1,3 +1,6 @@ +//! Check that `cfg!(target_feature = "...")` correctly detects available CPU features, +//! specifically `sse2` on x86/x86_64 platforms, and correctly reports absent features. + //@ run-pass #![allow(stable_features)] @@ -10,17 +13,23 @@ fn main() { Ok(s) => { // Skip this tests on i586-unknown-linux-gnu where sse2 is disabled if s.contains("i586") { - return + return; } } Err(_) => return, } if cfg!(any(target_arch = "x86", target_arch = "x86_64")) { - assert!(cfg!(target_feature = "sse2"), - "SSE2 was not detected as available on an x86 platform"); + assert!( + cfg!(target_feature = "sse2"), + "SSE2 was not detected as available on an x86 platform" + ); } // check a negative case too -- certainly not enabled by default #[expect(unexpected_cfgs)] - { assert!(cfg!(not(target_feature = "ferris_wheel")), - "🎡 shouldn't be detected as available by default on any platform") }; + { + assert!( + cfg!(not(target_feature = "ferris_wheel")), + "🎡 shouldn't be detected as available by default on any platform" + ) + }; } diff --git a/tests/ui/test-attrs/test-function-elided-no-main.rs b/tests/ui/test-attrs/test-function-elided-no-main.rs new file mode 100644 index 00000000000..97654581567 --- /dev/null +++ b/tests/ui/test-attrs/test-function-elided-no-main.rs @@ -0,0 +1,8 @@ +//! Test that #[test] functions are elided when not running tests, causing missing main error + +#[test] +fn main() { + // This function would normally serve as main, but since it's marked with #[test], + // it gets elided when not running tests +} +//~^ ERROR `main` function not found in crate `test_function_elided_no_main` diff --git a/tests/ui/test-attrs/test-function-elided-no-main.stderr b/tests/ui/test-attrs/test-function-elided-no-main.stderr new file mode 100644 index 00000000000..0bae690be2b --- /dev/null +++ b/tests/ui/test-attrs/test-function-elided-no-main.stderr @@ -0,0 +1,9 @@ +error[E0601]: `main` function not found in crate `test_function_elided_no_main` + --> $DIR/test-function-elided-no-main.rs:7:2 + | +LL | } + | ^ consider adding a `main` function to `$DIR/test-function-elided-no-main.rs` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0601`. diff --git a/tests/ui/thir-print/thir-tree-loop-match.rs b/tests/ui/thir-print/thir-tree-loop-match.rs new file mode 100644 index 00000000000..8c5f2244d54 --- /dev/null +++ b/tests/ui/thir-print/thir-tree-loop-match.rs @@ -0,0 +1,22 @@ +//@ check-pass +//@ compile-flags: -Zunpretty=thir-tree + +#![allow(incomplete_features)] +#![feature(loop_match)] + +fn boolean(mut state: bool) -> bool { + #[loop_match] + loop { + state = 'blk: { + match state { + true => { + #[const_continue] + break 'blk false; + } + false => return state, + } + } + } +} + +fn main() {} diff --git a/tests/ui/thir-print/thir-tree-loop-match.stdout b/tests/ui/thir-print/thir-tree-loop-match.stdout new file mode 100644 index 00000000000..5c4c50cb156 --- /dev/null +++ b/tests/ui/thir-print/thir-tree-loop-match.stdout @@ -0,0 +1,325 @@ +DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean): +params: [ + Param { + ty: bool + ty_span: Some($DIR/thir-tree-loop-match.rs:7:23: 7:27 (#0)) + self_kind: None + hir_id: Some(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).1)) + param: Some( + Pat: { + ty: bool + span: $DIR/thir-tree-loop-match.rs:7:12: 7:21 (#0) + kind: PatKind { + Binding { + name: "state" + mode: BindingMode(No, Mut) + var: LocalVarId(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).2)) + ty: bool + is_primary: true + subpattern: None + } + } + } + ) + } +] +body: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(28)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:7:37: 20:2 (#0) + kind: + Scope { + region_scope: Node(28) + lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).28)) + value: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(28)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:7:37: 20:2 (#0) + kind: + Block { + targeted_by_break: false + span: $DIR/thir-tree-loop-match.rs:7:37: 20:2 (#0) + region_scope: Node(3) + safety_mode: Safe + stmts: [] + expr: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(28)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:9:5: 19:6 (#0) + kind: + Scope { + region_scope: Node(4) + lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).4)) + value: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(28)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:9:5: 19:6 (#0) + kind: + NeverToAny { + source: + Expr { + ty: ! + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(28)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:9:5: 19:6 (#0) + kind: + LoopMatch { + state: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(5)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:10:9: 10:14 (#0) + kind: + Scope { + region_scope: Node(7) + lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).7)) + value: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(5)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:10:9: 10:14 (#0) + kind: + VarRef { + id: LocalVarId(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).2)) + } + } + } + } + region_scope: Node(10) + match_data: + LoopMatchMatchData { + span: $DIR/thir-tree-loop-match.rs:11:13: 17:14 (#0) + scrutinee: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(5)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:11:19: 11:24 (#0) + kind: + Scope { + region_scope: Node(12) + lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).12)) + value: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(5)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:11:19: 11:24 (#0) + kind: + VarRef { + id: LocalVarId(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).2)) + } + } + } + } + arms: [ + Arm { + pattern: + Pat: { + ty: bool + span: $DIR/thir-tree-loop-match.rs:12:17: 12:21 (#0) + kind: PatKind { + Constant { + value: Ty(bool, true) + } + } + } + guard: None + body: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(16)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:12:25: 15:18 (#0) + kind: + Scope { + region_scope: Node(17) + lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).17)) + value: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(16)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:12:25: 15:18 (#0) + kind: + NeverToAny { + source: + Expr { + ty: ! + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(16)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:12:25: 15:18 (#0) + kind: + Block { + targeted_by_break: false + span: $DIR/thir-tree-loop-match.rs:12:25: 15:18 (#0) + region_scope: Node(18) + safety_mode: Safe + stmts: [ + Stmt { + kind: Expr { + scope: Node(21) + expr: + Expr { + ty: ! + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(21)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:14:21: 14:37 (#0) + kind: + Scope { + region_scope: Node(19) + lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).19)) + value: + Expr { + ty: ! + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(21)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:14:21: 14:37 (#0) + kind: + ConstContinue ( + label: Node(10) + value: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(21)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:14:32: 14:37 (#0) + kind: + Scope { + region_scope: Node(20) + lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).20)) + value: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(21)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:14:32: 14:37 (#0) + kind: + Literal( lit: Spanned { node: Bool(false), span: $DIR/thir-tree-loop-match.rs:14:32: 14:37 (#0) }, neg: false) + + } + } + } + ) + } + } + } + } + } + ] + expr: [] + } + } + } + } + } + } + lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).16)) + scope: Node(16) + span: $DIR/thir-tree-loop-match.rs:12:17: 15:18 (#0) + } + Arm { + pattern: + Pat: { + ty: bool + span: $DIR/thir-tree-loop-match.rs:16:17: 16:22 (#0) + kind: PatKind { + Constant { + value: Ty(bool, false) + } + } + } + guard: None + body: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(24)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:16:26: 16:38 (#0) + kind: + Scope { + region_scope: Node(25) + lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).25)) + value: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(24)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:16:26: 16:38 (#0) + kind: + NeverToAny { + source: + Expr { + ty: ! + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(24)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:16:26: 16:38 (#0) + kind: + Return { + value: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(24)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:16:33: 16:38 (#0) + kind: + Scope { + region_scope: Node(26) + lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).26)) + value: + Expr { + ty: bool + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(24)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:16:33: 16:38 (#0) + kind: + VarRef { + id: LocalVarId(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).2)) + } + } + } + } + } + } + } + } + } + } + lint_level: Explicit(HirId(DefId(0:3 ~ thir_tree_loop_match[3c53]::boolean).24)) + scope: Node(24) + span: $DIR/thir-tree-loop-match.rs:16:17: 16:38 (#0) + } + ] + } + } + } + } + } + } + } + } + } + } + } + + +DefId(0:4 ~ thir_tree_loop_match[3c53]::main): +params: [ +] +body: + Expr { + ty: () + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(2)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:22:11: 22:13 (#0) + kind: + Scope { + region_scope: Node(2) + lint_level: Explicit(HirId(DefId(0:4 ~ thir_tree_loop_match[3c53]::main).2)) + value: + Expr { + ty: () + temp_lifetime: TempLifetime { temp_lifetime: Some(Node(2)), backwards_incompatible: None } + span: $DIR/thir-tree-loop-match.rs:22:11: 22:13 (#0) + kind: + Block { + targeted_by_break: false + span: $DIR/thir-tree-loop-match.rs:22:11: 22:13 (#0) + region_scope: Node(1) + safety_mode: Safe + stmts: [] + expr: [] + } + } + } + } + + diff --git a/tests/ui/no-send-res-ports.rs b/tests/ui/threads-sendsync/rc-is-not-send.rs index 1bac5868e73..dd562e9e8f3 100644 --- a/tests/ui/no-send-res-ports.rs +++ b/tests/ui/threads-sendsync/rc-is-not-send.rs @@ -1,28 +1,28 @@ -use std::thread; +//! Test that `Rc<T>` cannot be sent between threads. + use std::rc::Rc; +use std::thread; #[derive(Debug)] struct Port<T>(Rc<T>); -fn main() { - #[derive(Debug)] - struct Foo { - _x: Port<()>, - } +#[derive(Debug)] +struct Foo { + _x: Port<()>, +} - impl Drop for Foo { - fn drop(&mut self) {} - } +impl Drop for Foo { + fn drop(&mut self) {} +} - fn foo(x: Port<()>) -> Foo { - Foo { - _x: x - } - } +fn foo(x: Port<()>) -> Foo { + Foo { _x: x } +} +fn main() { let x = foo(Port(Rc::new(()))); - thread::spawn(move|| { + thread::spawn(move || { //~^ ERROR `Rc<()>` cannot be sent between threads safely let y = x; println!("{:?}", y); diff --git a/tests/ui/no-send-res-ports.stderr b/tests/ui/threads-sendsync/rc-is-not-send.stderr index 9c30261e5cb..a06b683f729 100644 --- a/tests/ui/no-send-res-ports.stderr +++ b/tests/ui/threads-sendsync/rc-is-not-send.stderr @@ -1,10 +1,10 @@ error[E0277]: `Rc<()>` cannot be sent between threads safely - --> $DIR/no-send-res-ports.rs:25:19 + --> $DIR/rc-is-not-send.rs:25:19 | -LL | thread::spawn(move|| { - | ------------- ^----- +LL | thread::spawn(move || { + | ------------- ^------ | | | - | _____|_____________within this `{closure@$DIR/no-send-res-ports.rs:25:19: 25:25}` + | _____|_____________within this `{closure@$DIR/rc-is-not-send.rs:25:19: 25:26}` | | | | | required by a bound introduced by this call LL | | @@ -13,22 +13,22 @@ LL | | println!("{:?}", y); LL | | }); | |_____^ `Rc<()>` cannot be sent between threads safely | - = help: within `{closure@$DIR/no-send-res-ports.rs:25:19: 25:25}`, the trait `Send` is not implemented for `Rc<()>` + = help: within `{closure@$DIR/rc-is-not-send.rs:25:19: 25:26}`, the trait `Send` is not implemented for `Rc<()>` note: required because it appears within the type `Port<()>` - --> $DIR/no-send-res-ports.rs:5:8 + --> $DIR/rc-is-not-send.rs:7:8 | LL | struct Port<T>(Rc<T>); | ^^^^ note: required because it appears within the type `Foo` - --> $DIR/no-send-res-ports.rs:9:12 + --> $DIR/rc-is-not-send.rs:10:8 | -LL | struct Foo { - | ^^^ +LL | struct Foo { + | ^^^ note: required because it's used within this closure - --> $DIR/no-send-res-ports.rs:25:19 + --> $DIR/rc-is-not-send.rs:25:19 | -LL | thread::spawn(move|| { - | ^^^^^^ +LL | thread::spawn(move || { + | ^^^^^^^ note: required by a bound in `spawn` --> $SRC_DIR/std/src/thread/mod.rs:LL:COL diff --git a/tests/ui/track-diagnostics/track.rs b/tests/ui/track-diagnostics/track.rs index 78ff85489be..1b2558c724b 100644 --- a/tests/ui/track-diagnostics/track.rs +++ b/tests/ui/track-diagnostics/track.rs @@ -1,5 +1,5 @@ //@ compile-flags: -Z track-diagnostics -//@ error-pattern: created at +//@ dont-require-annotations: NOTE //@ rustc-env:RUST_BACKTRACE=0 //@ failure-status: 101 @@ -16,6 +16,9 @@ fn main() { break rust //~^ ERROR cannot find value `rust` in this scope + //~| NOTE created at //~| ERROR `break` outside of a loop or labeled block + //~| NOTE created at //~| ERROR It looks like you're trying to break rust; would you like some ICE? + //~| NOTE created at } diff --git a/tests/ui/track-diagnostics/track.stderr b/tests/ui/track-diagnostics/track.stderr index 527c0d1b898..f82764958d4 100644 --- a/tests/ui/track-diagnostics/track.stderr +++ b/tests/ui/track-diagnostics/track.stderr @@ -3,22 +3,24 @@ error[E0425]: cannot find value `rust` in this scope | LL | break rust | ^^^^ not found in this scope --Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC + | + = note: -Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC error[E0268]: `break` outside of a loop or labeled block --> $DIR/track.rs:LL:CC | LL | break rust | ^^^^^^^^^^ cannot `break` outside of a loop or labeled block --Ztrack-diagnostics: created at compiler/rustc_hir_typeck/src/loops.rs:LL:CC + | + = note: -Ztrack-diagnostics: created at compiler/rustc_hir_typeck/src/loops.rs:LL:CC error: internal compiler error: It looks like you're trying to break rust; would you like some ICE? --> $DIR/track.rs:LL:CC | LL | break rust | ^^^^^^^^^^ --Ztrack-diagnostics: created at compiler/rustc_hir_typeck/src/lib.rs:LL:CC | + = note: -Ztrack-diagnostics: created at compiler/rustc_hir_typeck/src/lib.rs:LL:CC = note: the compiler expectedly panicked. this is a feature. = note: we would appreciate a joke overview: https://github.com/rust-lang/rust/issues/43162#issuecomment-320764675 = note: rustc $VERSION running on $TARGET diff --git a/tests/ui/track-diagnostics/track2.rs b/tests/ui/track-diagnostics/track2.rs index f51a42cf86f..591b84f330b 100644 --- a/tests/ui/track-diagnostics/track2.rs +++ b/tests/ui/track-diagnostics/track2.rs @@ -1,10 +1,12 @@ //@ compile-flags: -Z track-diagnostics -//@ error-pattern: created at +//@ dont-require-annotations: NOTE // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC" fn main() { - let _moved @ _from = String::from("foo"); //~ ERROR use of moved value + let _moved @ _from = String::from("foo"); + //~^ ERROR use of moved value + //~| NOTE created at } diff --git a/tests/ui/track-diagnostics/track2.stderr b/tests/ui/track-diagnostics/track2.stderr index dffa0b0c91c..02010639c02 100644 --- a/tests/ui/track-diagnostics/track2.stderr +++ b/tests/ui/track-diagnostics/track2.stderr @@ -6,8 +6,8 @@ LL | let _moved @ _from = String::from("foo"); | | | | | value moved here | value used here after move --Ztrack-diagnostics: created at compiler/rustc_borrowck/src/borrowck_errors.rs:LL:CC | + = note: -Ztrack-diagnostics: created at compiler/rustc_borrowck/src/borrowck_errors.rs:LL:CC help: borrow this binding in the pattern to avoid moving the value | LL | let ref _moved @ ref _from = String::from("foo"); diff --git a/tests/ui/track-diagnostics/track3.rs b/tests/ui/track-diagnostics/track3.rs index 428067572af..a39e71915d9 100644 --- a/tests/ui/track-diagnostics/track3.rs +++ b/tests/ui/track-diagnostics/track3.rs @@ -1,5 +1,5 @@ //@ compile-flags: -Z track-diagnostics -//@ error-pattern: created at +//@ dont-require-annotations: NOTE // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. @@ -8,5 +8,7 @@ fn main() { let _unimported = Blah { field: u8 }; //~^ ERROR cannot find struct, variant or union type `Blah` in this scope + //~| NOTE created at //~| ERROR expected value, found builtin type `u8` + //~| NOTE created at } diff --git a/tests/ui/track-diagnostics/track3.stderr b/tests/ui/track-diagnostics/track3.stderr index dc468d7e8ee..3e99c8d5f33 100644 --- a/tests/ui/track-diagnostics/track3.stderr +++ b/tests/ui/track-diagnostics/track3.stderr @@ -3,14 +3,16 @@ error[E0422]: cannot find struct, variant or union type `Blah` in this scope | LL | let _unimported = Blah { field: u8 }; | ^^^^ not found in this scope --Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC + | + = note: -Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC error[E0423]: expected value, found builtin type `u8` --> $DIR/track3.rs:LL:CC | LL | let _unimported = Blah { field: u8 }; | ^^ not a value --Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC + | + = note: -Ztrack-diagnostics: created at compiler/rustc_resolve/src/late/diagnostics.rs:LL:CC error: aborting due to 2 previous errors diff --git a/tests/ui/track-diagnostics/track4.rs b/tests/ui/track-diagnostics/track4.rs index b6edfdba259..0038c616aa5 100644 --- a/tests/ui/track-diagnostics/track4.rs +++ b/tests/ui/track-diagnostics/track4.rs @@ -1,11 +1,13 @@ //@ compile-flags: -Z track-diagnostics -//@ error-pattern: created at +//@ dont-require-annotations: NOTE // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC" -pub onion { //~ ERROR missing `enum` for enum definition +pub onion { + //~^ ERROR missing `enum` for enum definition + //~| NOTE created at Owo(u8), Uwu(i8), } diff --git a/tests/ui/track-diagnostics/track4.stderr b/tests/ui/track-diagnostics/track4.stderr index 19499fa7abc..2b6805849b5 100644 --- a/tests/ui/track-diagnostics/track4.stderr +++ b/tests/ui/track-diagnostics/track4.stderr @@ -3,8 +3,8 @@ error: missing `enum` for enum definition | LL | pub onion { | ^^^^^^^^^ --Ztrack-diagnostics: created at compiler/rustc_parse/src/parser/item.rs:LL:CC | + = note: -Ztrack-diagnostics: created at compiler/rustc_parse/src/parser/item.rs:LL:CC help: add `enum` here to parse `onion` as an enum | LL | pub enum onion { diff --git a/tests/ui/track-diagnostics/track5.rs b/tests/ui/track-diagnostics/track5.rs index 800bb21b2b1..09fda4eb527 100644 --- a/tests/ui/track-diagnostics/track5.rs +++ b/tests/ui/track-diagnostics/track5.rs @@ -1,8 +1,10 @@ //@ compile-flags: -Z track-diagnostics -//@ error-pattern: created at +//@ dont-require-annotations: NOTE // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. //@ normalize-stderr: ".rs:\d+:\d+" -> ".rs:LL:CC" -} //~ ERROR unexpected closing delimiter: `}` +} +//~^ ERROR unexpected closing delimiter: `}` +//~| NOTE created at diff --git a/tests/ui/track-diagnostics/track5.stderr b/tests/ui/track-diagnostics/track5.stderr index ecc7d81b3c3..5de0550918e 100644 --- a/tests/ui/track-diagnostics/track5.stderr +++ b/tests/ui/track-diagnostics/track5.stderr @@ -3,7 +3,8 @@ error: unexpected closing delimiter: `}` | LL | } | ^ unexpected closing delimiter --Ztrack-diagnostics: created at compiler/rustc_parse/src/lexer/tokentrees.rs:LL:CC + | + = note: -Ztrack-diagnostics: created at compiler/rustc_parse/src/lexer/tokentrees.rs:LL:CC error: aborting due to 1 previous error diff --git a/tests/ui/track-diagnostics/track6.rs b/tests/ui/track-diagnostics/track6.rs index 55db2ecf939..11d3b7e9764 100644 --- a/tests/ui/track-diagnostics/track6.rs +++ b/tests/ui/track-diagnostics/track6.rs @@ -1,5 +1,5 @@ //@ compile-flags: -Z track-diagnostics -//@ error-pattern: created at +//@ dont-require-annotations: NOTE // Normalize the emitted location so this doesn't need // updating everytime someone adds or removes a line. @@ -11,7 +11,9 @@ pub trait Foo { } impl <T> Foo for T { - default fn bar() {} //~ ERROR specialization is unstable + default fn bar() {} + //~^ ERROR specialization is unstable + //~| NOTE created at } fn main() {} diff --git a/tests/ui/track-diagnostics/track6.stderr b/tests/ui/track-diagnostics/track6.stderr index 9ed8a19629d..a61f7855e32 100644 --- a/tests/ui/track-diagnostics/track6.stderr +++ b/tests/ui/track-diagnostics/track6.stderr @@ -3,8 +3,8 @@ error[E0658]: specialization is unstable | LL | default fn bar() {} | ^^^^^^^^^^^^^^^^^^^ --Ztrack-diagnostics: created at compiler/rustc_ast_passes/src/feature_gate.rs:LL:CC | + = note: -Ztrack-diagnostics: created at compiler/rustc_ast_passes/src/feature_gate.rs:LL:CC = note: see issue #31844 <https://github.com/rust-lang/rust/issues/31844> for more information = help: add `#![feature(specialization)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date diff --git a/tests/ui/trait-bounds/false-span-in-trait-bound-label.rs b/tests/ui/trait-bounds/false-span-in-trait-bound-label.rs new file mode 100644 index 00000000000..0e307309860 --- /dev/null +++ b/tests/ui/trait-bounds/false-span-in-trait-bound-label.rs @@ -0,0 +1,10 @@ +// In this test, the span of the trait bound label should point to `1`, not `""`. +// See issue #143336 + +trait A<T> { + fn f(self, x: T); +} + +fn main() { + A::f(1, ""); //~ ERROR the trait bound `{integer}: A<_>` is not satisfied [E0277] +} diff --git a/tests/ui/trait-bounds/false-span-in-trait-bound-label.stderr b/tests/ui/trait-bounds/false-span-in-trait-bound-label.stderr new file mode 100644 index 00000000000..9a480273338 --- /dev/null +++ b/tests/ui/trait-bounds/false-span-in-trait-bound-label.stderr @@ -0,0 +1,17 @@ +error[E0277]: the trait bound `{integer}: A<_>` is not satisfied + --> $DIR/false-span-in-trait-bound-label.rs:9:10 + | +LL | A::f(1, ""); + | ---- ^ the trait `A<_>` is not implemented for `{integer}` + | | + | required by a bound introduced by this call + | +help: this trait has no implementations, consider adding one + --> $DIR/false-span-in-trait-bound-label.rs:4:1 + | +LL | trait A<T> { + | ^^^^^^^^^^ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/associated_type_bound/116464-invalid-assoc-type-suggestion-in-trait-impl.stderr b/tests/ui/traits/associated_type_bound/116464-invalid-assoc-type-suggestion-in-trait-impl.stderr index eedaae43f9a..54c0cf8ebee 100644 --- a/tests/ui/traits/associated_type_bound/116464-invalid-assoc-type-suggestion-in-trait-impl.stderr +++ b/tests/ui/traits/associated_type_bound/116464-invalid-assoc-type-suggestion-in-trait-impl.stderr @@ -1,9 +1,3 @@ -error[E0207]: the type parameter `S` is not constrained by the impl trait, self type, or predicates - --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:9:9 - | -LL | impl<T, S> Trait<T> for i32 { - | ^ unconstrained type parameter - error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:15:12 | @@ -16,6 +10,12 @@ note: trait defined here, with 1 generic parameter: `T` LL | pub trait Trait<T> { | ^^^^^ - +error[E0207]: the type parameter `S` is not constrained by the impl trait, self type, or predicates + --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:9:9 + | +LL | impl<T, S> Trait<T> for i32 { + | ^ unconstrained type parameter + error[E0107]: trait takes 1 generic argument but 2 generic arguments were supplied --> $DIR/116464-invalid-assoc-type-suggestion-in-trait-impl.rs:19:12 | diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs index 9141d327aee..ff1ce949f09 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-0.rs @@ -6,15 +6,15 @@ #[const_trait] trait Trait { - type Assoc: ~const Trait; + type Assoc: [const] Trait; fn func() -> i32; } -const fn unqualified<T: ~const Trait>() -> i32 { +const fn unqualified<T: [const] Trait>() -> i32 { T::Assoc::func() } -const fn qualified<T: ~const Trait>() -> i32 { +const fn qualified<T: [const] Trait>() -> i32 { <T as Trait>::Assoc::func() } diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs index 19e86b50d33..5773f2281c3 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-1.rs @@ -5,7 +5,7 @@ #[const_trait] trait Trait { - type Assoc: ~const Trait; + type Assoc: [const] Trait; fn func() -> i32; } diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr index 4cd87002e49..a0474e65efe 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.current.stderr @@ -1,10 +1,10 @@ -error[E0277]: the trait bound `U: ~const Other` is not satisfied +error[E0277]: the trait bound `U: [const] Other` is not satisfied --> $DIR/assoc-type-const-bound-usage-fail-2.rs:24:5 | LL | T::Assoc::<U>::func(); | ^^^^^^^^^^^^^ -error[E0277]: the trait bound `U: ~const Other` is not satisfied +error[E0277]: the trait bound `U: [const] Other` is not satisfied --> $DIR/assoc-type-const-bound-usage-fail-2.rs:26:5 | LL | <T as Trait>::Assoc::<U>::func(); diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr index 4cd87002e49..a0474e65efe 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.next.stderr @@ -1,10 +1,10 @@ -error[E0277]: the trait bound `U: ~const Other` is not satisfied +error[E0277]: the trait bound `U: [const] Other` is not satisfied --> $DIR/assoc-type-const-bound-usage-fail-2.rs:24:5 | LL | T::Assoc::<U>::func(); | ^^^^^^^^^^^^^ -error[E0277]: the trait bound `U: ~const Other` is not satisfied +error[E0277]: the trait bound `U: [const] Other` is not satisfied --> $DIR/assoc-type-const-bound-usage-fail-2.rs:26:5 | LL | <T as Trait>::Assoc::<U>::func(); diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs index e1c30b53611..5338c27bedc 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail-2.rs @@ -1,7 +1,7 @@ //@ revisions: current next //@[next] compile-flags: -Znext-solver -// Check that `~const` item bounds only hold if the where clauses on the +// Check that `[const]` item bounds only hold if the where clauses on the // associated type are also const. // i.e. check that we validate the const conditions for the associated type // when considering one of implied const bounds. @@ -10,9 +10,9 @@ #[const_trait] trait Trait { - type Assoc<U>: ~const Trait + type Assoc<U>: [const] Trait where - U: ~const Other; + U: [const] Other; fn func(); } @@ -20,14 +20,14 @@ trait Trait { #[const_trait] trait Other {} -const fn fails<T: ~const Trait, U: Other>() { +const fn fails<T: [const] Trait, U: Other>() { T::Assoc::<U>::func(); - //~^ ERROR the trait bound `U: ~const Other` is not satisfied + //~^ ERROR the trait bound `U: [const] Other` is not satisfied <T as Trait>::Assoc::<U>::func(); - //~^ ERROR the trait bound `U: ~const Other` is not satisfied + //~^ ERROR the trait bound `U: [const] Other` is not satisfied } -const fn works<T: ~const Trait, U: ~const Other>() { +const fn works<T: [const] Trait, U: [const] Other>() { T::Assoc::<U>::func(); <T as Trait>::Assoc::<U>::func(); } diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr index 9c29a894749..20b01d06e8d 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.current.stderr @@ -1,10 +1,10 @@ -error[E0277]: the trait bound `T: ~const Trait` is not satisfied +error[E0277]: the trait bound `T: [const] Trait` is not satisfied --> $DIR/assoc-type-const-bound-usage-fail.rs:17:5 | LL | T::Assoc::func(); | ^^^^^^^^ -error[E0277]: the trait bound `T: ~const Trait` is not satisfied +error[E0277]: the trait bound `T: [const] Trait` is not satisfied --> $DIR/assoc-type-const-bound-usage-fail.rs:19:5 | LL | <T as Trait>::Assoc::func(); diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr index 9c29a894749..20b01d06e8d 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.next.stderr @@ -1,10 +1,10 @@ -error[E0277]: the trait bound `T: ~const Trait` is not satisfied +error[E0277]: the trait bound `T: [const] Trait` is not satisfied --> $DIR/assoc-type-const-bound-usage-fail.rs:17:5 | LL | T::Assoc::func(); | ^^^^^^^^ -error[E0277]: the trait bound `T: ~const Trait` is not satisfied +error[E0277]: the trait bound `T: [const] Trait` is not satisfied --> $DIR/assoc-type-const-bound-usage-fail.rs:19:5 | LL | <T as Trait>::Assoc::func(); diff --git a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs index 3761fea1968..4940b3a1aa6 100644 --- a/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs +++ b/tests/ui/traits/const-traits/assoc-type-const-bound-usage-fail.rs @@ -1,7 +1,7 @@ //@ revisions: current next //@[next] compile-flags: -Znext-solver -// Check that `~const` item bounds only hold if the parent trait is `~const`. +// Check that `[const]` item bounds only hold if the parent trait is `[const]`. // i.e. check that we validate the const conditions for the associated type // when considering one of implied const bounds. @@ -9,18 +9,18 @@ #[const_trait] trait Trait { - type Assoc: ~const Trait; + type Assoc: [const] Trait; fn func(); } const fn unqualified<T: Trait>() { T::Assoc::func(); - //~^ ERROR the trait bound `T: ~const Trait` is not satisfied + //~^ ERROR the trait bound `T: [const] Trait` is not satisfied <T as Trait>::Assoc::func(); - //~^ ERROR the trait bound `T: ~const Trait` is not satisfied + //~^ ERROR the trait bound `T: [const] Trait` is not satisfied } -const fn works<T: ~const Trait>() { +const fn works<T: [const] Trait>() { T::Assoc::func(); <T as Trait>::Assoc::func(); } diff --git a/tests/ui/traits/const-traits/assoc-type.current.stderr b/tests/ui/traits/const-traits/assoc-type.current.stderr index 7526369194b..1e58efeedee 100644 --- a/tests/ui/traits/const-traits/assoc-type.current.stderr +++ b/tests/ui/traits/const-traits/assoc-type.current.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `NonConstAdd: ~const Add` is not satisfied +error[E0277]: the trait bound `NonConstAdd: [const] Add` is not satisfied --> $DIR/assoc-type.rs:37:16 | LL | type Bar = NonConstAdd; @@ -7,8 +7,8 @@ LL | type Bar = NonConstAdd; note: required by a bound in `Foo::Bar` --> $DIR/assoc-type.rs:33:15 | -LL | type Bar: ~const Add; - | ^^^^^^^^^^ required by this bound in `Foo::Bar` +LL | type Bar: [const] Add; + | ^^^^^^^^^^^ required by this bound in `Foo::Bar` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/assoc-type.next.stderr b/tests/ui/traits/const-traits/assoc-type.next.stderr index 7526369194b..1e58efeedee 100644 --- a/tests/ui/traits/const-traits/assoc-type.next.stderr +++ b/tests/ui/traits/const-traits/assoc-type.next.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `NonConstAdd: ~const Add` is not satisfied +error[E0277]: the trait bound `NonConstAdd: [const] Add` is not satisfied --> $DIR/assoc-type.rs:37:16 | LL | type Bar = NonConstAdd; @@ -7,8 +7,8 @@ LL | type Bar = NonConstAdd; note: required by a bound in `Foo::Bar` --> $DIR/assoc-type.rs:33:15 | -LL | type Bar: ~const Add; - | ^^^^^^^^^^ required by this bound in `Foo::Bar` +LL | type Bar: [const] Add; + | ^^^^^^^^^^^ required by this bound in `Foo::Bar` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/assoc-type.rs b/tests/ui/traits/const-traits/assoc-type.rs index a169b61994c..1faef1b0a32 100644 --- a/tests/ui/traits/const-traits/assoc-type.rs +++ b/tests/ui/traits/const-traits/assoc-type.rs @@ -30,12 +30,12 @@ impl Add for NonConstAdd { #[const_trait] trait Foo { - type Bar: ~const Add; + type Bar: [const] Add; } impl const Foo for NonConstAdd { type Bar = NonConstAdd; - //~^ ERROR the trait bound `NonConstAdd: ~const Add` is not satisfied + //~^ ERROR the trait bound `NonConstAdd: [const] Add` is not satisfied } #[const_trait] diff --git a/tests/ui/traits/const-traits/auxiliary/minicore.rs b/tests/ui/traits/const-traits/auxiliary/minicore.rs index 073337b2ac6..d2133bbbcae 100644 --- a/tests/ui/traits/const-traits/auxiliary/minicore.rs +++ b/tests/ui/traits/const-traits/auxiliary/minicore.rs @@ -86,14 +86,14 @@ enum ControlFlow<B, C = ()> { #[const_trait] #[lang = "fn"] #[rustc_paren_sugar] -pub trait Fn<Args: Tuple>: ~const FnMut<Args> { +pub trait Fn<Args: Tuple>: [const] FnMut<Args> { extern "rust-call" fn call(&self, args: Args) -> Self::Output; } #[const_trait] #[lang = "fn_mut"] #[rustc_paren_sugar] -pub trait FnMut<Args: Tuple>: ~const FnOnce<Args> { +pub trait FnMut<Args: Tuple>: [const] FnOnce<Args> { extern "rust-call" fn call_mut(&mut self, args: Args) -> Self::Output; } @@ -142,7 +142,7 @@ pub trait Drop { #[const_trait] pub trait Residual<O> { - type TryType: ~const Try<Output = O, Residual = Self> + Try<Output = O, Residual = Self>; + type TryType: [const] Try<Output = O, Residual = Self> + Try<Output = O, Residual = Self>; } const fn size_of<T>() -> usize { @@ -183,7 +183,7 @@ pub unsafe trait SliceIndex<T: PointeeSized> { impl<T, I> const Index<I> for [T] where - I: ~const SliceIndex<[T]>, + I: [const] SliceIndex<[T]>, { type Output = I::Output; @@ -195,7 +195,7 @@ where impl<T, I, const N: usize> const Index<I> for [T; N] where - [T]: ~const Index<I>, + [T]: [const] Index<I>, { type Output = <[T] as Index<I>>::Output; @@ -265,7 +265,7 @@ use Option::*; const fn as_deref<T>(opt: &Option<T>) -> Option<&T::Target> where - T: ~const Deref, + T: [const] Deref, { match opt { Option::Some(t) => Option::Some(t.deref()), @@ -285,7 +285,7 @@ pub trait From<T>: Sized { impl<T, U> const Into<U> for T where - U: ~const From<T>, + U: [const] From<T>, { fn into(self) -> U { U::from(self) @@ -323,7 +323,7 @@ pub trait PartialEq<Rhs: PointeeSized = Self>: PointeeSized { impl<A: PointeeSized, B: PointeeSized> const PartialEq<&B> for &A where - A: ~const PartialEq<B>, + A: [const] PartialEq<B>, { fn eq(&self, other: &&B) -> bool { PartialEq::eq(*self, *other) @@ -373,7 +373,7 @@ impl<'a, T: PointeeSized> Pin<&'a T> { impl<P: Deref> Pin<P> { const fn as_ref(&self) -> Pin<&P::Target> where - P: ~const Deref, + P: [const] Deref, { unsafe { Pin::new_unchecked(&*self.pointer) } } @@ -403,7 +403,7 @@ impl<T> Option<T> { } } -impl<P: ~const Deref> const Deref for Pin<P> { +impl<P: [const] Deref> const Deref for Pin<P> { type Target = P::Target; fn deref(&self) -> &P::Target { Pin::get_ref(Pin::as_ref(self)) @@ -467,7 +467,7 @@ pub trait Clone: Sized { fn clone(&self) -> Self; fn clone_from(&mut self, source: &Self) where - Self: ~const Destruct, + Self: [const] Destruct, { *self = source.clone() } @@ -476,7 +476,7 @@ pub trait Clone: Sized { #[lang = "structural_peq"] pub trait StructuralPartialEq {} -pub const fn drop<T: ~const Destruct>(_: T) {} +pub const fn drop<T: [const] Destruct>(_: T) {} #[rustc_intrinsic] const fn const_eval_select<ARG: Tuple, F, G, RET>( diff --git a/tests/ui/traits/const-traits/call-const-closure.rs b/tests/ui/traits/const-traits/call-const-closure.rs index 21f4374b8d5..70dfaf724c9 100644 --- a/tests/ui/traits/const-traits/call-const-closure.rs +++ b/tests/ui/traits/const-traits/call-const-closure.rs @@ -15,7 +15,7 @@ impl Bar for () { const FOO: () = { (const || ().foo())(); - //~^ ERROR the trait bound `(): ~const Bar` is not satisfied + //~^ ERROR the trait bound `(): [const] Bar` is not satisfied // FIXME(const_trait_impl): The constness environment for const closures is wrong. }; diff --git a/tests/ui/traits/const-traits/call-const-closure.stderr b/tests/ui/traits/const-traits/call-const-closure.stderr index fe7c115aaab..4bb8b2e9777 100644 --- a/tests/ui/traits/const-traits/call-const-closure.stderr +++ b/tests/ui/traits/const-traits/call-const-closure.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `(): ~const Bar` is not satisfied +error[E0277]: the trait bound `(): [const] Bar` is not satisfied --> $DIR/call-const-closure.rs:17:18 | LL | (const || ().foo())(); diff --git a/tests/ui/traits/const-traits/call-const-in-tilde-const.rs b/tests/ui/traits/const-traits/call-const-in-conditionally-const.rs index b6d1517499d..4e8c2cd171e 100644 --- a/tests/ui/traits/const-traits/call-const-in-tilde-const.rs +++ b/tests/ui/traits/const-traits/call-const-in-conditionally-const.rs @@ -5,7 +5,7 @@ fn foo(); } -const fn foo<T: ~const Foo>() { +const fn foo<T: [const] Foo>() { const { T::foo() } //~^ ERROR the trait bound `T: const Foo` is not satisfied } diff --git a/tests/ui/traits/const-traits/call-const-in-tilde-const.stderr b/tests/ui/traits/const-traits/call-const-in-conditionally-const.stderr index b9dabceb5de..f14b640ca31 100644 --- a/tests/ui/traits/const-traits/call-const-in-tilde-const.stderr +++ b/tests/ui/traits/const-traits/call-const-in-conditionally-const.stderr @@ -1,5 +1,5 @@ error[E0277]: the trait bound `T: const Foo` is not satisfied - --> $DIR/call-const-in-tilde-const.rs:9:13 + --> $DIR/call-const-in-conditionally-const.rs:9:13 | LL | const { T::foo() } | ^ diff --git a/tests/ui/traits/const-traits/call-const-trait-method-fail.rs b/tests/ui/traits/const-traits/call-const-trait-method-fail.rs index e06d04db804..c03d3e950b0 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-fail.rs +++ b/tests/ui/traits/const-traits/call-const-trait-method-fail.rs @@ -24,7 +24,7 @@ pub const fn add_i32(a: i32, b: i32) -> i32 { pub const fn add_u32(a: u32, b: u32) -> u32 { a.plus(b) - //~^ ERROR the trait bound `u32: ~const Plus` + //~^ ERROR the trait bound `u32: [const] Plus` } fn main() {} diff --git a/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr b/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr index 64850335c2a..4aaf53344c9 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr +++ b/tests/ui/traits/const-traits/call-const-trait-method-fail.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `u32: ~const Plus` is not satisfied +error[E0277]: the trait bound `u32: [const] Plus` is not satisfied --> $DIR/call-const-trait-method-fail.rs:26:5 | LL | a.plus(b) diff --git a/tests/ui/traits/const-traits/call-const-trait-method-pass.rs b/tests/ui/traits/const-traits/call-const-trait-method-pass.rs index 3004647ede0..d66a11490c5 100644 --- a/tests/ui/traits/const-traits/call-const-trait-method-pass.rs +++ b/tests/ui/traits/const-traits/call-const-trait-method-pass.rs @@ -1,6 +1,5 @@ -//@ known-bug: #110395 - #![feature(const_trait_impl, const_ops)] +//@ check-pass struct Int(i32); diff --git a/tests/ui/traits/const-traits/call-const-trait-method-pass.stderr b/tests/ui/traits/const-traits/call-const-trait-method-pass.stderr deleted file mode 100644 index 7746f103ac3..00000000000 --- a/tests/ui/traits/const-traits/call-const-trait-method-pass.stderr +++ /dev/null @@ -1,20 +0,0 @@ -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/call-const-trait-method-pass.rs:15:12 - | -LL | impl const PartialEq for Int { - | ^^^^^^^^^ this trait is not `const` - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error[E0015]: cannot call non-const method `<Int as PartialEq>::eq` in constant functions - --> $DIR/call-const-trait-method-pass.rs:20:15 - | -LL | !self.eq(other) - | ^^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/call-generic-in-impl.rs b/tests/ui/traits/const-traits/call-generic-in-impl.rs index 6149dc3d126..f38590fa3c0 100644 --- a/tests/ui/traits/const-traits/call-generic-in-impl.rs +++ b/tests/ui/traits/const-traits/call-generic-in-impl.rs @@ -1,5 +1,4 @@ -//@ known-bug: #110395 -// FIXME(const_trait_impl) check-pass +//@ check-pass #![feature(const_trait_impl)] #[const_trait] @@ -7,7 +6,7 @@ trait MyPartialEq { fn eq(&self, other: &Self) -> bool; } -impl<T: ~const PartialEq> const MyPartialEq for T { +impl<T: [const] PartialEq> const MyPartialEq for T { fn eq(&self, other: &Self) -> bool { PartialEq::eq(self, other) } diff --git a/tests/ui/traits/const-traits/call-generic-in-impl.stderr b/tests/ui/traits/const-traits/call-generic-in-impl.stderr deleted file mode 100644 index a45dfd95b4a..00000000000 --- a/tests/ui/traits/const-traits/call-generic-in-impl.stderr +++ /dev/null @@ -1,30 +0,0 @@ -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-in-impl.rs:10:9 - | -LL | impl<T: ~const PartialEq> const MyPartialEq for T { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-in-impl.rs:10:9 - | -LL | impl<T: ~const PartialEq> const MyPartialEq for T { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0015]: cannot call non-const method `<T as PartialEq>::eq` in constant functions - --> $DIR/call-generic-in-impl.rs:12:9 - | -LL | PartialEq::eq(self, other) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 3 previous errors - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/call-generic-method-chain.rs b/tests/ui/traits/const-traits/call-generic-method-chain.rs index 74beab71208..1ad71c424a3 100644 --- a/tests/ui/traits/const-traits/call-generic-method-chain.rs +++ b/tests/ui/traits/const-traits/call-generic-method-chain.rs @@ -1,8 +1,7 @@ //! Basic test for calling methods on generic type parameters in `const fn`. -//@ known-bug: #110395 //@ compile-flags: -Znext-solver -// FIXME(const_trait_impl) check-pass +//@ check-pass #![feature(const_trait_impl)] @@ -17,11 +16,11 @@ impl const PartialEq for S { } } -const fn equals_self<T: ~const PartialEq>(t: &T) -> bool { +const fn equals_self<T: [const] PartialEq>(t: &T) -> bool { *t == *t } -const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool { +const fn equals_self_wrapper<T: [const] PartialEq>(t: &T) -> bool { equals_self(t) } diff --git a/tests/ui/traits/const-traits/call-generic-method-chain.stderr b/tests/ui/traits/const-traits/call-generic-method-chain.stderr deleted file mode 100644 index 40b4f14733f..00000000000 --- a/tests/ui/traits/const-traits/call-generic-method-chain.stderr +++ /dev/null @@ -1,66 +0,0 @@ -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/call-generic-method-chain.rs:11:12 - | -LL | impl const PartialEq for S { - | ^^^^^^^^^ this trait is not `const` - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-method-chain.rs:20:25 - | -LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-method-chain.rs:20:25 - | -LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-method-chain.rs:24:33 - | -LL | const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-method-chain.rs:24:33 - | -LL | const fn equals_self_wrapper<T: ~const PartialEq>(t: &T) -> bool { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/call-generic-method-chain.rs:21:5 - | -LL | *t == *t - | ^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const method `<S as PartialEq>::eq` in constant functions - --> $DIR/call-generic-method-chain.rs:16:15 - | -LL | !self.eq(other) - | ^^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 7 previous errors - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs b/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs index ec615d8484c..58f293b5ac5 100644 --- a/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs +++ b/tests/ui/traits/const-traits/call-generic-method-dup-bound.rs @@ -1,6 +1,5 @@ //@ compile-flags: -Znext-solver -//@ known-bug: #110395 -// FIXME(const_trait_impl) check-pass +//@ check-pass #![feature(const_trait_impl)] @@ -15,16 +14,16 @@ impl const PartialEq for S { } } -// This duplicate bound should not result in ambiguities. It should be equivalent to a single ~const -// bound. -const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool { +// This duplicate bound should not result in ambiguities. +// It should be equivalent to a single [const] bound. +const fn equals_self<T: PartialEq + [const] PartialEq>(t: &T) -> bool { *t == *t } trait A: PartialEq {} impl<T: PartialEq> A for T {} -const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool { +const fn equals_self2<T: A + [const] PartialEq>(t: &T) -> bool { *t == *t } diff --git a/tests/ui/traits/const-traits/call-generic-method-dup-bound.stderr b/tests/ui/traits/const-traits/call-generic-method-dup-bound.stderr deleted file mode 100644 index c74f5cf786c..00000000000 --- a/tests/ui/traits/const-traits/call-generic-method-dup-bound.stderr +++ /dev/null @@ -1,74 +0,0 @@ -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/call-generic-method-dup-bound.rs:9:12 - | -LL | impl const PartialEq for S { - | ^^^^^^^^^ this trait is not `const` - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-method-dup-bound.rs:20:37 - | -LL | const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-method-dup-bound.rs:20:37 - | -LL | const fn equals_self<T: PartialEq + ~const PartialEq>(t: &T) -> bool { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-method-dup-bound.rs:27:30 - | -LL | const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-method-dup-bound.rs:27:30 - | -LL | const fn equals_self2<T: A + ~const PartialEq>(t: &T) -> bool { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/call-generic-method-dup-bound.rs:21:5 - | -LL | *t == *t - | ^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const method `<S as PartialEq>::eq` in constant functions - --> $DIR/call-generic-method-dup-bound.rs:14:15 - | -LL | !self.eq(other) - | ^^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/call-generic-method-dup-bound.rs:28:5 - | -LL | *t == *t - | ^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 8 previous errors - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/call-generic-method-fail.rs b/tests/ui/traits/const-traits/call-generic-method-fail.rs index 66881334a29..4528f3b122f 100644 --- a/tests/ui/traits/const-traits/call-generic-method-fail.rs +++ b/tests/ui/traits/const-traits/call-generic-method-fail.rs @@ -3,7 +3,7 @@ pub const fn equals_self<T: PartialEq>(t: &T) -> bool { *t == *t - //~^ ERROR cannot call non-const operator in constant functions + //~^ ERROR the trait bound `T: [const] PartialEq` is not satisfied } fn main() {} diff --git a/tests/ui/traits/const-traits/call-generic-method-fail.stderr b/tests/ui/traits/const-traits/call-generic-method-fail.stderr index 6bacb986fef..a2fba141f7b 100644 --- a/tests/ui/traits/const-traits/call-generic-method-fail.stderr +++ b/tests/ui/traits/const-traits/call-generic-method-fail.stderr @@ -1,11 +1,9 @@ -error[E0015]: cannot call non-const operator in constant functions +error[E0277]: the trait bound `T: [const] PartialEq` is not satisfied --> $DIR/call-generic-method-fail.rs:5:5 | LL | *t == *t | ^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/call-generic-method-nonconst.rs b/tests/ui/traits/const-traits/call-generic-method-nonconst.rs index 446a74eb7b7..0efc8a954de 100644 --- a/tests/ui/traits/const-traits/call-generic-method-nonconst.rs +++ b/tests/ui/traits/const-traits/call-generic-method-nonconst.rs @@ -14,7 +14,7 @@ impl Foo for S { } } -const fn equals_self<T: ~const Foo>(t: &T) -> bool { +const fn equals_self<T: [const] Foo>(t: &T) -> bool { true } diff --git a/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr b/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr index 11bbe8bbb40..9c1e0fee9e7 100644 --- a/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr +++ b/tests/ui/traits/const-traits/call-generic-method-nonconst.stderr @@ -9,8 +9,8 @@ LL | pub const EQ: bool = equals_self(&S); note: required by a bound in `equals_self` --> $DIR/call-generic-method-nonconst.rs:17:25 | -LL | const fn equals_self<T: ~const Foo>(t: &T) -> bool { - | ^^^^^^^^^^ required by this bound in `equals_self` +LL | const fn equals_self<T: [const] Foo>(t: &T) -> bool { + | ^^^^^^^^^^^ required by this bound in `equals_self` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/call-generic-method-pass.rs b/tests/ui/traits/const-traits/call-generic-method-pass.rs index af793b8da03..aa52a7b9e47 100644 --- a/tests/ui/traits/const-traits/call-generic-method-pass.rs +++ b/tests/ui/traits/const-traits/call-generic-method-pass.rs @@ -1,8 +1,7 @@ //! Basic test for calling methods on generic type parameters in `const fn`. //@ compile-flags: -Znext-solver -//@ known-bug: #110395 -// FIXME(const_trait_impl) check-pass +//@ check-pass #![feature(const_trait_impl)] @@ -17,7 +16,7 @@ impl const PartialEq for S { } } -const fn equals_self<T: ~const PartialEq>(t: &T) -> bool { +const fn equals_self<T: [const] PartialEq>(t: &T) -> bool { *t == *t } diff --git a/tests/ui/traits/const-traits/call-generic-method-pass.stderr b/tests/ui/traits/const-traits/call-generic-method-pass.stderr deleted file mode 100644 index 1a33ff5ab45..00000000000 --- a/tests/ui/traits/const-traits/call-generic-method-pass.stderr +++ /dev/null @@ -1,47 +0,0 @@ -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/call-generic-method-pass.rs:11:12 - | -LL | impl const PartialEq for S { - | ^^^^^^^^^ this trait is not `const` - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-method-pass.rs:20:25 - | -LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/call-generic-method-pass.rs:20:25 - | -LL | const fn equals_self<T: ~const PartialEq>(t: &T) -> bool { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/call-generic-method-pass.rs:21:5 - | -LL | *t == *t - | ^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const method `<S as PartialEq>::eq` in constant functions - --> $DIR/call-generic-method-pass.rs:16:15 - | -LL | !self.eq(other) - | ^^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 5 previous errors - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/tilde-const-and-const-params.rs b/tests/ui/traits/const-traits/conditionally-const-and-const-params.rs index 428223d92c0..29553884b21 100644 --- a/tests/ui/traits/const-traits/tilde-const-and-const-params.rs +++ b/tests/ui/traits/const-traits/conditionally-const-and-const-params.rs @@ -5,8 +5,8 @@ struct Foo<const N: usize>; impl<const N: usize> Foo<N> { - fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> { - //~^ ERROR `~const` is not allowed here + fn add<A: [const] Add42>(self) -> Foo<{ A::add(N) }> { + //~^ ERROR `[const]` is not allowed here //~| ERROR the trait bound `A: const Add42` is not satisfied Foo } @@ -23,8 +23,8 @@ impl const Add42 for () { } } -fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { - //~^ ERROR `~const` is not allowed here +fn bar<A: [const] Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { + //~^ ERROR `[const]` is not allowed here //~| ERROR the trait bound `A: const Add42` is not satisfied Foo } diff --git a/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr b/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr new file mode 100644 index 00000000000..ebd816ac9a5 --- /dev/null +++ b/tests/ui/traits/const-traits/conditionally-const-and-const-params.stderr @@ -0,0 +1,39 @@ +error: `[const]` is not allowed here + --> $DIR/conditionally-const-and-const-params.rs:8:15 + | +LL | fn add<A: [const] Add42>(self) -> Foo<{ A::add(N) }> { + | ^^^^^^^ + | +note: this function is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-and-const-params.rs:8:8 + | +LL | fn add<A: [const] Add42>(self) -> Foo<{ A::add(N) }> { + | ^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-and-const-params.rs:26:11 + | +LL | fn bar<A: [const] Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { + | ^^^^^^^ + | +note: this function is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-and-const-params.rs:26:4 + | +LL | fn bar<A: [const] Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { + | ^^^ + +error[E0277]: the trait bound `A: const Add42` is not satisfied + --> $DIR/conditionally-const-and-const-params.rs:26:62 + | +LL | fn bar<A: [const] Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { + | ^ + +error[E0277]: the trait bound `A: const Add42` is not satisfied + --> $DIR/conditionally-const-and-const-params.rs:8:45 + | +LL | fn add<A: [const] Add42>(self) -> Foo<{ A::add(N) }> { + | ^ + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/tilde-const-assoc-fn-in-trait-impl.rs b/tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs index 73b2bdc4e3f..7f01c0b7a5c 100644 --- a/tests/ui/traits/const-traits/tilde-const-assoc-fn-in-trait-impl.rs +++ b/tests/ui/traits/const-traits/conditionally-const-assoc-fn-in-trait-impl.rs @@ -5,11 +5,11 @@ #[const_trait] trait Main { - fn compute<T: ~const Aux>() -> u32; + fn compute<T: [const] Aux>() -> u32; } impl const Main for () { - fn compute<T: ~const Aux>() -> u32 { + fn compute<T: [const] Aux>() -> u32 { T::generate() } } diff --git a/tests/ui/traits/const-traits/tilde-const-in-struct-args.rs b/tests/ui/traits/const-traits/conditionally-const-in-struct-args.rs index e7ec3d31eb9..0c644694585 100644 --- a/tests/ui/traits/const-traits/tilde-const-in-struct-args.rs +++ b/tests/ui/traits/const-traits/conditionally-const-in-struct-args.rs @@ -11,7 +11,7 @@ trait Trait<const N: u32> {} const fn f< T: Trait< { - struct I<U: ~const Trait<0>>(U); + struct I<U: [const] Trait<0>>(U); 0 }, >, diff --git a/tests/ui/traits/const-traits/tilde-const-inherent-assoc-const-fn.rs b/tests/ui/traits/const-traits/conditionally-const-inherent-assoc-const-fn.rs index 0e010695587..56478a6674b 100644 --- a/tests/ui/traits/const-traits/tilde-const-inherent-assoc-const-fn.rs +++ b/tests/ui/traits/const-traits/conditionally-const-inherent-assoc-const-fn.rs @@ -10,7 +10,7 @@ trait Foo { struct Bar<T>(T); impl<T> Bar<T> { - const fn foo(&self) where T: ~const Foo { + const fn foo(&self) where T: [const] Foo { self.0.foo() } } diff --git a/tests/ui/traits/const-traits/conditionally-const-invalid-places.rs b/tests/ui/traits/const-traits/conditionally-const-invalid-places.rs new file mode 100644 index 00000000000..52627004fb2 --- /dev/null +++ b/tests/ui/traits/const-traits/conditionally-const-invalid-places.rs @@ -0,0 +1,61 @@ +#![feature(const_trait_impl)] + +#[const_trait] +trait Trait {} + +// Regression test for issue #90052. +fn non_const_function<T: [const] Trait>() {} //~ ERROR `[const]` is not allowed + +struct Struct<T: [const] Trait> { field: T } //~ ERROR `[const]` is not allowed here +struct TupleStruct<T: [const] Trait>(T); //~ ERROR `[const]` is not allowed here +struct UnitStruct<T: [const] Trait>; //~ ERROR `[const]` is not allowed here +//~^ ERROR parameter `T` is never used + +enum Enum<T: [const] Trait> { Variant(T) } //~ ERROR `[const]` is not allowed here + +union Union<T: [const] Trait> { field: T } //~ ERROR `[const]` is not allowed here +//~^ ERROR field must implement `Copy` + +type Type<T: [const] Trait> = T; //~ ERROR `[const]` is not allowed here + +const CONSTANT<T: [const] Trait>: () = (); //~ ERROR `[const]` is not allowed here +//~^ ERROR generic const items are experimental + +trait NonConstTrait { + type Type<T: [const] Trait>: [const] Trait; + //~^ ERROR `[const]` is not allowed + //~| ERROR `[const]` is not allowed + fn non_const_function<T: [const] Trait>(); //~ ERROR `[const]` is not allowed + const CONSTANT<T: [const] Trait>: (); //~ ERROR `[const]` is not allowed + //~^ ERROR generic const items are experimental +} + +impl NonConstTrait for () { + type Type<T: [const] Trait> = (); //~ ERROR `[const]` is not allowed + //~^ ERROR overflow evaluating the requirement `(): Trait` + fn non_const_function<T: [const] Trait>() {} //~ ERROR `[const]` is not allowed + const CONSTANT<T: [const] Trait>: () = (); //~ ERROR `[const]` is not allowed + //~^ ERROR generic const items are experimental +} + +struct Implementor; + +impl Implementor { + type Type<T: [const] Trait> = (); //~ ERROR `[const]` is not allowed + //~^ ERROR inherent associated types are unstable + fn non_const_function<T: [const] Trait>() {} //~ ERROR `[const]` is not allowed + const CONSTANT<T: [const] Trait>: () = (); //~ ERROR `[const]` is not allowed + //~^ ERROR generic const items are experimental +} + +// non-const traits +trait Child0: [const] Trait {} //~ ERROR `[const]` is not allowed +trait Child1 where Self: [const] Trait {} //~ ERROR `[const]` is not allowed + +// non-const impl +impl<T: [const] Trait> Trait for T {} //~ ERROR `[const]` is not allowed + +// inherent impl (regression test for issue #117004) +impl<T: [const] Trait> Struct<T> {} //~ ERROR `[const]` is not allowed + +fn main() {} diff --git a/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr b/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr new file mode 100644 index 00000000000..d0dd9502915 --- /dev/null +++ b/tests/ui/traits/const-traits/conditionally-const-invalid-places.stderr @@ -0,0 +1,310 @@ +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:7:26 + | +LL | fn non_const_function<T: [const] Trait>() {} + | ^^^^^^^ + | +note: this function is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:7:4 + | +LL | fn non_const_function<T: [const] Trait>() {} + | ^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:9:18 + | +LL | struct Struct<T: [const] Trait> { field: T } + | ^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:10:23 + | +LL | struct TupleStruct<T: [const] Trait>(T); + | ^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:11:22 + | +LL | struct UnitStruct<T: [const] Trait>; + | ^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:14:14 + | +LL | enum Enum<T: [const] Trait> { Variant(T) } + | ^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:16:16 + | +LL | union Union<T: [const] Trait> { field: T } + | ^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:19:14 + | +LL | type Type<T: [const] Trait> = T; + | ^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:21:19 + | +LL | const CONSTANT<T: [const] Trait>: () = (); + | ^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:25:18 + | +LL | type Type<T: [const] Trait>: [const] Trait; + | ^^^^^^^ + | +note: associated types in non-`#[const_trait]` traits cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:25:5 + | +LL | type Type<T: [const] Trait>: [const] Trait; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:25:34 + | +LL | type Type<T: [const] Trait>: [const] Trait; + | ^^^^^^^ + | +note: associated types in non-`#[const_trait]` traits cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:25:5 + | +LL | type Type<T: [const] Trait>: [const] Trait; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:28:30 + | +LL | fn non_const_function<T: [const] Trait>(); + | ^^^^^^^ + | +note: this function is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:28:8 + | +LL | fn non_const_function<T: [const] Trait>(); + | ^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:29:23 + | +LL | const CONSTANT<T: [const] Trait>: (); + | ^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:34:18 + | +LL | type Type<T: [const] Trait> = (); + | ^^^^^^^ + | +note: associated types in non-const impls cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:34:5 + | +LL | type Type<T: [const] Trait> = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:36:30 + | +LL | fn non_const_function<T: [const] Trait>() {} + | ^^^^^^^ + | +note: this function is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:36:8 + | +LL | fn non_const_function<T: [const] Trait>() {} + | ^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:37:23 + | +LL | const CONSTANT<T: [const] Trait>: () = (); + | ^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:44:18 + | +LL | type Type<T: [const] Trait> = (); + | ^^^^^^^ + | +note: inherent associated types cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:44:5 + | +LL | type Type<T: [const] Trait> = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:46:30 + | +LL | fn non_const_function<T: [const] Trait>() {} + | ^^^^^^^ + | +note: this function is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:46:8 + | +LL | fn non_const_function<T: [const] Trait>() {} + | ^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:47:23 + | +LL | const CONSTANT<T: [const] Trait>: () = (); + | ^^^^^^^ + | + = note: this item cannot have `[const]` trait bounds + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:52:15 + | +LL | trait Child0: [const] Trait {} + | ^^^^^^^ + | +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:52:1 + | +LL | trait Child0: [const] Trait {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:53:26 + | +LL | trait Child1 where Self: [const] Trait {} + | ^^^^^^^ + | +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:53:1 + | +LL | trait Child1 where Self: [const] Trait {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:56:9 + | +LL | impl<T: [const] Trait> Trait for T {} + | ^^^^^^^ + | +note: this impl is not `const`, so it cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:56:1 + | +LL | impl<T: [const] Trait> Trait for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: `[const]` is not allowed here + --> $DIR/conditionally-const-invalid-places.rs:59:9 + | +LL | impl<T: [const] Trait> Struct<T> {} + | ^^^^^^^ + | +note: inherent impls cannot have `[const]` trait bounds + --> $DIR/conditionally-const-invalid-places.rs:59:1 + | +LL | impl<T: [const] Trait> Struct<T> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error[E0658]: generic const items are experimental + --> $DIR/conditionally-const-invalid-places.rs:21:15 + | +LL | const CONSTANT<T: [const] Trait>: () = (); + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information + = help: add `#![feature(generic_const_items)]` 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]: generic const items are experimental + --> $DIR/conditionally-const-invalid-places.rs:29:19 + | +LL | const CONSTANT<T: [const] Trait>: (); + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information + = help: add `#![feature(generic_const_items)]` 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]: generic const items are experimental + --> $DIR/conditionally-const-invalid-places.rs:37:19 + | +LL | const CONSTANT<T: [const] Trait>: () = (); + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information + = help: add `#![feature(generic_const_items)]` 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]: generic const items are experimental + --> $DIR/conditionally-const-invalid-places.rs:47:19 + | +LL | const CONSTANT<T: [const] Trait>: () = (); + | ^^^^^^^^^^^^^^^^^^ + | + = note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information + = help: add `#![feature(generic_const_items)]` 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[E0392]: type parameter `T` is never used + --> $DIR/conditionally-const-invalid-places.rs:11:19 + | +LL | struct UnitStruct<T: [const] Trait>; + | ^ unused type parameter + | + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` + +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/conditionally-const-invalid-places.rs:16:33 + | +LL | union Union<T: [const] Trait> { field: T } + | ^^^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | union Union<T: [const] Trait> { field: std::mem::ManuallyDrop<T> } + | +++++++++++++++++++++++ + + +error[E0275]: overflow evaluating the requirement `(): Trait` + --> $DIR/conditionally-const-invalid-places.rs:34:35 + | +LL | type Type<T: [const] Trait> = (); + | ^^ + | +note: required by a bound in `NonConstTrait::Type` + --> $DIR/conditionally-const-invalid-places.rs:25:34 + | +LL | type Type<T: [const] Trait>: [const] Trait; + | ^^^^^^^^^^^^^ required by this bound in `NonConstTrait::Type` + +error[E0658]: inherent associated types are unstable + --> $DIR/conditionally-const-invalid-places.rs:44:5 + | +LL | type Type<T: [const] Trait> = (); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information + = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 30 previous errors + +Some errors have detailed explanations: E0275, E0392, E0658, E0740. +For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/const-traits/tilde-const-trait-assoc-tys.rs b/tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs index 53ddb5c0cdf..b0bd8466f66 100644 --- a/tests/ui/traits/const-traits/tilde-const-trait-assoc-tys.rs +++ b/tests/ui/traits/const-traits/conditionally-const-trait-bound-assoc-tys.rs @@ -4,11 +4,11 @@ #[const_trait] trait Trait { - type Assoc<T: ~const Bound>; + type Assoc<T: [const] Bound>; } impl const Trait for () { - type Assoc<T: ~const Bound> = T; + type Assoc<T: [const] Bound> = T; } #[const_trait] diff --git a/tests/ui/traits/const-traits/conditionally-const-trait-bound-syntax.rs b/tests/ui/traits/const-traits/conditionally-const-trait-bound-syntax.rs new file mode 100644 index 00000000000..89950c65ef6 --- /dev/null +++ b/tests/ui/traits/const-traits/conditionally-const-trait-bound-syntax.rs @@ -0,0 +1,9 @@ +//@ compile-flags: -Z parse-crate-root-only +//@ check-pass + +#![feature(const_trait_impl)] + +struct S< + T: for<'a> [const] Tr<'a> + 'static + [const] std::ops::Add, + T: for<'a: 'b> [const] m::Trait<'a>, +>; diff --git a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs index c735f855bce..94111272708 100644 --- a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs +++ b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.rs @@ -8,8 +8,8 @@ trait MyTrait { } trait OtherTrait { - fn do_something_else() where Self: ~const MyTrait; - //~^ ERROR `~const` is not allowed here + fn do_something_else() where Self: [const] MyTrait; + //~^ ERROR `[const]` is not allowed here } struct MyStruct<T>(T); @@ -19,8 +19,8 @@ impl const MyTrait for u32 { } impl<T> MyStruct<T> { - pub fn foo(&self) where T: ~const MyTrait { - //~^ ERROR `~const` is not allowed here + pub fn foo(&self) where T: [const] MyTrait { + //~^ ERROR `[const]` is not allowed here self.0.do_something(); } } diff --git a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr index 50ab52ade49..901c2cbd8a7 100644 --- a/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr +++ b/tests/ui/traits/const-traits/const-bound-on-not-const-associated-fn.stderr @@ -1,25 +1,25 @@ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> $DIR/const-bound-on-not-const-associated-fn.rs:11:40 | -LL | fn do_something_else() where Self: ~const MyTrait; - | ^^^^^^ +LL | fn do_something_else() where Self: [const] MyTrait; + | ^^^^^^^ | -note: this function is not `const`, so it cannot have `~const` trait bounds +note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/const-bound-on-not-const-associated-fn.rs:11:8 | -LL | fn do_something_else() where Self: ~const MyTrait; +LL | fn do_something_else() where Self: [const] MyTrait; | ^^^^^^^^^^^^^^^^^ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> $DIR/const-bound-on-not-const-associated-fn.rs:22:32 | -LL | pub fn foo(&self) where T: ~const MyTrait { - | ^^^^^^ +LL | pub fn foo(&self) where T: [const] MyTrait { + | ^^^^^^^ | -note: this function is not `const`, so it cannot have `~const` trait bounds +note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/const-bound-on-not-const-associated-fn.rs:22:12 | -LL | pub fn foo(&self) where T: ~const MyTrait { +LL | pub fn foo(&self) where T: [const] MyTrait { | ^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/const-bounds-non-const-trait.rs b/tests/ui/traits/const-traits/const-bounds-non-const-trait.rs index e446eb15481..ae31d9ae0ac 100644 --- a/tests/ui/traits/const-traits/const-bounds-non-const-trait.rs +++ b/tests/ui/traits/const-traits/const-bounds-non-const-trait.rs @@ -3,9 +3,9 @@ trait NonConst {} -const fn perform<T: ~const NonConst>() {} -//~^ ERROR `~const` can only be applied to `#[const_trait]` traits -//~| ERROR `~const` can only be applied to `#[const_trait]` traits +const fn perform<T: [const] NonConst>() {} +//~^ ERROR `[const]` can only be applied to `#[const_trait]` traits +//~| ERROR `[const]` can only be applied to `#[const_trait]` traits fn operate<T: const NonConst>() {} //~^ ERROR `const` can only be applied to `#[const_trait]` traits diff --git a/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr b/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr index f97d3a9181e..6c68e4ec3ac 100644 --- a/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr +++ b/tests/ui/traits/const-traits/const-bounds-non-const-trait.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-bounds-non-const-trait.rs:6:21 | -LL | const fn perform<T: ~const NonConst>() {} - | ^^^^^^ can't be applied to `NonConst` +LL | const fn perform<T: [const] NonConst>() {} + | ^^^^^^^ can't be applied to `NonConst` | help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations | LL | #[const_trait] trait NonConst {} | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-bounds-non-const-trait.rs:6:21 | -LL | const fn perform<T: ~const NonConst>() {} - | ^^^^^^ can't be applied to `NonConst` +LL | const fn perform<T: [const] NonConst>() {} + | ^^^^^^^ can't be applied to `NonConst` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `NonConst` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/const-closure-parse-not-item.rs b/tests/ui/traits/const-traits/const-closure-parse-not-item.rs index b1b0e68b90d..35127eda5c0 100644 --- a/tests/ui/traits/const-traits/const-closure-parse-not-item.rs +++ b/tests/ui/traits/const-traits/const-closure-parse-not-item.rs @@ -4,7 +4,7 @@ #![feature(const_trait_impl, const_closures)] #![allow(incomplete_features)] -const fn test() -> impl ~const Fn() { +const fn test() -> impl [const] Fn() { const move || {} } diff --git a/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr b/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr index 57afa2257b7..fdfe3b95d55 100644 --- a/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr +++ b/tests/ui/traits/const-traits/const-closure-parse-not-item.stderr @@ -1,29 +1,29 @@ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closure-parse-not-item.rs:7:25 | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^ can't be applied to `Fn` +LL | const fn test() -> impl [const] Fn() { + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closure-parse-not-item.rs:7:25 | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^ can't be applied to `Fn` +LL | const fn test() -> impl [const] Fn() { + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closure-parse-not-item.rs:7:25 | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^ can't be applied to `Fn` +LL | const fn test() -> impl [const] Fn() { + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/traits/const-traits/const-closure-trait-method-fail.rs b/tests/ui/traits/const-traits/const-closure-trait-method-fail.rs index 8c6286426d3..cbcc4aa7c3c 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method-fail.rs +++ b/tests/ui/traits/const-traits/const-closure-trait-method-fail.rs @@ -11,7 +11,7 @@ impl Tr for () { fn a(self) -> i32 { 42 } } -const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 { +const fn need_const_closure<T: [const] FnOnce(()) -> i32>(x: T) -> i32 { x(()) } diff --git a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr index 2a97846ccb4..89b202b3438 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr +++ b/tests/ui/traits/const-traits/const-closure-trait-method-fail.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closure-trait-method-fail.rs:14:32 | -LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 { - | ^^^^^^ can't be applied to `FnOnce` +LL | const fn need_const_closure<T: [const] FnOnce(()) -> i32>(x: T) -> i32 { + | ^^^^^^^ can't be applied to `FnOnce` | -note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closure-trait-method-fail.rs:14:32 | -LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 { - | ^^^^^^ can't be applied to `FnOnce` +LL | const fn need_const_closure<T: [const] FnOnce(()) -> i32>(x: T) -> i32 { + | ^^^^^^^ can't be applied to `FnOnce` | -note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/traits/const-traits/const-closure-trait-method.rs b/tests/ui/traits/const-traits/const-closure-trait-method.rs index ebee4daefbe..831d6e27946 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method.rs +++ b/tests/ui/traits/const-traits/const-closure-trait-method.rs @@ -11,7 +11,7 @@ impl const Tr for () { fn a(self) -> i32 { 42 } } -const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 { +const fn need_const_closure<T: [const] FnOnce(()) -> i32>(x: T) -> i32 { x(()) } diff --git a/tests/ui/traits/const-traits/const-closure-trait-method.stderr b/tests/ui/traits/const-traits/const-closure-trait-method.stderr index 9c63b7e63a6..6de25dc11ef 100644 --- a/tests/ui/traits/const-traits/const-closure-trait-method.stderr +++ b/tests/ui/traits/const-traits/const-closure-trait-method.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closure-trait-method.rs:14:32 | -LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 { - | ^^^^^^ can't be applied to `FnOnce` +LL | const fn need_const_closure<T: [const] FnOnce(()) -> i32>(x: T) -> i32 { + | ^^^^^^^ can't be applied to `FnOnce` | -note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closure-trait-method.rs:14:32 | -LL | const fn need_const_closure<T: ~const FnOnce(()) -> i32>(x: T) -> i32 { - | ^^^^^^ can't be applied to `FnOnce` +LL | const fn need_const_closure<T: [const] FnOnce(()) -> i32>(x: T) -> i32 { + | ^^^^^^^ can't be applied to `FnOnce` | -note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/traits/const-traits/const-closures.rs b/tests/ui/traits/const-traits/const-closures.rs index 98f8d039cd6..2f6f4dc4ba3 100644 --- a/tests/ui/traits/const-traits/const-closures.rs +++ b/tests/ui/traits/const-traits/const-closures.rs @@ -5,9 +5,9 @@ const fn answer_p1<F>(f: &F) -> u8 where - F: ~const FnOnce() -> u8, - F: ~const FnMut() -> u8, - F: ~const Fn() -> u8, + F: [const] FnOnce() -> u8, + F: [const] FnMut() -> u8, + F: [const] Fn() -> u8, { f() * 7 } @@ -20,7 +20,7 @@ const fn answer_p2() -> u8 { answer_p1(&three) } -const fn answer<F: ~const Fn() -> u8>(f: &F) -> u8 { +const fn answer<F: [const] Fn() -> u8>(f: &F) -> u8 { f() + f() } diff --git a/tests/ui/traits/const-traits/const-closures.stderr b/tests/ui/traits/const-traits/const-closures.stderr index 92f3ba20820..19869b47085 100644 --- a/tests/ui/traits/const-traits/const-closures.stderr +++ b/tests/ui/traits/const-traits/const-closures.stderr @@ -1,76 +1,76 @@ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closures.rs:8:12 | -LL | F: ~const FnOnce() -> u8, - | ^^^^^^ can't be applied to `FnOnce` +LL | F: [const] FnOnce() -> u8, + | ^^^^^^^ can't be applied to `FnOnce` | -note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closures.rs:9:12 | -LL | F: ~const FnMut() -> u8, - | ^^^^^^ can't be applied to `FnMut` +LL | F: [const] FnMut() -> u8, + | ^^^^^^^ can't be applied to `FnMut` | -note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closures.rs:10:12 | -LL | F: ~const Fn() -> u8, - | ^^^^^^ can't be applied to `Fn` +LL | F: [const] Fn() -> u8, + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closures.rs:8:12 | -LL | F: ~const FnOnce() -> u8, - | ^^^^^^ can't be applied to `FnOnce` +LL | F: [const] FnOnce() -> u8, + | ^^^^^^^ can't be applied to `FnOnce` | -note: `FnOnce` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnOnce` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closures.rs:9:12 | -LL | F: ~const FnMut() -> u8, - | ^^^^^^ can't be applied to `FnMut` +LL | F: [const] FnMut() -> u8, + | ^^^^^^^ can't be applied to `FnMut` | -note: `FnMut` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `FnMut` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closures.rs:10:12 | -LL | F: ~const Fn() -> u8, - | ^^^^^^ can't be applied to `Fn` +LL | F: [const] Fn() -> u8, + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closures.rs:23:20 | -LL | const fn answer<F: ~const Fn() -> u8>(f: &F) -> u8 { - | ^^^^^^ can't be applied to `Fn` +LL | const fn answer<F: [const] Fn() -> u8>(f: &F) -> u8 { + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/const-closures.rs:23:20 | -LL | const fn answer<F: ~const Fn() -> u8>(f: &F) -> u8 { - | ^^^^^^ can't be applied to `Fn` +LL | const fn answer<F: [const] Fn() -> u8>(f: &F) -> u8 { + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/traits/const-traits/const-cond-for-rpitit.rs b/tests/ui/traits/const-traits/const-cond-for-rpitit.rs index 50bf93f9a03..da83e054dd9 100644 --- a/tests/ui/traits/const-traits/const-cond-for-rpitit.rs +++ b/tests/ui/traits/const-traits/const-cond-for-rpitit.rs @@ -6,15 +6,15 @@ #[const_trait] pub trait Foo { - fn method(self) -> impl ~const Bar; + fn method(self) -> impl [const] Bar; } #[const_trait] pub trait Bar {} struct A<T>(T); -impl<T> const Foo for A<T> where A<T>: ~const Bar { - fn method(self) -> impl ~const Bar { +impl<T> const Foo for A<T> where A<T>: [const] Bar { + fn method(self) -> impl [const] Bar { self } } diff --git a/tests/ui/traits/const-traits/const-default-method-bodies.rs b/tests/ui/traits/const-traits/const-default-method-bodies.rs index 0ef11a7f0c9..27e828c7ab9 100644 --- a/tests/ui/traits/const-traits/const-default-method-bodies.rs +++ b/tests/ui/traits/const-traits/const-default-method-bodies.rs @@ -23,7 +23,7 @@ impl const ConstDefaultFn for ConstImpl { const fn test() { NonConstImpl.a(); - //~^ ERROR the trait bound `NonConstImpl: ~const ConstDefaultFn` is not satisfied + //~^ ERROR the trait bound `NonConstImpl: [const] ConstDefaultFn` is not satisfied ConstImpl.a(); } diff --git a/tests/ui/traits/const-traits/const-default-method-bodies.stderr b/tests/ui/traits/const-traits/const-default-method-bodies.stderr index 903f7d37f9d..03ca6f1d511 100644 --- a/tests/ui/traits/const-traits/const-default-method-bodies.stderr +++ b/tests/ui/traits/const-traits/const-default-method-bodies.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `NonConstImpl: ~const ConstDefaultFn` is not satisfied +error[E0277]: the trait bound `NonConstImpl: [const] ConstDefaultFn` is not satisfied --> $DIR/const-default-method-bodies.rs:25:18 | LL | NonConstImpl.a(); diff --git a/tests/ui/traits/const-traits/const-drop-bound.rs b/tests/ui/traits/const-traits/const-drop-bound.rs index 4819da7c3a4..7fa9b10fa04 100644 --- a/tests/ui/traits/const-traits/const-drop-bound.rs +++ b/tests/ui/traits/const-traits/const-drop-bound.rs @@ -5,7 +5,7 @@ use std::marker::Destruct; -const fn foo<T, E>(res: Result<T, E>) -> Option<T> where E: ~const Destruct { +const fn foo<T, E>(res: Result<T, E>) -> Option<T> where E: [const] Destruct { match res { Ok(t) => Some(t), Err(_e) => None, @@ -16,8 +16,8 @@ pub struct Foo<T>(T); const fn baz<T, E>(res: Result<Foo<T>, Foo<E>>) -> Option<Foo<T>> where - T: ~const Destruct, - E: ~const Destruct, + T: [const] Destruct, + E: [const] Destruct, { foo(res) } diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr b/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr index 76207ea0939..c2309ea6e12 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail-2.precise.stderr @@ -5,17 +5,17 @@ LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: required for `ConstDropImplWithBounds<NonTrivialDrop>` to implement `const Drop` - --> $DIR/const-drop-fail-2.rs:25:25 + --> $DIR/const-drop-fail-2.rs:25:26 | -LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { - | -------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl<T: [const] A> const Drop for ConstDropImplWithBounds<T> { + | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | unsatisfied trait bound introduced here note: required by a bound in `check` --> $DIR/const-drop-fail-2.rs:21:19 | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check<T: [const] Destruct>(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.rs b/tests/ui/traits/const-traits/const-drop-fail-2.rs index 1bcc87e9070..3f98a9f715e 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.rs +++ b/tests/ui/traits/const-traits/const-drop-fail-2.rs @@ -18,11 +18,11 @@ trait A { fn a() { } } impl A for NonTrivialDrop {} -const fn check<T: ~const Destruct>(_: T) {} +const fn check<T: [const] Destruct>(_: T) {} struct ConstDropImplWithBounds<T: A>(PhantomData<T>); -impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { +impl<T: [const] A> const Drop for ConstDropImplWithBounds<T> { fn drop(&mut self) { T::a(); } @@ -35,7 +35,7 @@ const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( struct ConstDropImplWithNonConstBounds<T: A>(PhantomData<T>); -impl<T: ~const A> const Drop for ConstDropImplWithNonConstBounds<T> { +impl<T: [const] A> const Drop for ConstDropImplWithNonConstBounds<T> { fn drop(&mut self) { T::a(); } diff --git a/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr b/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr index 76207ea0939..c2309ea6e12 100644 --- a/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail-2.stock.stderr @@ -5,17 +5,17 @@ LL | const _: () = check::<ConstDropImplWithBounds<NonTrivialDrop>>( | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | note: required for `ConstDropImplWithBounds<NonTrivialDrop>` to implement `const Drop` - --> $DIR/const-drop-fail-2.rs:25:25 + --> $DIR/const-drop-fail-2.rs:25:26 | -LL | impl<T: ~const A> const Drop for ConstDropImplWithBounds<T> { - | -------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | impl<T: [const] A> const Drop for ConstDropImplWithBounds<T> { + | --------- ^^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^ | | | unsatisfied trait bound introduced here note: required by a bound in `check` --> $DIR/const-drop-fail-2.rs:21:19 | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check<T: [const] Destruct>(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr b/tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr index f38e642bb63..9c49ee56b0f 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail.new_precise.stderr @@ -10,8 +10,8 @@ LL | NonTrivialDrop, note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check<T: [const] Destruct>(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied --> $DIR/const-drop-fail.rs:35:5 @@ -25,8 +25,8 @@ LL | ConstImplWithDropGlue(NonTrivialDrop), note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check<T: [const] Destruct>(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr b/tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr index f38e642bb63..9c49ee56b0f 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail.new_stock.stderr @@ -10,8 +10,8 @@ LL | NonTrivialDrop, note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check<T: [const] Destruct>(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied --> $DIR/const-drop-fail.rs:35:5 @@ -25,8 +25,8 @@ LL | ConstImplWithDropGlue(NonTrivialDrop), note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check<T: [const] Destruct>(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr b/tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr index f38e642bb63..9c49ee56b0f 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail.old_precise.stderr @@ -10,8 +10,8 @@ LL | NonTrivialDrop, note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check<T: [const] Destruct>(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied --> $DIR/const-drop-fail.rs:35:5 @@ -25,8 +25,8 @@ LL | ConstImplWithDropGlue(NonTrivialDrop), note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check<T: [const] Destruct>(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr b/tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr index f38e642bb63..9c49ee56b0f 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr +++ b/tests/ui/traits/const-traits/const-drop-fail.old_stock.stderr @@ -10,8 +10,8 @@ LL | NonTrivialDrop, note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check<T: [const] Destruct>(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error[E0277]: the trait bound `NonTrivialDrop: const Destruct` is not satisfied --> $DIR/const-drop-fail.rs:35:5 @@ -25,8 +25,8 @@ LL | ConstImplWithDropGlue(NonTrivialDrop), note: required by a bound in `check` --> $DIR/const-drop-fail.rs:24:19 | -LL | const fn check<T: ~const Destruct>(_: T) {} - | ^^^^^^^^^^^^^^^ required by this bound in `check` +LL | const fn check<T: [const] Destruct>(_: T) {} + | ^^^^^^^^^^^^^^^^ required by this bound in `check` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/const-drop-fail.rs b/tests/ui/traits/const-traits/const-drop-fail.rs index a7f3d5654de..4513d71f613 100644 --- a/tests/ui/traits/const-traits/const-drop-fail.rs +++ b/tests/ui/traits/const-traits/const-drop-fail.rs @@ -21,7 +21,7 @@ impl const Drop for ConstImplWithDropGlue { fn drop(&mut self) {} } -const fn check<T: ~const Destruct>(_: T) {} +const fn check<T: [const] Destruct>(_: T) {} macro_rules! check_all { ($($exp:expr),*$(,)?) => {$( diff --git a/tests/ui/traits/const-traits/const-drop.rs b/tests/ui/traits/const-traits/const-drop.rs index e2d87aeff47..5df3a77f73a 100644 --- a/tests/ui/traits/const-traits/const-drop.rs +++ b/tests/ui/traits/const-traits/const-drop.rs @@ -16,7 +16,7 @@ impl<'a> const Drop for S<'a> { } } -const fn a<T: ~const Destruct>(_: T) {} +const fn a<T: [const] Destruct>(_: T) {} //FIXME ~^ ERROR destructor of const fn b() -> u8 { @@ -108,7 +108,7 @@ fn main() { } } - // These types should pass because ~const in a non-const context should have no effect. + // These types should pass because [const] in a non-const context should have no effect. a(HasDropGlue(Box::new(0))); a(HasDropImpl); diff --git a/tests/ui/traits/const-traits/const-impl-trait.rs b/tests/ui/traits/const-traits/const-impl-trait.rs index d7fe43ef37c..dc960422a4a 100644 --- a/tests/ui/traits/const-traits/const-impl-trait.rs +++ b/tests/ui/traits/const-traits/const-impl-trait.rs @@ -8,23 +8,23 @@ use std::marker::Destruct; -const fn cmp(a: &impl ~const PartialEq) -> bool { +const fn cmp(a: &impl [const] PartialEq) -> bool { a == a } const fn wrap( - x: impl ~const PartialEq + ~const Destruct, -) -> impl ~const PartialEq + ~const Destruct { + x: impl [const] PartialEq + [const] Destruct, +) -> impl [const] PartialEq + [const] Destruct { x } #[const_trait] trait Foo { - fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; + fn huh() -> impl [const] PartialEq + [const] Destruct + Copy; } impl const Foo for () { - fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { + fn huh() -> impl [const] PartialEq + [const] Destruct + Copy { 123 } } @@ -43,16 +43,16 @@ trait T {} struct S; impl const T for S {} -const fn rpit() -> impl ~const T { +const fn rpit() -> impl [const] T { S } -const fn apit(_: impl ~const T + ~const Destruct) {} +const fn apit(_: impl [const] T + [const] Destruct) {} -const fn rpit_assoc_bound() -> impl IntoIterator<Item: ~const T> { +const fn rpit_assoc_bound() -> impl IntoIterator<Item: [const] T> { Some(S) } -const fn apit_assoc_bound(_: impl IntoIterator<Item: ~const T> + ~const Destruct) {} +const fn apit_assoc_bound(_: impl IntoIterator<Item: [const] T> + [const] Destruct) {} fn main() {} diff --git a/tests/ui/traits/const-traits/const-impl-trait.stderr b/tests/ui/traits/const-traits/const-impl-trait.stderr index 6783cec3960..cbb68d8c983 100644 --- a/tests/ui/traits/const-traits/const-impl-trait.stderr +++ b/tests/ui/traits/const-traits/const-impl-trait.stderr @@ -1,197 +1,17 @@ -error[E0635]: unknown feature `const_cmp` - --> $DIR/const-impl-trait.rs:7:30 +error[E0277]: the trait bound `(): const PartialEq` is not satisfied + --> $DIR/const-impl-trait.rs:34:17 | -LL | #![feature(const_trait_impl, const_cmp, const_destruct)] - | ^^^^^^^^^ - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:11:23 +LL | assert!(cmp(&())); + | --- ^^^ + | | + | required by a bound introduced by this call | -LL | const fn cmp(a: &impl ~const PartialEq) -> bool { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - -error: `~const` can only be applied to `#[const_trait]` traits +note: required by a bound in `cmp` --> $DIR/const-impl-trait.rs:11:23 | -LL | const fn cmp(a: &impl ~const PartialEq) -> bool { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:16:13 - | -LL | x: impl ~const PartialEq + ~const Destruct, - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:16:13 - | -LL | x: impl ~const PartialEq + ~const Destruct, - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:17:11 - | -LL | ) -> impl ~const PartialEq + ~const Destruct { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:17:11 - | -LL | ) -> impl ~const PartialEq + ~const Destruct { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:23:22 - | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:27:22 - | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:17:11 - | -LL | ) -> impl ~const PartialEq + ~const Destruct { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:27:22 - | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:27:22 - | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy { - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:23:22 - | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:23:22 - | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:23:22 - | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:23:22 - | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: `~const` can only be applied to `#[const_trait]` traits - --> $DIR/const-impl-trait.rs:23:22 - | -LL | fn huh() -> impl ~const PartialEq + ~const Destruct + Copy; - | ^^^^^^ can't be applied to `PartialEq` - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error[E0015]: cannot call non-const operator in constants - --> $DIR/const-impl-trait.rs:35:13 - | -LL | assert!(wrap(123) == wrap(123)); - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: calls in constants are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const operator in constants - --> $DIR/const-impl-trait.rs:36:13 - | -LL | assert!(wrap(123) != wrap(456)); - | ^^^^^^^^^^^^^^^^^^^^^^ - | - = note: calls in constants are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const operator in constants - --> $DIR/const-impl-trait.rs:38:13 - | -LL | assert!(x == x); - | ^^^^^^ - | - = note: calls in constants are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/const-impl-trait.rs:12:5 - | -LL | a == a - | ^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants +LL | const fn cmp(a: &impl [const] PartialEq) -> bool { + | ^^^^^^^^^^^^^^^^^ required by this bound in `cmp` -error: aborting due to 21 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0015, E0635. -For more information about an error, try `rustc --explain E0015`. +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/const-in-closure.rs b/tests/ui/traits/const-traits/const-in-closure.rs index ebc17a50c86..0657c5af588 100644 --- a/tests/ui/traits/const-traits/const-in-closure.rs +++ b/tests/ui/traits/const-traits/const-in-closure.rs @@ -3,13 +3,14 @@ #![feature(const_trait_impl)] -#[const_trait] trait Trait { +#[const_trait] +trait Trait { fn method(); } const fn foo<T: Trait>() { let _ = || { - // Make sure this doesn't enforce `T: ~const Trait` + // Make sure this doesn't enforce `T: [const] Trait` T::method(); }; } @@ -17,7 +18,9 @@ const fn foo<T: Trait>() { fn bar<T: const Trait>() { let _ = || { // Make sure unconditionally const bounds propagate from parent. - const { T::method(); }; + const { + T::method(); + }; }; } diff --git a/tests/ui/traits/const-traits/const-opaque.no.stderr b/tests/ui/traits/const-traits/const-opaque.no.stderr index 47e692936e0..acf19ba96ab 100644 --- a/tests/ui/traits/const-traits/const-opaque.no.stderr +++ b/tests/ui/traits/const-traits/const-opaque.no.stderr @@ -9,8 +9,8 @@ LL | let opaque = bar(()); note: required by a bound in `bar` --> $DIR/const-opaque.rs:26:17 | -LL | const fn bar<T: ~const Foo>(t: T) -> impl ~const Foo { - | ^^^^^^^^^^ required by this bound in `bar` +LL | const fn bar<T: [const] Foo>(t: T) -> impl [const] Foo { + | ^^^^^^^^^^^ required by this bound in `bar` error[E0277]: the trait bound `(): const Foo` is not satisfied --> $DIR/const-opaque.rs:33:12 diff --git a/tests/ui/traits/const-traits/const-opaque.rs b/tests/ui/traits/const-traits/const-opaque.rs index 96cdd7d9f26..56ebf0aefcc 100644 --- a/tests/ui/traits/const-traits/const-opaque.rs +++ b/tests/ui/traits/const-traits/const-opaque.rs @@ -9,7 +9,7 @@ trait Foo { fn method(&self); } -impl<T: ~const Foo> const Foo for (T,) { +impl<T: [const] Foo> const Foo for (T,) { fn method(&self) {} } @@ -23,7 +23,7 @@ impl Foo for () { fn method(&self) {} } -const fn bar<T: ~const Foo>(t: T) -> impl ~const Foo { +const fn bar<T: [const] Foo>(t: T) -> impl [const] Foo { (t,) } diff --git a/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.rs b/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.rs index 2dac1970835..ece87529c3e 100644 --- a/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.rs +++ b/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.rs @@ -7,12 +7,12 @@ trait Trait {} fn main() { let _: &dyn const Trait; //~ ERROR const trait bounds are not allowed in trait object types - let _: &dyn ~const Trait; //~ ERROR `~const` is not allowed here + let _: &dyn [const] Trait; //~ ERROR `[const]` is not allowed here } // Regression test for issue #119525. trait NonConst {} const fn handle(_: &dyn const NonConst) {} //~^ ERROR const trait bounds are not allowed in trait object types -const fn take(_: &dyn ~const NonConst) {} -//~^ ERROR `~const` is not allowed here +const fn take(_: &dyn [const] NonConst) {} +//~^ ERROR `[const]` is not allowed here diff --git a/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr b/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr index bd29b4b860b..090555c6377 100644 --- a/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr +++ b/tests/ui/traits/const-traits/const-trait-bounds-trait-objects.stderr @@ -4,13 +4,13 @@ error: const trait bounds are not allowed in trait object types LL | let _: &dyn const Trait; | ^^^^^^^^^^^ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> $DIR/const-trait-bounds-trait-objects.rs:10:17 | -LL | let _: &dyn ~const Trait; - | ^^^^^^ +LL | let _: &dyn [const] Trait; + | ^^^^^^^ | - = note: trait objects cannot have `~const` trait bounds + = note: trait objects cannot have `[const]` trait bounds error: const trait bounds are not allowed in trait object types --> $DIR/const-trait-bounds-trait-objects.rs:15:25 @@ -18,13 +18,13 @@ error: const trait bounds are not allowed in trait object types LL | const fn handle(_: &dyn const NonConst) {} | ^^^^^^^^^^^^^^ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> $DIR/const-trait-bounds-trait-objects.rs:17:23 | -LL | const fn take(_: &dyn ~const NonConst) {} - | ^^^^^^ +LL | const fn take(_: &dyn [const] NonConst) {} + | ^^^^^^^ | - = note: trait objects cannot have `~const` trait bounds + = note: trait objects cannot have `[const]` trait bounds error: aborting due to 4 previous errors diff --git a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs index b563b78f78a..5376baf15e0 100644 --- a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs +++ b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.rs @@ -6,14 +6,13 @@ // Regression test for issue #125877. //@ compile-flags: -Znext-solver -//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION" #![feature(const_trait_impl, effects)] //~^ ERROR feature has been removed #[const_trait] trait Main { - fn compute<T: ~const Aux>() -> u32; + fn compute<T: [const] Aux>() -> u32; } impl const Main for () { diff --git a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr index a04f98e68a6..736fde33ce3 100644 --- a/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr +++ b/tests/ui/traits/const-traits/const-trait-impl-parameter-mismatch.stderr @@ -1,16 +1,16 @@ error[E0557]: feature has been removed - --> $DIR/const-trait-impl-parameter-mismatch.rs:11:30 + --> $DIR/const-trait-impl-parameter-mismatch.rs:10:30 | LL | #![feature(const_trait_impl, effects)] | ^^^^^^^ feature has been removed | - = note: removed in 1.84.0 (you are using $RUSTC_VERSION); see <https://github.com/rust-lang/rust/pull/132479> for more information + = note: removed in 1.84.0; see <https://github.com/rust-lang/rust/pull/132479> for more information = note: removed, redundant with `#![feature(const_trait_impl)]` error[E0049]: associated function `compute` has 0 type parameters but its trait declaration has 1 type parameter - --> $DIR/const-trait-impl-parameter-mismatch.rs:20:16 + --> $DIR/const-trait-impl-parameter-mismatch.rs:19:16 | -LL | fn compute<T: ~const Aux>() -> u32; +LL | fn compute<T: [const] Aux>() -> u32; | - expected 1 type parameter ... LL | fn compute<'x>() -> u32 { diff --git a/tests/ui/traits/const-traits/const-via-item-bound.rs b/tests/ui/traits/const-traits/const-via-item-bound.rs new file mode 100644 index 00000000000..23f122b7413 --- /dev/null +++ b/tests/ui/traits/const-traits/const-via-item-bound.rs @@ -0,0 +1,19 @@ +//@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +#![feature(const_trait_impl)] + +#[const_trait] +trait Bar {} + +trait Baz: const Bar {} + +trait Foo { + // Well-formedenss of `Baz` requires `<Self as Foo>::Bar: const Bar`. + // Make sure we assemble a candidate for that via the item bounds. + type Bar: Baz; +} + +fn main() {} diff --git a/tests/ui/traits/const-traits/const_derives/derive-const-use.stderr b/tests/ui/traits/const-traits/const_derives/derive-const-use.stderr index 8297911a3f3..ce61eb9a1ab 100644 --- a/tests/ui/traits/const-traits/const_derives/derive-const-use.stderr +++ b/tests/ui/traits/const-traits/const_derives/derive-const-use.stderr @@ -1,9 +1,3 @@ -error[E0635]: unknown feature `const_cmp` - --> $DIR/derive-const-use.rs:3:30 - | -LL | #![feature(const_trait_impl, const_cmp, const_default_impls, derive_const)] - | ^^^^^^^^^ - error[E0635]: unknown feature `const_default_impls` --> $DIR/derive-const-use.rs:3:41 | @@ -28,23 +22,13 @@ LL | #[derive_const(Default, PartialEq)] = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` = note: adding a non-const method body in the future would be a breaking change -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/derive-const-use.rs:11:12 - | -LL | impl const PartialEq for A { - | ^^^^^^^^^ this trait is not `const` - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/derive-const-use.rs:15:25 +error[E0277]: the trait bound `(): [const] PartialEq` is not satisfied + --> $DIR/derive-const-use.rs:16:14 | LL | #[derive_const(Default, PartialEq)] - | ^^^^^^^^^ this trait is not `const` - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change + | --------- in this derive macro expansion +LL | pub struct S((), A); + | ^^ error[E0015]: cannot call non-const associated function `<S as Default>::default` in constants --> $DIR/derive-const-use.rs:18:35 @@ -54,14 +38,6 @@ LL | const _: () = assert!(S((), A) == S::default()); | = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const operator in constants - --> $DIR/derive-const-use.rs:18:23 - | -LL | const _: () = assert!(S((), A) == S::default()); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: calls in constants are limited to constant functions, tuple structs and tuple variants - error[E0015]: cannot call non-const associated function `<() as Default>::default` in constant functions --> $DIR/derive-const-use.rs:16:14 | @@ -82,27 +58,7 @@ LL | pub struct S((), A); | = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/derive-const-use.rs:16:14 - | -LL | #[derive_const(Default, PartialEq)] - | --------- in this derive macro expansion -LL | pub struct S((), A); - | ^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/derive-const-use.rs:16:18 - | -LL | #[derive_const(Default, PartialEq)] - | --------- in this derive macro expansion -LL | pub struct S((), A); - | ^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 12 previous errors +error: aborting due to 7 previous errors -Some errors have detailed explanations: E0015, E0635. +Some errors have detailed explanations: E0015, E0277, E0635. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/const_derives/derive-const-with-params.rs b/tests/ui/traits/const-traits/const_derives/derive-const-with-params.rs index 18b224af278..b39f97b5938 100644 --- a/tests/ui/traits/const-traits/const_derives/derive-const-with-params.rs +++ b/tests/ui/traits/const-traits/const_derives/derive-const-with-params.rs @@ -1,5 +1,4 @@ -//@ known-bug: #110395 -// FIXME(const_trait_impl) check-pass +//@ check-pass #![feature(derive_const)] #![feature(const_trait_impl)] diff --git a/tests/ui/traits/const-traits/const_derives/derive-const-with-params.stderr b/tests/ui/traits/const-traits/const_derives/derive-const-with-params.stderr deleted file mode 100644 index d1dbf62d566..00000000000 --- a/tests/ui/traits/const-traits/const_derives/derive-const-with-params.stderr +++ /dev/null @@ -1,35 +0,0 @@ -error: const `impl` for trait `PartialEq` which is not marked with `#[const_trait]` - --> $DIR/derive-const-with-params.rs:7:16 - | -LL | #[derive_const(PartialEq)] - | ^^^^^^^^^ this trait is not `const` - | - = note: marking a trait with `#[const_trait]` ensures all default method bodies are `const` - = note: adding a non-const method body in the future would be a breaking change - -error: `~const` can only be applied to `#[const_trait]` traits - | -note: `PartialEq` can't be used with `~const` because it isn't annotated with `#[const_trait]` - --> $SRC_DIR/core/src/cmp.rs:LL:COL - -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/derive-const-with-params.rs:8:23 - | -LL | #[derive_const(PartialEq)] - | --------- in this derive macro expansion -LL | pub struct Reverse<T>(T); - | ^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/derive-const-with-params.rs:11:5 - | -LL | a == b - | ^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/cross-crate.gatednc.stderr b/tests/ui/traits/const-traits/cross-crate.gatednc.stderr index 4d5abf643a8..1da51915118 100644 --- a/tests/ui/traits/const-traits/cross-crate.gatednc.stderr +++ b/tests/ui/traits/const-traits/cross-crate.gatednc.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `cross_crate::NonConst: ~const cross_crate::MyTrait` is not satisfied +error[E0277]: the trait bound `cross_crate::NonConst: [const] cross_crate::MyTrait` is not satisfied --> $DIR/cross-crate.rs:19:14 | LL | NonConst.func(); diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.rs b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.rs index 96acdc300e0..ea97f755d55 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.rs +++ b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.rs @@ -4,13 +4,13 @@ trait Tr {} impl Tr for () {} -const fn foo<T>() where T: ~const Tr {} +const fn foo<T>() where T: [const] Tr {} #[const_trait] pub trait Foo { fn foo() { foo::<()>(); - //~^ ERROR the trait bound `(): ~const Tr` is not satisfied + //~^ ERROR the trait bound `(): [const] Tr` is not satisfied } } diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr index b3017523b27..2e236cecfb4 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr +++ b/tests/ui/traits/const-traits/default-method-body-is-const-body-checking.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `(): ~const Tr` is not satisfied +error[E0277]: the trait bound `(): [const] Tr` is not satisfied --> $DIR/default-method-body-is-const-body-checking.rs:12:15 | LL | foo::<()>(); @@ -7,8 +7,8 @@ LL | foo::<()>(); note: required by a bound in `foo` --> $DIR/default-method-body-is-const-body-checking.rs:7:28 | -LL | const fn foo<T>() where T: ~const Tr {} - | ^^^^^^^^^ required by this bound in `foo` +LL | const fn foo<T>() where T: [const] Tr {} + | ^^^^^^^^^^ required by this bound in `foo` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.rs b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.rs index b3beba08237..eb2c472e3bf 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.rs +++ b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.rs @@ -7,7 +7,7 @@ pub trait Tr { fn b(&self) { ().a() - //~^ ERROR the trait bound `(): ~const Tr` is not satisfied + //~^ ERROR the trait bound `(): [const] Tr` is not satisfied } } diff --git a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr index 2bd71c940e7..2dc2d484617 100644 --- a/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr +++ b/tests/ui/traits/const-traits/default-method-body-is-const-same-trait-ck.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `(): ~const Tr` is not satisfied +error[E0277]: the trait bound `(): [const] Tr` is not satisfied --> $DIR/default-method-body-is-const-same-trait-ck.rs:9:12 | LL | ().a() diff --git a/tests/ui/traits/const-traits/dont-ice-on-const-pred-for-bounds.rs b/tests/ui/traits/const-traits/dont-ice-on-const-pred-for-bounds.rs index 2295c2c3857..d39e661ed92 100644 --- a/tests/ui/traits/const-traits/dont-ice-on-const-pred-for-bounds.rs +++ b/tests/ui/traits/const-traits/dont-ice-on-const-pred-for-bounds.rs @@ -13,7 +13,7 @@ trait Trait { type Assoc: const Trait; } -const fn needs_trait<T: ~const Trait>() {} +const fn needs_trait<T: [const] Trait>() {} fn test<T: Trait>() { const { needs_trait::<T::Assoc>() }; diff --git a/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs b/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs index 08dcd7d80b3..f1fc98d72a5 100644 --- a/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs +++ b/tests/ui/traits/const-traits/dont-prefer-param-env-for-infer-self-ty.rs @@ -5,11 +5,11 @@ #[const_trait] trait Foo {} -impl<T> const Foo for (T,) where T: ~const Foo {} +impl<T> const Foo for (T,) where T: [const] Foo {} -const fn needs_const_foo(_: impl ~const Foo + Copy) {} +const fn needs_const_foo(_: impl [const] Foo + Copy) {} -const fn test<T: ~const Foo + Copy>(t: T) { +const fn test<T: [const] Foo + Copy>(t: T) { needs_const_foo((t,)); } diff --git a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs index f4b01efe959..414b80ca0da 100644 --- a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs +++ b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.rs @@ -7,7 +7,7 @@ trait Trait { type Out; } -const fn needs_const<T: ~const Trait>(_: &T) {} +const fn needs_const<T: [const] Trait>(_: &T) {} const IN_CONST: () = { needs_const(&()); diff --git a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr index cd68cdaf8a2..740a05be06b 100644 --- a/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr +++ b/tests/ui/traits/const-traits/double-error-for-unimplemented-trait.stderr @@ -14,8 +14,8 @@ LL | trait Trait { note: required by a bound in `needs_const` --> $DIR/double-error-for-unimplemented-trait.rs:10:25 | -LL | const fn needs_const<T: ~const Trait>(_: &T) {} - | ^^^^^^^^^^^^ required by this bound in `needs_const` +LL | const fn needs_const<T: [const] Trait>(_: &T) {} + | ^^^^^^^^^^^^^ required by this bound in `needs_const` error[E0277]: the trait bound `(): Trait` is not satisfied --> $DIR/double-error-for-unimplemented-trait.rs:18:15 @@ -33,8 +33,8 @@ LL | trait Trait { note: required by a bound in `needs_const` --> $DIR/double-error-for-unimplemented-trait.rs:10:25 | -LL | const fn needs_const<T: ~const Trait>(_: &T) {} - | ^^^^^^^^^^^^ required by this bound in `needs_const` +LL | const fn needs_const<T: [const] Trait>(_: &T) {} + | ^^^^^^^^^^^^^ required by this bound in `needs_const` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/tilde-twice.rs b/tests/ui/traits/const-traits/duplicate-constness.rs index d341513b8a8..4b13abe3cf2 100644 --- a/tests/ui/traits/const-traits/tilde-twice.rs +++ b/tests/ui/traits/const-traits/duplicate-constness.rs @@ -2,5 +2,5 @@ #![feature(const_trait_impl)] -struct S<T: ~const ~const Tr>; -//~^ ERROR expected identifier, found `~` +struct S<T: [const] [const] Tr>; +//~^ ERROR expected identifier, found `]` diff --git a/tests/ui/traits/const-traits/duplicate-constness.stderr b/tests/ui/traits/const-traits/duplicate-constness.stderr new file mode 100644 index 00000000000..27f69cd2386 --- /dev/null +++ b/tests/ui/traits/const-traits/duplicate-constness.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `]` + --> $DIR/duplicate-constness.rs:5:27 + | +LL | struct S<T: [const] [const] Tr>; + | ^ expected identifier + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/const-traits/eval-bad-signature.rs b/tests/ui/traits/const-traits/eval-bad-signature.rs index 97c573ea652..66e296d4388 100644 --- a/tests/ui/traits/const-traits/eval-bad-signature.rs +++ b/tests/ui/traits/const-traits/eval-bad-signature.rs @@ -7,7 +7,7 @@ trait Value { fn value() -> u32; } -const fn get_value<T: ~const Value>() -> u32 { +const fn get_value<T: [const] Value>() -> u32 { T::value() } diff --git a/tests/ui/traits/const-traits/feature-gate.rs b/tests/ui/traits/const-traits/feature-gate.rs index 921dfb054e3..5ad56ddcd33 100644 --- a/tests/ui/traits/const-traits/feature-gate.rs +++ b/tests/ui/traits/const-traits/feature-gate.rs @@ -10,12 +10,12 @@ trait T {} impl const T for S {} //[stock]~^ ERROR const trait impls are experimental -const fn f<A: ~const T>() {} //[stock]~ ERROR const trait impls are experimental +const fn f<A: [const] T>() {} //[stock]~ ERROR const trait impls are experimental fn g<A: const T>() {} //[stock]~ ERROR const trait impls are experimental macro_rules! discard { ($ty:ty) => {} } -discard! { impl ~const T } //[stock]~ ERROR const trait impls are experimental +discard! { impl [const] T } //[stock]~ ERROR const trait impls are experimental discard! { impl const T } //[stock]~ ERROR const trait impls are experimental fn main() {} diff --git a/tests/ui/traits/const-traits/feature-gate.stock.stderr b/tests/ui/traits/const-traits/feature-gate.stock.stderr index 78157d57056..f9d966f0362 100644 --- a/tests/ui/traits/const-traits/feature-gate.stock.stderr +++ b/tests/ui/traits/const-traits/feature-gate.stock.stderr @@ -11,8 +11,8 @@ LL | impl const T for S {} error[E0658]: const trait impls are experimental --> $DIR/feature-gate.rs:13:15 | -LL | const fn f<A: ~const T>() {} - | ^^^^^^ +LL | const fn f<A: [const] T>() {} + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable @@ -31,8 +31,8 @@ LL | fn g<A: const T>() {} error[E0658]: const trait impls are experimental --> $DIR/feature-gate.rs:18:17 | -LL | discard! { impl ~const T } - | ^^^^^^ +LL | discard! { impl [const] T } + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable diff --git a/tests/ui/traits/const-traits/function-pointer-does-not-require-const.rs b/tests/ui/traits/const-traits/function-pointer-does-not-require-const.rs index 61826e9977e..8acd195e546 100644 --- a/tests/ui/traits/const-traits/function-pointer-does-not-require-const.rs +++ b/tests/ui/traits/const-traits/function-pointer-does-not-require-const.rs @@ -6,7 +6,7 @@ pub trait Test {} impl Test for () {} -pub const fn test<T: ~const Test>() {} +pub const fn test<T: [const] Test>() {} pub const fn min_by_i32() -> fn() { test::<()> diff --git a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.rs b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.rs index 4cb013b9323..026f2c0d603 100644 --- a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.rs +++ b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.rs @@ -1,9 +1,9 @@ #![feature(const_trait_impl)] -const fn test() -> impl ~const Fn() { - //~^ ERROR `~const` can only be applied to `#[const_trait]` traits - //~| ERROR `~const` can only be applied to `#[const_trait]` traits - //~| ERROR `~const` can only be applied to `#[const_trait]` traits +const fn test() -> impl [const] Fn() { + //~^ ERROR `[const]` can only be applied to `#[const_trait]` traits + //~| ERROR `[const]` can only be applied to `#[const_trait]` traits + //~| ERROR `[const]` can only be applied to `#[const_trait]` traits const move || { //~ ERROR const closures are experimental let sl: &[u8] = b"foo"; @@ -11,7 +11,6 @@ const fn test() -> impl ~const Fn() { [first, remainder @ ..] => { assert_eq!(first, &b'f'); //~^ ERROR cannot call non-const function - //~| ERROR cannot call non-const operator } [] => panic!(), } diff --git a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr index 8d9371bf9f6..78d7b962cc4 100644 --- a/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr +++ b/tests/ui/traits/const-traits/ice-112822-expected-type-for-param.stderr @@ -8,44 +8,35 @@ LL | const move || { = help: add `#![feature(const_closures)]` 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: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/ice-112822-expected-type-for-param.rs:3:25 | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^ can't be applied to `Fn` +LL | const fn test() -> impl [const] Fn() { + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/ice-112822-expected-type-for-param.rs:3:25 | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^ can't be applied to `Fn` +LL | const fn test() -> impl [const] Fn() { + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/ice-112822-expected-type-for-param.rs:3:25 | -LL | const fn test() -> impl ~const Fn() { - | ^^^^^^ can't be applied to `Fn` +LL | const fn test() -> impl [const] Fn() { + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0015]: cannot call non-const operator in constant functions - --> $DIR/ice-112822-expected-type-for-param.rs:12:17 - | -LL | assert_eq!(first, &b'f'); - | ^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants - = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) - error[E0015]: cannot call non-const function `core::panicking::assert_failed::<&u8, &u8>` in constant functions --> $DIR/ice-112822-expected-type-for-param.rs:12:17 | @@ -55,7 +46,7 @@ LL | assert_eq!(first, &b'f'); = note: calls in constant functions are limited to constant functions, tuple structs and tuple variants = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) -error: aborting due to 6 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0015, E0658. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr index c6e0c699520..a165ef12060 100644 --- a/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr +++ b/tests/ui/traits/const-traits/ice-119717-constant-lifetime.stderr @@ -16,7 +16,7 @@ LL | impl<T> const FromResidual for T { = note: implementing a foreign trait is only possible if at least one of the types for which it is implemented is local = note: only traits defined in the current crate can be implemented for a type parameter -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/ice-119717-constant-lifetime.rs:9:31 | LL | fn from_residual(t: T) -> _ { diff --git a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.rs b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.rs index fadcaa39816..f1dbd947161 100644 --- a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.rs +++ b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.rs @@ -1,8 +1,8 @@ #![allow(incomplete_features)] #![feature(generic_const_exprs, const_trait_impl)] -const fn with_positive<F: ~const Fn()>() {} -//~^ ERROR `~const` can only be applied to `#[const_trait]` traits -//~| ERROR `~const` can only be applied to `#[const_trait]` traits +const fn with_positive<F: [const] Fn()>() {} +//~^ ERROR `[const]` can only be applied to `#[const_trait]` traits +//~| ERROR `[const]` can only be applied to `#[const_trait]` traits pub fn main() {} diff --git a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr index 821b257af88..1eccb16b46e 100644 --- a/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr +++ b/tests/ui/traits/const-traits/ice-123664-unexpected-bound-var.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/ice-123664-unexpected-bound-var.rs:4:27 | -LL | const fn with_positive<F: ~const Fn()>() {} - | ^^^^^^ can't be applied to `Fn` +LL | const fn with_positive<F: [const] Fn()>() {} + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/ice-123664-unexpected-bound-var.rs:4:27 | -LL | const fn with_positive<F: ~const Fn()>() {} - | ^^^^^^ can't be applied to `Fn` +LL | const fn with_positive<F: [const] Fn()>() {} + | ^^^^^^^ can't be applied to `Fn` | -note: `Fn` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `Fn` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/ops/function.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs index d6df1714314..ea4db0515cd 100644 --- a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs +++ b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.rs @@ -7,7 +7,7 @@ trait Foo {} impl const Foo for i32 {} -impl<T> const Foo for T where T: ~const Foo {} +impl<T> const Foo for T where T: [const] Foo {} //~^ ERROR conflicting implementations of trait `Foo` for type `i32` fn main() {} diff --git a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr index 183c2c2cdf4..5b417dcfe2c 100644 --- a/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr +++ b/tests/ui/traits/const-traits/ice-124857-combine-effect-const-infer-vars.stderr @@ -4,8 +4,8 @@ error[E0119]: conflicting implementations of trait `Foo` for type `i32` LL | impl const Foo for i32 {} | ---------------------- first implementation here LL | -LL | impl<T> const Foo for T where T: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` +LL | impl<T> const Foo for T where T: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `i32` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/impl-conditionally-const-trait.rs b/tests/ui/traits/const-traits/impl-conditionally-const-trait.rs new file mode 100644 index 00000000000..f3783c9e69b --- /dev/null +++ b/tests/ui/traits/const-traits/impl-conditionally-const-trait.rs @@ -0,0 +1,12 @@ +//! This test ensures that we can only implement `const Trait` for a type +//! and not have the conditionally const syntax in that position. + +#![feature(const_trait_impl)] + +struct S; +trait T {} + +impl [const] T for S {} +//~^ ERROR expected identifier, found `]` + +fn main() {} diff --git a/tests/ui/traits/const-traits/impl-conditionally-const-trait.stderr b/tests/ui/traits/const-traits/impl-conditionally-const-trait.stderr new file mode 100644 index 00000000000..fc8db61b940 --- /dev/null +++ b/tests/ui/traits/const-traits/impl-conditionally-const-trait.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `]` + --> $DIR/impl-conditionally-const-trait.rs:9:12 + | +LL | impl [const] T for S {} + | ^ expected identifier + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/const-traits/impl-tilde-const-trait.rs b/tests/ui/traits/const-traits/impl-tilde-const-trait.rs deleted file mode 100644 index 05b26465c5b..00000000000 --- a/tests/ui/traits/const-traits/impl-tilde-const-trait.rs +++ /dev/null @@ -1,9 +0,0 @@ -#![feature(const_trait_impl)] - -struct S; -trait T {} - -impl ~const T for S {} -//~^ ERROR expected a trait, found type - -fn main() {} diff --git a/tests/ui/traits/const-traits/impl-tilde-const-trait.stderr b/tests/ui/traits/const-traits/impl-tilde-const-trait.stderr deleted file mode 100644 index 4695728f8ca..00000000000 --- a/tests/ui/traits/const-traits/impl-tilde-const-trait.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected a trait, found type - --> $DIR/impl-tilde-const-trait.rs:6:6 - | -LL | impl ~const T for S {} - | ^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs b/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs index 5ead1353bcd..941f0542803 100644 --- a/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs +++ b/tests/ui/traits/const-traits/inherent-impl-const-bounds.rs @@ -12,7 +12,7 @@ impl const A for S {} impl const B for S {} impl S { - const fn a<T: ~const A>() where T: ~const B { + const fn a<T: [const] A>() where T: [const] B { } } diff --git a/tests/ui/traits/const-traits/issue-100222.rs b/tests/ui/traits/const-traits/issue-100222.rs index 55722d35075..4c93272b224 100644 --- a/tests/ui/traits/const-traits/issue-100222.rs +++ b/tests/ui/traits/const-traits/issue-100222.rs @@ -11,21 +11,28 @@ pub trait Index { } #[cfg_attr(any(ny, yy), const_trait)] -pub trait IndexMut where Self: Index { +pub trait IndexMut +where + Self: Index, +{ const C: <Self as Index>::Output; type Assoc = <Self as Index>::Output; fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output; } -impl Index for () { type Output = (); } +impl Index for () { + type Output = (); +} #[cfg(not(any(nn, yn)))] impl const IndexMut for <() as Index>::Output { const C: <Self as Index>::Output = (); type Assoc = <Self as Index>::Output; fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output - where <Self as Index>::Output:, - {} + where + <Self as Index>::Output:, + { + } } #[cfg(any(nn, yn))] @@ -33,8 +40,10 @@ impl IndexMut for <() as Index>::Output { const C: <Self as Index>::Output = (); type Assoc = <Self as Index>::Output; fn foo(&mut self, x: <Self as Index>::Output) -> <Self as Index>::Output - where <Self as Index>::Output:, - {} + where + <Self as Index>::Output:, + { + } } const C: <() as Index>::Output = (); diff --git a/tests/ui/traits/const-traits/issue-92111.rs b/tests/ui/traits/const-traits/issue-92111.rs index c8db5cc9e7a..2450136793e 100644 --- a/tests/ui/traits/const-traits/issue-92111.rs +++ b/tests/ui/traits/const-traits/issue-92111.rs @@ -14,7 +14,7 @@ pub struct S(i32); impl Tr for S {} -const fn a<T: ~const Destruct>(t: T) {} +const fn a<T: [const] Destruct>(t: T) {} fn main() { a(S(0)); diff --git a/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs b/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs index a3edc5ff8b1..0eb7f54d596 100644 --- a/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs +++ b/tests/ui/traits/const-traits/issue-92230-wf-super-trait-env.rs @@ -10,7 +10,7 @@ pub trait Super {} #[const_trait] pub trait Sub: Super {} -impl<A> const Super for &A where A: ~const Super {} -impl<A> const Sub for &A where A: ~const Sub {} +impl<A> const Super for &A where A: [const] Super {} +impl<A> const Sub for &A where A: [const] Sub {} fn main() {} diff --git a/tests/ui/traits/const-traits/item-bound-entailment-fails.rs b/tests/ui/traits/const-traits/item-bound-entailment-fails.rs index f4bfcbda0ac..029597ea1f0 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment-fails.rs +++ b/tests/ui/traits/const-traits/item-bound-entailment-fails.rs @@ -2,27 +2,27 @@ #![feature(const_trait_impl)] #[const_trait] trait Foo { - type Assoc<T>: ~const Bar + type Assoc<T>: [const] Bar where - T: ~const Bar; + T: [const] Bar; } #[const_trait] trait Bar {} struct N<T>(T); impl<T> Bar for N<T> where T: Bar {} struct C<T>(T); -impl<T> const Bar for C<T> where T: ~const Bar {} +impl<T> const Bar for C<T> where T: [const] Bar {} impl const Foo for u32 { type Assoc<T> = N<T> - //~^ ERROR the trait bound `N<T>: ~const Bar` is not satisfied + //~^ ERROR the trait bound `N<T>: [const] Bar` is not satisfied where - T: ~const Bar; + T: [const] Bar; } impl const Foo for i32 { type Assoc<T> = C<T> - //~^ ERROR the trait bound `T: ~const Bar` is not satisfied + //~^ ERROR the trait bound `T: [const] Bar` is not satisfied where T: Bar; } diff --git a/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr b/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr index 7e72dc9abaa..8e5894a3296 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr +++ b/tests/ui/traits/const-traits/item-bound-entailment-fails.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `N<T>: ~const Bar` is not satisfied +error[E0277]: the trait bound `N<T>: [const] Bar` is not satisfied --> $DIR/item-bound-entailment-fails.rs:17:21 | LL | type Assoc<T> = N<T> @@ -7,25 +7,25 @@ LL | type Assoc<T> = N<T> note: required by a bound in `Foo::Assoc` --> $DIR/item-bound-entailment-fails.rs:5:20 | -LL | type Assoc<T>: ~const Bar - | ^^^^^^^^^^ required by this bound in `Foo::Assoc` +LL | type Assoc<T>: [const] Bar + | ^^^^^^^^^^^ required by this bound in `Foo::Assoc` -error[E0277]: the trait bound `T: ~const Bar` is not satisfied +error[E0277]: the trait bound `T: [const] Bar` is not satisfied --> $DIR/item-bound-entailment-fails.rs:24:21 | LL | type Assoc<T> = C<T> | ^^^^ | -note: required for `C<T>` to implement `~const Bar` +note: required for `C<T>` to implement `[const] Bar` --> $DIR/item-bound-entailment-fails.rs:14:15 | -LL | impl<T> const Bar for C<T> where T: ~const Bar {} - | ^^^ ^^^^ ---------- unsatisfied trait bound introduced here +LL | impl<T> const Bar for C<T> where T: [const] Bar {} + | ^^^ ^^^^ ----------- unsatisfied trait bound introduced here note: required by a bound in `Foo::Assoc` --> $DIR/item-bound-entailment-fails.rs:5:20 | -LL | type Assoc<T>: ~const Bar - | ^^^^^^^^^^ required by this bound in `Foo::Assoc` +LL | type Assoc<T>: [const] Bar + | ^^^^^^^^^^^ required by this bound in `Foo::Assoc` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/item-bound-entailment.rs b/tests/ui/traits/const-traits/item-bound-entailment.rs index 11db57be815..6e053adb385 100644 --- a/tests/ui/traits/const-traits/item-bound-entailment.rs +++ b/tests/ui/traits/const-traits/item-bound-entailment.rs @@ -4,16 +4,16 @@ #![feature(const_trait_impl)] #[const_trait] trait Foo { - type Assoc<T>: ~const Bar + type Assoc<T>: [const] Bar where - T: ~const Bar; + T: [const] Bar; } #[const_trait] trait Bar {} struct N<T>(T); impl<T> Bar for N<T> where T: Bar {} struct C<T>(T); -impl<T> const Bar for C<T> where T: ~const Bar {} +impl<T> const Bar for C<T> where T: [const] Bar {} impl Foo for u32 { type Assoc<T> = N<T> @@ -24,7 +24,7 @@ impl Foo for u32 { impl const Foo for i32 { type Assoc<T> = C<T> where - T: ~const Bar; + T: [const] Bar; } fn main() {} diff --git a/tests/ui/traits/const-traits/mbe-bare-trait-objects-const-trait-bounds.rs b/tests/ui/traits/const-traits/macro-bare-trait-objects-const-trait-bounds.rs index 820d3d63b62..a5f6ae198f6 100644 --- a/tests/ui/traits/const-traits/mbe-bare-trait-objects-const-trait-bounds.rs +++ b/tests/ui/traits/const-traits/macro-bare-trait-objects-const-trait-bounds.rs @@ -1,20 +1,24 @@ -// Ensure that we don't consider `const Trait` and `~const Trait` to +// Ensure that we don't consider `const Trait` to // match the macro fragment specifier `ty` as that would be a breaking // change theoretically speaking. Syntactically trait object types can // be "bare", i.e., lack the prefix `dyn`. // By contrast, `?Trait` *does* match `ty` and therefore an arm like // `?$Trait:path` would never be reached. // See `parser/macro/mbe-bare-trait-object-maybe-trait-bound.rs`. - -//@ check-pass +// `[const] Trait` is already an error for a `ty` fragment, +// so we do not need to prevent that. macro_rules! check { - ($Type:ty) => { compile_error!("ty"); }; + ($Type:ty) => { + compile_error!("ty"); + }; (const $Trait:path) => {}; - (~const $Trait:path) => {}; + ([const] $Trait:path) => {}; } check! { const Trait } -check! { ~const Trait } +check! { [const] Trait } +//~^ ERROR: expected identifier, found `]` +//~| ERROR: const trait impls are experimental fn main() {} diff --git a/tests/ui/traits/const-traits/macro-bare-trait-objects-const-trait-bounds.stderr b/tests/ui/traits/const-traits/macro-bare-trait-objects-const-trait-bounds.stderr new file mode 100644 index 00000000000..bc0e48112b9 --- /dev/null +++ b/tests/ui/traits/const-traits/macro-bare-trait-objects-const-trait-bounds.stderr @@ -0,0 +1,22 @@ +error: expected identifier, found `]` + --> $DIR/macro-bare-trait-objects-const-trait-bounds.rs:20:16 + | +LL | ($Type:ty) => { + | -------- while parsing argument for this `ty` macro fragment +... +LL | check! { [const] Trait } + | ^ expected identifier + +error[E0658]: const trait impls are experimental + --> $DIR/macro-bare-trait-objects-const-trait-bounds.rs:20:11 + | +LL | check! { [const] Trait } + | ^^^^^ + | + = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information + = help: add `#![feature(const_trait_impl)]` 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`. diff --git a/tests/ui/traits/const-traits/mbe-const-trait-bound-theoretical-regression.rs b/tests/ui/traits/const-traits/macro-const-trait-bound-theoretical-regression.rs index 3dcdb0cad94..3dcdb0cad94 100644 --- a/tests/ui/traits/const-traits/mbe-const-trait-bound-theoretical-regression.rs +++ b/tests/ui/traits/const-traits/macro-const-trait-bound-theoretical-regression.rs diff --git a/tests/ui/traits/const-traits/mbe-const-trait-bound-theoretical-regression.stderr b/tests/ui/traits/const-traits/macro-const-trait-bound-theoretical-regression.stderr index f4b401b7386..5dd648554c9 100644 --- a/tests/ui/traits/const-traits/mbe-const-trait-bound-theoretical-regression.stderr +++ b/tests/ui/traits/const-traits/macro-const-trait-bound-theoretical-regression.stderr @@ -1,5 +1,5 @@ error: ty - --> $DIR/mbe-const-trait-bound-theoretical-regression.rs:8:19 + --> $DIR/macro-const-trait-bound-theoretical-regression.rs:8:19 | LL | ($ty:ty) => { compile_error!("ty"); }; | ^^^^^^^^^^^^^^^^^^^^ @@ -10,7 +10,7 @@ LL | demo! { impl const Trait } = note: this error originates in the macro `demo` (in Nightly builds, run with -Z macro-backtrace for more info) error: ty - --> $DIR/mbe-const-trait-bound-theoretical-regression.rs:8:19 + --> $DIR/macro-const-trait-bound-theoretical-regression.rs:8:19 | LL | ($ty:ty) => { compile_error!("ty"); }; | ^^^^^^^^^^^^^^^^^^^^ @@ -21,7 +21,7 @@ LL | demo! { dyn const Trait } = note: this error originates in the macro `demo` (in Nightly builds, run with -Z macro-backtrace for more info) error[E0658]: const trait impls are experimental - --> $DIR/mbe-const-trait-bound-theoretical-regression.rs:15:14 + --> $DIR/macro-const-trait-bound-theoretical-regression.rs:15:14 | LL | demo! { impl const Trait } | ^^^^^ @@ -31,7 +31,7 @@ LL | demo! { impl const Trait } = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: const trait impls are experimental - --> $DIR/mbe-const-trait-bound-theoretical-regression.rs:18:13 + --> $DIR/macro-const-trait-bound-theoretical-regression.rs:18:13 | LL | demo! { dyn const Trait } | ^^^^^ diff --git a/tests/ui/traits/const-traits/mbe-dyn-const-2015.rs b/tests/ui/traits/const-traits/macro-dyn-const-2015.rs index fadfbe66788..fadfbe66788 100644 --- a/tests/ui/traits/const-traits/mbe-dyn-const-2015.rs +++ b/tests/ui/traits/const-traits/macro-dyn-const-2015.rs diff --git a/tests/ui/traits/const-traits/minicore-deref-fail.rs b/tests/ui/traits/const-traits/minicore-deref-fail.rs index f4a7678a009..d9b33fa040a 100644 --- a/tests/ui/traits/const-traits/minicore-deref-fail.rs +++ b/tests/ui/traits/const-traits/minicore-deref-fail.rs @@ -11,10 +11,12 @@ use minicore::*; struct Ty; impl Deref for Ty { type Target = (); - fn deref(&self) -> &Self::Target { &() } + fn deref(&self) -> &Self::Target { + &() + } } const fn foo() { *Ty; - //~^ ERROR the trait bound `Ty: ~const minicore::Deref` is not satisfied + //~^ ERROR the trait bound `Ty: [const] minicore::Deref` is not satisfied } diff --git a/tests/ui/traits/const-traits/minicore-deref-fail.stderr b/tests/ui/traits/const-traits/minicore-deref-fail.stderr index a1f840114fc..4329b235756 100644 --- a/tests/ui/traits/const-traits/minicore-deref-fail.stderr +++ b/tests/ui/traits/const-traits/minicore-deref-fail.stderr @@ -1,5 +1,5 @@ -error[E0277]: the trait bound `Ty: ~const minicore::Deref` is not satisfied - --> $DIR/minicore-deref-fail.rs:18:5 +error[E0277]: the trait bound `Ty: [const] minicore::Deref` is not satisfied + --> $DIR/minicore-deref-fail.rs:20:5 | LL | *Ty; | ^^^ diff --git a/tests/ui/traits/const-traits/minicore-drop-fail.rs b/tests/ui/traits/const-traits/minicore-drop-fail.rs index 274e5db21c4..f3e7c7df4d4 100644 --- a/tests/ui/traits/const-traits/minicore-drop-fail.rs +++ b/tests/ui/traits/const-traits/minicore-drop-fail.rs @@ -19,7 +19,7 @@ impl Drop for NotDropImpl { impl Foo for () {} struct Conditional<T: Foo>(T); -impl<T> const Drop for Conditional<T> where T: ~const Foo { +impl<T> const Drop for Conditional<T> where T: [const] Foo { fn drop(&mut self) {} } diff --git a/tests/ui/traits/const-traits/minicore-fn-fail.rs b/tests/ui/traits/const-traits/minicore-fn-fail.rs index ae1cbc6ca58..d4cd41a51ca 100644 --- a/tests/ui/traits/const-traits/minicore-fn-fail.rs +++ b/tests/ui/traits/const-traits/minicore-fn-fail.rs @@ -8,14 +8,14 @@ extern crate minicore; use minicore::*; -const fn call_indirect<T: ~const Fn()>(t: &T) { t() } +const fn call_indirect<T: [const] Fn()>(t: &T) { t() } #[const_trait] trait Foo {} impl Foo for () {} -const fn foo<T: ~const Foo>() {} +const fn foo<T: [const] Foo>() {} const fn test() { call_indirect(&foo::<()>); - //~^ ERROR the trait bound `(): ~const Foo` is not satisfied + //~^ ERROR the trait bound `(): [const] Foo` is not satisfied } diff --git a/tests/ui/traits/const-traits/minicore-fn-fail.stderr b/tests/ui/traits/const-traits/minicore-fn-fail.stderr index 03c7ade87c0..c02a067774b 100644 --- a/tests/ui/traits/const-traits/minicore-fn-fail.stderr +++ b/tests/ui/traits/const-traits/minicore-fn-fail.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `(): ~const Foo` is not satisfied +error[E0277]: the trait bound `(): [const] Foo` is not satisfied --> $DIR/minicore-fn-fail.rs:19:19 | LL | call_indirect(&foo::<()>); @@ -9,8 +9,8 @@ LL | call_indirect(&foo::<()>); note: required by a bound in `call_indirect` --> $DIR/minicore-fn-fail.rs:11:27 | -LL | const fn call_indirect<T: ~const Fn()>(t: &T) { t() } - | ^^^^^^^^^^^ required by this bound in `call_indirect` +LL | const fn call_indirect<T: [const] Fn()>(t: &T) { t() } + | ^^^^^^^^^^^^ required by this bound in `call_indirect` error: aborting due to 1 previous error diff --git a/tests/ui/traits/const-traits/minicore-works.rs b/tests/ui/traits/const-traits/minicore-works.rs index c79b4fc07df..ef08e84c02b 100644 --- a/tests/ui/traits/const-traits/minicore-works.rs +++ b/tests/ui/traits/const-traits/minicore-works.rs @@ -21,7 +21,9 @@ const fn test_op() { let _y = Custom + Custom; } -const fn call_indirect<T: ~const Fn()>(t: &T) { t() } +const fn call_indirect<T: [const] Fn()>(t: &T) { + t() +} const fn call() { call_indirect(&call); diff --git a/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.rs b/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.rs index aaab8e819a3..5f47778a140 100644 --- a/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.rs +++ b/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.rs @@ -1,13 +1,13 @@ #![feature(const_trait_impl)] -const fn maybe_const_maybe<T: ~const ?Sized>() {} -//~^ ERROR `~const` trait not allowed with `?` trait polarity modifier +const fn maybe_const_maybe<T: [const] ?Sized>() {} +//~^ ERROR `[const]` trait not allowed with `?` trait polarity modifier fn const_maybe<T: const ?Sized>() {} //~^ ERROR `const` trait not allowed with `?` trait polarity modifier -const fn maybe_const_negative<T: ~const !Trait>() {} -//~^ ERROR `~const` trait not allowed with `!` trait polarity modifier +const fn maybe_const_negative<T: [const] !Trait>() {} +//~^ ERROR `[const]` trait not allowed with `!` trait polarity modifier //~| ERROR negative bounds are not supported fn const_negative<T: const !Trait>() {} diff --git a/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.stderr b/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.stderr index 18e4d160f5f..429131f905f 100644 --- a/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.stderr +++ b/tests/ui/traits/const-traits/mutually-exclusive-trait-bound-modifiers.stderr @@ -1,10 +1,10 @@ -error: `~const` trait not allowed with `?` trait polarity modifier - --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:3:38 +error: `[const]` trait not allowed with `?` trait polarity modifier + --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:3:39 | -LL | const fn maybe_const_maybe<T: ~const ?Sized>() {} - | ------ ^ +LL | const fn maybe_const_maybe<T: [const] ?Sized>() {} + | ------- ^ | | - | there is not a well-defined meaning for a `~const ?` trait + | there is not a well-defined meaning for a `[const] ?` trait error: `const` trait not allowed with `?` trait polarity modifier --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:6:25 @@ -14,13 +14,13 @@ LL | fn const_maybe<T: const ?Sized>() {} | | | there is not a well-defined meaning for a `const ?` trait -error: `~const` trait not allowed with `!` trait polarity modifier - --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:9:41 +error: `[const]` trait not allowed with `!` trait polarity modifier + --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:9:42 | -LL | const fn maybe_const_negative<T: ~const !Trait>() {} - | ------ ^ +LL | const fn maybe_const_negative<T: [const] !Trait>() {} + | ------- ^ | | - | there is not a well-defined meaning for a `~const !` trait + | there is not a well-defined meaning for a `[const] !` trait error: `const` trait not allowed with `!` trait polarity modifier --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:13:28 @@ -31,10 +31,10 @@ LL | fn const_negative<T: const !Trait>() {} | there is not a well-defined meaning for a `const !` trait error: negative bounds are not supported - --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:9:41 + --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:9:42 | -LL | const fn maybe_const_negative<T: ~const !Trait>() {} - | ^ +LL | const fn maybe_const_negative<T: [const] !Trait>() {} + | ^ error: negative bounds are not supported --> $DIR/mutually-exclusive-trait-bound-modifiers.rs:13:28 diff --git a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs index 8f11c8a6e55..86e3e5f769f 100644 --- a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs +++ b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.rs @@ -7,7 +7,7 @@ trait Convert<T> { fn to(self) -> T; } -impl<A, B> const Convert<B> for A where B: ~const From<A> { +impl<A, B> const Convert<B> for A where B: [const] From<A> { fn to(self) -> B { B::from(self) } diff --git a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr index 190af5e7c2d..e7f10e73c69 100644 --- a/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr +++ b/tests/ui/traits/const-traits/non-const-op-in-closure-in-const.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/non-const-op-in-closure-in-const.rs:10:44 | -LL | impl<A, B> const Convert<B> for A where B: ~const From<A> { - | ^^^^^^ can't be applied to `From` +LL | impl<A, B> const Convert<B> for A where B: [const] From<A> { + | ^^^^^^^ can't be applied to `From` | -note: `From` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `From` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/non-const-op-in-closure-in-const.rs:10:44 | -LL | impl<A, B> const Convert<B> for A where B: ~const From<A> { - | ^^^^^^ can't be applied to `From` +LL | impl<A, B> const Convert<B> for A where B: [const] From<A> { + | ^^^^^^^ can't be applied to `From` | -note: `From` can't be used with `~const` because it isn't annotated with `#[const_trait]` +note: `From` can't be used with `[const]` because it isn't annotated with `#[const_trait]` --> $SRC_DIR/core/src/convert/mod.rs:LL:COL = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr b/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr index bd822970ad1..ed671bee63a 100644 --- a/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr +++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.min_spec.stderr @@ -3,8 +3,8 @@ error[E0119]: conflicting implementations of trait `Foo` for type `(_,)` | LL | / impl<T> const Foo for T LL | | where -LL | | T: ~const Bar, - | |__________________- first implementation here +LL | | T: [const] Bar, + | |___________________- first implementation here ... LL | impl<T> Foo for (T,) { | ^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)` diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs b/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs index eb66d03faa6..f45690b2f78 100644 --- a/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs +++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.rs @@ -15,7 +15,7 @@ trait Foo { } impl<T> const Foo for T where - T: ~const Bar, + T: [const] Bar, { default fn method(&self) {} } @@ -27,7 +27,7 @@ impl<T> Foo for (T,) { } } -const fn dispatch<T: ~const Bar + Copy>(t: T) { +const fn dispatch<T: [const] Bar + Copy>(t: T) { t.method(); } diff --git a/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr b/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr index cbdcb45f6be..35f4d9184cf 100644 --- a/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr +++ b/tests/ui/traits/const-traits/overlap-const-with-nonconst.spec.stderr @@ -13,8 +13,8 @@ error[E0119]: conflicting implementations of trait `Foo` for type `(_,)` | LL | / impl<T> const Foo for T LL | | where -LL | | T: ~const Bar, - | |__________________- first implementation here +LL | | T: [const] Bar, + | |___________________- first implementation here ... LL | impl<T> Foo for (T,) { | ^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `(_,)` diff --git a/tests/ui/traits/const-traits/predicate-entailment-fails.rs b/tests/ui/traits/const-traits/predicate-entailment-fails.rs index 266a49f9e38..0e6c277fd82 100644 --- a/tests/ui/traits/const-traits/predicate-entailment-fails.rs +++ b/tests/ui/traits/const-traits/predicate-entailment-fails.rs @@ -6,9 +6,9 @@ impl const Bar for () {} #[const_trait] trait TildeConst { - type Bar<T> where T: ~const Bar; + type Bar<T> where T: [const] Bar; - fn foo<T>() where T: ~const Bar; + fn foo<T>() where T: [const] Bar; } impl TildeConst for () { type Bar<T> = () where T: const Bar; @@ -32,10 +32,10 @@ impl NeverConst for i32 { //~^ ERROR impl has stricter requirements than trait } impl const NeverConst for u32 { - type Bar<T> = () where T: ~const Bar; + type Bar<T> = () where T: [const] Bar; //~^ ERROR impl has stricter requirements than trait - fn foo<T>() where T: ~const Bar {} + fn foo<T>() where T: [const] Bar {} //~^ ERROR impl has stricter requirements than trait } diff --git a/tests/ui/traits/const-traits/predicate-entailment-fails.stderr b/tests/ui/traits/const-traits/predicate-entailment-fails.stderr index dfdc4d23250..cba7c979a42 100644 --- a/tests/ui/traits/const-traits/predicate-entailment-fails.stderr +++ b/tests/ui/traits/const-traits/predicate-entailment-fails.stderr @@ -1,7 +1,7 @@ error[E0276]: impl has stricter requirements than trait --> $DIR/predicate-entailment-fails.rs:14:31 | -LL | type Bar<T> where T: ~const Bar; +LL | type Bar<T> where T: [const] Bar; | ----------- definition of `Bar` from trait ... LL | type Bar<T> = () where T: const Bar; @@ -10,8 +10,8 @@ LL | type Bar<T> = () where T: const Bar; error[E0276]: impl has stricter requirements than trait --> $DIR/predicate-entailment-fails.rs:17:26 | -LL | fn foo<T>() where T: ~const Bar; - | -------------------------------- definition of `foo` from trait +LL | fn foo<T>() where T: [const] Bar; + | --------------------------------- definition of `foo` from trait ... LL | fn foo<T>() where T: const Bar {} | ^^^^^^^^^ impl has extra requirement `T: const Bar` @@ -40,8 +40,8 @@ error[E0276]: impl has stricter requirements than trait LL | type Bar<T> where T: Bar; | ----------- definition of `Bar` from trait ... -LL | type Bar<T> = () where T: ~const Bar; - | ^^^^^^^^^^ impl has extra requirement `T: ~const Bar` +LL | type Bar<T> = () where T: [const] Bar; + | ^^^^^^^^^^^ impl has extra requirement `T: [const] Bar` error[E0276]: impl has stricter requirements than trait --> $DIR/predicate-entailment-fails.rs:38:26 @@ -49,8 +49,8 @@ error[E0276]: impl has stricter requirements than trait LL | fn foo<T>() where T: Bar; | ------------------------- definition of `foo` from trait ... -LL | fn foo<T>() where T: ~const Bar {} - | ^^^^^^^^^^ impl has extra requirement `T: ~const Bar` +LL | fn foo<T>() where T: [const] Bar {} + | ^^^^^^^^^^^ impl has extra requirement `T: [const] Bar` error: aborting due to 6 previous errors diff --git a/tests/ui/traits/const-traits/predicate-entailment-passes.rs b/tests/ui/traits/const-traits/predicate-entailment-passes.rs index 28ae21891f3..fe871483186 100644 --- a/tests/ui/traits/const-traits/predicate-entailment-passes.rs +++ b/tests/ui/traits/const-traits/predicate-entailment-passes.rs @@ -7,7 +7,7 @@ impl const Bar for () {} #[const_trait] trait TildeConst { - fn foo<T>() where T: ~const Bar; + fn foo<T>() where T: [const] Bar; } impl TildeConst for () { fn foo<T>() where T: Bar {} @@ -21,7 +21,7 @@ impl AlwaysConst for i32 { fn foo<T>() where T: Bar {} } impl const AlwaysConst for u32 { - fn foo<T>() where T: ~const Bar {} + fn foo<T>() where T: [const] Bar {} } fn main() {} diff --git a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs index 5af9ee8614f..212d869d94d 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs +++ b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.rs @@ -1,5 +1,5 @@ -// Tests that trait bounds on specializing trait impls must be `~const` if the -// same bound is present on the default impl and is `~const` there. +// Tests that trait bounds on specializing trait impls must be `[const]` if the +// same bound is present on the default impl and is `[const]` there. //@ known-bug: #110395 // FIXME(const_trait_impl) ^ should error @@ -20,14 +20,14 @@ trait Bar { impl<T> const Bar for T where - T: ~const Foo, + T: [const] Foo, { default fn bar() {} } impl<T> Bar for T where - T: Foo, //FIXME ~ ERROR missing `~const` qualifier + T: Foo, //FIXME ~ ERROR missing `[const]` qualifier T: Specialize, { fn bar() {} @@ -40,7 +40,7 @@ trait Baz { impl<T> const Baz for T where - T: ~const Foo, + T: [const] Foo, { default fn baz() {} } diff --git a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr index 9166b8ca5d2..074e6237cc2 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr +++ b/tests/ui/traits/const-traits/specialization/const-default-bound-non-const-specialized-bound.stderr @@ -3,12 +3,12 @@ error[E0119]: conflicting implementations of trait `Bar` | LL | / impl<T> const Bar for T LL | | where -LL | | T: ~const Foo, - | |__________________- first implementation here +LL | | T: [const] Foo, + | |___________________- first implementation here ... LL | / impl<T> Bar for T LL | | where -LL | | T: Foo, //FIXME ~ ERROR missing `~const` qualifier +LL | | T: Foo, //FIXME ~ ERROR missing `[const]` qualifier LL | | T: Specialize, | |__________________^ conflicting implementation @@ -17,8 +17,8 @@ error[E0119]: conflicting implementations of trait `Baz` | LL | / impl<T> const Baz for T LL | | where -LL | | T: ~const Foo, - | |__________________- first implementation here +LL | | T: [const] Foo, + | |___________________- first implementation here ... LL | / impl<T> const Baz for T //FIXME ~ ERROR conflicting implementations of trait `Baz` LL | | where diff --git a/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs b/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs index 89ad61c3c31..6991b7deda3 100644 --- a/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs +++ b/tests/ui/traits/const-traits/specialization/const-default-const-specialized.rs @@ -11,7 +11,7 @@ trait Value { fn value() -> u32; } -const fn get_value<T: ~const Value>() -> u32 { +const fn get_value<T: [const] Value>() -> u32 { T::value() } diff --git a/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs b/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs index d97469edaf9..754f1c6d09d 100644 --- a/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs +++ b/tests/ui/traits/const-traits/specialization/issue-95187-same-trait-bound-different-constness.rs @@ -1,4 +1,4 @@ -// Tests that `T: ~const Foo` in a specializing impl is treated as equivalent to +// Tests that `T: [const] Foo` in a specializing impl is treated as equivalent to // `T: Foo` in the default impl for the purposes of specialization (i.e., it // does not think that the user is attempting to specialize on trait `Foo`). @@ -28,7 +28,7 @@ where impl<T> const Bar for T where - T: ~const Foo, + T: [const] Foo, T: Specialize, { fn bar() {} @@ -48,7 +48,7 @@ where impl<T> const Baz for T where - T: ~const Foo, + T: [const] Foo, T: Specialize, { fn baz() {} diff --git a/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs b/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs index e9b494bc2c0..b1a1b4a2399 100644 --- a/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs +++ b/tests/ui/traits/const-traits/specialization/non-const-default-const-specialized.rs @@ -11,7 +11,7 @@ trait Value { fn value() -> u32; } -const fn get_value<T: ~const Value>() -> u32 { +const fn get_value<T: [const] Value>() -> u32 { T::value() } diff --git a/tests/ui/traits/const-traits/specialization/issue-95186-specialize-on-tilde-const.rs b/tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs index d80370aee82..0106bb13875 100644 --- a/tests/ui/traits/const-traits/specialization/issue-95186-specialize-on-tilde-const.rs +++ b/tests/ui/traits/const-traits/specialization/specialize-on-conditionally-const.rs @@ -1,4 +1,5 @@ -// Tests that `~const` trait bounds can be used to specialize const trait impls. +// Tests that `[const]` trait bounds can be used to specialize const trait impls. +// cc #95186 //@ check-pass @@ -21,7 +22,7 @@ impl<T> const Foo for T { impl<T> const Foo for T where - T: ~const Specialize, + T: [const] Specialize, { fn foo() {} } @@ -33,15 +34,15 @@ trait Bar { impl<T> const Bar for T where - T: ~const Foo, + T: [const] Foo, { default fn bar() {} } impl<T> const Bar for T where - T: ~const Foo, - T: ~const Specialize, + T: [const] Foo, + T: [const] Specialize, { fn bar() {} } diff --git a/tests/ui/traits/const-traits/specializing-constness-2.rs b/tests/ui/traits/const-traits/specializing-constness-2.rs index c1fe42b9751..86c2cee9fed 100644 --- a/tests/ui/traits/const-traits/specializing-constness-2.rs +++ b/tests/ui/traits/const-traits/specializing-constness-2.rs @@ -17,7 +17,7 @@ impl<T: Default> A for T { } } -impl<T: Default + ~const Sup> const A for T { +impl<T: Default + [const] Sup> const A for T { fn a() -> u32 { 3 } @@ -25,7 +25,7 @@ impl<T: Default + ~const Sup> const A for T { const fn generic<T: Default>() { <T as A>::a(); - //FIXME ~^ ERROR: the trait bound `T: ~const Sup` is not satisfied + //FIXME ~^ ERROR: the trait bound `T: [const] Sup` is not satisfied } fn main() {} diff --git a/tests/ui/traits/const-traits/specializing-constness-2.stderr b/tests/ui/traits/const-traits/specializing-constness-2.stderr index edba836aac3..850e6939dae 100644 --- a/tests/ui/traits/const-traits/specializing-constness-2.stderr +++ b/tests/ui/traits/const-traits/specializing-constness-2.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `T: ~const A` is not satisfied +error[E0277]: the trait bound `T: [const] A` is not satisfied --> $DIR/specializing-constness-2.rs:27:6 | LL | <T as A>::a(); diff --git a/tests/ui/traits/const-traits/specializing-constness.rs b/tests/ui/traits/const-traits/specializing-constness.rs index 94b6da7124d..b64d8b21b24 100644 --- a/tests/ui/traits/const-traits/specializing-constness.rs +++ b/tests/ui/traits/const-traits/specializing-constness.rs @@ -14,7 +14,7 @@ pub trait A { #[const_trait] pub trait Spec {} -impl<T: ~const Spec> const A for T { +impl<T: [const] Spec> const A for T { default fn a() -> u32 { 2 } diff --git a/tests/ui/traits/const-traits/specializing-constness.stderr b/tests/ui/traits/const-traits/specializing-constness.stderr index 2ca70b53e4e..f411ebcdfca 100644 --- a/tests/ui/traits/const-traits/specializing-constness.stderr +++ b/tests/ui/traits/const-traits/specializing-constness.stderr @@ -1,8 +1,8 @@ error[E0119]: conflicting implementations of trait `A` --> $DIR/specializing-constness.rs:23:1 | -LL | impl<T: ~const Spec> const A for T { - | ---------------------------------- first implementation here +LL | impl<T: [const] Spec> const A for T { + | ----------------------------------- first implementation here ... LL | impl<T: Spec + Sup> A for T { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation diff --git a/tests/ui/traits/const-traits/staged-api.rs b/tests/ui/traits/const-traits/staged-api.rs index bf09a5f7803..d24b26be569 100644 --- a/tests/ui/traits/const-traits/staged-api.rs +++ b/tests/ui/traits/const-traits/staged-api.rs @@ -23,7 +23,7 @@ impl const MyTrait for Foo { } #[rustc_allow_const_fn_unstable(const_trait_impl, unstable)] -const fn conditionally_const<T: ~const MyTrait>() { +const fn conditionally_const<T: [const] MyTrait>() { T::func(); } diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr index 8f88e3aa8bc..19f072b289e 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.nn.stderr @@ -1,31 +1,31 @@ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> $DIR/super-traits-fail-2.rs:11:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/super-traits-fail-2.rs:11:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-2.rs:11:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations | LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-2.rs:11:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -33,11 +33,11 @@ help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-2.rs:11:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr index 087e80de788..4921f78d3ac 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.ny.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-2.rs:11:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations | LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-2.rs:11:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -21,11 +21,11 @@ help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-2.rs:11:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -33,11 +33,11 @@ help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-2.rs:11:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -45,11 +45,11 @@ help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-2.rs:11:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.rs b/tests/ui/traits/const-traits/super-traits-fail-2.rs index 6cc9d739476..781dacb81a1 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.rs +++ b/tests/ui/traits/const-traits/super-traits-fail-2.rs @@ -8,17 +8,17 @@ trait Foo { } #[cfg_attr(any(yy, ny), const_trait)] -trait Bar: ~const Foo {} -//[ny,nn]~^ ERROR: `~const` can only be applied to `#[const_trait]` -//[ny,nn]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[ny,nn]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[ny]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[ny]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[yn,nn]~^^^^^^ ERROR: `~const` is not allowed here +trait Bar: [const] Foo {} +//[ny,nn]~^ ERROR: `[const]` can only be applied to `#[const_trait]` +//[ny,nn]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[ny,nn]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[ny]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[ny]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[yn,nn]~^^^^^^ ERROR: `[const]` is not allowed here const fn foo<T: Bar>(x: &T) { x.a(); - //[yy,yn]~^ ERROR the trait bound `T: ~const Foo` + //[yy,yn]~^ ERROR the trait bound `T: [const] Foo` //[nn,ny]~^^ ERROR cannot call non-const method `<T as Foo>::a` in constant functions } diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr index ee49810bace..a151349822e 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.yn.stderr @@ -1,16 +1,16 @@ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> $DIR/super-traits-fail-2.rs:11:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/super-traits-fail-2.rs:11:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error[E0277]: the trait bound `T: ~const Foo` is not satisfied +error[E0277]: the trait bound `T: [const] Foo` is not satisfied --> $DIR/super-traits-fail-2.rs:20:7 | LL | x.a(); diff --git a/tests/ui/traits/const-traits/super-traits-fail-2.yy.stderr b/tests/ui/traits/const-traits/super-traits-fail-2.yy.stderr index a213273c1c7..4ae4bbde99b 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-2.yy.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-2.yy.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `T: ~const Foo` is not satisfied +error[E0277]: the trait bound `T: [const] Foo` is not satisfied --> $DIR/super-traits-fail-2.rs:20:7 | LL | x.a(); diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr index a5ef716a62a..eb1beb41e37 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nnn.stderr @@ -1,20 +1,20 @@ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/super-traits-fail-3.rs:23:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: const trait impls are experimental --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable @@ -23,29 +23,29 @@ LL | trait Bar: ~const Foo {} error[E0658]: const trait impls are experimental --> $DIR/super-traits-fail-3.rs:32:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` 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: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations | LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -53,11 +53,11 @@ help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[ LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -65,27 +65,27 @@ help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[ LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:32:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ can't be applied to `Bar` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:32:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ can't be applied to `Bar` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ error[E0015]: cannot call non-const method `<T as Foo>::a` in constant functions diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr index a5ef716a62a..eb1beb41e37 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nny.stderr @@ -1,20 +1,20 @@ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/super-traits-fail-3.rs:23:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0658]: const trait impls are experimental --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable @@ -23,29 +23,29 @@ LL | trait Bar: ~const Foo {} error[E0658]: const trait impls are experimental --> $DIR/super-traits-fail-3.rs:32:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` 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: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations | LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -53,11 +53,11 @@ help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[ LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -65,27 +65,27 @@ help: enable `#![feature(const_trait_impl)]` in your crate and mark `Foo` as `#[ LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:32:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ can't be applied to `Bar` | help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:32:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ can't be applied to `Bar` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: enable `#![feature(const_trait_impl)]` in your crate and mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ error[E0015]: cannot call non-const method `<T as Foo>::a` in constant functions diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr index 024db4b6d68..7c465731a99 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nyn.stderr @@ -1,8 +1,8 @@ error[E0658]: const trait impls are experimental --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable @@ -11,8 +11,8 @@ LL | trait Bar: ~const Foo {} error[E0658]: const trait impls are experimental --> $DIR/super-traits-fail-3.rs:32:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr index 024db4b6d68..7c465731a99 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.nyy.stderr @@ -1,8 +1,8 @@ error[E0658]: const trait impls are experimental --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable @@ -11,8 +11,8 @@ LL | trait Bar: ~const Foo {} error[E0658]: const trait impls are experimental --> $DIR/super-traits-fail-3.rs:32:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ | = note: see issue #67792 <https://github.com/rust-lang/rust/issues/67792> for more information = help: add `#![feature(const_trait_impl)]` to the crate attributes to enable diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.rs b/tests/ui/traits/const-traits/super-traits-fail-3.rs index d7e0cdc26ed..5370f607dec 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.rs +++ b/tests/ui/traits/const-traits/super-traits-fail-3.rs @@ -20,21 +20,21 @@ trait Foo { #[cfg_attr(any(yyy, yny, nyy, nyn), const_trait)] //[nyy,nyn]~^ ERROR: `const_trait` is a temporary placeholder for marking a trait that is suitable for `const` `impls` and all default bodies as `const`, which may be removed or renamed in the future -trait Bar: ~const Foo {} -//[yny,ynn,nny,nnn]~^ ERROR: `~const` can only be applied to `#[const_trait]` -//[yny,ynn,nny,nnn]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[yny,ynn,nny,nnn]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[yny]~^^^^ ERROR: `~const` can only be applied to `#[const_trait]` -//[yny]~| ERROR: `~const` can only be applied to `#[const_trait]` -//[yyn,ynn,nny,nnn]~^^^^^^ ERROR: `~const` is not allowed here +trait Bar: [const] Foo {} +//[yny,ynn,nny,nnn]~^ ERROR: `[const]` can only be applied to `#[const_trait]` +//[yny,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[yny,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[yny]~^^^^ ERROR: `[const]` can only be applied to `#[const_trait]` +//[yny]~| ERROR: `[const]` can only be applied to `#[const_trait]` +//[yyn,ynn,nny,nnn]~^^^^^^ ERROR: `[const]` is not allowed here //[nyy,nyn,nny,nnn]~^^^^^^^ ERROR: const trait impls are experimental -const fn foo<T: ~const Bar>(x: &T) { - //[yyn,ynn,nny,nnn]~^ ERROR: `~const` can only be applied to `#[const_trait]` - //[yyn,ynn,nny,nnn]~| ERROR: `~const` can only be applied to `#[const_trait]` +const fn foo<T: [const] Bar>(x: &T) { + //[yyn,ynn,nny,nnn]~^ ERROR: `[const]` can only be applied to `#[const_trait]` + //[yyn,ynn,nny,nnn]~| ERROR: `[const]` can only be applied to `#[const_trait]` //[nyy,nyn,nny,nnn]~^^^ ERROR: const trait impls are experimental x.a(); - //[yyn]~^ ERROR: the trait bound `T: ~const Foo` is not satisfied + //[yyn]~^ ERROR: the trait bound `T: [const] Foo` is not satisfied //[ynn,yny,nny,nnn]~^^ ERROR: cannot call non-const method `<T as Foo>::a` in constant functions //[nyy,nyn]~^^^ ERROR: cannot call conditionally-const method `<T as Foo>::a` in constant functions } diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr index f22bdd472e5..89e090b7d1c 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.ynn.stderr @@ -1,31 +1,31 @@ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/super-traits-fail-3.rs:23:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations | LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -33,11 +33,11 @@ help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -45,27 +45,27 @@ help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:32:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ can't be applied to `Bar` | help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:32:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ can't be applied to `Bar` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ error[E0015]: cannot call non-const method `<T as Foo>::a` in constant functions diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr index 14b50815b8e..683eeb73850 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.yny.stderr @@ -1,19 +1,19 @@ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations | LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -21,11 +21,11 @@ help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -33,11 +33,11 @@ help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations @@ -45,11 +45,11 @@ help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations LL | #[const_trait] trait Foo { | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ can't be applied to `Foo` +LL | trait Bar: [const] Foo {} + | ^^^^^^^ can't be applied to `Foo` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Foo` as `#[const_trait]` to allow it to have `const` implementations diff --git a/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr b/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr index 3270611dace..39cfdfe2030 100644 --- a/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail-3.yyn.stderr @@ -1,39 +1,39 @@ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> $DIR/super-traits-fail-3.rs:23:12 | -LL | trait Bar: ~const Foo {} - | ^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^ | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds +note: this trait is not a `#[const_trait]`, so it cannot have `[const]` trait bounds --> $DIR/super-traits-fail-3.rs:23:1 | -LL | trait Bar: ~const Foo {} - | ^^^^^^^^^^^^^^^^^^^^^^^^ +LL | trait Bar: [const] Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:32:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ can't be applied to `Bar` | help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ -error: `~const` can only be applied to `#[const_trait]` traits +error: `[const]` can only be applied to `#[const_trait]` traits --> $DIR/super-traits-fail-3.rs:32:17 | -LL | const fn foo<T: ~const Bar>(x: &T) { - | ^^^^^^ can't be applied to `Bar` +LL | const fn foo<T: [const] Bar>(x: &T) { + | ^^^^^^^ can't be applied to `Bar` | = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: mark `Bar` as `#[const_trait]` to allow it to have `const` implementations | -LL | #[const_trait] trait Bar: ~const Foo {} +LL | #[const_trait] trait Bar: [const] Foo {} | ++++++++++++++ -error[E0277]: the trait bound `T: ~const Foo` is not satisfied +error[E0277]: the trait bound `T: [const] Foo` is not satisfied --> $DIR/super-traits-fail-3.rs:36:7 | LL | x.a(); diff --git a/tests/ui/traits/const-traits/super-traits-fail.rs b/tests/ui/traits/const-traits/super-traits-fail.rs index 9fd6263118b..15e05be4d86 100644 --- a/tests/ui/traits/const-traits/super-traits-fail.rs +++ b/tests/ui/traits/const-traits/super-traits-fail.rs @@ -7,7 +7,7 @@ trait Foo { fn a(&self); } #[const_trait] -trait Bar: ~const Foo {} +trait Bar: [const] Foo {} struct S; impl Foo for S { diff --git a/tests/ui/traits/const-traits/super-traits-fail.stderr b/tests/ui/traits/const-traits/super-traits-fail.stderr index 1f453edf035..e19aa30cf95 100644 --- a/tests/ui/traits/const-traits/super-traits-fail.stderr +++ b/tests/ui/traits/const-traits/super-traits-fail.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `S: ~const Foo` is not satisfied +error[E0277]: the trait bound `S: [const] Foo` is not satisfied --> $DIR/super-traits-fail.rs:17:20 | LL | impl const Bar for S {} diff --git a/tests/ui/traits/const-traits/super-traits.rs b/tests/ui/traits/const-traits/super-traits.rs index 73ddc037cd7..b5fd985ae43 100644 --- a/tests/ui/traits/const-traits/super-traits.rs +++ b/tests/ui/traits/const-traits/super-traits.rs @@ -8,7 +8,7 @@ trait Foo { } #[const_trait] -trait Bar: ~const Foo {} +trait Bar: [const] Foo {} struct S; impl const Foo for S { @@ -17,7 +17,7 @@ impl const Foo for S { impl const Bar for S {} -const fn foo<T: ~const Bar>(t: &T) { +const fn foo<T: [const] Bar>(t: &T) { t.a(); } diff --git a/tests/ui/traits/const-traits/syntactical-unstable.rs b/tests/ui/traits/const-traits/syntactical-unstable.rs index e192e80fabd..5c542d327f1 100644 --- a/tests/ui/traits/const-traits/syntactical-unstable.rs +++ b/tests/ui/traits/const-traits/syntactical-unstable.rs @@ -1,6 +1,6 @@ //@ aux-build:staged-api.rs -// Ensure that we enforce const stability of traits in `~const`/`const` bounds. +// Ensure that we enforce const stability of traits in `[const]`/`const` bounds. #![feature(const_trait_impl)] @@ -10,19 +10,19 @@ extern crate staged_api; use staged_api::MyTrait; #[const_trait] -trait Foo: ~const MyTrait { +trait Foo: [const] MyTrait { //~^ ERROR use of unstable const library feature `unstable` - type Item: ~const MyTrait; + type Item: [const] MyTrait; //~^ ERROR use of unstable const library feature `unstable` } -const fn where_clause<T>() where T: ~const MyTrait {} +const fn where_clause<T>() where T: [const] MyTrait {} //~^ ERROR use of unstable const library feature `unstable` -const fn nested<T>() where T: Deref<Target: ~const MyTrait> {} +const fn nested<T>() where T: Deref<Target: [const] MyTrait> {} //~^ ERROR use of unstable const library feature `unstable` -const fn rpit() -> impl ~const MyTrait { Local } +const fn rpit() -> impl [const] MyTrait { Local } //~^ ERROR use of unstable const library feature `unstable` struct Local; diff --git a/tests/ui/traits/const-traits/syntactical-unstable.stderr b/tests/ui/traits/const-traits/syntactical-unstable.stderr index a2ce2f2b6e9..b8cc8e69f75 100644 --- a/tests/ui/traits/const-traits/syntactical-unstable.stderr +++ b/tests/ui/traits/const-traits/syntactical-unstable.stderr @@ -1,8 +1,8 @@ error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:13:19 + --> $DIR/syntactical-unstable.rs:13:20 | -LL | trait Foo: ~const MyTrait { - | ------ ^^^^^^^ +LL | trait Foo: [const] MyTrait { + | ------- ^^^^^^^ | | | trait is not stable as const yet | @@ -10,10 +10,10 @@ LL | trait Foo: ~const MyTrait { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:19:44 + --> $DIR/syntactical-unstable.rs:19:45 | -LL | const fn where_clause<T>() where T: ~const MyTrait {} - | ------ ^^^^^^^ +LL | const fn where_clause<T>() where T: [const] MyTrait {} + | ------- ^^^^^^^ | | | trait is not stable as const yet | @@ -21,10 +21,10 @@ LL | const fn where_clause<T>() where T: ~const MyTrait {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:22:52 + --> $DIR/syntactical-unstable.rs:22:53 | -LL | const fn nested<T>() where T: Deref<Target: ~const MyTrait> {} - | ------ ^^^^^^^ +LL | const fn nested<T>() where T: Deref<Target: [const] MyTrait> {} + | ------- ^^^^^^^ | | | trait is not stable as const yet | @@ -32,10 +32,10 @@ LL | const fn nested<T>() where T: Deref<Target: ~const MyTrait> {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:25:32 + --> $DIR/syntactical-unstable.rs:25:33 | -LL | const fn rpit() -> impl ~const MyTrait { Local } - | ------ ^^^^^^^ +LL | const fn rpit() -> impl [const] MyTrait { Local } + | ------- ^^^^^^^ | | | trait is not stable as const yet | @@ -52,10 +52,10 @@ LL | impl const MyTrait for Local { = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: use of unstable const library feature `unstable` - --> $DIR/syntactical-unstable.rs:15:23 + --> $DIR/syntactical-unstable.rs:15:24 | -LL | type Item: ~const MyTrait; - | ------ ^^^^^^^ +LL | type Item: [const] MyTrait; + | ------- ^^^^^^^ | | | trait is not stable as const yet | diff --git a/tests/ui/traits/const-traits/syntax.rs b/tests/ui/traits/const-traits/syntax.rs index cfac6e0a93e..b8e0f46e4f8 100644 --- a/tests/ui/traits/const-traits/syntax.rs +++ b/tests/ui/traits/const-traits/syntax.rs @@ -1,8 +1,9 @@ //@ compile-flags: -Z parse-crate-root-only -//@ check-pass -#![feature(const_trait_bound_opt_out)] #![feature(const_trait_impl)] -// For now, this parses since an error does not occur until AST lowering. -impl ~const T {} +// This is going down the slice/array parsing route +impl [const] T {} +//~^ ERROR: expected identifier, found `]` + +impl const T {} diff --git a/tests/ui/traits/const-traits/syntax.stderr b/tests/ui/traits/const-traits/syntax.stderr new file mode 100644 index 00000000000..2e9807866b0 --- /dev/null +++ b/tests/ui/traits/const-traits/syntax.stderr @@ -0,0 +1,8 @@ +error: expected identifier, found `]` + --> $DIR/syntax.rs:6:12 + | +LL | impl [const] T {} + | ^ expected identifier + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/const-traits/tilde-const-and-const-params.stderr b/tests/ui/traits/const-traits/tilde-const-and-const-params.stderr deleted file mode 100644 index 95e684bd0c4..00000000000 --- a/tests/ui/traits/const-traits/tilde-const-and-const-params.stderr +++ /dev/null @@ -1,39 +0,0 @@ -error: `~const` is not allowed here - --> $DIR/tilde-const-and-const-params.rs:8:15 - | -LL | fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> { - | ^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-and-const-params.rs:8:8 - | -LL | fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> { - | ^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-and-const-params.rs:26:11 - | -LL | fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { - | ^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-and-const-params.rs:26:4 - | -LL | fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { - | ^^^ - -error[E0277]: the trait bound `A: const Add42` is not satisfied - --> $DIR/tilde-const-and-const-params.rs:26:61 - | -LL | fn bar<A: ~const Add42, const N: usize>(_: Foo<N>) -> Foo<{ A::add(N) }> { - | ^ - -error[E0277]: the trait bound `A: const Add42` is not satisfied - --> $DIR/tilde-const-and-const-params.rs:8:44 - | -LL | fn add<A: ~const Add42>(self) -> Foo<{ A::add(N) }> { - | ^ - -error: aborting due to 4 previous errors - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/tilde-const-invalid-places.rs b/tests/ui/traits/const-traits/tilde-const-invalid-places.rs deleted file mode 100644 index 9d220686771..00000000000 --- a/tests/ui/traits/const-traits/tilde-const-invalid-places.rs +++ /dev/null @@ -1,61 +0,0 @@ -#![feature(const_trait_impl)] - -#[const_trait] -trait Trait {} - -// Regression test for issue #90052. -fn non_const_function<T: ~const Trait>() {} //~ ERROR `~const` is not allowed - -struct Struct<T: ~const Trait> { field: T } //~ ERROR `~const` is not allowed here -struct TupleStruct<T: ~const Trait>(T); //~ ERROR `~const` is not allowed here -struct UnitStruct<T: ~const Trait>; //~ ERROR `~const` is not allowed here -//~^ ERROR parameter `T` is never used - -enum Enum<T: ~const Trait> { Variant(T) } //~ ERROR `~const` is not allowed here - -union Union<T: ~const Trait> { field: T } //~ ERROR `~const` is not allowed here -//~^ ERROR field must implement `Copy` - -type Type<T: ~const Trait> = T; //~ ERROR `~const` is not allowed here - -const CONSTANT<T: ~const Trait>: () = (); //~ ERROR `~const` is not allowed here -//~^ ERROR generic const items are experimental - -trait NonConstTrait { - type Type<T: ~const Trait>: ~const Trait; - //~^ ERROR `~const` is not allowed - //~| ERROR `~const` is not allowed - fn non_const_function<T: ~const Trait>(); //~ ERROR `~const` is not allowed - const CONSTANT<T: ~const Trait>: (); //~ ERROR `~const` is not allowed - //~^ ERROR generic const items are experimental -} - -impl NonConstTrait for () { - type Type<T: ~const Trait> = (); //~ ERROR `~const` is not allowed - //~^ ERROR overflow evaluating the requirement `(): Trait` - fn non_const_function<T: ~const Trait>() {} //~ ERROR `~const` is not allowed - const CONSTANT<T: ~const Trait>: () = (); //~ ERROR `~const` is not allowed - //~^ ERROR generic const items are experimental -} - -struct Implementor; - -impl Implementor { - type Type<T: ~const Trait> = (); //~ ERROR `~const` is not allowed - //~^ ERROR inherent associated types are unstable - fn non_const_function<T: ~const Trait>() {} //~ ERROR `~const` is not allowed - const CONSTANT<T: ~const Trait>: () = (); //~ ERROR `~const` is not allowed - //~^ ERROR generic const items are experimental -} - -// non-const traits -trait Child0: ~const Trait {} //~ ERROR `~const` is not allowed -trait Child1 where Self: ~const Trait {} //~ ERROR `~const` is not allowed - -// non-const impl -impl<T: ~const Trait> Trait for T {} //~ ERROR `~const` is not allowed - -// inherent impl (regression test for issue #117004) -impl<T: ~const Trait> Struct<T> {} //~ ERROR `~const` is not allowed - -fn main() {} diff --git a/tests/ui/traits/const-traits/tilde-const-invalid-places.stderr b/tests/ui/traits/const-traits/tilde-const-invalid-places.stderr deleted file mode 100644 index 8151b9aaa23..00000000000 --- a/tests/ui/traits/const-traits/tilde-const-invalid-places.stderr +++ /dev/null @@ -1,310 +0,0 @@ -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:7:26 - | -LL | fn non_const_function<T: ~const Trait>() {} - | ^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:7:4 - | -LL | fn non_const_function<T: ~const Trait>() {} - | ^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:9:18 - | -LL | struct Struct<T: ~const Trait> { field: T } - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:10:23 - | -LL | struct TupleStruct<T: ~const Trait>(T); - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:11:22 - | -LL | struct UnitStruct<T: ~const Trait>; - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:14:14 - | -LL | enum Enum<T: ~const Trait> { Variant(T) } - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:16:16 - | -LL | union Union<T: ~const Trait> { field: T } - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:19:14 - | -LL | type Type<T: ~const Trait> = T; - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:21:19 - | -LL | const CONSTANT<T: ~const Trait>: () = (); - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:25:18 - | -LL | type Type<T: ~const Trait>: ~const Trait; - | ^^^^^^ - | -note: associated types in non-`#[const_trait]` traits cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:25:5 - | -LL | type Type<T: ~const Trait>: ~const Trait; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:25:33 - | -LL | type Type<T: ~const Trait>: ~const Trait; - | ^^^^^^ - | -note: associated types in non-`#[const_trait]` traits cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:25:5 - | -LL | type Type<T: ~const Trait>: ~const Trait; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:28:30 - | -LL | fn non_const_function<T: ~const Trait>(); - | ^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:28:8 - | -LL | fn non_const_function<T: ~const Trait>(); - | ^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:29:23 - | -LL | const CONSTANT<T: ~const Trait>: (); - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:34:18 - | -LL | type Type<T: ~const Trait> = (); - | ^^^^^^ - | -note: associated types in non-const impls cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:34:5 - | -LL | type Type<T: ~const Trait> = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:36:30 - | -LL | fn non_const_function<T: ~const Trait>() {} - | ^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:36:8 - | -LL | fn non_const_function<T: ~const Trait>() {} - | ^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:37:23 - | -LL | const CONSTANT<T: ~const Trait>: () = (); - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:44:18 - | -LL | type Type<T: ~const Trait> = (); - | ^^^^^^ - | -note: inherent associated types cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:44:5 - | -LL | type Type<T: ~const Trait> = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:46:30 - | -LL | fn non_const_function<T: ~const Trait>() {} - | ^^^^^^ - | -note: this function is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:46:8 - | -LL | fn non_const_function<T: ~const Trait>() {} - | ^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:47:23 - | -LL | const CONSTANT<T: ~const Trait>: () = (); - | ^^^^^^ - | - = note: this item cannot have `~const` trait bounds - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:52:15 - | -LL | trait Child0: ~const Trait {} - | ^^^^^^ - | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:52:1 - | -LL | trait Child0: ~const Trait {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:53:26 - | -LL | trait Child1 where Self: ~const Trait {} - | ^^^^^^ - | -note: this trait is not a `#[const_trait]`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:53:1 - | -LL | trait Child1 where Self: ~const Trait {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:56:9 - | -LL | impl<T: ~const Trait> Trait for T {} - | ^^^^^^ - | -note: this impl is not `const`, so it cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:56:1 - | -LL | impl<T: ~const Trait> Trait for T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: `~const` is not allowed here - --> $DIR/tilde-const-invalid-places.rs:59:9 - | -LL | impl<T: ~const Trait> Struct<T> {} - | ^^^^^^ - | -note: inherent impls cannot have `~const` trait bounds - --> $DIR/tilde-const-invalid-places.rs:59:1 - | -LL | impl<T: ~const Trait> Struct<T> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error[E0658]: generic const items are experimental - --> $DIR/tilde-const-invalid-places.rs:21:15 - | -LL | const CONSTANT<T: ~const Trait>: () = (); - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information - = help: add `#![feature(generic_const_items)]` 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]: generic const items are experimental - --> $DIR/tilde-const-invalid-places.rs:29:19 - | -LL | const CONSTANT<T: ~const Trait>: (); - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information - = help: add `#![feature(generic_const_items)]` 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]: generic const items are experimental - --> $DIR/tilde-const-invalid-places.rs:37:19 - | -LL | const CONSTANT<T: ~const Trait>: () = (); - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information - = help: add `#![feature(generic_const_items)]` 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]: generic const items are experimental - --> $DIR/tilde-const-invalid-places.rs:47:19 - | -LL | const CONSTANT<T: ~const Trait>: () = (); - | ^^^^^^^^^^^^^^^^^ - | - = note: see issue #113521 <https://github.com/rust-lang/rust/issues/113521> for more information - = help: add `#![feature(generic_const_items)]` 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[E0392]: type parameter `T` is never used - --> $DIR/tilde-const-invalid-places.rs:11:19 - | -LL | struct UnitStruct<T: ~const Trait>; - | ^ unused type parameter - | - = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` - -error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/tilde-const-invalid-places.rs:16:32 - | -LL | union Union<T: ~const Trait> { field: T } - | ^^^^^^^^ - | - = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` -help: wrap the field type in `ManuallyDrop<...>` - | -LL | union Union<T: ~const Trait> { field: std::mem::ManuallyDrop<T> } - | +++++++++++++++++++++++ + - -error[E0275]: overflow evaluating the requirement `(): Trait` - --> $DIR/tilde-const-invalid-places.rs:34:34 - | -LL | type Type<T: ~const Trait> = (); - | ^^ - | -note: required by a bound in `NonConstTrait::Type` - --> $DIR/tilde-const-invalid-places.rs:25:33 - | -LL | type Type<T: ~const Trait>: ~const Trait; - | ^^^^^^^^^^^^ required by this bound in `NonConstTrait::Type` - -error[E0658]: inherent associated types are unstable - --> $DIR/tilde-const-invalid-places.rs:44:5 - | -LL | type Type<T: ~const Trait> = (); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #8995 <https://github.com/rust-lang/rust/issues/8995> for more information - = help: add `#![feature(inherent_associated_types)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - -error: aborting due to 30 previous errors - -Some errors have detailed explanations: E0275, E0392, E0658, E0740. -For more information about an error, try `rustc --explain E0275`. diff --git a/tests/ui/traits/const-traits/tilde-const-syntax.rs b/tests/ui/traits/const-traits/tilde-const-syntax.rs deleted file mode 100644 index f9944c426cc..00000000000 --- a/tests/ui/traits/const-traits/tilde-const-syntax.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ compile-flags: -Z parse-crate-root-only -//@ check-pass - -#![feature(const_trait_impl)] - -struct S< - T: for<'a> ~const Tr<'a> + 'static + ~const std::ops::Add, - T: for<'a: 'b> ~const m::Trait<'a>, ->; diff --git a/tests/ui/traits/const-traits/tilde-twice.stderr b/tests/ui/traits/const-traits/tilde-twice.stderr deleted file mode 100644 index a809736a4f8..00000000000 --- a/tests/ui/traits/const-traits/tilde-twice.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: expected identifier, found `~` - --> $DIR/tilde-twice.rs:5:20 - | -LL | struct S<T: ~const ~const Tr>; - | ^ expected identifier - -error: aborting due to 1 previous error - diff --git a/tests/ui/traits/const-traits/trait-where-clause-const.rs b/tests/ui/traits/const-traits/trait-where-clause-const.rs index 6f281ca5718..ccb514086cc 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-const.rs +++ b/tests/ui/traits/const-traits/trait-where-clause-const.rs @@ -12,11 +12,11 @@ trait Bar {} #[const_trait] trait Foo { fn a(); - fn b() where Self: ~const Bar; - fn c<T: ~const Bar>(); + fn b() where Self: [const] Bar; + fn c<T: [const] Bar>(); } -const fn test1<T: ~const Foo + Bar>() { +const fn test1<T: [const] Foo + Bar>() { T::a(); T::b(); //~^ ERROR the trait bound @@ -24,7 +24,7 @@ const fn test1<T: ~const Foo + Bar>() { //~^ ERROR the trait bound } -const fn test2<T: ~const Foo + ~const Bar>() { +const fn test2<T: [const] Foo + [const] Bar>() { T::a(); T::b(); T::c::<T>(); diff --git a/tests/ui/traits/const-traits/trait-where-clause-const.stderr b/tests/ui/traits/const-traits/trait-where-clause-const.stderr index 4ebd7b9757f..71f9bdff878 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-const.stderr +++ b/tests/ui/traits/const-traits/trait-where-clause-const.stderr @@ -1,4 +1,4 @@ -error[E0277]: the trait bound `T: ~const Bar` is not satisfied +error[E0277]: the trait bound `T: [const] Bar` is not satisfied --> $DIR/trait-where-clause-const.rs:21:5 | LL | T::b(); @@ -7,10 +7,10 @@ LL | T::b(); note: required by a bound in `Foo::b` --> $DIR/trait-where-clause-const.rs:15:24 | -LL | fn b() where Self: ~const Bar; - | ^^^^^^^^^^ required by this bound in `Foo::b` +LL | fn b() where Self: [const] Bar; + | ^^^^^^^^^^^ required by this bound in `Foo::b` -error[E0277]: the trait bound `T: ~const Bar` is not satisfied +error[E0277]: the trait bound `T: [const] Bar` is not satisfied --> $DIR/trait-where-clause-const.rs:23:12 | LL | T::c::<T>(); @@ -19,8 +19,8 @@ LL | T::c::<T>(); note: required by a bound in `Foo::c` --> $DIR/trait-where-clause-const.rs:16:13 | -LL | fn c<T: ~const Bar>(); - | ^^^^^^^^^^ required by this bound in `Foo::c` +LL | fn c<T: [const] Bar>(); + | ^^^^^^^^^^^ required by this bound in `Foo::c` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/const-traits/trait-where-clause-run.rs b/tests/ui/traits/const-traits/trait-where-clause-run.rs index 2582a69acab..c40f071f457 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-run.rs +++ b/tests/ui/traits/const-traits/trait-where-clause-run.rs @@ -10,7 +10,7 @@ trait Bar { #[const_trait] trait Foo { - fn foo() -> u8 where Self: ~const Bar { + fn foo() -> u8 where Self: [const] Bar { <Self as Bar>::bar() * 6 } } diff --git a/tests/ui/traits/const-traits/trait-where-clause-self-referential.rs b/tests/ui/traits/const-traits/trait-where-clause-self-referential.rs index b6ac574a4fc..3a5350cd4ea 100644 --- a/tests/ui/traits/const-traits/trait-where-clause-self-referential.rs +++ b/tests/ui/traits/const-traits/trait-where-clause-self-referential.rs @@ -4,7 +4,7 @@ #[const_trait] trait Foo { - fn bar() where Self: ~const Foo; + fn bar() where Self: [const] Foo; } struct S; @@ -17,7 +17,7 @@ fn baz<T: Foo>() { T::bar(); } -const fn qux<T: ~const Foo>() { +const fn qux<T: [const] Foo>() { T::bar(); } diff --git a/tests/ui/traits/const-traits/trait-where-clause.rs b/tests/ui/traits/const-traits/trait-where-clause.rs index 11f353f3f8a..6aebab79090 100644 --- a/tests/ui/traits/const-traits/trait-where-clause.rs +++ b/tests/ui/traits/const-traits/trait-where-clause.rs @@ -5,10 +5,10 @@ trait Bar {} trait Foo { fn a(); - fn b() where Self: ~const Bar; - //~^ ERROR `~const` is not allowed here - fn c<T: ~const Bar>(); - //~^ ERROR `~const` is not allowed here + fn b() where Self: [const] Bar; + //~^ ERROR `[const]` is not allowed here + fn c<T: [const] Bar>(); + //~^ ERROR `[const]` is not allowed here } fn test1<T: Foo>() { diff --git a/tests/ui/traits/const-traits/trait-where-clause.stderr b/tests/ui/traits/const-traits/trait-where-clause.stderr index 3a15cc63f32..dda91e6bca1 100644 --- a/tests/ui/traits/const-traits/trait-where-clause.stderr +++ b/tests/ui/traits/const-traits/trait-where-clause.stderr @@ -1,25 +1,25 @@ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> $DIR/trait-where-clause.rs:8:24 | -LL | fn b() where Self: ~const Bar; - | ^^^^^^ +LL | fn b() where Self: [const] Bar; + | ^^^^^^^ | -note: this function is not `const`, so it cannot have `~const` trait bounds +note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/trait-where-clause.rs:8:8 | -LL | fn b() where Self: ~const Bar; +LL | fn b() where Self: [const] Bar; | ^ -error: `~const` is not allowed here +error: `[const]` is not allowed here --> $DIR/trait-where-clause.rs:10:13 | -LL | fn c<T: ~const Bar>(); - | ^^^^^^ +LL | fn c<T: [const] Bar>(); + | ^^^^^^^ | -note: this function is not `const`, so it cannot have `~const` trait bounds +note: this function is not `const`, so it cannot have `[const]` trait bounds --> $DIR/trait-where-clause.rs:10:8 | -LL | fn c<T: ~const Bar>(); +LL | fn c<T: [const] Bar>(); | ^ error[E0277]: the trait bound `T: Bar` is not satisfied @@ -31,8 +31,8 @@ LL | T::b(); note: required by a bound in `Foo::b` --> $DIR/trait-where-clause.rs:8:24 | -LL | fn b() where Self: ~const Bar; - | ^^^^^^^^^^ required by this bound in `Foo::b` +LL | fn b() where Self: [const] Bar; + | ^^^^^^^^^^^ required by this bound in `Foo::b` help: consider further restricting type parameter `T` with trait `Bar` | LL | fn test1<T: Foo + Bar>() { @@ -47,8 +47,8 @@ LL | T::c::<T>(); note: required by a bound in `Foo::c` --> $DIR/trait-where-clause.rs:10:13 | -LL | fn c<T: ~const Bar>(); - | ^^^^^^^^^^ required by this bound in `Foo::c` +LL | fn c<T: [const] Bar>(); + | ^^^^^^^^^^^ required by this bound in `Foo::c` help: consider further restricting type parameter `T` with trait `Bar` | LL | fn test1<T: Foo + Bar>() { diff --git a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs index 6d19ef771af..c82b4427500 100644 --- a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs +++ b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.rs @@ -29,5 +29,5 @@ struct Container<const N: u32>; fn accept0<T: Trait>(_: Container<{ T::make() }>) {} // FIXME(const_trait_impl): Instead of suggesting `+ const Trait`, suggest -// changing `~const Trait` to `const Trait`. -const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} +// changing `[const] Trait` to `const Trait`. +const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} diff --git a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr index 03e26615d7e..3ed6dc69d0b 100644 --- a/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr +++ b/tests/ui/traits/const-traits/unsatisfied-const-trait-bound.stderr @@ -64,74 +64,74 @@ LL | fn accept0<T: Trait>(_: Container<{ T::make() }>) {} | ^^^^^^^^^^^^^ = note: ...which again requires evaluating type-level constant, completing the cycle note: cycle used when checking that `accept0` is well-formed - --> $DIR/unsatisfied-const-trait-bound.rs:29:1 + --> $DIR/unsatisfied-const-trait-bound.rs:29:35 | LL | fn accept0<T: Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when caching mir of `accept1::{constant#0}` for CTFE - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ | note: ...which requires elaborating drops for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires borrow-checking `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires promoting constants in MIR for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires const checking `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires building MIR for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires building an abstract representation for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires building THIR for `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires type-checking `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires evaluating type-level constant... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ note: ...which requires const-evaluating + checking `accept1::{constant#0}`... - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ = note: ...which again requires caching mir of `accept1::{constant#0}` for CTFE, completing the cycle note: cycle used when const-evaluating + checking `accept1::{constant#0}` - --> $DIR/unsatisfied-const-trait-bound.rs:33:48 + --> $DIR/unsatisfied-const-trait-bound.rs:33:49 | -LL | const fn accept1<T: ~const Trait>(_: Container<{ T::make() }>) {} - | ^^^^^^^^^^^^^ +LL | const fn accept1<T: [const] Trait>(_: Container<{ T::make() }>) {} + | ^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error: aborting due to 3 previous errors diff --git a/tests/ui/impl-unused-tps.rs b/tests/ui/traits/constrained-type-params-trait-impl.rs index a5836db3c8e..301bbdb2ccb 100644 --- a/tests/ui/impl-unused-tps.rs +++ b/tests/ui/traits/constrained-type-params-trait-impl.rs @@ -1,3 +1,11 @@ +//! Comprehensive test for type parameter constraints in trait implementations +//! +//! This tests various scenarios of type parameter usage in trait implementations: +//! - Properly constrained parameters through trait bounds +//! - Unconstrained parameters that should cause compilation errors +//! - Complex constraint scenarios with `where` clauses and associated types +//! - Conflicting implementations detection + trait Foo<A> { fn get(&self, A: &A) {} } @@ -7,34 +15,34 @@ trait Bar { } impl<T> Foo<T> for [isize; 0] { - // OK, T is used in `Foo<T>`. + // OK: T is used in the trait bound `Foo<T>` } impl<T, U> Foo<T> for [isize; 1] { //~^ ERROR the type parameter `U` is not constrained + // T is constrained by `Foo<T>`, but U is completely unused } impl<T, U> Foo<T> for [isize; 2] where T: Bar<Out = U>, { - // OK, `U` is now constrained by the output type parameter. + // OK: T is constrained by `Foo<T>`, U is constrained by the where clause } impl<T: Bar<Out = U>, U> Foo<T> for [isize; 3] { - // OK, same as above but written differently. + // OK: Same as above but using bound syntax instead of where clause } impl<T, U> Foo<T> for U { //~^ ERROR conflicting implementations of trait `Foo<_>` for type `[isize; 0]` + // This conflicts with the first impl when U = [isize; 0] } impl<T, U> Bar for T { //~^ ERROR the type parameter `U` is not constrained - type Out = U; - - // Using `U` in an associated type within the impl is not good enough! + // Using U only in associated type definition is insufficient for constraint } impl<T, U> Bar for T @@ -43,7 +51,7 @@ where { //~^^^^ ERROR the type parameter `U` is not constrained by the impl trait, self type, or predicates //~| ERROR conflicting implementations of trait `Bar` - // This crafty self-referential attempt is still no good. + // Self-referential constraint doesn't properly constrain U } impl<T, U, V> Foo<T> for T @@ -53,9 +61,7 @@ where //~^^^^ ERROR the type parameter `U` is not constrained //~| ERROR the type parameter `V` is not constrained //~| ERROR conflicting implementations of trait `Foo<[isize; 0]>` for type `[isize; 0]` - - // Here, `V` is bound by an output type parameter, but the inputs - // are not themselves constrained. + // V is bound through output type, but U and V are not properly constrained as inputs } impl<T, U, V> Foo<(T, U)> for T @@ -63,7 +69,7 @@ where (T, U): Bar<Out = V>, { //~^^^^ ERROR conflicting implementations of trait `Foo<([isize; 0], _)>` for type `[isize; 0]` - // As above, but both T and U ARE constrained. + // Both T and U are constrained through `Foo<(T, U)>`, but creates conflicting impl } fn main() {} diff --git a/tests/ui/impl-unused-tps.stderr b/tests/ui/traits/constrained-type-params-trait-impl.stderr index eff5ffff9b6..e59fad6e72d 100644 --- a/tests/ui/impl-unused-tps.stderr +++ b/tests/ui/traits/constrained-type-params-trait-impl.stderr @@ -1,5 +1,5 @@ error[E0119]: conflicting implementations of trait `Foo<_>` for type `[isize; 0]` - --> $DIR/impl-unused-tps.rs:28:1 + --> $DIR/constrained-type-params-trait-impl.rs:37:1 | LL | impl<T> Foo<T> for [isize; 0] { | ----------------------------- first implementation here @@ -8,7 +8,7 @@ LL | impl<T, U> Foo<T> for U { | ^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `[isize; 0]` error[E0119]: conflicting implementations of trait `Foo<[isize; 0]>` for type `[isize; 0]` - --> $DIR/impl-unused-tps.rs:49:1 + --> $DIR/constrained-type-params-trait-impl.rs:57:1 | LL | impl<T> Foo<T> for [isize; 0] { | ----------------------------- first implementation here @@ -19,7 +19,7 @@ LL | | (T, U): Bar<Out = V>, | |_________________________^ conflicting implementation for `[isize; 0]` error[E0119]: conflicting implementations of trait `Foo<([isize; 0], _)>` for type `[isize; 0]` - --> $DIR/impl-unused-tps.rs:61:1 + --> $DIR/constrained-type-params-trait-impl.rs:67:1 | LL | impl<T> Foo<T> for [isize; 0] { | ----------------------------- first implementation here @@ -30,46 +30,46 @@ LL | | (T, U): Bar<Out = V>, | |_________________________^ conflicting implementation for `[isize; 0]` error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:13:9 + --> $DIR/constrained-type-params-trait-impl.rs:21:9 | LL | impl<T, U> Foo<T> for [isize; 1] { | ^ unconstrained type parameter +error[E0119]: conflicting implementations of trait `Bar` + --> $DIR/constrained-type-params-trait-impl.rs:48:1 + | +LL | impl<T, U> Bar for T { + | -------------------- first implementation here +... +LL | / impl<T, U> Bar for T +LL | | where +LL | | T: Bar<Out = U>, + | |____________________^ conflicting implementation + error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:32:9 + --> $DIR/constrained-type-params-trait-impl.rs:42:9 | LL | impl<T, U> Bar for T { | ^ unconstrained type parameter error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:40:9 + --> $DIR/constrained-type-params-trait-impl.rs:48:9 | LL | impl<T, U> Bar for T | ^ unconstrained type parameter error[E0207]: the type parameter `U` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:49:9 + --> $DIR/constrained-type-params-trait-impl.rs:57:9 | LL | impl<T, U, V> Foo<T> for T | ^ unconstrained type parameter error[E0207]: the type parameter `V` is not constrained by the impl trait, self type, or predicates - --> $DIR/impl-unused-tps.rs:49:12 + --> $DIR/constrained-type-params-trait-impl.rs:57:12 | LL | impl<T, U, V> Foo<T> for T | ^ unconstrained type parameter -error[E0119]: conflicting implementations of trait `Bar` - --> $DIR/impl-unused-tps.rs:40:1 - | -LL | impl<T, U> Bar for T { - | -------------------- first implementation here -... -LL | / impl<T, U> Bar for T -LL | | where -LL | | T: Bar<Out = U>, - | |____________________^ conflicting implementation - error: aborting due to 9 previous errors Some errors have detailed explanations: E0119, E0207. diff --git a/tests/ui/opt-in-copy.rs b/tests/ui/traits/copy-requires-all-fields-copy.rs index d0257b5745d..8c829a7382b 100644 --- a/tests/ui/opt-in-copy.rs +++ b/tests/ui/traits/copy-requires-all-fields-copy.rs @@ -1,3 +1,5 @@ +//! Test that `Copy` cannot be implemented if any field doesn't implement `Copy`. + struct CantCopyThis; struct IWantToCopyThis { diff --git a/tests/ui/opt-in-copy.stderr b/tests/ui/traits/copy-requires-all-fields-copy.stderr index 258ff16e6e4..1a9e1ada366 100644 --- a/tests/ui/opt-in-copy.stderr +++ b/tests/ui/traits/copy-requires-all-fields-copy.stderr @@ -1,5 +1,5 @@ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/opt-in-copy.rs:7:15 + --> $DIR/copy-requires-all-fields-copy.rs:9:15 | LL | but_i_cant: CantCopyThis, | ------------------------ this field does not implement `Copy` @@ -8,7 +8,7 @@ LL | impl Copy for IWantToCopyThis {} | ^^^^^^^^^^^^^^^ error[E0204]: the trait `Copy` cannot be implemented for this type - --> $DIR/opt-in-copy.rs:19:15 + --> $DIR/copy-requires-all-fields-copy.rs:21:15 | LL | ButICant(CantCopyThisEither), | ------------------ this field does not implement `Copy` diff --git a/tests/ui/traits/deep-norm-pending.rs b/tests/ui/traits/deep-norm-pending.rs index f56c3cfa3ea..d6c498dcf2b 100644 --- a/tests/ui/traits/deep-norm-pending.rs +++ b/tests/ui/traits/deep-norm-pending.rs @@ -8,9 +8,10 @@ trait Bar { } impl<T> Bar for T //~^ ERROR the trait bound `T: Foo` is not satisfied -//~| ERROR the trait bound `T: Foo` is not satisfied where <T as Foo>::Assoc: Sized, + //~^ ERROR the trait bound `T: Foo` is not satisfied + //~| ERROR the trait bound `T: Foo` is not satisfied { fn method() {} //~^ ERROR the trait bound `T: Foo` is not satisfied @@ -18,7 +19,6 @@ where //~| ERROR the trait bound `T: Foo` is not satisfied //~| ERROR the trait bound `T: Foo` is not satisfied //~| ERROR the trait bound `T: Foo` is not satisfied - //~| ERROR the trait bound `T: Foo` is not satisfied } fn main() {} diff --git a/tests/ui/traits/deep-norm-pending.stderr b/tests/ui/traits/deep-norm-pending.stderr index b95b9d7f4ae..c1d6120c390 100644 --- a/tests/ui/traits/deep-norm-pending.stderr +++ b/tests/ui/traits/deep-norm-pending.stderr @@ -1,20 +1,8 @@ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:15:5 - | -LL | fn method() {} - | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` - | -help: consider further restricting type parameter `T` with trait `Foo` - | -LL | <T as Foo>::Assoc: Sized, T: Foo - | ++++++ - -error[E0277]: the trait bound `T: Foo` is not satisfied --> $DIR/deep-norm-pending.rs:9:1 | LL | / impl<T> Bar for T LL | | -LL | | LL | | where LL | | <T as Foo>::Assoc: Sized, | |_____________________________^ the trait `Foo` is not implemented for `T` @@ -25,15 +13,10 @@ LL | <T as Foo>::Assoc: Sized, T: Foo | ++++++ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:9:1 + --> $DIR/deep-norm-pending.rs:16:5 | -LL | / impl<T> Bar for T -LL | | -LL | | -LL | | where -... | -LL | | } - | |_^ the trait `Foo` is not implemented for `T` +LL | fn method() {} + | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` | help: consider further restricting type parameter `T` with trait `Foo` | @@ -41,7 +24,7 @@ LL | <T as Foo>::Assoc: Sized, T: Foo | ++++++ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:15:5 + --> $DIR/deep-norm-pending.rs:16:5 | LL | fn method() {} | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` @@ -53,7 +36,7 @@ LL | <T as Foo>::Assoc: Sized, T: Foo | ++++++ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:15:5 + --> $DIR/deep-norm-pending.rs:16:5 | LL | fn method() {} | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` @@ -72,7 +55,7 @@ LL | <T as Foo>::Assoc: Sized, T: Foo | ++++++ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:15:5 + --> $DIR/deep-norm-pending.rs:16:5 | LL | fn method() {} | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` @@ -103,7 +86,18 @@ LL | <T as Foo>::Assoc: Sized, T: Foo | ++++++ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:15:5 + --> $DIR/deep-norm-pending.rs:12:24 + | +LL | <T as Foo>::Assoc: Sized, + | ^^^^^ the trait `Foo` is not implemented for `T` + | +help: consider further restricting type parameter `T` with trait `Foo` + | +LL | <T as Foo>::Assoc: Sized, T: Foo + | ++++++ + +error[E0277]: the trait bound `T: Foo` is not satisfied + --> $DIR/deep-norm-pending.rs:16:5 | LL | fn method() {} | ^^^^^^^^^^^ the trait `Foo` is not implemented for `T` @@ -115,11 +109,12 @@ LL | <T as Foo>::Assoc: Sized, T: Foo | ++++++ error[E0277]: the trait bound `T: Foo` is not satisfied - --> $DIR/deep-norm-pending.rs:15:8 + --> $DIR/deep-norm-pending.rs:12:24 | -LL | fn method() {} - | ^^^^^^ the trait `Foo` is not implemented for `T` +LL | <T as Foo>::Assoc: Sized, + | ^^^^^ the trait `Foo` is not implemented for `T` | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider further restricting type parameter `T` with trait `Foo` | LL | <T as Foo>::Assoc: Sized, T: Foo diff --git a/tests/ui/invalid_dispatch_from_dyn_impls.rs b/tests/ui/traits/dispatch-from-dyn-invalid-impls.rs index b1d4b261bab..f5f66ca69cf 100644 --- a/tests/ui/invalid_dispatch_from_dyn_impls.rs +++ b/tests/ui/traits/dispatch-from-dyn-invalid-impls.rs @@ -1,20 +1,30 @@ +//! Test various invalid implementations of DispatchFromDyn trait. +//! +//! DispatchFromDyn is a special trait used by the compiler for dyn-compatible dynamic dispatch. +//! This checks that the compiler correctly rejects invalid implementations: +//! - Structs with extra non-coercible fields +//! - Structs with multiple pointer fields +//! - Structs with no coercible fields +//! - Structs with repr(C) or other incompatible representations +//! - Structs with over-aligned fields + #![feature(unsize, dispatch_from_dyn)] -use std::{ - ops::DispatchFromDyn, - marker::{Unsize, PhantomData}, -}; +use std::marker::{PhantomData, Unsize}; +use std::ops::DispatchFromDyn; +// Extra field prevents DispatchFromDyn struct WrapperWithExtraField<T>(T, i32); impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T> //~^ ERROR [E0378] where - T: DispatchFromDyn<U>, -{} - + T: DispatchFromDyn<U> +{ +} -struct MultiplePointers<T: ?Sized>{ +// Multiple pointer fields create ambiguous coercion +struct MultiplePointers<T: ?Sized> { ptr1: *const T, ptr2: *const T, } @@ -22,10 +32,11 @@ struct MultiplePointers<T: ?Sized>{ impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for MultiplePointers<T> //~^ ERROR implementing `DispatchFromDyn` does not allow multiple fields to be coerced where - T: Unsize<U>, -{} - + T: Unsize<U> +{ +} +// No coercible fields (only PhantomData) struct NothingToCoerce<T: ?Sized> { data: PhantomData<T>, } @@ -33,23 +44,28 @@ struct NothingToCoerce<T: ?Sized> { impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {} //~^ ERROR implementing `DispatchFromDyn` requires a field to be coerced +// repr(C) is incompatible with DispatchFromDyn #[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>, -{} + T: Unsize<U> +{ +} +// Over-aligned fields are incompatible #[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>, -{} +where + T: Unsize<U> +{ +} fn main() {} diff --git a/tests/ui/invalid_dispatch_from_dyn_impls.stderr b/tests/ui/traits/dispatch-from-dyn-invalid-impls.stderr index 93ec6bbe089..676da0ce81f 100644 --- a/tests/ui/invalid_dispatch_from_dyn_impls.stderr +++ b/tests/ui/traits/dispatch-from-dyn-invalid-impls.stderr @@ -1,25 +1,25 @@ 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:10:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:19:1 | LL | / impl<T, U> DispatchFromDyn<WrapperWithExtraField<U>> for WrapperWithExtraField<T> LL | | LL | | where -LL | | T: DispatchFromDyn<U>, - | |__________________________^ +LL | | T: DispatchFromDyn<U> + | |_________________________^ | = note: extra field `1` of type `i32` is not allowed error[E0375]: implementing `DispatchFromDyn` does not allow multiple fields to be coerced - --> $DIR/invalid_dispatch_from_dyn_impls.rs:22:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:32:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<MultiplePointers<U>> for MultiplePointers<T> LL | | LL | | where -LL | | T: Unsize<U>, - | |_________________^ +LL | | T: Unsize<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 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:28:5 | LL | ptr1: *const T, | ^^^^^^^^^^^^^^ @@ -27,7 +27,7 @@ LL | ptr2: *const T, | ^^^^^^^^^^^^^^ error[E0374]: implementing `DispatchFromDyn` requires a field to be coerced - --> $DIR/invalid_dispatch_from_dyn_impls.rs:33:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:44:1 | LL | impl<T: ?Sized, U: ?Sized> DispatchFromDyn<NothingToCoerce<T>> for NothingToCoerce<U> {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -35,22 +35,22 @@ 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:39:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:51:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<HasReprC<U>> for HasReprC<T> LL | | LL | | where -LL | | T: Unsize<U>, - | |_________________^ +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:49:1 + --> $DIR/dispatch-from-dyn-invalid-impls.rs:64:1 | LL | / impl<T: ?Sized, U: ?Sized> DispatchFromDyn<OverAligned<U>> for OverAligned<T> LL | | -LL | | where -LL | | T: Unsize<U>, - | |_____________________^ +LL | | where +LL | | T: Unsize<U> + | |________________^ | = note: extra field `1` of type `OverAlignedZst` is not allowed diff --git a/tests/ui/traits/dyn-star-drop-principal.rs b/tests/ui/traits/dyn-star-drop-principal.rs deleted file mode 100644 index 1ad99070339..00000000000 --- a/tests/ui/traits/dyn-star-drop-principal.rs +++ /dev/null @@ -1,12 +0,0 @@ -#![feature(dyn_star)] -#![allow(incomplete_features)] - -trait Trait {} -impl Trait for usize {} - -fn main() { - // We allow &dyn Trait + Send -> &dyn Send (i.e. dropping principal), - // but we don't (currently?) allow the same for dyn* - let x: dyn* Trait + Send = 1usize; - x as dyn* Send; //~ error: `dyn* Trait + Send` needs to have the same ABI as a pointer -} diff --git a/tests/ui/traits/dyn-star-drop-principal.stderr b/tests/ui/traits/dyn-star-drop-principal.stderr deleted file mode 100644 index 721ae7e191e..00000000000 --- a/tests/ui/traits/dyn-star-drop-principal.stderr +++ /dev/null @@ -1,11 +0,0 @@ -error[E0277]: `dyn* Trait + Send` needs to have the same ABI as a pointer - --> $DIR/dyn-star-drop-principal.rs:11:5 - | -LL | x as dyn* Send; - | ^ `dyn* Trait + Send` needs to be a pointer-like type - | - = help: the trait `PointerLike` is not implemented for `dyn* Trait + Send` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/dyn-trait.rs b/tests/ui/traits/dyn-trait.rs index 4fb7aea5cba..a378ce5a696 100644 --- a/tests/ui/traits/dyn-trait.rs +++ b/tests/ui/traits/dyn-trait.rs @@ -7,7 +7,7 @@ static BYTE: u8 = 33; fn main() { let x: &(dyn 'static + Display) = &BYTE; let y: Box<dyn Display + 'static> = Box::new(BYTE); - let _: &dyn (Display) = &BYTE; + let _: &dyn Display = &BYTE; let _: &dyn (::std::fmt::Display) = &BYTE; let xstr = format!("{}", x); let ystr = format!("{}", y); diff --git a/tests/ui/issue-11881.rs b/tests/ui/traits/encoder-trait-bounds-regression.rs index 1abe0797203..292b921cdf7 100644 --- a/tests/ui/issue-11881.rs +++ b/tests/ui/traits/encoder-trait-bounds-regression.rs @@ -1,14 +1,23 @@ +//! Regression test for issue #11881 +//! +//! Originally, the compiler would ICE when trying to parameterize on certain encoder types +//! due to issues with higher-ranked trait bounds and lifetime inference. This test checks +//! that various encoder patterns work correctly: +//! - Generic encoders with associated error types +//! - Higher-ranked trait bounds (for<'r> Encodable<JsonEncoder<'r>>) +//! - Multiple encoder implementations for the same type +//! - Polymorphic encoding functions + //@ run-pass #![allow(unused_must_use)] #![allow(dead_code)] #![allow(unused_imports)] -use std::fmt; -use std::io::prelude::*; use std::io::Cursor; -use std::slice; +use std::io::prelude::*; use std::marker::PhantomData; +use std::{fmt, slice}; trait Encoder { type Error; @@ -45,7 +54,6 @@ impl Encoder for OpaqueEncoder { type Error = (); } - struct Foo { baz: bool, } @@ -69,7 +77,6 @@ impl<S: Encoder> Encodable<S> for Bar { enum WireProtocol { JSON, Opaque, - // ... } fn encode_json<T: for<'a> Encodable<JsonEncoder<'a>>>(val: &T, wr: &mut Cursor<Vec<u8>>) { diff --git a/tests/ui/traits/enum-negative-send-impl.rs b/tests/ui/traits/enum-negative-send-impl.rs new file mode 100644 index 00000000000..6bff42e9999 --- /dev/null +++ b/tests/ui/traits/enum-negative-send-impl.rs @@ -0,0 +1,22 @@ +//! Test that enums inherit Send/!Send properties from their variants. +//! +//! Uses the unstable `negative_impls` feature to explicitly opt-out of Send. + +#![feature(negative_impls)] + +use std::marker::Send; + +struct NoSend; +impl !Send for NoSend {} + +enum Container { + WithNoSend(NoSend), +} + +fn requires_send<T: Send>(_: T) {} + +fn main() { + let container = Container::WithNoSend(NoSend); + requires_send(container); + //~^ ERROR `NoSend` cannot be sent between threads safely +} diff --git a/tests/ui/traits/enum-negative-send-impl.stderr b/tests/ui/traits/enum-negative-send-impl.stderr new file mode 100644 index 00000000000..1992becccf4 --- /dev/null +++ b/tests/ui/traits/enum-negative-send-impl.stderr @@ -0,0 +1,23 @@ +error[E0277]: `NoSend` cannot be sent between threads safely + --> $DIR/enum-negative-send-impl.rs:20:19 + | +LL | requires_send(container); + | ------------- ^^^^^^^^^ `NoSend` cannot be sent between threads safely + | | + | required by a bound introduced by this call + | + = help: within `Container`, the trait `Send` is not implemented for `NoSend` +note: required because it appears within the type `Container` + --> $DIR/enum-negative-send-impl.rs:12:6 + | +LL | enum Container { + | ^^^^^^^^^ +note: required by a bound in `requires_send` + --> $DIR/enum-negative-send-impl.rs:16:21 + | +LL | fn requires_send<T: Send>(_: T) {} + | ^^^^ required by this bound in `requires_send` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/enum-negative-sync-impl.rs b/tests/ui/traits/enum-negative-sync-impl.rs new file mode 100644 index 00000000000..aa81a9fbbf9 --- /dev/null +++ b/tests/ui/traits/enum-negative-sync-impl.rs @@ -0,0 +1,22 @@ +//! Test that enums inherit Sync/!Sync properties from their variants. +//! +//! Uses the unstable `negative_impls` feature to explicitly opt-out of Sync. + +#![feature(negative_impls)] + +use std::marker::Sync; + +struct NoSync; +impl !Sync for NoSync {} + +enum Container { + WithNoSync(NoSync), +} + +fn requires_sync<T: Sync>(_: T) {} + +fn main() { + let container = Container::WithNoSync(NoSync); + requires_sync(container); + //~^ ERROR `NoSync` cannot be shared between threads safely [E0277] +} diff --git a/tests/ui/traits/enum-negative-sync-impl.stderr b/tests/ui/traits/enum-negative-sync-impl.stderr new file mode 100644 index 00000000000..a97b7a36a7b --- /dev/null +++ b/tests/ui/traits/enum-negative-sync-impl.stderr @@ -0,0 +1,23 @@ +error[E0277]: `NoSync` cannot be shared between threads safely + --> $DIR/enum-negative-sync-impl.rs:20:19 + | +LL | requires_sync(container); + | ------------- ^^^^^^^^^ `NoSync` cannot be shared between threads safely + | | + | required by a bound introduced by this call + | + = help: within `Container`, the trait `Sync` is not implemented for `NoSync` +note: required because it appears within the type `Container` + --> $DIR/enum-negative-sync-impl.rs:12:6 + | +LL | enum Container { + | ^^^^^^^^^ +note: required by a bound in `requires_sync` + --> $DIR/enum-negative-sync-impl.rs:16:21 + | +LL | fn requires_sync<T: Sync>(_: T) {} + | ^^^^ required by this bound in `requires_sync` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/string-box-error.rs b/tests/ui/traits/error-trait-object-from-string.rs index 9a7cd81ee04..896f164a04d 100644 --- a/tests/ui/string-box-error.rs +++ b/tests/ui/traits/error-trait-object-from-string.rs @@ -1,6 +1,7 @@ +//! Check that `String` and `&str` can be converted into `Box<dyn Error>` and +//! `Box<dyn Error + Send + Sync>` trait objects + //@ run-pass -// Ensure that both `Box<dyn Error + Send + Sync>` and `Box<dyn Error>` can be -// obtained from `String`. use std::error::Error; diff --git a/tests/ui/traits/eval-caching-error-region.rs b/tests/ui/traits/eval-caching-error-region.rs new file mode 100644 index 00000000000..831b5ab80c1 --- /dev/null +++ b/tests/ui/traits/eval-caching-error-region.rs @@ -0,0 +1,23 @@ +// Regression test for #132882. + +use std::ops::Add; + +pub trait Numoid: Sized +where + &'missing Self: Add<Self>, + //~^ ERROR use of undeclared lifetime name `'missing` +{ +} + +// Proving `N: Numoid`'s well-formedness causes us to have to prove `&'missing N: Add<N>`. +// Since `'missing` is a region error, that will lead to us consider the predicate to hold, +// since it references errors. Since the freshener turns error regions into fresh regions, +// this means that subsequent lookups of `&'?0 N: Add<N>` will also hit this cache entry +// even if candidate assembly can't assemble anything for `&'?0 N: Add<?1>` anyways. This +// led to an ICE. +pub fn compute<N: Numoid>(a: N) { + let _ = &a + a; + //~^ ERROR cannot add `N` to `&N` +} + +fn main() {} diff --git a/tests/ui/traits/eval-caching-error-region.stderr b/tests/ui/traits/eval-caching-error-region.stderr new file mode 100644 index 00000000000..6365d242d2e --- /dev/null +++ b/tests/ui/traits/eval-caching-error-region.stderr @@ -0,0 +1,33 @@ +error[E0261]: use of undeclared lifetime name `'missing` + --> $DIR/eval-caching-error-region.rs:7:6 + | +LL | &'missing Self: Add<Self>, + | ^^^^^^^^ undeclared lifetime + | + = note: for more information on higher-ranked polymorphism, visit https://doc.rust-lang.org/nomicon/hrtb.html +help: consider making the bound lifetime-generic with a new `'missing` lifetime + | +LL | for<'missing> &'missing Self: Add<Self>, + | +++++++++++++ +help: consider introducing lifetime `'missing` here + | +LL | pub trait Numoid<'missing>: Sized + | ++++++++++ + +error[E0369]: cannot add `N` to `&N` + --> $DIR/eval-caching-error-region.rs:19:16 + | +LL | let _ = &a + a; + | -- ^ - N + | | + | &N + | +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | pub fn compute<N: Numoid>(a: N) where &N: Add<N> { + | ++++++++++++++++ + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0261, E0369. +For more information about an error, try `rustc --explain E0261`. diff --git a/tests/ui/traits/impl-2.rs b/tests/ui/traits/impl-2.rs index 41fa1cd334f..eafbaeaa167 100644 --- a/tests/ui/traits/impl-2.rs +++ b/tests/ui/traits/impl-2.rs @@ -10,7 +10,7 @@ pub mod Foo { } mod Bar { - impl<'a> dyn (crate::Foo::Trait) + 'a { + impl<'a> dyn crate::Foo::Trait + 'a { fn bar(&self) { self.foo() } } } diff --git a/tests/ui/traits/inheritance/repeated-supertrait-ambig.stderr b/tests/ui/traits/inheritance/repeated-supertrait-ambig.stderr index fdf0b1722be..23cced2bc28 100644 --- a/tests/ui/traits/inheritance/repeated-supertrait-ambig.stderr +++ b/tests/ui/traits/inheritance/repeated-supertrait-ambig.stderr @@ -34,10 +34,10 @@ LL | <dyn CompareToInts>::same_as(c, 22) `i64` implements `CompareTo<u64>` error[E0277]: the trait bound `C: CompareTo<i32>` is not satisfied - --> $DIR/repeated-supertrait-ambig.rs:38:27 + --> $DIR/repeated-supertrait-ambig.rs:38:24 | LL | CompareTo::same_as(c, 22) - | ------------------ ^^ the trait `CompareTo<i32>` is not implemented for `C` + | ------------------ ^ the trait `CompareTo<i32>` is not implemented for `C` | | | required by a bound introduced by this call | diff --git a/tests/ui/traits/issue-105231.stderr b/tests/ui/traits/issue-105231.stderr index e113f8382b2..b048548018a 100644 --- a/tests/ui/traits/issue-105231.stderr +++ b/tests/ui/traits/issue-105231.stderr @@ -1,3 +1,14 @@ +error: type parameter `T` is only used recursively + --> $DIR/issue-105231.rs:1:15 + | +LL | struct A<T>(B<T>); + | - ^ + | | + | type parameter must be used non-recursively in the definition + | + = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` + = note: all type parameters must be used in a non-recursive way in order to constrain their variance + error[E0072]: recursive types `A` and `B` have infinite size --> $DIR/issue-105231.rs:1:1 | @@ -16,17 +27,6 @@ LL ~ struct B<T>(Box<A<A<T>>>); | error: type parameter `T` is only used recursively - --> $DIR/issue-105231.rs:1:15 - | -LL | struct A<T>(B<T>); - | - ^ - | | - | type parameter must be used non-recursively in the definition - | - = help: consider removing `T`, referring to it in a field, or using a marker such as `PhantomData` - = note: all type parameters must be used in a non-recursive way in order to constrain their variance - -error: type parameter `T` is only used recursively --> $DIR/issue-105231.rs:4:17 | LL | struct B<T>(A<A<T>>); diff --git a/tests/ui/traits/issue-78372.stderr b/tests/ui/traits/issue-78372.stderr index fbc60ce5d83..a1c772f58e1 100644 --- a/tests/ui/traits/issue-78372.stderr +++ b/tests/ui/traits/issue-78372.stderr @@ -56,6 +56,12 @@ LL | impl<T> DispatchFromDyn<Smaht<U, MISC>> for T {} = help: add `#![feature(dispatch_from_dyn)]` 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[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 {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + error[E0307]: invalid `self` parameter type: `Smaht<Self, T>` --> $DIR/issue-78372.rs:9:18 | @@ -65,12 +71,6 @@ 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[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 {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - error: aborting due to 7 previous errors Some errors have detailed explanations: E0307, E0377, E0412, E0658. diff --git a/tests/ui/traits/issue-87558.stderr b/tests/ui/traits/issue-87558.stderr index 4cc3ec2ea8b..dc5bd6ece36 100644 --- a/tests/ui/traits/issue-87558.stderr +++ b/tests/ui/traits/issue-87558.stderr @@ -24,6 +24,14 @@ help: parenthesized trait syntax expands to `Fn<(&isize,), Output=()>` LL | impl Fn(&isize) for Error { | ^^^^^^^^^^ +error[E0046]: not all trait items implemented, missing: `call` + --> $DIR/issue-87558.rs:3:1 + | +LL | impl Fn(&isize) for Error { + | ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation + | + = help: implement the missing item: `fn call(&self, _: (&isize,)) -> <Self as FnOnce<(&isize,)>>::Output { todo!() }` + error[E0277]: expected a `FnMut(&isize)` closure, found `Error` --> $DIR/issue-87558.rs:3:21 | @@ -34,14 +42,6 @@ LL | impl Fn(&isize) for Error { note: required by a bound in `Fn` --> $SRC_DIR/core/src/ops/function.rs:LL:COL -error[E0046]: not all trait items implemented, missing: `call` - --> $DIR/issue-87558.rs:3:1 - | -LL | impl Fn(&isize) for Error { - | ^^^^^^^^^^^^^^^^^^^^^^^^^ missing `call` in implementation - | - = help: implement the missing item: `fn call(&self, _: (&isize,)) -> <Self as FnOnce<(&isize,)>>::Output { todo!() }` - error: aborting due to 5 previous errors Some errors have detailed explanations: E0046, E0183, E0229, E0277, E0407. diff --git a/tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs new file mode 100644 index 00000000000..04963c98765 --- /dev/null +++ b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.rs @@ -0,0 +1,18 @@ +//! Test that ?Trait bounds are forbidden in supertraits and trait object types. +//! +//! While `?Sized` and other maybe bounds are allowed in type parameter bounds and where clauses, +//! they are explicitly forbidden in certain syntactic positions: +//! - As supertraits in trait definitions +//! - In trait object type expressions +//! +//! See https://github.com/rust-lang/rust/issues/20503 + +trait Tr: ?Sized {} +//~^ ERROR `?Trait` is not permitted in supertraits + +type A1 = dyn Tr + (?Sized); +//~^ ERROR `?Trait` is not permitted in trait object types +type A2 = dyn for<'a> Tr + (?Sized); +//~^ ERROR `?Trait` is not permitted in trait object types + +fn main() {} diff --git a/tests/ui/maybe-bounds.stderr b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr index 230d11fd0ae..bd0baa580bd 100644 --- a/tests/ui/maybe-bounds.stderr +++ b/tests/ui/traits/maybe-trait-bounds-forbidden-locations.stderr @@ -1,5 +1,5 @@ error[E0658]: `?Trait` is not permitted in supertraits - --> $DIR/maybe-bounds.rs:1:11 + --> $DIR/maybe-trait-bounds-forbidden-locations.rs:10:11 | LL | trait Tr: ?Sized {} | ^^^^^^ @@ -9,7 +9,7 @@ LL | trait Tr: ?Sized {} = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `?Trait` is not permitted in trait object types - --> $DIR/maybe-bounds.rs:4:20 + --> $DIR/maybe-trait-bounds-forbidden-locations.rs:13:20 | LL | type A1 = dyn Tr + (?Sized); | ^^^^^^^^ @@ -18,7 +18,7 @@ LL | type A1 = dyn Tr + (?Sized); = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `?Trait` is not permitted in trait object types - --> $DIR/maybe-bounds.rs:6:28 + --> $DIR/maybe-trait-bounds-forbidden-locations.rs:15:28 | LL | type A2 = dyn for<'a> Tr + (?Sized); | ^^^^^^^^ diff --git a/tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr b/tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr index d535c39639f..6472ac7363b 100644 --- a/tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr +++ b/tests/ui/traits/method-argument-mismatch-variance-ice-119867.stderr @@ -1,4 +1,4 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions --> $DIR/method-argument-mismatch-variance-ice-119867.rs:8:23 | LL | fn deserialize(s: _) {} diff --git a/tests/ui/traits/multidispatch-convert-ambig-dest.stderr b/tests/ui/traits/multidispatch-convert-ambig-dest.stderr index 17c3db9ad33..12984c7936c 100644 --- a/tests/ui/traits/multidispatch-convert-ambig-dest.stderr +++ b/tests/ui/traits/multidispatch-convert-ambig-dest.stderr @@ -2,7 +2,7 @@ error[E0283]: type annotations needed --> $DIR/multidispatch-convert-ambig-dest.rs:26:5 | LL | test(22, std::default::Default::default()); - | ^^^^ -------------------------------- type must be known at this point + | ^^^^ -- type must be known at this point | | | cannot infer type of the type parameter `U` declared on the function `test` | diff --git a/tests/ui/traits/negative-bounds/negative-sized.rs b/tests/ui/traits/negative-bounds/negative-sized.rs new file mode 100644 index 00000000000..18369c78427 --- /dev/null +++ b/tests/ui/traits/negative-bounds/negative-sized.rs @@ -0,0 +1,8 @@ +#![feature(negative_bounds)] + +fn foo<T: !Sized>() {} + +fn main() { + foo::<()>(); + //~^ ERROR the trait bound `(): !Sized` is not satisfied +} diff --git a/tests/ui/traits/negative-bounds/negative-sized.stderr b/tests/ui/traits/negative-bounds/negative-sized.stderr new file mode 100644 index 00000000000..143933803b8 --- /dev/null +++ b/tests/ui/traits/negative-bounds/negative-sized.stderr @@ -0,0 +1,15 @@ +error[E0277]: the trait bound `(): !Sized` is not satisfied + --> $DIR/negative-sized.rs:6:11 + | +LL | foo::<()>(); + | ^^ the trait bound `(): !Sized` is not satisfied + | +note: required by a bound in `foo` + --> $DIR/negative-sized.rs:3:11 + | +LL | fn foo<T: !Sized>() {} + | ^^^^^^ required by this bound in `foo` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.rs b/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.rs index ff577da32c2..3fd22c7dbf0 100644 --- a/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.rs +++ b/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.rs @@ -1,15 +1,17 @@ //@ compile-flags: -Znext-solver=coherence +#![feature(rustc_attrs)] +#![rustc_no_implicit_bounds] #![recursion_limit = "10"] trait Trait {} -struct W<T: ?Sized>(*const T); +struct W<T>(*const T); trait TwoW {} -impl<T: ?Sized + TwoW> TwoW for W<W<T>> {} +impl<T: TwoW> TwoW for W<W<T>> {} -impl<T: ?Sized + TwoW> Trait for W<T> {} -impl<T: ?Sized + TwoW> Trait for T {} +impl<T: TwoW> Trait for W<T> {} +impl<T: TwoW> Trait for T {} //~^ ERROR conflicting implementations of trait `Trait` for type `W fn main() {} diff --git a/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr b/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr index 7d39c82d22f..1827533a84d 100644 --- a/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr +++ b/tests/ui/traits/next-solver/coherence/coherence-fulfill-overflow.stderr @@ -1,10 +1,10 @@ error[E0119]: conflicting implementations of trait `Trait` for type `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>>>` - --> $DIR/coherence-fulfill-overflow.rs:12:1 + --> $DIR/coherence-fulfill-overflow.rs:14:1 | -LL | impl<T: ?Sized + TwoW> Trait for W<T> {} - | ------------------------------------- first implementation here -LL | impl<T: ?Sized + TwoW> Trait for T {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>>>` +LL | impl<T: TwoW> Trait for W<T> {} + | ---------------------------- first implementation here +LL | impl<T: TwoW> Trait for T {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<W<_>>>>>>>>>>>>>>>>>>>>>>>` error: aborting due to 1 previous error diff --git a/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.rs b/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.rs index 920f8add507..9da79f7ac83 100644 --- a/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.rs +++ b/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.rs @@ -1,6 +1,7 @@ //@ revisions: with without //@ compile-flags: -Znext-solver #![feature(rustc_attrs)] +#![rustc_no_implicit_bounds] // This test is incredibly subtle. At its core the goal is to get a coinductive cycle, // which, depending on its root goal, either holds or errors. We achieve this by getting @@ -17,20 +18,20 @@ // test for that. #[rustc_coinductive] -trait Trait<T: ?Sized, V: ?Sized, D: ?Sized> {} -struct A<T: ?Sized>(*const T); -struct B<T: ?Sized>(*const T); +trait Trait<T, V, D> {} +struct A<T>(*const T); +struct B<T>(*const T); -trait IncompleteGuidance<T: ?Sized, V: ?Sized> {} -impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, u8> for T {} -impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, i8> for T {} -impl<T: ?Sized, U: ?Sized + 'static> IncompleteGuidance<U, i16> for T {} +trait IncompleteGuidance<T, V> {} +impl<T, U: 'static> IncompleteGuidance<U, u8> for T {} +impl<T, U: 'static> IncompleteGuidance<U, i8> for T {} +impl<T, U: 'static> IncompleteGuidance<U, i16> for T {} -trait ImplGuidance<T: ?Sized, V: ?Sized> {} -impl<T: ?Sized> ImplGuidance<u32, u8> for T {} -impl<T: ?Sized> ImplGuidance<i32, i8> for T {} +trait ImplGuidance<T, V> {} +impl<T> ImplGuidance<u32, u8> for T {} +impl<T> ImplGuidance<i32, i8> for T {} -impl<T: ?Sized, U: ?Sized, V: ?Sized, D: ?Sized> Trait<U, V, D> for A<T> +impl<T, U, V, D> Trait<U, V, D> for A<T> where T: IncompleteGuidance<U, V>, A<T>: Trait<U, D, V>, @@ -39,17 +40,17 @@ where { } -trait ToU8<T: ?Sized> {} +trait ToU8<T> {} impl ToU8<u8> for () {} -impl<T: ?Sized, U: ?Sized, V: ?Sized, D: ?Sized> Trait<U, V, D> for B<T> +impl<T, U, V, D> Trait<U, V, D> for B<T> where T: ImplGuidance<U, V>, A<T>: Trait<U, V, D>, { } -fn impls_trait<T: ?Sized + Trait<U, V, D>, U: ?Sized, V: ?Sized, D: ?Sized>() {} +fn impls_trait<T: Trait<U, V, D>, U, V, D>() {} fn with_bound<X>() where diff --git a/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.with.stderr b/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.with.stderr index 9114bcadac0..d27104de541 100644 --- a/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.with.stderr +++ b/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.with.stderr @@ -1,25 +1,25 @@ error[E0277]: the trait bound `A<X>: Trait<_, _, _>` is not satisfied - --> $DIR/incompleteness-unstable-result.rs:65:19 + --> $DIR/incompleteness-unstable-result.rs:66:19 | LL | impls_trait::<A<X>, _, _, _>(); | ^^^^ the trait `Trait<_, _, _>` is not implemented for `A<X>` | = help: the trait `Trait<U, V, D>` is implemented for `A<T>` note: required for `A<X>` to implement `Trait<_, _, _>` - --> $DIR/incompleteness-unstable-result.rs:33:50 + --> $DIR/incompleteness-unstable-result.rs:34:18 | -LL | impl<T: ?Sized, U: ?Sized, V: ?Sized, D: ?Sized> Trait<U, V, D> for A<T> - | ^^^^^^^^^^^^^^ ^^^^ +LL | impl<T, U, V, D> Trait<U, V, D> for A<T> + | ^^^^^^^^^^^^^^ ^^^^ ... LL | A<T>: Trait<U, D, V>, | -------------- unsatisfied trait bound introduced here = note: 8 redundant requirements hidden = note: required for `A<X>` to implement `Trait<_, _, _>` note: required by a bound in `impls_trait` - --> $DIR/incompleteness-unstable-result.rs:52:28 + --> $DIR/incompleteness-unstable-result.rs:53:19 | -LL | fn impls_trait<T: ?Sized + Trait<U, V, D>, U: ?Sized, V: ?Sized, D: ?Sized>() {} - | ^^^^^^^^^^^^^^ required by this bound in `impls_trait` +LL | fn impls_trait<T: Trait<U, V, D>, U, V, D>() {} + | ^^^^^^^^^^^^^^ required by this bound in `impls_trait` error: aborting due to 1 previous error diff --git a/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.without.stderr b/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.without.stderr index 9114bcadac0..d27104de541 100644 --- a/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.without.stderr +++ b/tests/ui/traits/next-solver/cycles/coinduction/incompleteness-unstable-result.without.stderr @@ -1,25 +1,25 @@ error[E0277]: the trait bound `A<X>: Trait<_, _, _>` is not satisfied - --> $DIR/incompleteness-unstable-result.rs:65:19 + --> $DIR/incompleteness-unstable-result.rs:66:19 | LL | impls_trait::<A<X>, _, _, _>(); | ^^^^ the trait `Trait<_, _, _>` is not implemented for `A<X>` | = help: the trait `Trait<U, V, D>` is implemented for `A<T>` note: required for `A<X>` to implement `Trait<_, _, _>` - --> $DIR/incompleteness-unstable-result.rs:33:50 + --> $DIR/incompleteness-unstable-result.rs:34:18 | -LL | impl<T: ?Sized, U: ?Sized, V: ?Sized, D: ?Sized> Trait<U, V, D> for A<T> - | ^^^^^^^^^^^^^^ ^^^^ +LL | impl<T, U, V, D> Trait<U, V, D> for A<T> + | ^^^^^^^^^^^^^^ ^^^^ ... LL | A<T>: Trait<U, D, V>, | -------------- unsatisfied trait bound introduced here = note: 8 redundant requirements hidden = note: required for `A<X>` to implement `Trait<_, _, _>` note: required by a bound in `impls_trait` - --> $DIR/incompleteness-unstable-result.rs:52:28 + --> $DIR/incompleteness-unstable-result.rs:53:19 | -LL | fn impls_trait<T: ?Sized + Trait<U, V, D>, U: ?Sized, V: ?Sized, D: ?Sized>() {} - | ^^^^^^^^^^^^^^ required by this bound in `impls_trait` +LL | fn impls_trait<T: Trait<U, V, D>, U, V, D>() {} + | ^^^^^^^^^^^^^^ required by this bound in `impls_trait` error: aborting due to 1 previous error diff --git a/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.rs b/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.rs index f7ed0e100c4..326d888a55f 100644 --- a/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.rs +++ b/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.rs @@ -1,23 +1,24 @@ //@ compile-flags: -Znext-solver #![feature(rustc_attrs)] +#![rustc_no_implicit_bounds] // Check that we correctly rerun the trait solver for heads of cycles, // even if they are not the root. -struct A<T: ?Sized>(*const T); -struct B<T: ?Sized>(*const T); -struct C<T: ?Sized>(*const T); +struct A<T>(*const T); +struct B<T>(*const T); +struct C<T>(*const T); #[rustc_coinductive] trait Trait<'a, 'b> {} trait NotImplemented {} -impl<'a, 'b, T: ?Sized> Trait<'a, 'b> for A<T> where B<T>: Trait<'a, 'b> {} +impl<'a, 'b, T> Trait<'a, 'b> for A<T> where B<T>: Trait<'a, 'b> {} // With this the root of `B<T>` is `A<T>`, even if the other impl does // not have a cycle with `A<T>`. This candidate never applies because of // the `A<T>: NotImplemented` bound. -impl<'a, 'b, T: ?Sized> Trait<'a, 'b> for B<T> +impl<'a, 'b, T> Trait<'a, 'b> for B<T> where A<T>: Trait<'a, 'b>, A<T>: NotImplemented, @@ -31,7 +32,7 @@ where // use the impl itself to prove that adds region constraints as we uniquified the // regions in the `A<T>: Trait<'a, 'b>` where-bound. As both the impl above // and the impl below now apply with some constraints, we failed with ambiguity. -impl<'a, 'b, T: ?Sized> Trait<'a, 'b> for B<T> +impl<'a, 'b, T> Trait<'a, 'b> for B<T> where A<T>: NotImplemented, {} @@ -40,7 +41,7 @@ where // // Because of the coinductive cycle through `C<T>` it also requires // 'a to be 'static. -impl<'a, T: ?Sized> Trait<'a, 'static> for B<T> +impl<'a, T> Trait<'a, 'static> for B<T> where C<T>: Trait<'a, 'a>, {} @@ -48,14 +49,14 @@ where // In the first iteration of `B<T>: Trait<'a, 'b>` we don't add any // constraints here, only after setting the provisional result to require // `'b == 'static` do we also add that constraint for `'a`. -impl<'a, 'b, T: ?Sized> Trait<'a, 'b> for C<T> +impl<'a, 'b, T> Trait<'a, 'b> for C<T> where B<T>: Trait<'a, 'b>, {} -fn impls_trait<'a, 'b, T: Trait<'a, 'b> + ?Sized>() {} +fn impls_trait<'a, 'b, T: Trait<'a, 'b>>() {} -fn check<'a, T: ?Sized>() { +fn check<'a, T>() { impls_trait::<'a, 'static, A<T>>(); //~^ ERROR lifetime may not live long enough } diff --git a/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr b/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr index 0cbd9654044..c88081736f3 100644 --- a/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr +++ b/tests/ui/traits/next-solver/cycles/fixpoint-rerun-all-cycle-heads.stderr @@ -1,7 +1,7 @@ error: lifetime may not live long enough - --> $DIR/fixpoint-rerun-all-cycle-heads.rs:59:5 + --> $DIR/fixpoint-rerun-all-cycle-heads.rs:60:5 | -LL | fn check<'a, T: ?Sized>() { +LL | fn check<'a, T>() { | -- lifetime `'a` defined here LL | impls_trait::<'a, 'static, A<T>>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ requires that `'a` must outlive `'static` diff --git a/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.rs b/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.rs index 9cbcc5a3cdf..12feb1e2771 100644 --- a/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.rs +++ b/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.rs @@ -1,4 +1,6 @@ //@ compile-flags: -Znext-solver +#![feature(rustc_attrs)] +#![rustc_no_implicit_bounds] // This currently hangs if we do not erase constraints from // overflow. @@ -17,9 +19,9 @@ // the solver to hang without hitting the recursion limit. trait Trait {} -struct W<T: ?Sized>(*const T); +struct W<T>(*const T); -impl<T: ?Sized> Trait for W<W<T>> +impl<T> Trait for W<W<T>> where W<T>: Trait, W<T>: Trait, diff --git a/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.stderr b/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.stderr index a2a5c028cf8..5ba3c511c17 100644 --- a/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.stderr +++ b/tests/ui/traits/next-solver/cycles/inductive-fixpoint-hang.stderr @@ -1,11 +1,11 @@ error[E0275]: overflow evaluating the requirement `W<_>: Trait` - --> $DIR/inductive-fixpoint-hang.rs:31:19 + --> $DIR/inductive-fixpoint-hang.rs:33:19 | LL | impls_trait::<W<_>>(); | ^^^^ | note: required by a bound in `impls_trait` - --> $DIR/inductive-fixpoint-hang.rs:28:19 + --> $DIR/inductive-fixpoint-hang.rs:30:19 | LL | fn impls_trait<T: Trait>() {} | ^^^^^ required by this bound in `impls_trait` diff --git a/tests/ui/traits/next-solver/cycles/provisional-cache-impacts-behavior.rs b/tests/ui/traits/next-solver/cycles/provisional-cache-impacts-behavior.rs index b005b909aed..88a1196b7e5 100644 --- a/tests/ui/traits/next-solver/cycles/provisional-cache-impacts-behavior.rs +++ b/tests/ui/traits/next-solver/cycles/provisional-cache-impacts-behavior.rs @@ -1,6 +1,7 @@ //@ compile-flags: -Znext-solver //@ check-pass #![feature(rustc_attrs)] +#![rustc_no_implicit_bounds] // A test showcasing that using a provisional cache can differ // from only tracking stack entries. @@ -59,9 +60,9 @@ trait B {} #[rustc_coinductive] trait C {} -impl<T: ?Sized + B + C> A for T {} -impl<T: ?Sized + A + C> B for T {} -impl<T: ?Sized + B> C for T {} +impl<T: B + C> A for T {} +impl<T: A + C> B for T {} +impl<T: B> C for T {} fn impls_a<T: A>() {} diff --git a/tests/ui/traits/next-solver/dont-canonicalize-re-error.rs b/tests/ui/traits/next-solver/dont-canonicalize-re-error.rs index 57f814bc81e..a2ed73b2c86 100644 --- a/tests/ui/traits/next-solver/dont-canonicalize-re-error.rs +++ b/tests/ui/traits/next-solver/dont-canonicalize-re-error.rs @@ -1,4 +1,6 @@ //@ compile-flags: -Znext-solver +#![feature(rustc_attrs)] +#![rustc_no_implicit_bounds] trait Tr<'a> {} @@ -16,9 +18,9 @@ trait Tr<'a> {} // Then, when we recompute the goal `W<?0>: Constrain<'error>`, when // collecting ambiguities and overflows, we end up assembling a default // error candidate w/o ambiguity, which causes the goal to pass, and ICE. -impl<'a, A: ?Sized> Tr<'a> for W<A> {} -struct W<A: ?Sized>(A); -impl<'a, A: ?Sized> Tr<'a> for A where A: Constrain<'a> {} +impl<'a, A> Tr<'a> for W<A> {} +struct W<A>(A); +impl<'a, A> Tr<'a> for A where A: Constrain<'a> {} //~^ ERROR conflicting implementations of trait `Tr<'_>` for type `W<_>` trait Constrain<'a> {} diff --git a/tests/ui/traits/next-solver/dont-canonicalize-re-error.stderr b/tests/ui/traits/next-solver/dont-canonicalize-re-error.stderr index cf85c52fb42..867efd4a0e7 100644 --- a/tests/ui/traits/next-solver/dont-canonicalize-re-error.stderr +++ b/tests/ui/traits/next-solver/dont-canonicalize-re-error.stderr @@ -1,19 +1,22 @@ error[E0261]: use of undeclared lifetime name `'missing` - --> $DIR/dont-canonicalize-re-error.rs:25:26 + --> $DIR/dont-canonicalize-re-error.rs:27:26 | LL | impl<A: Sized> Constrain<'missing> for W<A> {} - | - ^^^^^^^^ undeclared lifetime - | | - | help: consider introducing lifetime `'missing` here: `'missing,` + | ^^^^^^^^ undeclared lifetime + | +help: consider introducing lifetime `'missing` here + | +LL | impl<'missing, A: Sized> Constrain<'missing> for W<A> {} + | +++++++++ error[E0119]: conflicting implementations of trait `Tr<'_>` for type `W<_>` - --> $DIR/dont-canonicalize-re-error.rs:21:1 + --> $DIR/dont-canonicalize-re-error.rs:23:1 | -LL | impl<'a, A: ?Sized> Tr<'a> for W<A> {} - | ----------------------------------- first implementation here -LL | struct W<A: ?Sized>(A); -LL | impl<'a, A: ?Sized> Tr<'a> for A where A: Constrain<'a> {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<_>` +LL | impl<'a, A> Tr<'a> for W<A> {} + | --------------------------- first implementation here +LL | struct W<A>(A); +LL | impl<'a, A> Tr<'a> for A where A: Constrain<'a> {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ conflicting implementation for `W<_>` error: aborting due to 2 previous errors diff --git a/tests/ui/traits/next-solver/issue-118950-root-region.stderr b/tests/ui/traits/next-solver/issue-118950-root-region.stderr index 45fa33dff52..ce4f742a3fa 100644 --- a/tests/ui/traits/next-solver/issue-118950-root-region.stderr +++ b/tests/ui/traits/next-solver/issue-118950-root-region.stderr @@ -14,10 +14,10 @@ LL | #![feature(lazy_type_alias)] = note: `#[warn(incomplete_features)]` on by default error[E0277]: the trait bound `*const T: ToUnit<'a>` is not satisfied - --> $DIR/issue-118950-root-region.rs:14:21 + --> $DIR/issue-118950-root-region.rs:14:1 | LL | type Assoc<'a, T> = <*const T as ToUnit<'a>>::Unit; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ the trait `ToUnit<'a>` is not implemented for `*const T` + | ^^^^^^^^^^^^^^^^^ the trait `ToUnit<'a>` is not implemented for `*const T` | help: this trait has no implementations, consider adding one --> $DIR/issue-118950-root-region.rs:8:1 @@ -25,7 +25,7 @@ help: this trait has no implementations, consider adding one LL | trait ToUnit<'a> { | ^^^^^^^^^^^^^^^^ - WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a), "'a"), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc), .. } + WARN rustc_infer::infer::relate::generalize may incompletely handle alias type: AliasTy { args: ['^0.Named(DefId(0:15 ~ issue_118950_root_region[d54f]::{impl#1}::'a)), ?1t], def_id: DefId(0:8 ~ issue_118950_root_region[d54f]::Assoc), .. } error[E0277]: the trait bound `for<'a> *const T: ToUnit<'a>` is not satisfied --> $DIR/issue-118950-root-region.rs:19:9 | diff --git a/tests/ui/traits/next-solver/normalize/normalize-region-obligations.rs b/tests/ui/traits/next-solver/normalize/normalize-region-obligations.rs index c4c2e695a1d..e1ffa4e29d6 100644 --- a/tests/ui/traits/next-solver/normalize/normalize-region-obligations.rs +++ b/tests/ui/traits/next-solver/normalize/normalize-region-obligations.rs @@ -1,6 +1,8 @@ //@ revisions: normalize_param_env normalize_obligation hrtb //@ check-pass //@ compile-flags: -Znext-solver +#![feature(rustc_attrs)] +#![rustc_no_implicit_bounds] trait Foo { #[cfg(normalize_param_env)] @@ -11,11 +13,11 @@ trait Foo { type Gat<'b> where for<'a> <Self as MirrorRegion<'a>>::Assoc: 'b; } -trait Mirror { type Assoc: ?Sized; } -impl<T: ?Sized> Mirror for T { type Assoc = T; } +trait Mirror { type Assoc; } +impl<T> Mirror for T { type Assoc = T; } -trait MirrorRegion<'a> { type Assoc: ?Sized; } -impl<'a, T: ?Sized> MirrorRegion<'a> for T { type Assoc = T; } +trait MirrorRegion<'a> { type Assoc; } +impl<'a, T> MirrorRegion<'a> for T { type Assoc = T; } impl<T> Foo for T { #[cfg(normalize_param_env)] diff --git a/tests/ui/traits/next-solver/overflow/coherence-alias-hang.rs b/tests/ui/traits/next-solver/overflow/coherence-alias-hang.rs index f88f74680b9..4874e2e1f99 100644 --- a/tests/ui/traits/next-solver/overflow/coherence-alias-hang.rs +++ b/tests/ui/traits/next-solver/overflow/coherence-alias-hang.rs @@ -4,16 +4,18 @@ // Regression test for nalgebra hang <https://github.com/rust-lang/rust/issues/130056>. #![feature(lazy_type_alias)] +#![feature(rustc_attrs)] +#![rustc_no_implicit_bounds] #![allow(incomplete_features)] -type Id<T: ?Sized> = T; +type Id<T> = T; trait NotImplemented {} -struct W<T: ?Sized, U: ?Sized>(*const T, *const U); +struct W<T, U>(*const T, *const U); trait Trait { - type Assoc: ?Sized; + type Assoc; } -impl<T: ?Sized + Trait> Trait for W<T, T> { +impl<T: Trait> Trait for W<T, T> { #[cfg(ai)] type Assoc = W<T::Assoc, Id<T::Assoc>>; #[cfg(ia)] @@ -22,8 +24,8 @@ impl<T: ?Sized + Trait> Trait for W<T, T> { type Assoc = W<Id<T::Assoc>, Id<T::Assoc>>; } -trait Overlap<T: ?Sized> {} -impl<T: ?Sized> Overlap<T> for W<T, T> {} -impl<T: ?Sized + Trait + NotImplemented> Overlap<T::Assoc> for T {} +trait Overlap<T> {} +impl<T> Overlap<T> for W<T, T> {} +impl<T: Trait + NotImplemented> Overlap<T::Assoc> for T {} fn main() {} diff --git a/tests/ui/traits/next-solver/overflow/recursion-limit-normalizes-to-constraints.rs b/tests/ui/traits/next-solver/overflow/recursion-limit-normalizes-to-constraints.rs index dee5500aadd..e5a57a44d49 100644 --- a/tests/ui/traits/next-solver/overflow/recursion-limit-normalizes-to-constraints.rs +++ b/tests/ui/traits/next-solver/overflow/recursion-limit-normalizes-to-constraints.rs @@ -1,5 +1,7 @@ //@ compile-flags: -Znext-solver=coherence //@ check-pass +#![feature(rustc_attrs)] +#![rustc_no_implicit_bounds] // A regression test for trait-system-refactor-initiative#70. @@ -7,8 +9,8 @@ trait Trait { type Assoc; } -struct W<T: ?Sized>(*mut T); -impl<T: ?Sized> Trait for W<W<T>> +struct W<T>(*mut T); +impl<T> Trait for W<W<T>> where W<T>: Trait, { @@ -20,6 +22,6 @@ impl<T: Trait<Assoc = u32>> NoOverlap for T {} // `Projection(<W<_> as Trait>::Assoc, u32)` should result in error even // though applying the impl results in overflow. This is necessary to match // the behavior of the old solver. -impl<T: ?Sized> NoOverlap for W<T> {} +impl<T> NoOverlap for W<T> {} fn main() {} diff --git a/tests/ui/traits/next-solver/pointer-like.rs b/tests/ui/traits/next-solver/pointer-like.rs deleted file mode 100644 index bdcad4d4c5e..00000000000 --- a/tests/ui/traits/next-solver/pointer-like.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ compile-flags: -Znext-solver - -#![feature(pointer_like_trait)] - -use std::marker::PointerLike; - -fn require_(_: impl PointerLike) {} - -fn main() { - require_(1usize); - require_(1u16); - //~^ ERROR `u16` needs to have the same ABI as a pointer - require_(&1i16); -} diff --git a/tests/ui/traits/next-solver/pointer-like.stderr b/tests/ui/traits/next-solver/pointer-like.stderr deleted file mode 100644 index 4b624fd0d35..00000000000 --- a/tests/ui/traits/next-solver/pointer-like.stderr +++ /dev/null @@ -1,24 +0,0 @@ -error[E0277]: `u16` needs to have the same ABI as a pointer - --> $DIR/pointer-like.rs:11:14 - | -LL | require_(1u16); - | -------- ^^^^ the trait `PointerLike` is not implemented for `u16` - | | - | required by a bound introduced by this call - | - = note: the trait bound `u16: PointerLike` is not satisfied -note: required by a bound in `require_` - --> $DIR/pointer-like.rs:7:21 - | -LL | fn require_(_: impl PointerLike) {} - | ^^^^^^^^^^^ required by this bound in `require_` -help: consider borrowing here - | -LL | require_(&1u16); - | + -LL | require_(&mut 1u16); - | ++++ - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/next-solver/supertrait-alias-1.rs b/tests/ui/traits/next-solver/supertrait-alias-1.rs index 579a44677c2..2671eed7fce 100644 --- a/tests/ui/traits/next-solver/supertrait-alias-1.rs +++ b/tests/ui/traits/next-solver/supertrait-alias-1.rs @@ -1,5 +1,7 @@ //@ compile-flags: -Znext-solver //@ check-pass +#![feature(rustc_attrs)] +#![rustc_no_implicit_bounds] // Regression test for <https://github.com/rust-lang/trait-system-refactor-initiative/issues/171>. // Tests that we don't try to replace `<V as Super>::Output` when replacing projections in the @@ -13,9 +15,9 @@ pub trait Super { type Output; } -fn bound<T: Trait + ?Sized>() {} +fn bound<T: Trait>() {} -fn visit_simd_operator<V: Super + ?Sized>() { +fn visit_simd_operator<V: Super>() { bound::<dyn Trait<Output = <V as Super>::Output>>(); } diff --git a/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.bad.stderr b/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.bad.stderr index 7dd383b1e7a..d51927aaa34 100644 --- a/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.bad.stderr +++ b/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.bad.stderr @@ -7,19 +7,19 @@ LL | #![feature(non_lifetime_binders)] = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information = note: `#[warn(incomplete_features)]` on by default -error[E0310]: the placeholder type `!1_"T"` may not live long enough +error[E0310]: the placeholder type `T` may not live long enough --> $DIR/placeholders-dont-outlive-static.rs:13:5 | LL | foo(); | ^^^^^ | | - | the placeholder type `!1_"T"` must be valid for the static lifetime... + | the placeholder type `T` must be valid for the static lifetime... | ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound | -LL | fn bad() where !1_"T": 'static { - | +++++++++++++++++++++ +LL | fn bad() where T: 'static { + | ++++++++++++++++ error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.good.stderr b/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.good.stderr index b4f00978ada..bc1a1992399 100644 --- a/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.good.stderr +++ b/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.good.stderr @@ -7,19 +7,19 @@ LL | #![feature(non_lifetime_binders)] = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information = note: `#[warn(incomplete_features)]` on by default -error[E0310]: the placeholder type `!1_"T"` may not live long enough +error[E0310]: the placeholder type `T` may not live long enough --> $DIR/placeholders-dont-outlive-static.rs:19:5 | LL | foo(); | ^^^^^ | | - | the placeholder type `!1_"T"` must be valid for the static lifetime... + | the placeholder type `T` must be valid for the static lifetime... | ...so that the type `T` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound | -LL | fn good() where for<T> T: 'static, !1_"T": 'static { - | +++++++++++++++++ +LL | fn good() where for<T> T: 'static, T: 'static { + | ++++++++++++ error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs b/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs index e87863ab251..3133d6aeedc 100644 --- a/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs +++ b/tests/ui/traits/non_lifetime_binders/placeholders-dont-outlive-static.rs @@ -11,7 +11,7 @@ fn foo() where for<T> T: 'static {} #[cfg(bad)] fn bad() { foo(); - //[bad]~^ ERROR the placeholder type `!1_"T"` may not live long enough + //[bad]~^ ERROR the placeholder type `T` may not live long enough } #[cfg(good)] diff --git a/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr index 9d54675c260..15902bf16de 100644 --- a/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr +++ b/tests/ui/traits/non_lifetime_binders/type-match-with-late-bound.stderr @@ -7,11 +7,11 @@ LL | #![feature(non_lifetime_binders)] = note: see issue #108185 <https://github.com/rust-lang/rust/issues/108185> for more information = note: `#[warn(incomplete_features)]` on by default -error[E0309]: the placeholder type `!1_"F"` may not live long enough +error[E0309]: the placeholder type `F` may not live long enough --> $DIR/type-match-with-late-bound.rs:8:1 | LL | async fn walk2<'a, T: 'a>(_: T) - | ^ -- the placeholder type `!1_"F"` must be valid for the lifetime `'a` as defined here... + | ^ -- the placeholder type `F` must be valid for the lifetime `'a` as defined here... | _| | | LL | | where @@ -25,36 +25,37 @@ LL | for<F> F: 'a, | ^^ help: consider adding an explicit lifetime bound | -LL | for<F> F: 'a, !1_"F": 'a - | ++++++++++ +LL | for<F> F: 'a, F: 'a + | +++++ -error[E0309]: the placeholder type `!1_"F"` may not live long enough +error[E0309]: the placeholder type `F` may not live long enough --> $DIR/type-match-with-late-bound.rs:11:1 | LL | async fn walk2<'a, T: 'a>(_: T) - | -- the placeholder type `!1_"F"` must be valid for the lifetime `'a` as defined here... + | -- the placeholder type `F` must be valid for the lifetime `'a` as defined here... ... LL | {} | ^^ ...so that the type `F` will meet its required lifetime bounds | help: consider adding an explicit lifetime bound | -LL | for<F> F: 'a, !1_"F": 'a - | ++++++++++ +LL | for<F> F: 'a, F: 'a + | +++++ -error[E0309]: the placeholder type `!2_"F"` may not live long enough +error[E0309]: the placeholder type `F` may not live long enough --> $DIR/type-match-with-late-bound.rs:11:1 | LL | async fn walk2<'a, T: 'a>(_: T) - | -- the placeholder type `!2_"F"` must be valid for the lifetime `'a` as defined here... + | -- the placeholder type `F` must be valid for the lifetime `'a` as defined here... ... LL | {} | ^^ ...so that the type `F` will meet its required lifetime bounds | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` help: consider adding an explicit lifetime bound | -LL | for<F> F: 'a, !2_"F": 'a - | ++++++++++ +LL | for<F> F: 'a, F: 'a + | +++++ error: aborting due to 3 previous errors; 1 warning emitted diff --git a/tests/ui/traits/on_unimplemented_long_types.stderr b/tests/ui/traits/on_unimplemented_long_types.stderr index 1628466e081..f32d99a42b1 100644 --- a/tests/ui/traits/on_unimplemented_long_types.stderr +++ b/tests/ui/traits/on_unimplemented_long_types.stderr @@ -2,7 +2,7 @@ error[E0277]: `Option<Option<Option<...>>>` doesn't implement `std::fmt::Display --> $DIR/on_unimplemented_long_types.rs:3:17 | LL | pub fn foo() -> impl std::fmt::Display { - | ^^^^^^^^^^^^^^^^^^^^^^ `Option<Option<Option<...>>>` cannot be formatted with the default formatter + | ^^^^^^^^^^^^^^^^^^^^^^ unsatisfied trait bound LL | LL | / Some(Some(Some(Some(Some(Some(Some(Some(Some(S... LL | | Some(Some(Some(Some(Some(Some(Some(Some(So... @@ -14,7 +14,6 @@ LL | | ))))))))))) | |_______________- return type was inferred to be `Option<Option<Option<...>>>` here | = help: the trait `std::fmt::Display` is not implemented for `Option<Option<Option<...>>>` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead = note: the full name for the type has been written to '$TEST_BUILD_DIR/on_unimplemented_long_types.long-type-$LONG_TYPE_HASH.txt' = note: consider using `--verbose` to print the full type name to the console diff --git a/tests/ui/traits/overflow-computing-ambiguity.rs b/tests/ui/traits/overflow-computing-ambiguity.rs index b8f11efeda2..88eeca56cdd 100644 --- a/tests/ui/traits/overflow-computing-ambiguity.rs +++ b/tests/ui/traits/overflow-computing-ambiguity.rs @@ -1,12 +1,15 @@ +#![feature(rustc_attrs)] +#![rustc_no_implicit_bounds] + trait Hello {} -struct Foo<'a, T: ?Sized>(&'a T); +struct Foo<'a, T>(&'a T); -impl<'a, T: ?Sized> Hello for Foo<'a, &'a T> where Foo<'a, T>: Hello {} +impl<'a, T> Hello for Foo<'a, &'a T> where Foo<'a, T>: Hello {} impl Hello for Foo<'static, i32> {} -fn hello<T: ?Sized + Hello>() {} +fn hello<T: Hello>() {} fn main() { hello(); diff --git a/tests/ui/traits/overflow-computing-ambiguity.stderr b/tests/ui/traits/overflow-computing-ambiguity.stderr index a2e255865bf..f3e91a29a9c 100644 --- a/tests/ui/traits/overflow-computing-ambiguity.stderr +++ b/tests/ui/traits/overflow-computing-ambiguity.stderr @@ -1,5 +1,5 @@ error[E0283]: type annotations needed - --> $DIR/overflow-computing-ambiguity.rs:12:5 + --> $DIR/overflow-computing-ambiguity.rs:15:5 | LL | hello(); | ^^^^^ cannot infer type of the type parameter `T` declared on the function `hello` @@ -9,10 +9,10 @@ LL | hello(); Foo<'a, &'a T> Foo<'static, i32> note: required by a bound in `hello` - --> $DIR/overflow-computing-ambiguity.rs:9:22 + --> $DIR/overflow-computing-ambiguity.rs:12:13 | -LL | fn hello<T: ?Sized + Hello>() {} - | ^^^^^ required by this bound in `hello` +LL | fn hello<T: Hello>() {} + | ^^^^^ required by this bound in `hello` help: consider specifying the generic argument | LL | hello::<T>(); diff --git a/tests/ui/traits/rc-not-send.rs b/tests/ui/traits/rc-not-send.rs new file mode 100644 index 00000000000..83084c6173a --- /dev/null +++ b/tests/ui/traits/rc-not-send.rs @@ -0,0 +1,11 @@ +//! Test that `Rc<T>` does not implement `Send`. + +use std::rc::Rc; + +fn requires_send<T: Send>(_: T) {} + +fn main() { + let rc_value = Rc::new(5); + requires_send(rc_value); + //~^ ERROR `Rc<{integer}>` cannot be sent between threads safely +} diff --git a/tests/ui/traits/rc-not-send.stderr b/tests/ui/traits/rc-not-send.stderr new file mode 100644 index 00000000000..d6171a39ad0 --- /dev/null +++ b/tests/ui/traits/rc-not-send.stderr @@ -0,0 +1,22 @@ +error[E0277]: `Rc<{integer}>` cannot be sent between threads safely + --> $DIR/rc-not-send.rs:9:19 + | +LL | requires_send(rc_value); + | ------------- ^^^^^^^^ `Rc<{integer}>` cannot be sent between threads safely + | | + | required by a bound introduced by this call + | + = help: the trait `Send` is not implemented for `Rc<{integer}>` +note: required by a bound in `requires_send` + --> $DIR/rc-not-send.rs:5:21 + | +LL | fn requires_send<T: Send>(_: T) {} + | ^^^^ required by this bound in `requires_send` +help: consider dereferencing here + | +LL | requires_send(*rc_value); + | + + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/span-bug-issue-121414.stderr b/tests/ui/traits/span-bug-issue-121414.stderr index 744806a3415..2eeda00d9cb 100644 --- a/tests/ui/traits/span-bug-issue-121414.stderr +++ b/tests/ui/traits/span-bug-issue-121414.stderr @@ -2,9 +2,12 @@ error[E0261]: use of undeclared lifetime name `'f` --> $DIR/span-bug-issue-121414.rs:5:22 | LL | impl<'a> Bar for Foo<'f> { - | - ^^ undeclared lifetime - | | - | help: consider introducing lifetime `'f` here: `'f,` + | ^^ undeclared lifetime + | +help: consider introducing lifetime `'f` here + | +LL | impl<'f, 'a> Bar for Foo<'f> { + | +++ error: aborting due to 1 previous error diff --git a/tests/ui/traits/struct-negative-sync-impl.rs b/tests/ui/traits/struct-negative-sync-impl.rs new file mode 100644 index 00000000000..d32846276f6 --- /dev/null +++ b/tests/ui/traits/struct-negative-sync-impl.rs @@ -0,0 +1,21 @@ +//! Test negative Sync implementation on structs. +//! +//! Uses the unstable `negative_impls` feature to explicitly opt-out of Sync. + +#![feature(negative_impls)] + +use std::marker::Sync; + +struct NotSync { + value: isize, +} + +impl !Sync for NotSync {} + +fn requires_sync<T: Sync>(_: T) {} + +fn main() { + let not_sync = NotSync { value: 5 }; + requires_sync(not_sync); + //~^ ERROR `NotSync` cannot be shared between threads safely [E0277] +} diff --git a/tests/ui/traits/struct-negative-sync-impl.stderr b/tests/ui/traits/struct-negative-sync-impl.stderr new file mode 100644 index 00000000000..c5fd13f42e5 --- /dev/null +++ b/tests/ui/traits/struct-negative-sync-impl.stderr @@ -0,0 +1,18 @@ +error[E0277]: `NotSync` cannot be shared between threads safely + --> $DIR/struct-negative-sync-impl.rs:19:19 + | +LL | requires_sync(not_sync); + | ------------- ^^^^^^^^ `NotSync` cannot be shared between threads safely + | | + | required by a bound introduced by this call + | + = help: the trait `Sync` is not implemented for `NotSync` +note: required by a bound in `requires_sync` + --> $DIR/struct-negative-sync-impl.rs:15:21 + | +LL | fn requires_sync<T: Sync>(_: T) {} + | ^^^^ required by this bound in `requires_sync` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/suggest-remove-deref-issue-140166.stderr b/tests/ui/traits/suggest-remove-deref-issue-140166.stderr index 90f24d86d53..7c61f957fdc 100644 --- a/tests/ui/traits/suggest-remove-deref-issue-140166.stderr +++ b/tests/ui/traits/suggest-remove-deref-issue-140166.stderr @@ -4,7 +4,7 @@ error[E0277]: the trait bound `&Chars: Trait` is not satisfied LL | format_args!("{:?}", FlatMap(&Chars)); | ---- ^^^^^^^^^^^^^^^ the trait `Trait` is not implemented for `&Chars` | | - | required by a bound introduced by this call + | required by this formatting parameter | = help: the trait `Trait` is implemented for `Chars` note: required for `FlatMap<&Chars>` to implement `Debug` @@ -14,8 +14,6 @@ LL | impl<T: Trait> std::fmt::Debug for FlatMap<T> { | ----- ^^^^^^^^^^^^^^^ ^^^^^^^^^^ | | | unsatisfied trait bound introduced here -note: required by a bound in `core::fmt::rt::Argument::<'_>::new_debug` - --> $SRC_DIR/core/src/fmt/rt.rs:LL:COL error: aborting due to 1 previous error diff --git a/tests/ui/traits/trait-object-destructure.rs b/tests/ui/traits/trait-object-destructure.rs new file mode 100644 index 00000000000..6c091677c8c --- /dev/null +++ b/tests/ui/traits/trait-object-destructure.rs @@ -0,0 +1,29 @@ +//! Regression test for destructuring trait references (`&dyn T`/`Box<dyn T>`). +//! Checks cases where number of `&`/`Box` patterns (n) matches/doesn't match references (m). +//! +//! Issue: https://github.com/rust-lang/rust/issues/15031 + +#![feature(box_patterns)] + +trait T { + fn foo(&self) {} +} + +impl T for isize {} + +fn main() { + // Valid cases: n < m (can dereference) + let &x = &(&1isize as &dyn T); + let &x = &&(&1isize as &dyn T); + let &&x = &&(&1isize as &dyn T); + + // Error cases: n == m (cannot dereference trait object) + let &x = &1isize as &dyn T; //~ ERROR type `&dyn T` cannot be dereferenced + let &&x = &(&1isize as &dyn T); //~ ERROR type `&dyn T` cannot be dereferenced + let box x = Box::new(1isize) as Box<dyn T>; //~ ERROR type `Box<dyn T>` cannot be dereferenced + + // Error cases: n > m (type mismatch) + let &&x = &1isize as &dyn T; //~ ERROR mismatched types + let &&&x = &(&1isize as &dyn T); //~ ERROR mismatched types + let box box x = Box::new(1isize) as Box<dyn T>; //~ ERROR mismatched types +} diff --git a/tests/ui/destructure-trait-ref.stderr b/tests/ui/traits/trait-object-destructure.stderr index 0b5ea551a57..c7c832dc40a 100644 --- a/tests/ui/destructure-trait-ref.stderr +++ b/tests/ui/traits/trait-object-destructure.stderr @@ -1,23 +1,23 @@ error[E0033]: type `&dyn T` cannot be dereferenced - --> $DIR/destructure-trait-ref.rs:28:9 + --> $DIR/trait-object-destructure.rs:21:9 | LL | let &x = &1isize as &dyn T; | ^^ type `&dyn T` cannot be dereferenced error[E0033]: type `&dyn T` cannot be dereferenced - --> $DIR/destructure-trait-ref.rs:29:10 + --> $DIR/trait-object-destructure.rs:22:10 | LL | let &&x = &(&1isize as &dyn T); | ^^ type `&dyn T` cannot be dereferenced error[E0033]: type `Box<dyn T>` cannot be dereferenced - --> $DIR/destructure-trait-ref.rs:30:9 + --> $DIR/trait-object-destructure.rs:23:9 | LL | let box x = Box::new(1isize) as Box<dyn T>; | ^^^^^ type `Box<dyn T>` cannot be dereferenced error[E0308]: mismatched types - --> $DIR/destructure-trait-ref.rs:34:10 + --> $DIR/trait-object-destructure.rs:26:10 | LL | let &&x = &1isize as &dyn T; | ^^ ----------------- this expression has type `&dyn T` @@ -33,7 +33,7 @@ LL + let &x = &1isize as &dyn T; | error[E0308]: mismatched types - --> $DIR/destructure-trait-ref.rs:38:11 + --> $DIR/trait-object-destructure.rs:27:11 | LL | let &&&x = &(&1isize as &dyn T); | ^^ -------------------- this expression has type `&&dyn T` @@ -49,7 +49,7 @@ LL + let &&x = &(&1isize as &dyn T); | error[E0308]: mismatched types - --> $DIR/destructure-trait-ref.rs:42:13 + --> $DIR/trait-object-destructure.rs:28:13 | LL | let box box x = Box::new(1isize) as Box<dyn T>; | ^^^^^ ------------------------------ this expression has type `Box<dyn T>` diff --git a/tests/ui/object-pointer-types.rs b/tests/ui/traits/trait-object-method-receiver-rules.rs index 760a50e5b79..383e59c131a 100644 --- a/tests/ui/object-pointer-types.rs +++ b/tests/ui/traits/trait-object-method-receiver-rules.rs @@ -1,7 +1,8 @@ +//! Checks that method availability rules for trait objects depend on receiver type. + trait Foo { fn borrowed(&self); fn borrowed_mut(&mut self); - fn owned(self: Box<Self>); } @@ -20,7 +21,7 @@ fn borrowed_mut_receiver(x: &mut dyn Foo) { fn owned_receiver(x: Box<dyn Foo>) { x.borrowed(); x.borrowed_mut(); // See [1] - x.managed(); //~ ERROR no method named `managed` found + x.managed(); //~ ERROR no method named `managed` found x.owned(); } diff --git a/tests/ui/object-pointer-types.stderr b/tests/ui/traits/trait-object-method-receiver-rules.stderr index 72b290f2ad9..83b61a2e6b5 100644 --- a/tests/ui/object-pointer-types.stderr +++ b/tests/ui/traits/trait-object-method-receiver-rules.stderr @@ -1,5 +1,5 @@ error[E0599]: no method named `owned` found for reference `&dyn Foo` in the current scope - --> $DIR/object-pointer-types.rs:11:7 + --> $DIR/trait-object-method-receiver-rules.rs:12:7 | LL | fn owned(self: Box<Self>); | --------- the method might not be found because of this arbitrary self type @@ -13,7 +13,7 @@ LL | x.to_owned(); | +++ error[E0599]: no method named `owned` found for mutable reference `&mut dyn Foo` in the current scope - --> $DIR/object-pointer-types.rs:17:7 + --> $DIR/trait-object-method-receiver-rules.rs:18:7 | LL | fn owned(self: Box<Self>); | --------- the method might not be found because of this arbitrary self type @@ -22,7 +22,7 @@ LL | x.owned(); | ^^^^^ method not found in `&mut dyn Foo` error[E0599]: no method named `managed` found for struct `Box<(dyn Foo + 'static)>` in the current scope - --> $DIR/object-pointer-types.rs:23:7 + --> $DIR/trait-object-method-receiver-rules.rs:24:7 | LL | x.managed(); | ^^^^^^^ method not found in `Box<(dyn Foo + 'static)>` diff --git a/tests/ui/objects-coerce-freeze-borrored.rs b/tests/ui/traits/trait-object-mut-to-shared-coercion.rs index e122bb99380..26b5cc6d2df 100644 --- a/tests/ui/objects-coerce-freeze-borrored.rs +++ b/tests/ui/traits/trait-object-mut-to-shared-coercion.rs @@ -1,6 +1,6 @@ -//@ run-pass -// Test that we can coerce an `@Object` to an `&Object` +//! Tests that coercion from `&mut dyn Trait` to `&dyn Trait` works correctly. +//@ run-pass trait Foo { fn foo(&self) -> usize; diff --git a/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr b/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr index b9988e2e6d3..4264f2688ac 100644 --- a/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr +++ b/tests/ui/traits/trait-upcasting/cyclic-trait-resolution.stderr @@ -9,7 +9,7 @@ note: cycle used when checking that `A` is well-formed --> $DIR/cyclic-trait-resolution.rs:1:1 | LL | trait A: B + A {} - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^ = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information error[E0391]: cycle detected when computing the implied predicates of `A` diff --git a/tests/ui/traits/trait-upcasting/dyn-to-dyn-star.rs b/tests/ui/traits/trait-upcasting/dyn-to-dyn-star.rs deleted file mode 100644 index 5936c93efad..00000000000 --- a/tests/ui/traits/trait-upcasting/dyn-to-dyn-star.rs +++ /dev/null @@ -1,19 +0,0 @@ -// While somewhat nonsensical, this is a cast from a wide pointer to a thin pointer. -// Thus, we don't need to check an unsize goal here; there isn't any vtable casting -// happening at all. - -// Regression test for <https://github.com/rust-lang/rust/issues/137579>. - -//@ check-pass - -#![allow(incomplete_features)] -#![feature(dyn_star)] - -trait Foo {} -trait Bar {} - -fn cast(x: *const dyn Foo) { - x as *const dyn* Bar; -} - -fn main() {} diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr b/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr index 2bb389c6ec1..9ce0e8d957d 100644 --- a/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr +++ b/tests/ui/traits/unconstrained-projection-normalization-2.current.stderr @@ -4,6 +4,31 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T: ?Sized> Every for Thing { | ^ unconstrained type parameter -error: aborting due to 1 previous error +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unconstrained-projection-normalization-2.rs:16:18 + | +LL | impl<T: ?Sized> Every for Thing { + | - this type parameter needs to be `Sized` +LL | +LL | type Assoc = T; + | ^ doesn't have a size known at compile-time + | +note: required by a bound in `Every::Assoc` + --> $DIR/unconstrained-projection-normalization-2.rs:12:5 + | +LL | type Assoc; + | ^^^^^^^^^^^ required by this bound in `Every::Assoc` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - impl<T: ?Sized> Every for Thing { +LL + impl<T> Every for Thing { + | +help: consider relaxing the implicit `Sized` restriction + | +LL | type Assoc: ?Sized; + | ++++++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0207, E0277. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr b/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr index 3eacab33e46..2da655afa93 100644 --- a/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr +++ b/tests/ui/traits/unconstrained-projection-normalization-2.next.stderr @@ -4,13 +4,37 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T: ?Sized> Every for Thing { | ^ unconstrained type parameter +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unconstrained-projection-normalization-2.rs:16:18 + | +LL | impl<T: ?Sized> Every for Thing { + | - this type parameter needs to be `Sized` +LL | +LL | type Assoc = T; + | ^ doesn't have a size known at compile-time + | +note: required by a bound in `Every::Assoc` + --> $DIR/unconstrained-projection-normalization-2.rs:12:5 + | +LL | type Assoc; + | ^^^^^^^^^^^ required by this bound in `Every::Assoc` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - impl<T: ?Sized> Every for Thing { +LL + impl<T> Every for Thing { + | +help: consider relaxing the implicit `Sized` restriction + | +LL | type Assoc: ?Sized; + | ++++++++ + error[E0282]: type annotations needed - --> $DIR/unconstrained-projection-normalization-2.rs:19:11 + --> $DIR/unconstrained-projection-normalization-2.rs:20:11 | LL | fn foo(_: <Thing as Every>::Assoc) {} | ^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type for associated type `<Thing as Every>::Assoc` -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0207, E0282. +Some errors have detailed explanations: E0207, E0277, E0282. For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization-2.rs b/tests/ui/traits/unconstrained-projection-normalization-2.rs index 9d95c73eea7..899d67571e7 100644 --- a/tests/ui/traits/unconstrained-projection-normalization-2.rs +++ b/tests/ui/traits/unconstrained-projection-normalization-2.rs @@ -12,8 +12,9 @@ pub trait Every { type Assoc; } impl<T: ?Sized> Every for Thing { -//~^ ERROR the type parameter `T` is not constrained + //~^ ERROR the type parameter `T` is not constrained type Assoc = T; + //~^ ERROR: the size for values of type `T` cannot be known at compilation time } fn foo(_: <Thing as Every>::Assoc) {} diff --git a/tests/ui/traits/unconstrained-projection-normalization.current.stderr b/tests/ui/traits/unconstrained-projection-normalization.current.stderr index 991f0e8ba66..c52e8dd68aa 100644 --- a/tests/ui/traits/unconstrained-projection-normalization.current.stderr +++ b/tests/ui/traits/unconstrained-projection-normalization.current.stderr @@ -4,6 +4,31 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T: ?Sized> Every for Thing { | ^ unconstrained type parameter -error: aborting due to 1 previous error +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unconstrained-projection-normalization.rs:15:18 + | +LL | impl<T: ?Sized> Every for Thing { + | - this type parameter needs to be `Sized` +LL | +LL | type Assoc = T; + | ^ doesn't have a size known at compile-time + | +note: required by a bound in `Every::Assoc` + --> $DIR/unconstrained-projection-normalization.rs:11:5 + | +LL | type Assoc; + | ^^^^^^^^^^^ required by this bound in `Every::Assoc` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - impl<T: ?Sized> Every for Thing { +LL + impl<T> Every for Thing { + | +help: consider relaxing the implicit `Sized` restriction + | +LL | type Assoc: ?Sized; + | ++++++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0207, E0277. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization.next.stderr b/tests/ui/traits/unconstrained-projection-normalization.next.stderr index 991f0e8ba66..c52e8dd68aa 100644 --- a/tests/ui/traits/unconstrained-projection-normalization.next.stderr +++ b/tests/ui/traits/unconstrained-projection-normalization.next.stderr @@ -4,6 +4,31 @@ error[E0207]: the type parameter `T` is not constrained by the impl trait, self LL | impl<T: ?Sized> Every for Thing { | ^ unconstrained type parameter -error: aborting due to 1 previous error +error[E0277]: the size for values of type `T` cannot be known at compilation time + --> $DIR/unconstrained-projection-normalization.rs:15:18 + | +LL | impl<T: ?Sized> Every for Thing { + | - this type parameter needs to be `Sized` +LL | +LL | type Assoc = T; + | ^ doesn't have a size known at compile-time + | +note: required by a bound in `Every::Assoc` + --> $DIR/unconstrained-projection-normalization.rs:11:5 + | +LL | type Assoc; + | ^^^^^^^^^^^ required by this bound in `Every::Assoc` +help: consider removing the `?Sized` bound to make the type parameter `Sized` + | +LL - impl<T: ?Sized> Every for Thing { +LL + impl<T> Every for Thing { + | +help: consider relaxing the implicit `Sized` restriction + | +LL | type Assoc: ?Sized; + | ++++++++ + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0207, E0277. +For more information about an error, try `rustc --explain E0207`. diff --git a/tests/ui/traits/unconstrained-projection-normalization.rs b/tests/ui/traits/unconstrained-projection-normalization.rs index fa4ab7fec4c..8e9444533a8 100644 --- a/tests/ui/traits/unconstrained-projection-normalization.rs +++ b/tests/ui/traits/unconstrained-projection-normalization.rs @@ -11,8 +11,9 @@ pub trait Every { type Assoc; } impl<T: ?Sized> Every for Thing { -//~^ ERROR the type parameter `T` is not constrained + //~^ ERROR the type parameter `T` is not constrained type Assoc = T; + //~^ ERROR: the size for values of type `T` cannot be known at compilation time } static I: <Thing as Every>::Assoc = 3; diff --git a/tests/ui/transmute/diverging-fn-transmute.rs b/tests/ui/transmute/diverging-fn-transmute.rs new file mode 100644 index 00000000000..aca82037a0c --- /dev/null +++ b/tests/ui/transmute/diverging-fn-transmute.rs @@ -0,0 +1,10 @@ +//! Regression test for issue #35849: transmute with panic in diverging function + +fn assert_sizeof() -> ! { + unsafe { + ::std::mem::transmute::<f64, [u8; 8]>(panic!()) + //~^ ERROR mismatched types + } +} + +fn main() {} diff --git a/tests/ui/diverging-fn-tail-35849.stderr b/tests/ui/transmute/diverging-fn-transmute.stderr index 614f9b9cb5d..b9aeae7ed62 100644 --- a/tests/ui/diverging-fn-tail-35849.stderr +++ b/tests/ui/transmute/diverging-fn-transmute.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/diverging-fn-tail-35849.rs:3:9 + --> $DIR/diverging-fn-transmute.rs:5:9 | LL | fn assert_sizeof() -> ! { | - expected `!` because of return type diff --git a/tests/ui/type-alias-enum-variants/module-type-args-error.rs b/tests/ui/type-alias-enum-variants/module-type-args-error.rs new file mode 100644 index 00000000000..9f7dae4f4f5 --- /dev/null +++ b/tests/ui/type-alias-enum-variants/module-type-args-error.rs @@ -0,0 +1,16 @@ +//! Test that type arguments are properly rejected on modules. +//! +//! Related PR: https://github.com/rust-lang/rust/pull/56225 (RFC 2338 implementation) + +mod Mod { + pub struct FakeVariant<T>(pub T); +} + +fn main() { + // This should work fine - normal generic struct constructor + Mod::FakeVariant::<i32>(0); + + // This should error - type arguments not allowed on modules + Mod::<i32>::FakeVariant(0); + //~^ ERROR type arguments are not allowed on module `Mod` [E0109] +} diff --git a/tests/ui/mod-subitem-as-enum-variant.stderr b/tests/ui/type-alias-enum-variants/module-type-args-error.stderr index 92d972eba42..4c59d19eaa7 100644 --- a/tests/ui/mod-subitem-as-enum-variant.stderr +++ b/tests/ui/type-alias-enum-variants/module-type-args-error.stderr @@ -1,5 +1,5 @@ error[E0109]: type arguments are not allowed on module `Mod` - --> $DIR/mod-subitem-as-enum-variant.rs:7:11 + --> $DIR/module-type-args-error.rs:14:11 | LL | Mod::<i32>::FakeVariant(0); | --- ^^^ type argument not allowed diff --git a/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr b/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr index c0f6d678097..01d24cabf48 100644 --- a/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr +++ b/tests/ui/type-alias-impl-trait/bounds-are-checked3.stderr @@ -2,9 +2,8 @@ error[E0277]: `T` doesn't implement `std::fmt::Display` --> $DIR/bounds-are-checked3.rs:9:35 | LL | type Foo<T: Debug> = (impl Debug, Struct<T>); - | ^^^^^^^^^ `T` cannot be formatted with the default formatter + | ^^^^^^^^^ the trait `std::fmt::Display` is not implemented for `T` | - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `Struct` --> $DIR/bounds-are-checked3.rs:5:18 | diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr index ef0e73f1481..193f0c92c9d 100644 --- a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr +++ b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use2.stderr @@ -2,7 +2,7 @@ error[E0277]: `T` doesn't implement `Debug` --> $DIR/generic_duplicate_param_use2.rs:12:5 | LL | t - | ^ `T` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^ the trait `Debug` is not implemented for `T` | note: required by a bound in an opaque type --> $DIR/generic_duplicate_param_use2.rs:8:23 diff --git a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr index 0932c72ff93..f0d1e93b0b7 100644 --- a/tests/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr +++ b/tests/ui/type-alias-impl-trait/generic_duplicate_param_use4.stderr @@ -2,7 +2,7 @@ error[E0277]: `U` doesn't implement `Debug` --> $DIR/generic_duplicate_param_use4.rs:12:5 | LL | u - | ^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^ the trait `Debug` is not implemented for `U` | note: required by a bound in an opaque type --> $DIR/generic_duplicate_param_use4.rs:8:23 diff --git a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr index 429c3b9175a..1e3c454a5bc 100644 --- a/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr +++ b/tests/ui/type-alias-impl-trait/generic_underconstrained2.stderr @@ -2,7 +2,7 @@ error[E0277]: `U` doesn't implement `Debug` --> $DIR/generic_underconstrained2.rs:9:33 | LL | fn underconstrained<U>(_: U) -> Underconstrained<U> { - | ^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `U` | note: required by a bound on the type alias `Underconstrained` --> $DIR/generic_underconstrained2.rs:5:26 @@ -18,7 +18,7 @@ error[E0277]: `V` doesn't implement `Debug` --> $DIR/generic_underconstrained2.rs:19:43 | LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> { - | ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `V` | note: required by a bound on the type alias `Underconstrained2` --> $DIR/generic_underconstrained2.rs:15:27 @@ -34,7 +34,7 @@ error[E0277]: `U` doesn't implement `Debug` --> $DIR/generic_underconstrained2.rs:9:33 | LL | fn underconstrained<U>(_: U) -> Underconstrained<U> { - | ^^^^^^^^^^^^^^^^^^^ `U` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `U` | note: required by a bound on the type alias `Underconstrained` --> $DIR/generic_underconstrained2.rs:5:26 @@ -51,7 +51,7 @@ error[E0277]: `V` doesn't implement `Debug` --> $DIR/generic_underconstrained2.rs:19:43 | LL | fn underconstrained2<U, V>(_: U, _: V) -> Underconstrained2<V> { - | ^^^^^^^^^^^^^^^^^^^^ `V` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ^^^^^^^^^^^^^^^^^^^^ the trait `Debug` is not implemented for `V` | note: required by a bound on the type alias `Underconstrained2` --> $DIR/generic_underconstrained2.rs:15:27 diff --git a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.edition2015.stderr index 0bf9dccfad8..4f1e769bc6c 100644 --- a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.stderr +++ b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.edition2015.stderr @@ -1,5 +1,5 @@ error[E0700]: hidden type for `impl PlusOne` captures lifetime that does not appear in bounds - --> $DIR/imply_bounds_from_bounds_param.rs:26:5 + --> $DIR/imply_bounds_from_bounds_param.rs:29:5 | LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne { | -- ------------ opaque type defined here diff --git a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.edition2024.stderr b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.edition2024.stderr new file mode 100644 index 00000000000..a7135e8f05f --- /dev/null +++ b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.edition2024.stderr @@ -0,0 +1,91 @@ +error[E0499]: cannot borrow `z` as mutable more than once at a time + --> $DIR/imply_bounds_from_bounds_param.rs:36:27 + | +LL | let mut thing = test(&mut z); + | ------ first mutable borrow occurs here +LL | let mut thing2 = test(&mut z); + | ^^^^^^ second mutable borrow occurs here +LL | thing.plus_one(); + | ----- first borrow later used here + | +note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules + --> $DIR/imply_bounds_from_bounds_param.rs:35:21 + | +LL | let mut thing = test(&mut z); + | ^^^^^^^^^^^^ +help: use the precise capturing `use<...>` syntax to make the captures explicit + | +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + use<> { + | +++++++ + +error[E0502]: cannot borrow `z` as immutable because it is also borrowed as mutable + --> $DIR/imply_bounds_from_bounds_param.rs:38:5 + | +LL | let mut thing = test(&mut z); + | ------ mutable borrow occurs here +... +LL | assert_eq!(z, 43); + | ^^^^^^^^^^^^^^^^^ immutable borrow occurs here +... +LL | thing.plus_one(); + | ----- mutable borrow later used here + | +note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules + --> $DIR/imply_bounds_from_bounds_param.rs:35:21 + | +LL | let mut thing = test(&mut z); + | ^^^^^^^^^^^^ + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use the precise capturing `use<...>` syntax to make the captures explicit + | +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + use<> { + | +++++++ + +error[E0502]: cannot borrow `z` as immutable because it is also borrowed as mutable + --> $DIR/imply_bounds_from_bounds_param.rs:40:5 + | +LL | let mut thing = test(&mut z); + | ------ mutable borrow occurs here +... +LL | assert_eq!(z, 44); + | ^^^^^^^^^^^^^^^^^ immutable borrow occurs here +LL | thing.plus_one(); + | ----- mutable borrow later used here + | +note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules + --> $DIR/imply_bounds_from_bounds_param.rs:35:21 + | +LL | let mut thing = test(&mut z); + | ^^^^^^^^^^^^ + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use the precise capturing `use<...>` syntax to make the captures explicit + | +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + use<> { + | +++++++ + +error[E0502]: cannot borrow `z` as immutable because it is also borrowed as mutable + --> $DIR/imply_bounds_from_bounds_param.rs:42:5 + | +LL | let mut thing = test(&mut z); + | ------ mutable borrow occurs here +... +LL | assert_eq!(z, 45); + | ^^^^^^^^^^^^^^^^^ immutable borrow occurs here +LL | } + | - mutable borrow might be used here, when `thing` is dropped and runs the destructor for type `impl PlusOne` + | +note: this call may capture more lifetimes than intended, because Rust 2024 has adjusted the `impl Trait` lifetime capture rules + --> $DIR/imply_bounds_from_bounds_param.rs:35:21 + | +LL | let mut thing = test(&mut z); + | ^^^^^^^^^^^^ + = note: this error originates in the macro `assert_eq` (in Nightly builds, run with -Z macro-backtrace for more info) +help: use the precise capturing `use<...>` syntax to make the captures explicit + | +LL | fn test<'a>(y: &'a mut i32) -> impl PlusOne + use<> { + | +++++++ + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0499, E0502. +For more information about an error, try `rustc --explain E0499`. diff --git a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs index 5d5645077c2..672019ba73a 100644 --- a/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs +++ b/tests/ui/type-alias-impl-trait/imply_bounds_from_bounds_param.rs @@ -1,3 +1,6 @@ +//@revisions: edition2015 edition2024 +//@[edition2015] edition:2015 +//@[edition2024] edition:2024 #![feature(impl_trait_in_assoc_type)] trait Callable { @@ -24,17 +27,17 @@ impl<T: PlusOne> Callable for T { fn test<'a>(y: &'a mut i32) -> impl PlusOne { <&'a mut i32 as Callable>::call(y) - //~^ ERROR hidden type for `impl PlusOne` captures lifetime that does not appear in bounds + //[edition2015]~^ ERROR hidden type for `impl PlusOne` captures lifetime that does not appear in bounds } fn main() { let mut z = 42; let mut thing = test(&mut z); - let mut thing2 = test(&mut z); + let mut thing2 = test(&mut z); //[edition2024]~ ERROR cannot borrow `z` as mutable more than once thing.plus_one(); - assert_eq!(z, 43); + assert_eq!(z, 43); //[edition2024]~ ERROR cannot borrow `z` as immutable thing2.plus_one(); - assert_eq!(z, 44); + assert_eq!(z, 44); //[edition2024]~ ERROR cannot borrow `z` as immutable thing.plus_one(); - assert_eq!(z, 45); + assert_eq!(z, 45); //[edition2024]~ ERROR cannot borrow `z` as immutable } diff --git a/tests/ui/type-alias-impl-trait/nested.stderr b/tests/ui/type-alias-impl-trait/nested.stderr index 59911f65a23..f72830b864d 100644 --- a/tests/ui/type-alias-impl-trait/nested.stderr +++ b/tests/ui/type-alias-impl-trait/nested.stderr @@ -15,7 +15,9 @@ error[E0277]: `Bar` doesn't implement `Debug` --> $DIR/nested.rs:17:22 | LL | println!("{:?}", bar()); - | ^^^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | ---- ^^^^^ `Bar` cannot be formatted using `{:?}` because it doesn't implement `Debug` + | | + | required by this formatting parameter | = help: the trait `Debug` is not implemented for `Bar` = note: this error originates in the macro `$crate::format_args_nl` which comes from the expansion of the macro `println` (in Nightly builds, run with -Z macro-backtrace for more info) diff --git a/tests/ui/type-inference/direct-self-reference-occurs-check.rs b/tests/ui/type-inference/direct-self-reference-occurs-check.rs new file mode 100644 index 00000000000..6e3d8251fc4 --- /dev/null +++ b/tests/ui/type-inference/direct-self-reference-occurs-check.rs @@ -0,0 +1,9 @@ +//! Test that occurs check prevents direct self-reference in variable assignment. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/768>. + +fn main() { + let f; + f = Box::new(f); + //~^ ERROR overflow assigning `Box<_>` to `_` +} diff --git a/tests/ui/occurs-check.stderr b/tests/ui/type-inference/direct-self-reference-occurs-check.stderr index ea7c541abc1..6c522ffac1f 100644 --- a/tests/ui/occurs-check.stderr +++ b/tests/ui/type-inference/direct-self-reference-occurs-check.stderr @@ -1,5 +1,5 @@ error[E0275]: overflow assigning `Box<_>` to `_` - --> $DIR/occurs-check.rs:3:18 + --> $DIR/direct-self-reference-occurs-check.rs:7:18 | LL | f = Box::new(f); | ^ diff --git a/tests/ui/type-inference/enum-self-reference-occurs-check.rs b/tests/ui/type-inference/enum-self-reference-occurs-check.rs new file mode 100644 index 00000000000..2905868b8bf --- /dev/null +++ b/tests/ui/type-inference/enum-self-reference-occurs-check.rs @@ -0,0 +1,16 @@ +//! Test that occurs check prevents infinite types with enum self-references. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/778>. + +enum Clam<T> { + A(T), +} + +fn main() { + let c; + c = Clam::A(c); + //~^ ERROR overflow assigning `Clam<_>` to `_` + match c { + Clam::A::<isize>(_) => {} + } +} diff --git a/tests/ui/occurs-check-3.stderr b/tests/ui/type-inference/enum-self-reference-occurs-check.stderr index eb05c94957c..3239be51a17 100644 --- a/tests/ui/occurs-check-3.stderr +++ b/tests/ui/type-inference/enum-self-reference-occurs-check.stderr @@ -1,5 +1,5 @@ error[E0275]: overflow assigning `Clam<_>` to `_` - --> $DIR/occurs-check-3.rs:6:17 + --> $DIR/enum-self-reference-occurs-check.rs:11:17 | LL | c = Clam::A(c); | ^ diff --git a/tests/ui/type-inference/infinite-type-occurs-check.rs b/tests/ui/type-inference/infinite-type-occurs-check.rs new file mode 100644 index 00000000000..b353824e931 --- /dev/null +++ b/tests/ui/type-inference/infinite-type-occurs-check.rs @@ -0,0 +1,12 @@ +//! Test that occurs check prevents infinite types during type inference. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/768>. + +fn main() { + let f; + let g; + + g = f; + //~^ ERROR overflow assigning `Box<_>` to `_` + f = Box::new(g); +} diff --git a/tests/ui/occurs-check-2.stderr b/tests/ui/type-inference/infinite-type-occurs-check.stderr index 5f296967f30..9cb8bb91796 100644 --- a/tests/ui/occurs-check-2.stderr +++ b/tests/ui/type-inference/infinite-type-occurs-check.stderr @@ -1,5 +1,5 @@ error[E0275]: overflow assigning `Box<_>` to `_` - --> $DIR/occurs-check-2.rs:6:9 + --> $DIR/infinite-type-occurs-check.rs:9:9 | LL | g = f; | ^ diff --git a/tests/ui/type/binding-assigned-block-without-tail-expression.stderr b/tests/ui/type/binding-assigned-block-without-tail-expression.stderr index 3e96d7f317b..ff34facf389 100644 --- a/tests/ui/type/binding-assigned-block-without-tail-expression.stderr +++ b/tests/ui/type/binding-assigned-block-without-tail-expression.stderr @@ -5,7 +5,9 @@ LL | 42; | - help: remove this semicolon ... LL | println!("{}", x); - | ^ `()` cannot be formatted with the default formatter + | -- ^ `()` cannot be formatted with the default formatter + | | + | required by this formatting parameter | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead @@ -18,7 +20,9 @@ LL | let y = {}; | -- this empty block is missing a tail expression ... LL | println!("{}", y); - | ^ `()` cannot be formatted with the default formatter + | -- ^ `()` cannot be formatted with the default formatter + | | + | required by this formatting parameter | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead @@ -31,7 +35,9 @@ LL | "hi"; | - help: remove this semicolon ... LL | println!("{}", z); - | ^ `()` cannot be formatted with the default formatter + | -- ^ `()` cannot be formatted with the default formatter + | | + | required by this formatting parameter | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead @@ -47,7 +53,9 @@ LL | | }; | |_____- this block is missing a tail expression ... LL | println!("{}", s); - | ^ `()` cannot be formatted with the default formatter + | -- ^ `()` cannot be formatted with the default formatter + | | + | required by this formatting parameter | = help: the trait `std::fmt::Display` is not implemented for `()` = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead diff --git a/tests/ui/type/inherent-impl-primitive-types-error.rs b/tests/ui/type/inherent-impl-primitive-types-error.rs new file mode 100644 index 00000000000..88b8b9da56b --- /dev/null +++ b/tests/ui/type/inherent-impl-primitive-types-error.rs @@ -0,0 +1,28 @@ +//! Test that inherent impl blocks cannot be defined for primitive types + +impl u8 { + //~^ ERROR: cannot define inherent `impl` for primitive types + pub const B: u8 = 0; +} + +impl str { + //~^ ERROR: cannot define inherent `impl` for primitive types + fn foo() {} + fn bar(self) {} //~ ERROR: size for values of type `str` cannot be known +} + +impl char { + //~^ ERROR: cannot define inherent `impl` for primitive types + pub const B: u8 = 0; + pub const C: u8 = 0; + fn foo() {} + fn bar(self) {} +} + +struct MyType; +impl &MyType { + //~^ ERROR: cannot define inherent `impl` for primitive types + pub fn for_ref(self) {} +} + +fn main() {} diff --git a/tests/ui/kinds-of-primitive-impl.stderr b/tests/ui/type/inherent-impl-primitive-types-error.stderr index 1c8c417e88c..5b79521a35e 100644 --- a/tests/ui/kinds-of-primitive-impl.stderr +++ b/tests/ui/type/inherent-impl-primitive-types-error.stderr @@ -1,5 +1,5 @@ error[E0390]: cannot define inherent `impl` for primitive types - --> $DIR/kinds-of-primitive-impl.rs:1:1 + --> $DIR/inherent-impl-primitive-types-error.rs:3:1 | LL | impl u8 { | ^^^^^^^ @@ -7,7 +7,7 @@ LL | impl u8 { = help: consider using an extension trait instead error[E0390]: cannot define inherent `impl` for primitive types - --> $DIR/kinds-of-primitive-impl.rs:6:1 + --> $DIR/inherent-impl-primitive-types-error.rs:8:1 | LL | impl str { | ^^^^^^^^ @@ -15,7 +15,7 @@ LL | impl str { = help: consider using an extension trait instead error[E0390]: cannot define inherent `impl` for primitive types - --> $DIR/kinds-of-primitive-impl.rs:12:1 + --> $DIR/inherent-impl-primitive-types-error.rs:14:1 | LL | impl char { | ^^^^^^^^^ @@ -23,7 +23,7 @@ LL | impl char { = help: consider using an extension trait instead error[E0390]: cannot define inherent `impl` for primitive types - --> $DIR/kinds-of-primitive-impl.rs:21:1 + --> $DIR/inherent-impl-primitive-types-error.rs:23:1 | LL | impl &MyType { | ^^^^^^^^^^^^ @@ -32,7 +32,7 @@ LL | impl &MyType { = note: you could also try moving the reference to uses of `MyType` (such as `self`) within the implementation error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/kinds-of-primitive-impl.rs:9:12 + --> $DIR/inherent-impl-primitive-types-error.rs:11:12 | LL | fn bar(self) {} | ^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/type/mutually-recursive-types.rs b/tests/ui/type/mutually-recursive-types.rs new file mode 100644 index 00000000000..5472e158221 --- /dev/null +++ b/tests/ui/type/mutually-recursive-types.rs @@ -0,0 +1,47 @@ +//! Test that mutually recursive type definitions are properly handled by the compiler. +//! This checks that types can reference each other in their definitions through +//! `Box` indirection, creating cycles in the type dependency graph. + +//@ run-pass + +#[derive(Debug, PartialEq)] +enum Colour { + Red, + Green, + Blue, +} + +#[derive(Debug, PartialEq)] +enum Tree { + Children(Box<List>), + Leaf(Colour), +} + +#[derive(Debug, PartialEq)] +enum List { + Cons(Box<Tree>, Box<List>), + Nil, +} + +#[derive(Debug, PartialEq)] +enum SmallList { + Kons(isize, Box<SmallList>), + Neel, +} + +pub fn main() { + // Construct and test all variants of Colour + let _ = Tree::Leaf(Colour::Red); + + let _ = Tree::Leaf(Colour::Green); + + let _ = Tree::Leaf(Colour::Blue); + + let _ = List::Nil; + + let _ = Tree::Children(Box::new(List::Nil)); + + let _ = List::Cons(Box::new(Tree::Leaf(Colour::Blue)), Box::new(List::Nil)); + + let _ = SmallList::Kons(42, Box::new(SmallList::Neel)); +} diff --git a/tests/ui/type/option-ref-advice.rs b/tests/ui/type/option-ref-advice.rs index 2dcee5a2eb9..435b15d01e3 100644 --- a/tests/ui/type/option-ref-advice.rs +++ b/tests/ui/type/option-ref-advice.rs @@ -3,9 +3,9 @@ fn takes_option(_arg: Option<&String>) {} fn main() { - takes_option(&None); //~ ERROR 6:18: 6:23: mismatched types [E0308] + takes_option(&None); //~ ERROR mismatched types [E0308] let x = String::from("x"); let res = Some(x); - takes_option(&res); //~ ERROR 10:18: 10:22: mismatched types [E0308] + takes_option(&res); //~ ERROR mismatched types [E0308] } diff --git a/tests/ui/type/pattern_types/derives_fail.stderr b/tests/ui/type/pattern_types/derives_fail.stderr index 78bef726341..6b2e27494f0 100644 --- a/tests/ui/type/pattern_types/derives_fail.stderr +++ b/tests/ui/type/pattern_types/derives_fail.stderr @@ -26,9 +26,7 @@ LL | #[derive(Clone, Copy, PartialEq, Eq, Debug, Ord, PartialOrd, Hash, Default) | ----- in this derive macro expansion LL | #[repr(transparent)] LL | struct Nanoseconds(NanoI32); - | ^^^^^^^ `(i32) is 0..=999999999` cannot be formatted using `{:?}` because it doesn't implement `Debug` - | - = help: the trait `Debug` is not implemented for `(i32) is 0..=999999999` + | ^^^^^^^ the trait `Debug` is not implemented for `(i32) is 0..=999999999` error[E0277]: the trait bound `(i32) is 0..=999999999: Ord` is not satisfied --> $DIR/derives_fail.rs:11:20 diff --git a/tests/ui/type/type-check-defaults.stderr b/tests/ui/type/type-check-defaults.stderr index ab3378eaa4a..bbe93a05d4d 100644 --- a/tests/ui/type/type-check-defaults.stderr +++ b/tests/ui/type/type-check-defaults.stderr @@ -29,18 +29,36 @@ error[E0277]: the trait bound `String: Copy` is not satisfied | LL | struct Bounds<T:Copy=String>(T); | ^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `Bounds` + --> $DIR/type-check-defaults.rs:11:17 + | +LL | struct Bounds<T:Copy=String>(T); + | ^^^^ required by this bound in `Bounds` error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/type-check-defaults.rs:14:42 | LL | struct WhereClause<T=String>(T) where T: Copy; | ^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `WhereClause` + --> $DIR/type-check-defaults.rs:14:42 + | +LL | struct WhereClause<T=String>(T) where T: Copy; + | ^^^^ required by this bound in `WhereClause` error[E0277]: the trait bound `String: Copy` is not satisfied --> $DIR/type-check-defaults.rs:17:20 | LL | trait TraitBound<T:Copy=String> {} | ^^^^ the trait `Copy` is not implemented for `String` + | +note: required by a bound in `TraitBound` + --> $DIR/type-check-defaults.rs:17:20 + | +LL | trait TraitBound<T:Copy=String> {} + | ^^^^ required by this bound in `TraitBound` error[E0277]: the trait bound `T: Copy` is not satisfied --> $DIR/type-check-defaults.rs:21:25 @@ -70,6 +88,11 @@ LL | trait ProjectionPred<T:Iterator = IntoIter<i32>> where T::Item : Add<u8> {} `&i32` implements `Add` `i32` implements `Add<&i32>` `i32` implements `Add` +note: required by a bound in `ProjectionPred` + --> $DIR/type-check-defaults.rs:24:66 + | +LL | trait ProjectionPred<T:Iterator = IntoIter<i32>> where T::Item : Add<u8> {} + | ^^^^^^^ required by this bound in `ProjectionPred` error: aborting due to 7 previous errors diff --git a/tests/ui/typeck/auxiliary/private-dep.rs b/tests/ui/typeck/auxiliary/private-dep.rs new file mode 100644 index 00000000000..472b40ef622 --- /dev/null +++ b/tests/ui/typeck/auxiliary/private-dep.rs @@ -0,0 +1,3 @@ +pub trait A { + fn foo() {} +} diff --git a/tests/ui/typeck/auxiliary/public-dep.rs b/tests/ui/typeck/auxiliary/public-dep.rs new file mode 100644 index 00000000000..438692a1caa --- /dev/null +++ b/tests/ui/typeck/auxiliary/public-dep.rs @@ -0,0 +1,11 @@ +//@ aux-crate:priv:private_dep=private-dep.rs +//@ compile-flags: -Zunstable-options + +extern crate private_dep; +use private_dep::A; + +pub struct B; + +impl A for B { + fn foo() {} +} diff --git a/tests/ui/typeck/consider-borrowing-141810-1.stderr b/tests/ui/typeck/consider-borrowing-141810-1.stderr index 9291721ac71..35ca6793eee 100644 --- a/tests/ui/typeck/consider-borrowing-141810-1.stderr +++ b/tests/ui/typeck/consider-borrowing-141810-1.stderr @@ -1,20 +1,17 @@ error[E0308]: `if` and `else` have incompatible types --> $DIR/consider-borrowing-141810-1.rs:4:12 | -LL | let x = if true { - | ______________- -LL | | &true - | | ----- expected because of this -LL | | } else if false { - | | ____________^ -LL | || true -LL | || } else { -LL | || true -LL | || }; - | || ^ - | ||_____| - | |_____`if` and `else` have incompatible types - | expected `&bool`, found `bool` +LL | let x = if true { + | ------- `if` and `else` have incompatible types +LL | &true + | ----- expected because of this +LL | } else if false { + | ____________^ +LL | | true +LL | | } else { +LL | | true +LL | | }; + | |_____^ expected `&bool`, found `bool` | help: consider borrowing here | diff --git a/tests/ui/typeck/consider-borrowing-141810-2.stderr b/tests/ui/typeck/consider-borrowing-141810-2.stderr index dd229897283..44ecb5a4a94 100644 --- a/tests/ui/typeck/consider-borrowing-141810-2.stderr +++ b/tests/ui/typeck/consider-borrowing-141810-2.stderr @@ -1,18 +1,15 @@ error[E0308]: `if` and `else` have incompatible types --> $DIR/consider-borrowing-141810-2.rs:4:12 | -LL | let x = if true { - | ______________- -LL | | &() - | | --- expected because of this -LL | | } else if false { - | | ____________^ -LL | || } else { -LL | || }; - | || ^ - | ||_____| - | |_____`if` and `else` have incompatible types - | expected `&()`, found `()` +LL | let x = if true { + | ------- `if` and `else` have incompatible types +LL | &() + | --- expected because of this +LL | } else if false { + | ____________^ +LL | | } else { +LL | | }; + | |_____^ expected `&()`, found `()` error: aborting due to 1 previous error diff --git a/tests/ui/typeck/consider-borrowing-141810-3.stderr b/tests/ui/typeck/consider-borrowing-141810-3.stderr index 0b0c5f191a0..3adf8ba1a89 100644 --- a/tests/ui/typeck/consider-borrowing-141810-3.stderr +++ b/tests/ui/typeck/consider-borrowing-141810-3.stderr @@ -1,18 +1,15 @@ error[E0308]: `if` and `else` have incompatible types --> $DIR/consider-borrowing-141810-3.rs:4:12 | -LL | let x = if true { - | ______________- -LL | | &() - | | --- expected because of this -LL | | } else if false { - | | ____________^ -LL | || -LL | || }; - | || ^ - | ||_____| - | |_____`if` and `else` have incompatible types - | expected `&()`, found `()` +LL | let x = if true { + | ------- `if` and `else` have incompatible types +LL | &() + | --- expected because of this +LL | } else if false { + | ____________^ +LL | | +LL | | }; + | |_____^ expected `&()`, found `()` | = note: `if` expressions without `else` evaluate to `()` = note: consider adding an `else` block that evaluates to the expected type diff --git a/tests/ui/typeck/dont-suggest-private-dependencies.rs b/tests/ui/typeck/dont-suggest-private-dependencies.rs new file mode 100644 index 00000000000..ee5224e2d82 --- /dev/null +++ b/tests/ui/typeck/dont-suggest-private-dependencies.rs @@ -0,0 +1,37 @@ +// Don't suggest importing a function from a private dependency. +// Issues: #138191, #142676 + +// Avoid suggesting traits from std-private deps +//@ forbid-output: compiler_builtins +//@ forbid-output: object + +// Check a custom trait to withstand changes in above crates +//@ aux-crate:public_dep=public-dep.rs +//@ compile-flags: -Zunstable-options +//@ forbid-output: private_dep + +// By default, the `read` diagnostic suggests `std::os::unix::fs::FileExt::read_at`. Add +// something more likely to be recommended to make the diagnostic cross-platform. +trait DecoyRead { + fn read1(&self) {} +} +impl<T> DecoyRead for Vec<T> {} + +struct VecReader(Vec<u8>); + +impl std::io::Read for VecReader { + fn read(&mut self, buf: &mut [u8]) -> std::io::Result<usize> { + self.0.read(buf) + //~^ ERROR no method named `read` found for struct `Vec<u8>` + } +} + +extern crate public_dep; +use public_dep::B; + +fn main() { + let _ = u8::cast_from_lossy(9); + //~^ ERROR no function or associated item named `cast_from_lossy` found for type `u8` + let _ = B::foo(); + //~^ ERROR no function or associated item named `foo` found for struct `B` +} diff --git a/tests/ui/typeck/dont-suggest-private-dependencies.stderr b/tests/ui/typeck/dont-suggest-private-dependencies.stderr new file mode 100644 index 00000000000..b7b14ee6b9b --- /dev/null +++ b/tests/ui/typeck/dont-suggest-private-dependencies.stderr @@ -0,0 +1,27 @@ +error[E0599]: no method named `read` found for struct `Vec<u8>` in the current scope + --> $DIR/dont-suggest-private-dependencies.rs:24:16 + | +LL | self.0.read(buf) + | ^^^^ + | +help: there is a method `read1` with a similar name, but with different arguments + --> $DIR/dont-suggest-private-dependencies.rs:16:5 + | +LL | fn read1(&self) {} + | ^^^^^^^^^^^^^^^ + +error[E0599]: no function or associated item named `cast_from_lossy` found for type `u8` in the current scope + --> $DIR/dont-suggest-private-dependencies.rs:33:17 + | +LL | let _ = u8::cast_from_lossy(9); + | ^^^^^^^^^^^^^^^ function or associated item not found in `u8` + +error[E0599]: no function or associated item named `foo` found for struct `B` in the current scope + --> $DIR/dont-suggest-private-dependencies.rs:35:16 + | +LL | let _ = B::foo(); + | ^^^ function or associated item not found in `B` + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0599`. diff --git a/tests/ui/typeck/inference-method-chain-diverging-fallback.rs b/tests/ui/typeck/inference-method-chain-diverging-fallback.rs new file mode 100644 index 00000000000..8f549b7d9d6 --- /dev/null +++ b/tests/ui/typeck/inference-method-chain-diverging-fallback.rs @@ -0,0 +1,19 @@ +//! Test type inference in method chains with diverging fallback. +//! Verifies that closure type in `unwrap_or_else` is properly inferred +//! when chained with other combinators and contains a diverging path. + +//@ run-pass + +fn produce<T>() -> Result<&'static str, T> { + Ok("22") +} + +fn main() { + // The closure's error type `T` must unify with `ParseIntError`, + // while the success type must be `usize` (from parse()) + let x: usize = produce() + .and_then(|x| x.parse::<usize>()) // Explicit turbofish for clarity + .unwrap_or_else(|_| panic!()); // Diverging fallback + + assert_eq!(x, 22); +} diff --git a/tests/ui/typeck/issue-100246.rs b/tests/ui/typeck/issue-100246.rs index 8f0b34bab0c..e05bb2a1362 100644 --- a/tests/ui/typeck/issue-100246.rs +++ b/tests/ui/typeck/issue-100246.rs @@ -25,6 +25,6 @@ fn downcast<'a, W: ?Sized>() -> std::io::Result<&'a W> { struct Other; fn main() -> std::io::Result<()> { - let other: Other = downcast()?;//~ERROR 28:24: 28:35: `?` operator has incompatible types + let other: Other = downcast()?; //~ ERROR `?` operator has incompatible types Ok(()) } diff --git a/tests/ui/typeck/issue-13853-5.rs b/tests/ui/typeck/issue-13853-5.rs index fc97c6c67d6..47596aa4927 100644 --- a/tests/ui/typeck/issue-13853-5.rs +++ b/tests/ui/typeck/issue-13853-5.rs @@ -1,4 +1,4 @@ -trait Deserializer<'a> { } +trait Deserializer<'a> {} trait Deserializable { fn deserialize_token<'a, D: Deserializer<'a>>(_: D, _: &'a str) -> Self; @@ -8,6 +8,7 @@ impl<'a, T: Deserializable> Deserializable for &'a str { //~^ ERROR type parameter `T` is not constrained fn deserialize_token<D: Deserializer<'a>>(_x: D, _y: &'a str) -> &'a str { //~^ ERROR mismatched types + //~| ERROR do not match the trait declaration } } diff --git a/tests/ui/typeck/issue-13853-5.stderr b/tests/ui/typeck/issue-13853-5.stderr index 4e483a0a58e..bb967b07b81 100644 --- a/tests/ui/typeck/issue-13853-5.stderr +++ b/tests/ui/typeck/issue-13853-5.stderr @@ -1,3 +1,12 @@ +error[E0195]: lifetime parameters or bounds on associated function `deserialize_token` do not match the trait declaration + --> $DIR/issue-13853-5.rs:9:25 + | +LL | fn deserialize_token<'a, D: Deserializer<'a>>(_: D, _: &'a str) -> Self; + | ------------------------- lifetimes in impl do not match this associated function in trait +... +LL | fn deserialize_token<D: Deserializer<'a>>(_x: D, _y: &'a str) -> &'a str { + | ^^^^^^^^^^^^^^^^^^^^^ lifetimes do not match associated function in trait + error[E0207]: the type parameter `T` is not constrained by the impl trait, self type, or predicates --> $DIR/issue-13853-5.rs:7:10 | @@ -19,7 +28,7 @@ LL ~ _y LL ~ | -error: aborting due to 2 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0207, E0308. -For more information about an error, try `rustc --explain E0207`. +Some errors have detailed explanations: E0195, E0207, E0308. +For more information about an error, try `rustc --explain E0195`. diff --git a/tests/ui/typeck/issue-74086.rs b/tests/ui/typeck/issue-74086.rs index 9b7c0d7cc6e..c00ba81f551 100644 --- a/tests/ui/typeck/issue-74086.rs +++ b/tests/ui/typeck/issue-74086.rs @@ -1,5 +1,4 @@ fn main() { static BUG: fn(_) -> u8 = |_| 8; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions [E0121] - //~| ERROR the placeholder `_` is not allowed within types on item signatures for static items + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for statics } diff --git a/tests/ui/typeck/issue-74086.stderr b/tests/ui/typeck/issue-74086.stderr index 95ebf9a906c..02c48201918 100644 --- a/tests/ui/typeck/issue-74086.stderr +++ b/tests/ui/typeck/issue-74086.stderr @@ -1,15 +1,9 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/issue-74086.rs:2:20 | LL | static BUG: fn(_) -> u8 = |_| 8; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items - --> $DIR/issue-74086.rs:2:20 - | -LL | static BUG: fn(_) -> u8 = |_| 8; - | ^ not allowed in type signatures - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/typeck/issue-75889.stderr b/tests/ui/typeck/issue-75889.stderr index 1438f481ec7..c76f7c60b2e 100644 --- a/tests/ui/typeck/issue-75889.stderr +++ b/tests/ui/typeck/issue-75889.stderr @@ -1,10 +1,10 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/issue-75889.rs:3:24 | LL | const FOO: dyn Fn() -> _ = ""; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/issue-75889.rs:4:25 | LL | static BOO: dyn Fn() -> _ = ""; diff --git a/tests/ui/typeck/issue-81885.rs b/tests/ui/typeck/issue-81885.rs index fb3949478a4..d675231d898 100644 --- a/tests/ui/typeck/issue-81885.rs +++ b/tests/ui/typeck/issue-81885.rs @@ -1,9 +1,7 @@ const TEST4: fn() -> _ = 42; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions - //~| ERROR the placeholder `_` is not allowed within types on item signatures for constant items +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants fn main() { const TEST5: fn() -> _ = 42; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions - //~| ERROR the placeholder `_` is not allowed within types on item signatures for constant items + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants } diff --git a/tests/ui/typeck/issue-81885.stderr b/tests/ui/typeck/issue-81885.stderr index 91c08bd8235..414fe548883 100644 --- a/tests/ui/typeck/issue-81885.stderr +++ b/tests/ui/typeck/issue-81885.stderr @@ -1,27 +1,15 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/issue-81885.rs:1:22 | LL | const TEST4: fn() -> _ = 42; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items - --> $DIR/issue-81885.rs:1:22 - | -LL | const TEST4: fn() -> _ = 42; - | ^ not allowed in type signatures - -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/issue-81885.rs:6:26 - | -LL | const TEST5: fn() -> _ = 42; - | ^ not allowed in type signatures - -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items - --> $DIR/issue-81885.rs:6:26 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants + --> $DIR/issue-81885.rs:5:26 | LL | const TEST5: fn() -> _ = 42; | ^ not allowed in type signatures -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr b/tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr index a4cb53025e3..c4a5c0dea6e 100644 --- a/tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr +++ b/tests/ui/typeck/issue-83621-placeholder-static-in-extern.stderr @@ -1,4 +1,4 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/issue-83621-placeholder-static-in-extern.rs:4:15 | LL | static x: _; diff --git a/tests/ui/typeck/issue-88643.rs b/tests/ui/typeck/issue-88643.rs index 4435cba0207..e562f3e55ac 100644 --- a/tests/ui/typeck/issue-88643.rs +++ b/tests/ui/typeck/issue-88643.rs @@ -8,12 +8,12 @@ use std::collections::HashMap; pub trait T {} static CALLBACKS: HashMap<*const dyn T, dyn FnMut(&mut _) + 'static> = HashMap::new(); -//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static items [E0121] +//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for statics [E0121] static CALLBACKS2: Vec<dyn Fn(& _)> = Vec::new(); -//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static items [E0121] +//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for statics [E0121] static CALLBACKS3: Option<dyn Fn(& _)> = None; -//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for static items [E0121] +//~^ ERROR: the placeholder `_` is not allowed within types on item signatures for statics [E0121] fn main() {} diff --git a/tests/ui/typeck/issue-88643.stderr b/tests/ui/typeck/issue-88643.stderr index d5d596b6f42..ad11c3ea8e0 100644 --- a/tests/ui/typeck/issue-88643.stderr +++ b/tests/ui/typeck/issue-88643.stderr @@ -1,16 +1,16 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/issue-88643.rs:10:56 | LL | static CALLBACKS: HashMap<*const dyn T, dyn FnMut(&mut _) + 'static> = HashMap::new(); | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/issue-88643.rs:13:33 | LL | static CALLBACKS2: Vec<dyn Fn(& _)> = Vec::new(); | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for static items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for statics --> $DIR/issue-88643.rs:16:36 | LL | static CALLBACKS3: Option<dyn Fn(& _)> = None; diff --git a/tests/ui/typeck/issue-89275.rs b/tests/ui/typeck/issue-89275.rs index b91c0017548..6e4211de185 100644 --- a/tests/ui/typeck/issue-89275.rs +++ b/tests/ui/typeck/issue-89275.rs @@ -25,5 +25,5 @@ fn downcast<'a, W: ?Sized>() -> &'a W { struct Other; fn main() { - let other: &mut Other = downcast();//~ERROR 28:29: 28:39: mismatched types [E0308] + let other: &mut Other = downcast();//~ ERROR mismatched types [E0308] } diff --git a/tests/ui/typeck/nested-generic-traits-performance.rs b/tests/ui/typeck/nested-generic-traits-performance.rs new file mode 100644 index 00000000000..e029228c1b2 --- /dev/null +++ b/tests/ui/typeck/nested-generic-traits-performance.rs @@ -0,0 +1,82 @@ +//! Test that deeply nested generic traits with complex bounds +//! don't cause excessive memory usage during type checking. +//! +//! Regression test for <https://github.com/rust-lang/rust/issues/31849>. + +//@ run-pass + +pub trait Upcast<T> { + fn upcast(self) -> T; +} + +impl<S1, S2, T1, T2> Upcast<(T1, T2)> for (S1, S2) +where + S1: Upcast<T1>, + S2: Upcast<T2>, +{ + fn upcast(self) -> (T1, T2) { + (self.0.upcast(), self.1.upcast()) + } +} + +impl Upcast<()> for () { + fn upcast(self) -> () { + () + } +} + +pub trait ToStatic { + type Static: 'static; + fn to_static(self) -> Self::Static + where + Self: Sized; +} + +impl<T, U> ToStatic for (T, U) +where + T: ToStatic, + U: ToStatic, +{ + type Static = (T::Static, U::Static); + fn to_static(self) -> Self::Static { + (self.0.to_static(), self.1.to_static()) + } +} + +impl ToStatic for () { + type Static = (); + fn to_static(self) -> () { + () + } +} + +trait Factory { + type Output; + fn build(&self) -> Self::Output; +} + +impl<S, T> Factory for (S, T) +where + S: Factory, + T: Factory, + S::Output: ToStatic, + <S::Output as ToStatic>::Static: Upcast<S::Output>, +{ + type Output = (S::Output, T::Output); + fn build(&self) -> Self::Output { + (self.0.build().to_static().upcast(), self.1.build()) + } +} + +impl Factory for () { + type Output = (); + fn build(&self) -> Self::Output { + () + } +} + +fn main() { + // Deeply nested tuple to trigger the original performance issue + let it = ((((((((((), ()), ()), ()), ()), ()), ()), ()), ()), ()); + it.build(); +} diff --git a/tests/ui/typeck/point-at-type-param-in-path-expr.stderr b/tests/ui/typeck/point-at-type-param-in-path-expr.stderr index 14642b25c99..3701b3e3798 100644 --- a/tests/ui/typeck/point-at-type-param-in-path-expr.stderr +++ b/tests/ui/typeck/point-at-type-param-in-path-expr.stderr @@ -2,10 +2,8 @@ error[E0277]: `()` doesn't implement `std::fmt::Display` --> $DIR/point-at-type-param-in-path-expr.rs:4:19 | LL | let x = foo::<()>; - | ^^ `()` cannot be formatted with the default formatter + | ^^ the trait `std::fmt::Display` is not implemented for `()` | - = help: the trait `std::fmt::Display` is not implemented for `()` - = note: in format strings you may be able to use `{:?}` (or {:#?} for pretty-print) instead note: required by a bound in `foo` --> $DIR/point-at-type-param-in-path-expr.rs:1:11 | diff --git a/tests/ui/typeck/type-placeholder-fn-in-const.rs b/tests/ui/typeck/type-placeholder-fn-in-const.rs index bbb95a5798a..1600534dd4f 100644 --- a/tests/ui/typeck/type-placeholder-fn-in-const.rs +++ b/tests/ui/typeck/type-placeholder-fn-in-const.rs @@ -2,14 +2,12 @@ struct MyStruct; trait Test { const TEST: fn() -> _; - //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions [E0121] - //~| ERROR: the placeholder `_` is not allowed within types on item signatures for associated constants [E0121] + //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for associated constants [E0121] } impl Test for MyStruct { const TEST: fn() -> _ = 42; - //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for functions [E0121] - //~| ERROR: the placeholder `_` is not allowed within types on item signatures for associated constants [E0121] + //~^ ERROR: the placeholder `_` is not allowed within types on item signatures for associated constants [E0121] } fn main() {} diff --git a/tests/ui/typeck/type-placeholder-fn-in-const.stderr b/tests/ui/typeck/type-placeholder-fn-in-const.stderr index 92b47bd4781..a29752948fe 100644 --- a/tests/ui/typeck/type-placeholder-fn-in-const.stderr +++ b/tests/ui/typeck/type-placeholder-fn-in-const.stderr @@ -1,17 +1,5 @@ -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/type-placeholder-fn-in-const.rs:10:25 - | -LL | const TEST: fn() -> _ = 42; - | ^ not allowed in type signatures - -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/type-placeholder-fn-in-const.rs:4:25 - | -LL | const TEST: fn() -> _; - | ^ not allowed in type signatures - error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants - --> $DIR/type-placeholder-fn-in-const.rs:10:25 + --> $DIR/type-placeholder-fn-in-const.rs:9:25 | LL | const TEST: fn() -> _ = 42; | ^ not allowed in type signatures @@ -22,6 +10,6 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures LL | const TEST: fn() -> _; | ^ not allowed in type signatures -error: aborting due to 4 previous errors +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0121`. diff --git a/tests/ui/typeck/typeck_type_placeholder_item.rs b/tests/ui/typeck/typeck_type_placeholder_item.rs index d7351f2e51a..48547c019d6 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.rs +++ b/tests/ui/typeck/typeck_type_placeholder_item.rs @@ -33,7 +33,6 @@ fn test7(x: _) { let _x: usize = x; } fn test8(_f: fn() -> _) { } //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions -//~^^ ERROR the placeholder `_` is not allowed within types on item signatures for functions struct Test9; @@ -42,7 +41,7 @@ impl Test9 { //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types fn test10(&self, _x : _) { } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods } fn test11(x: &usize) -> &_ { @@ -57,16 +56,18 @@ unsafe fn test12(x: *const usize) -> *const *const _ { impl Clone for Test9 { fn clone(&self) -> _ { Test9 } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods fn clone_from(&mut self, other: _) { *self = Test9; } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods } struct Test10 { a: _, //~^ ERROR the placeholder `_` is not allowed within types on item signatures for structs b: (_, _), + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for structs + //~| ERROR the placeholder `_` is not allowed within types on item signatures for structs } pub fn main() { @@ -99,7 +100,6 @@ pub fn main() { fn fn_test8(_f: fn() -> _) { } //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions - //~^^ ERROR the placeholder `_` is not allowed within types on item signatures for functions struct FnTest9; @@ -108,21 +108,23 @@ pub fn main() { //~^ ERROR the placeholder `_` is not allowed within types on item signatures for return types fn fn_test10(&self, _x : _) { } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods } impl Clone for FnTest9 { fn clone(&self) -> _ { FnTest9 } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods fn clone_from(&mut self, other: _) { *self = FnTest9; } - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods } struct FnTest10 { a: _, //~^ ERROR the placeholder `_` is not allowed within types on item signatures for structs b: (_, _), + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for structs + //~| ERROR the placeholder `_` is not allowed within types on item signatures for structs } fn fn_test11(_: _) -> (_, _) { panic!() } @@ -138,17 +140,19 @@ pub fn main() { trait T { fn method_test1(&self, x: _); - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods fn method_test2(&self, x: _) -> _; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods + //~| ERROR the placeholder `_` is not allowed within types on item signatures for methods fn method_test3(&self) -> _; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for methods fn assoc_fn_test1(x: _); - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions fn assoc_fn_test2(x: _) -> _; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions + //~| ERROR the placeholder `_` is not allowed within types on item signatures for associated functions fn assoc_fn_test3() -> _; - //~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions + //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated functions } struct BadStruct<_>(_); @@ -158,9 +162,11 @@ trait BadTrait<_> {} //~^ ERROR expected identifier, found reserved identifier `_` impl BadTrait<_> for BadStruct<_> {} //~^ ERROR the placeholder `_` is not allowed within types on item signatures for implementations +//~| ERROR the placeholder `_` is not allowed within types on item signatures for implementations fn impl_trait() -> impl BadTrait<_> { -//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for opaque types +//~| ERROR the placeholder `_` is not allowed within types on item signatures for opaque types unimplemented!() } @@ -180,7 +186,8 @@ struct Struct; trait Trait<T> {} impl Trait<usize> for Struct {} type Y = impl Trait<_>; -//~^ ERROR the placeholder `_` is not allowed within types on item signatures for type aliases +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for opaque types +//~| ERROR the placeholder `_` is not allowed within types on item signatures for opaque types #[define_opaque(Y)] fn foo() -> Y { Struct @@ -197,6 +204,7 @@ trait Qux { // type E: _; // FIXME: make the parser propagate the existence of `B` type F: std::ops::Fn(_); //~^ ERROR the placeholder `_` is not allowed within types on item signatures for associated types + //~| ERROR the placeholder `_` is not allowed within types on item signatures for associated types } impl Qux for Struct { //~^ ERROR not all trait items implemented, missing: `F` diff --git a/tests/ui/typeck/typeck_type_placeholder_item.stderr b/tests/ui/typeck/typeck_type_placeholder_item.stderr index 7184244f5dc..87750ee6dc1 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item.stderr @@ -1,35 +1,35 @@ error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:154:18 + --> $DIR/typeck_type_placeholder_item.rs:158:18 | LL | struct BadStruct<_>(_); | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:157:16 + --> $DIR/typeck_type_placeholder_item.rs:161:16 | LL | trait BadTrait<_> {} | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:167:19 + --> $DIR/typeck_type_placeholder_item.rs:173:19 | LL | struct BadStruct1<_, _>(_); | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:167:22 + --> $DIR/typeck_type_placeholder_item.rs:173:22 | LL | struct BadStruct1<_, _>(_); | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/typeck_type_placeholder_item.rs:172:19 + --> $DIR/typeck_type_placeholder_item.rs:178:19 | LL | struct BadStruct2<_, T>(_, T); | ^ expected identifier, found reserved identifier error: associated constant in `impl` without body - --> $DIR/typeck_type_placeholder_item.rs:207:5 + --> $DIR/typeck_type_placeholder_item.rs:215:5 | LL | const C: _; | ^^^^^^^^^^- @@ -37,7 +37,7 @@ LL | const C: _; | help: provide a definition for the constant: `= <expr>;` error[E0403]: the name `_` is already used for a generic parameter in this item's generic parameters - --> $DIR/typeck_type_placeholder_item.rs:167:22 + --> $DIR/typeck_type_placeholder_item.rs:173:22 | LL | struct BadStruct1<_, _>(_); | - ^ already used @@ -106,72 +106,87 @@ error[E0121]: the placeholder `_` is not allowed within types on item signatures | LL | fn test6(_: _) { } | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn test6(_: _) { } -LL + fn test6<T>(_: T) { } - | error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:25:18 | LL | fn test6_b<T>(_: _, _: T) { } | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn test6_b<T>(_: _, _: T) { } -LL + fn test6_b<T, U>(_: U, _: T) { } - | error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:28:30 | LL | fn test6_c<T, K, L, A, B>(_: _, _: (T, K, L, A, B)) { } | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn test6_c<T, K, L, A, B>(_: _, _: (T, K, L, A, B)) { } -LL + fn test6_c<T, K, L, A, B, U>(_: U, _: (T, K, L, A, B)) { } - | error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:31:13 | LL | fn test7(x: _) { let _x: usize = x; } | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn test7(x: _) { let _x: usize = x; } -LL + fn test7<T>(x: T) { let _x: usize = x; } - | error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions --> $DIR/typeck_type_placeholder_item.rs:34:22 | LL | fn test8(_f: fn() -> _) { } - | ^ - | | - | not allowed in type signatures - | help: use type parameters instead: `T` + | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:34:22 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/typeck_type_placeholder_item.rs:66:8 | -LL | fn test8(_f: fn() -> _) { } - | ^ not allowed in type signatures +LL | a: _, + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/typeck_type_placeholder_item.rs:68:9 + | +LL | b: (_, _), + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/typeck_type_placeholder_item.rs:68:12 | -help: use type parameters instead +LL | b: (_, _), + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/typeck_type_placeholder_item.rs:123:12 + | +LL | a: _, + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/typeck_type_placeholder_item.rs:125:13 + | +LL | b: (_, _), + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/typeck_type_placeholder_item.rs:125:16 | -LL - fn test8(_f: fn() -> _) { } -LL + fn test8<T>(_f: fn() -> T) { } +LL | b: (_, _), + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/typeck_type_placeholder_item.rs:158:21 | +LL | struct BadStruct<_>(_); + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/typeck_type_placeholder_item.rs:173:25 + | +LL | struct BadStruct1<_, _>(_); + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs + --> $DIR/typeck_type_placeholder_item.rs:178:25 + | +LL | struct BadStruct2<_, T>(_, T); + | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:48:26 + --> $DIR/typeck_type_placeholder_item.rs:47:26 | LL | fn test11(x: &usize) -> &_ { | -^ @@ -180,7 +195,7 @@ LL | fn test11(x: &usize) -> &_ { | help: replace with the correct return type: `&&usize` error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:53:52 + --> $DIR/typeck_type_placeholder_item.rs:52:52 | LL | unsafe fn test12(x: *const usize) -> *const *const _ { | --------------^ @@ -188,8 +203,8 @@ LL | unsafe fn test12(x: *const usize) -> *const *const _ { | | not allowed in type signatures | help: replace with the correct return type: `*const *const usize` -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:59:24 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods + --> $DIR/typeck_type_placeholder_item.rs:58:24 | LL | fn clone(&self) -> _ { Test9 } | ^ not allowed in type signatures @@ -200,8 +215,8 @@ LL - fn clone(&self) -> _ { Test9 } LL + fn clone(&self) -> Test9 { Test9 } | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:62:37 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods + --> $DIR/typeck_type_placeholder_item.rs:61:37 | LL | fn clone_from(&mut self, other: _) { *self = Test9; } | ^ not allowed in type signatures @@ -212,33 +227,14 @@ LL - fn clone_from(&mut self, other: _) { *self = Test9; } LL + fn clone_from(&mut self, other: &Test9) { *self = Test9; } | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs - --> $DIR/typeck_type_placeholder_item.rs:67:8 - | -LL | a: _, - | ^ not allowed in type signatures -LL | -LL | b: (_, _), - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures - | -help: use type parameters instead - | -LL ~ struct Test10<T> { -LL ~ a: T, -LL | -LL ~ b: (T, T), - | - error: missing type for `static` item - --> $DIR/typeck_type_placeholder_item.rs:73:13 + --> $DIR/typeck_type_placeholder_item.rs:74:13 | LL | static A = 42; | ^ help: provide a type for the static variable: `: i32` error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables - --> $DIR/typeck_type_placeholder_item.rs:75:15 + --> $DIR/typeck_type_placeholder_item.rs:76:15 | LL | static B: _ = 42; | ^ not allowed in type signatures @@ -250,7 +246,7 @@ LL + static B: i32 = 42; | error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables - --> $DIR/typeck_type_placeholder_item.rs:77:22 + --> $DIR/typeck_type_placeholder_item.rs:78:22 | LL | static C: Option<_> = Some(42); | ^ not allowed in type signatures @@ -262,7 +258,7 @@ LL + static C: Option<i32> = Some(42); | error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:79:21 + --> $DIR/typeck_type_placeholder_item.rs:80:21 | LL | fn fn_test() -> _ { 5 } | ^ @@ -271,7 +267,7 @@ LL | fn fn_test() -> _ { 5 } | help: replace with the correct return type: `i32` error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:82:23 + --> $DIR/typeck_type_placeholder_item.rs:83:23 | LL | fn fn_test2() -> (_, _) { (5, 5) } | -^--^- @@ -281,7 +277,7 @@ LL | fn fn_test2() -> (_, _) { (5, 5) } | help: replace with the correct return type: `(i32, i32)` error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables - --> $DIR/typeck_type_placeholder_item.rs:85:22 + --> $DIR/typeck_type_placeholder_item.rs:86:22 | LL | static FN_TEST3: _ = "test"; | ^ not allowed in type signatures @@ -293,7 +289,7 @@ LL + static FN_TEST3: &str = "test"; | error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables - --> $DIR/typeck_type_placeholder_item.rs:88:22 + --> $DIR/typeck_type_placeholder_item.rs:89:22 | LL | static FN_TEST4: _ = 145; | ^ not allowed in type signatures @@ -305,7 +301,7 @@ LL + static FN_TEST4: i32 = 145; | error[E0121]: the placeholder `_` is not allowed within types on item signatures for static variables - --> $DIR/typeck_type_placeholder_item.rs:91:23 + --> $DIR/typeck_type_placeholder_item.rs:92:23 | LL | static FN_TEST5: (_, _) = (1, 2); | ^ ^ not allowed in type signatures @@ -319,51 +315,24 @@ LL + static FN_TEST5: (i32, i32) = (1, 2); | error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:94:20 + --> $DIR/typeck_type_placeholder_item.rs:95:20 | LL | fn fn_test6(_: _) { } | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn fn_test6(_: _) { } -LL + fn fn_test6<T>(_: T) { } - | error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:97:20 + --> $DIR/typeck_type_placeholder_item.rs:98:20 | LL | fn fn_test7(x: _) { let _x: usize = x; } | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn fn_test7(x: _) { let _x: usize = x; } -LL + fn fn_test7<T>(x: T) { let _x: usize = x; } - | - -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:100:29 - | -LL | fn fn_test8(_f: fn() -> _) { } - | ^ - | | - | not allowed in type signatures - | help: use type parameters instead: `T` error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:100:29 + --> $DIR/typeck_type_placeholder_item.rs:101:29 | LL | fn fn_test8(_f: fn() -> _) { } | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn fn_test8(_f: fn() -> _) { } -LL + fn fn_test8<T>(_f: fn() -> T) { } - | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:115:28 | LL | fn clone(&self) -> _ { FnTest9 } @@ -375,7 +344,7 @@ LL - fn clone(&self) -> _ { FnTest9 } LL + fn clone(&self) -> FnTest9 { FnTest9 } | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:118:41 | LL | fn clone_from(&mut self, other: _) { *self = FnTest9; } @@ -387,33 +356,14 @@ LL - fn clone_from(&mut self, other: _) { *self = FnTest9; } LL + fn clone_from(&mut self, other: &FnTest9) { *self = FnTest9; } | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs - --> $DIR/typeck_type_placeholder_item.rs:123:12 - | -LL | a: _, - | ^ not allowed in type signatures -LL | -LL | b: (_, _), - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures - | -help: use type parameters instead - | -LL ~ struct FnTest10<T> { -LL ~ a: T, -LL | -LL ~ b: (T, T), - | - error[E0282]: type annotations needed - --> $DIR/typeck_type_placeholder_item.rs:128:21 + --> $DIR/typeck_type_placeholder_item.rs:130:21 | LL | fn fn_test11(_: _) -> (_, _) { panic!() } | ^ cannot infer type error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:128:28 + --> $DIR/typeck_type_placeholder_item.rs:130:28 | LL | fn fn_test11(_: _) -> (_, _) { panic!() } | ^ ^ not allowed in type signatures @@ -421,7 +371,7 @@ LL | fn fn_test11(_: _) -> (_, _) { panic!() } | not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:132:30 + --> $DIR/typeck_type_placeholder_item.rs:134:30 | LL | fn fn_test12(x: i32) -> (_, _) { (x, x) } | -^--^- @@ -431,7 +381,7 @@ LL | fn fn_test12(x: i32) -> (_, _) { (x, x) } | help: replace with the correct return type: `(i32, i32)` error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:135:33 + --> $DIR/typeck_type_placeholder_item.rs:137:33 | LL | fn fn_test13(x: _) -> (i32, _) { (x, x) } | ------^- @@ -439,152 +389,116 @@ LL | fn fn_test13(x: _) -> (i32, _) { (x, x) } | | not allowed in type signatures | help: replace with the correct return type: `(i32, i32)` -error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs - --> $DIR/typeck_type_placeholder_item.rs:154:21 - | -LL | struct BadStruct<_>(_); - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - struct BadStruct<_>(_); -LL + struct BadStruct<T>(T); - | - -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:140:31 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods + --> $DIR/typeck_type_placeholder_item.rs:142:31 | LL | fn method_test1(&self, x: _); | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn method_test1(&self, x: _); -LL + fn method_test1<T>(&self, x: T); - | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:142:31 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods + --> $DIR/typeck_type_placeholder_item.rs:144:31 | LL | fn method_test2(&self, x: _) -> _; - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures - | -help: use type parameters instead - | -LL - fn method_test2(&self, x: _) -> _; -LL + fn method_test2<T>(&self, x: T) -> T; + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods + --> $DIR/typeck_type_placeholder_item.rs:144:37 | +LL | fn method_test2(&self, x: _) -> _; + | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:144:31 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods + --> $DIR/typeck_type_placeholder_item.rs:147:31 | LL | fn method_test3(&self) -> _; | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn method_test3(&self) -> _; -LL + fn method_test3<T>(&self) -> T; - | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:146:26 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions + --> $DIR/typeck_type_placeholder_item.rs:149:26 | LL | fn assoc_fn_test1(x: _); | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn assoc_fn_test1(x: _); -LL + fn assoc_fn_test1<T>(x: T); - | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:148:26 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions + --> $DIR/typeck_type_placeholder_item.rs:151:26 | LL | fn assoc_fn_test2(x: _) -> _; - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures - | -help: use type parameters instead - | -LL - fn assoc_fn_test2(x: _) -> _; -LL + fn assoc_fn_test2<T>(x: T) -> T; + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions + --> $DIR/typeck_type_placeholder_item.rs:151:32 | +LL | fn assoc_fn_test2(x: _) -> _; + | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:150:28 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated functions + --> $DIR/typeck_type_placeholder_item.rs:154:28 | LL | fn assoc_fn_test3() -> _; | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for implementations + --> $DIR/typeck_type_placeholder_item.rs:163:32 | -help: use type parameters instead - | -LL - fn assoc_fn_test3() -> _; -LL + fn assoc_fn_test3<T>() -> T; - | +LL | impl BadTrait<_> for BadStruct<_> {} + | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for implementations - --> $DIR/typeck_type_placeholder_item.rs:159:15 + --> $DIR/typeck_type_placeholder_item.rs:163:15 | LL | impl BadTrait<_> for BadStruct<_> {} - | ^ ^ not allowed in type signatures - | | - | not allowed in type signatures + | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:162:34 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for opaque types + --> $DIR/typeck_type_placeholder_item.rs:167:34 | LL | fn impl_trait() -> impl BadTrait<_> { | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs - --> $DIR/typeck_type_placeholder_item.rs:167:25 - | -LL | struct BadStruct1<_, _>(_); - | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - struct BadStruct1<_, _>(_); -LL + struct BadStruct1<T, _>(T); +error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases + --> $DIR/typeck_type_placeholder_item.rs:182:14 | +LL | type X = Box<_>; + | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for structs - --> $DIR/typeck_type_placeholder_item.rs:172:25 - | -LL | struct BadStruct2<_, T>(_, T); - | ^ not allowed in type signatures +error[E0121]: the placeholder `_` is not allowed within types on item signatures for opaque types + --> $DIR/typeck_type_placeholder_item.rs:188:21 | -help: use type parameters instead +LL | type Y = impl Trait<_>; + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types + --> $DIR/typeck_type_placeholder_item.rs:198:14 | -LL - struct BadStruct2<_, T>(_, T); -LL + struct BadStruct2<U, T>(U, T); +LL | type B = _; + | ^ not allowed in type signatures + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types + --> $DIR/typeck_type_placeholder_item.rs:211:14 | +LL | type A = _; + | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases - --> $DIR/typeck_type_placeholder_item.rs:176:14 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types + --> $DIR/typeck_type_placeholder_item.rs:213:14 | -LL | type X = Box<_>; +LL | type B = _; | ^ not allowed in type signatures -error[E0121]: the placeholder `_` is not allowed within types on item signatures for type aliases - --> $DIR/typeck_type_placeholder_item.rs:182:21 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants + --> $DIR/typeck_type_placeholder_item.rs:200:14 | -LL | type Y = impl Trait<_>; - | ^ not allowed in type signatures +LL | const C: _; + | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants - --> $DIR/typeck_type_placeholder_item.rs:207:14 + --> $DIR/typeck_type_placeholder_item.rs:215:14 | LL | const C: _; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants - --> $DIR/typeck_type_placeholder_item.rs:195:14 + --> $DIR/typeck_type_placeholder_item.rs:202:14 | LL | const D: _ = 42; | ^ not allowed in type signatures @@ -596,13 +510,13 @@ LL + const D: i32 = 42; | error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants - --> $DIR/typeck_type_placeholder_item.rs:210:14 + --> $DIR/typeck_type_placeholder_item.rs:218:14 | LL | const D: _ = 42; | ^ not allowed in type signatures error[E0046]: not all trait items implemented, missing: `F` - --> $DIR/typeck_type_placeholder_item.rs:201:1 + --> $DIR/typeck_type_placeholder_item.rs:209:1 | LL | type F: std::ops::Fn(_); | ----------------------- `F` from trait @@ -611,7 +525,7 @@ LL | impl Qux for Struct { | ^^^^^^^^^^^^^^^^^^^ missing `F` in implementation error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:218:31 + --> $DIR/typeck_type_placeholder_item.rs:226:31 | LL | fn value() -> Option<&'static _> { | ----------------^- @@ -620,7 +534,7 @@ LL | fn value() -> Option<&'static _> { | help: replace with the correct return type: `Option<&'static u8>` error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/typeck_type_placeholder_item.rs:223:17 + --> $DIR/typeck_type_placeholder_item.rs:231:17 | LL | const _: Option<_> = map(value); | ^ not allowed in type signatures @@ -632,7 +546,7 @@ LL + const _: Option<u8> = map(value); | error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:227:31 + --> $DIR/typeck_type_placeholder_item.rs:235:31 | LL | fn evens_squared(n: usize) -> _ { | ^ @@ -641,19 +555,19 @@ LL | fn evens_squared(n: usize) -> _ { | help: replace with an appropriate return type: `impl Iterator<Item = usize>` error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants - --> $DIR/typeck_type_placeholder_item.rs:232:10 + --> $DIR/typeck_type_placeholder_item.rs:240:10 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^ not allowed in type signatures | -note: however, the inferred type `Map<Filter<Range<i32>, {closure@typeck_type_placeholder_item.rs:232:29}>, {closure@typeck_type_placeholder_item.rs:232:49}>` cannot be named - --> $DIR/typeck_type_placeholder_item.rs:232:14 +note: however, the inferred type `Map<Filter<Range<i32>, {closure@typeck_type_placeholder_item.rs:240:29}>, {closure@typeck_type_placeholder_item.rs:240:49}>` cannot be named + --> $DIR/typeck_type_placeholder_item.rs:240:14 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types - --> $DIR/typeck_type_placeholder_item.rs:41:24 + --> $DIR/typeck_type_placeholder_item.rs:40:24 | LL | fn test9(&self) -> _ { () } | ^ @@ -661,17 +575,11 @@ LL | fn test9(&self) -> _ { () } | not allowed in type signatures | help: replace with the correct return type: `()` -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item.rs:44:27 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods + --> $DIR/typeck_type_placeholder_item.rs:43:27 | LL | fn test10(&self, _x : _) { } | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn test10(&self, _x : _) { } -LL + fn test10<T>(&self, _x : T) { } - | error[E0121]: the placeholder `_` is not allowed within types on item signatures for return types --> $DIR/typeck_type_placeholder_item.rs:107:31 @@ -682,73 +590,67 @@ LL | fn fn_test9(&self) -> _ { () } | not allowed in type signatures | help: replace with the correct return type: `()` -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions +error[E0121]: the placeholder `_` is not allowed within types on item signatures for methods --> $DIR/typeck_type_placeholder_item.rs:110:34 | LL | fn fn_test10(&self, _x : _) { } | ^ not allowed in type signatures - | -help: use type parameters instead - | -LL - fn fn_test10(&self, _x : _) { } -LL + fn fn_test10<T>(&self, _x : T) { } - | error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types - --> $DIR/typeck_type_placeholder_item.rs:203:14 + --> $DIR/typeck_type_placeholder_item.rs:205:26 | -LL | type A = _; - | ^ not allowed in type signatures +LL | type F: std::ops::Fn(_); + | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types - --> $DIR/typeck_type_placeholder_item.rs:205:14 + --> $DIR/typeck_type_placeholder_item.rs:205:26 | -LL | type B = _; - | ^ not allowed in type signatures - -error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types - --> $DIR/typeck_type_placeholder_item.rs:191:14 +LL | type F: std::ops::Fn(_); + | ^ not allowed in type signatures | -LL | type B = _; - | ^ not allowed in type signatures + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants - --> $DIR/typeck_type_placeholder_item.rs:193:14 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for opaque types + --> $DIR/typeck_type_placeholder_item.rs:167:34 | -LL | const C: _; - | ^ not allowed in type signatures +LL | fn impl_trait() -> impl BadTrait<_> { + | ^ not allowed in type signatures + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated types - --> $DIR/typeck_type_placeholder_item.rs:198:26 +error[E0121]: the placeholder `_` is not allowed within types on item signatures for opaque types + --> $DIR/typeck_type_placeholder_item.rs:188:21 | -LL | type F: std::ops::Fn(_); - | ^ not allowed in type signatures +LL | type Y = impl Trait<_>; + | ^ not allowed in type signatures + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error[E0015]: cannot call non-const function `map::<u8>` in constants - --> $DIR/typeck_type_placeholder_item.rs:223:22 + --> $DIR/typeck_type_placeholder_item.rs:231:22 | LL | const _: Option<_> = map(value); | ^^^^^^^^^^ | = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const method `<std::ops::Range<i32> as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:232:29: 232:32}>` in constants - --> $DIR/typeck_type_placeholder_item.rs:232:22 +error[E0015]: cannot call non-const method `<std::ops::Range<i32> as Iterator>::filter::<{closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}>` in constants + --> $DIR/typeck_type_placeholder_item.rs:240:22 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^^^^^^^^^ | = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot call non-const method `<Filter<std::ops::Range<i32>, {closure@$DIR/typeck_type_placeholder_item.rs:232:29: 232:32}> as Iterator>::map::<i32, {closure@$DIR/typeck_type_placeholder_item.rs:232:49: 232:52}>` in constants - --> $DIR/typeck_type_placeholder_item.rs:232:45 +error[E0015]: cannot call non-const method `<Filter<std::ops::Range<i32>, {closure@$DIR/typeck_type_placeholder_item.rs:240:29: 240:32}> as Iterator>::map::<i32, {closure@$DIR/typeck_type_placeholder_item.rs:240:49: 240:52}>` in constants + --> $DIR/typeck_type_placeholder_item.rs:240:45 | LL | const _: _ = (1..10).filter(|x| x % 2 == 0).map(|x| x * x); | ^^^^^^^^^^^^^^ | = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error: aborting due to 75 previous errors +error: aborting due to 83 previous errors Some errors have detailed explanations: E0015, E0046, E0121, E0282, E0403. For more information about an error, try `rustc --explain E0015`. diff --git a/tests/ui/typeck/typeck_type_placeholder_item_help.rs b/tests/ui/typeck/typeck_type_placeholder_item_help.rs index ff6182588c7..758b94f9854 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item_help.rs +++ b/tests/ui/typeck/typeck_type_placeholder_item_help.rs @@ -11,8 +11,7 @@ const TEST3: _ = Some(42); //~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants const TEST4: fn() -> _ = 42; -//~^ ERROR the placeholder `_` is not allowed within types on item signatures for functions -//~| ERROR the placeholder `_` is not allowed within types on item signatures for constant items +//~^ ERROR the placeholder `_` is not allowed within types on item signatures for constants trait Test5 { const TEST5: _ = 42; diff --git a/tests/ui/typeck/typeck_type_placeholder_item_help.stderr b/tests/ui/typeck/typeck_type_placeholder_item_help.stderr index afdd58e0a03..2fce00e7a8e 100644 --- a/tests/ui/typeck/typeck_type_placeholder_item_help.stderr +++ b/tests/ui/typeck/typeck_type_placeholder_item_help.stderr @@ -31,20 +31,14 @@ LL - const TEST3: _ = Some(42); LL + const TEST3: Option<i32> = Some(42); | -error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions - --> $DIR/typeck_type_placeholder_item_help.rs:13:22 - | -LL | const TEST4: fn() -> _ = 42; - | ^ not allowed in type signatures - -error[E0121]: the placeholder `_` is not allowed within types on item signatures for constant items +error[E0121]: the placeholder `_` is not allowed within types on item signatures for constants --> $DIR/typeck_type_placeholder_item_help.rs:13:22 | LL | const TEST4: fn() -> _ = 42; | ^ not allowed in type signatures error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants - --> $DIR/typeck_type_placeholder_item_help.rs:25:18 + --> $DIR/typeck_type_placeholder_item_help.rs:24:18 | LL | const TEST6: _ = 13; | ^ not allowed in type signatures @@ -56,7 +50,7 @@ LL + const TEST6: i32 = 13; | error[E0121]: the placeholder `_` is not allowed within types on item signatures for associated constants - --> $DIR/typeck_type_placeholder_item_help.rs:18:18 + --> $DIR/typeck_type_placeholder_item_help.rs:17:18 | LL | const TEST5: _ = 42; | ^ not allowed in type signatures @@ -68,7 +62,7 @@ LL + const TEST5: i32 = 42; | error[E0308]: mismatched types - --> $DIR/typeck_type_placeholder_item_help.rs:30:28 + --> $DIR/typeck_type_placeholder_item_help.rs:29:28 | LL | let _: Option<usize> = test1(); | ------------- ^^^^^^^ expected `Option<usize>`, found `Option<i32>` @@ -79,7 +73,7 @@ LL | let _: Option<usize> = test1(); found enum `Option<i32>` error[E0308]: mismatched types - --> $DIR/typeck_type_placeholder_item_help.rs:31:18 + --> $DIR/typeck_type_placeholder_item_help.rs:30:18 | LL | let _: f64 = test1(); | --- ^^^^^^^ expected `f64`, found `Option<i32>` @@ -89,7 +83,7 @@ LL | let _: f64 = test1(); = note: expected type `f64` found enum `Option<i32>` -error: aborting due to 9 previous errors +error: aborting due to 8 previous errors Some errors have detailed explanations: E0121, E0308. For more information about an error, try `rustc --explain E0121`. diff --git a/tests/ui/underscore-imports/issue-110164.stderr b/tests/ui/underscore-imports/issue-110164.ed2015.stderr index d8a4b6bbb75..f34b5ab5dde 100644 --- a/tests/ui/underscore-imports/issue-110164.stderr +++ b/tests/ui/underscore-imports/issue-110164.ed2015.stderr @@ -1,17 +1,17 @@ error: expected identifier, found reserved identifier `_` - --> $DIR/issue-110164.rs:5:5 + --> $DIR/issue-110164.rs:8:5 | LL | use _::a; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/issue-110164.rs:8:5 + --> $DIR/issue-110164.rs:10:5 | LL | use _::*; | ^ expected identifier, found reserved identifier error: expected identifier, found reserved identifier `_` - --> $DIR/issue-110164.rs:13:9 + --> $DIR/issue-110164.rs:14:9 | LL | use _::a; | ^ expected identifier, found reserved identifier @@ -23,41 +23,17 @@ LL | use _::*; | ^ expected identifier, found reserved identifier error[E0432]: unresolved import `self::*` - --> $DIR/issue-110164.rs:1:5 + --> $DIR/issue-110164.rs:4:5 | LL | use self::*; | ^^^^^^^ cannot glob-import a module into itself error[E0432]: unresolved import `crate::*` - --> $DIR/issue-110164.rs:3:5 + --> $DIR/issue-110164.rs:6:5 | LL | use crate::*; | ^^^^^^^^ cannot glob-import a module into itself -error[E0432]: unresolved import `_` - --> $DIR/issue-110164.rs:8:5 - | -LL | use _::*; - | ^ `_` is not a valid crate or module name - -error[E0432]: unresolved import `_` - --> $DIR/issue-110164.rs:5:5 - | -LL | use _::a; - | ^ `_` is not a valid crate or module name - -error[E0432]: unresolved import `_` - --> $DIR/issue-110164.rs:13:9 - | -LL | use _::a; - | ^ `_` is not a valid crate or module name - -error[E0432]: unresolved import `_` - --> $DIR/issue-110164.rs:16:9 - | -LL | use _::*; - | ^ `_` is not a valid crate or module name - -error: aborting due to 10 previous errors +error: aborting due to 6 previous errors For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/underscore-imports/issue-110164.ed2021.stderr b/tests/ui/underscore-imports/issue-110164.ed2021.stderr new file mode 100644 index 00000000000..f34b5ab5dde --- /dev/null +++ b/tests/ui/underscore-imports/issue-110164.ed2021.stderr @@ -0,0 +1,39 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-110164.rs:8:5 + | +LL | use _::a; + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-110164.rs:10:5 + | +LL | use _::*; + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-110164.rs:14:9 + | +LL | use _::a; + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/issue-110164.rs:16:9 + | +LL | use _::*; + | ^ expected identifier, found reserved identifier + +error[E0432]: unresolved import `self::*` + --> $DIR/issue-110164.rs:4:5 + | +LL | use self::*; + | ^^^^^^^ cannot glob-import a module into itself + +error[E0432]: unresolved import `crate::*` + --> $DIR/issue-110164.rs:6:5 + | +LL | use crate::*; + | ^^^^^^^^ cannot glob-import a module into itself + +error: aborting due to 6 previous errors + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/underscore-imports/issue-110164.rs b/tests/ui/underscore-imports/issue-110164.rs index 6fd13414500..bb080c5e471 100644 --- a/tests/ui/underscore-imports/issue-110164.rs +++ b/tests/ui/underscore-imports/issue-110164.rs @@ -1,19 +1,18 @@ +//@ revisions: ed2015 ed2021 +//@[ed2015] edition: 2015 +//@[ed2021] edition: 2021 use self::*; //~^ ERROR unresolved import `self::*` use crate::*; //~^ ERROR unresolved import `crate::*` use _::a; //~^ ERROR expected identifier, found reserved identifier `_` -//~| ERROR unresolved import `_` use _::*; //~^ ERROR expected identifier, found reserved identifier `_` -//~| ERROR unresolved import `_` fn main() { use _::a; //~^ ERROR expected identifier, found reserved identifier `_` - //~| ERROR unresolved import `_` use _::*; //~^ ERROR expected identifier, found reserved identifier `_` - //~| ERROR unresolved import `_` } diff --git a/tests/ui/underscore-imports/multiple-uses.ed2015.stderr b/tests/ui/underscore-imports/multiple-uses.ed2015.stderr new file mode 100644 index 00000000000..a295586fa16 --- /dev/null +++ b/tests/ui/underscore-imports/multiple-uses.ed2015.stderr @@ -0,0 +1,49 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/multiple-uses.rs:4:9 + | +LL | pub use _::{a, b}; + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/multiple-uses.rs:6:18 + | +LL | pub use std::{a, _}; + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/multiple-uses.rs:9:18 + | +LL | pub use std::{b, _, c}; + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/multiple-uses.rs:12:15 + | +LL | pub use std::{_, d}; + | ^ expected identifier, found reserved identifier + +error[E0432]: unresolved import `std::a` + --> $DIR/multiple-uses.rs:6:15 + | +LL | pub use std::{a, _}; + | ^ no `a` in the root + +error[E0432]: unresolved imports `std::b`, `std::c` + --> $DIR/multiple-uses.rs:9:15 + | +LL | pub use std::{b, _, c}; + | ^ ^ + | | | + | | no `c` in the root + | | help: a similar name exists in the module: `rc` + | no `b` in the root + +error[E0432]: unresolved import `std::d` + --> $DIR/multiple-uses.rs:12:18 + | +LL | pub use std::{_, d}; + | ^ no `d` in the root + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/underscore-imports/multiple-uses.ed2021.stderr b/tests/ui/underscore-imports/multiple-uses.ed2021.stderr new file mode 100644 index 00000000000..a295586fa16 --- /dev/null +++ b/tests/ui/underscore-imports/multiple-uses.ed2021.stderr @@ -0,0 +1,49 @@ +error: expected identifier, found reserved identifier `_` + --> $DIR/multiple-uses.rs:4:9 + | +LL | pub use _::{a, b}; + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/multiple-uses.rs:6:18 + | +LL | pub use std::{a, _}; + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/multiple-uses.rs:9:18 + | +LL | pub use std::{b, _, c}; + | ^ expected identifier, found reserved identifier + +error: expected identifier, found reserved identifier `_` + --> $DIR/multiple-uses.rs:12:15 + | +LL | pub use std::{_, d}; + | ^ expected identifier, found reserved identifier + +error[E0432]: unresolved import `std::a` + --> $DIR/multiple-uses.rs:6:15 + | +LL | pub use std::{a, _}; + | ^ no `a` in the root + +error[E0432]: unresolved imports `std::b`, `std::c` + --> $DIR/multiple-uses.rs:9:15 + | +LL | pub use std::{b, _, c}; + | ^ ^ + | | | + | | no `c` in the root + | | help: a similar name exists in the module: `rc` + | no `b` in the root + +error[E0432]: unresolved import `std::d` + --> $DIR/multiple-uses.rs:12:18 + | +LL | pub use std::{_, d}; + | ^ no `d` in the root + +error: aborting due to 7 previous errors + +For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/underscore-imports/multiple-uses.rs b/tests/ui/underscore-imports/multiple-uses.rs new file mode 100644 index 00000000000..31dd1862429 --- /dev/null +++ b/tests/ui/underscore-imports/multiple-uses.rs @@ -0,0 +1,16 @@ +//@ revisions: ed2015 ed2021 +//@[ed2015] edition: 2015 +//@[ed2021] edition: 2021 +pub use _::{a, b}; +//~^ ERROR expected identifier, found reserved identifier `_` +pub use std::{a, _}; +//~^ ERROR expected identifier, found reserved identifier `_` +//~| ERROR unresolved import `std::a` +pub use std::{b, _, c}; +//~^ ERROR expected identifier, found reserved identifier `_` +//~| ERROR unresolved imports `std::b`, `std::c` +pub use std::{_, d}; +//~^ ERROR expected identifier, found reserved identifier `_` +//~| ERROR unresolved import `std::d` + +fn main() {} diff --git a/tests/ui/underscore-lifetime/in-binder.stderr b/tests/ui/underscore-lifetime/in-binder.stderr index fcd7eddb576..f25db4d0889 100644 --- a/tests/ui/underscore-lifetime/in-binder.stderr +++ b/tests/ui/underscore-lifetime/in-binder.stderr @@ -3,36 +3,48 @@ error[E0637]: `'_` cannot be used here | LL | impl<'_> IceCube<'_> {} | ^^ `'_` is a reserved lifetime name + | + = help: use another lifetime specifier error[E0637]: `'_` cannot be used here --> $DIR/in-binder.rs:12:15 | LL | struct Struct<'_> { | ^^ `'_` is a reserved lifetime name + | + = help: use another lifetime specifier error[E0637]: `'_` cannot be used here --> $DIR/in-binder.rs:17:11 | LL | enum Enum<'_> { | ^^ `'_` is a reserved lifetime name + | + = help: use another lifetime specifier error[E0637]: `'_` cannot be used here --> $DIR/in-binder.rs:22:13 | LL | union Union<'_> { | ^^ `'_` is a reserved lifetime name + | + = help: use another lifetime specifier error[E0637]: `'_` cannot be used here --> $DIR/in-binder.rs:27:13 | LL | trait Trait<'_> { | ^^ `'_` is a reserved lifetime name + | + = help: use another lifetime specifier error[E0637]: `'_` cannot be used here --> $DIR/in-binder.rs:31:8 | LL | fn foo<'_>() { | ^^ `'_` is a reserved lifetime name + | + = help: use another lifetime specifier error: aborting due to 6 previous errors diff --git a/tests/ui/underscore-lifetime/underscore-lifetime-binders.stderr b/tests/ui/underscore-lifetime/underscore-lifetime-binders.stderr index d940166e9e2..50359309c92 100644 --- a/tests/ui/underscore-lifetime/underscore-lifetime-binders.stderr +++ b/tests/ui/underscore-lifetime/underscore-lifetime-binders.stderr @@ -15,12 +15,16 @@ error[E0637]: `'_` cannot be used here | LL | fn foo<'_> | ^^ `'_` is a reserved lifetime name + | + = help: use another lifetime specifier error[E0637]: `'_` cannot be used here --> $DIR/underscore-lifetime-binders.rs:10:25 | LL | fn meh() -> Box<dyn for<'_> Meh<'_>> | ^^ `'_` is a reserved lifetime name + | + = help: use another lifetime specifier error[E0106]: missing lifetime specifier --> $DIR/underscore-lifetime-binders.rs:10:33 diff --git a/tests/ui/uninhabited/uninhabited-patterns.rs b/tests/ui/uninhabited/uninhabited-patterns.rs index b7429464fa5..1f30af2acc6 100644 --- a/tests/ui/uninhabited/uninhabited-patterns.rs +++ b/tests/ui/uninhabited/uninhabited-patterns.rs @@ -27,7 +27,11 @@ fn main() { let x: Result<Box<NotSoSecretlyEmpty>, &[Result<!, !>]> = Err(&[]); match x { - Ok(box _) => (), //~ ERROR unreachable pattern + Ok(box _) => (), // We'd get a non-exhaustiveness error if this arm was removed; don't lint. + Err(&[]) => (), + Err(&[..]) => (), + } + match x { //~ ERROR non-exhaustive patterns Err(&[]) => (), Err(&[..]) => (), } diff --git a/tests/ui/uninhabited/uninhabited-patterns.stderr b/tests/ui/uninhabited/uninhabited-patterns.stderr index 7a872767d95..62113c82a36 100644 --- a/tests/ui/uninhabited/uninhabited-patterns.stderr +++ b/tests/ui/uninhabited/uninhabited-patterns.stderr @@ -1,21 +1,23 @@ -error: unreachable pattern - --> $DIR/uninhabited-patterns.rs:30:9 +error[E0004]: non-exhaustive patterns: `Ok(_)` not covered + --> $DIR/uninhabited-patterns.rs:34:11 | -LL | Ok(box _) => (), - | ^^^^^^^^^------- - | | - | matches no values because `NotSoSecretlyEmpty` is uninhabited - | help: remove the match arm +LL | match x { + | ^ pattern `Ok(_)` not covered | - = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types -note: the lint level is defined here - --> $DIR/uninhabited-patterns.rs:4:9 +note: `Result<Box<NotSoSecretlyEmpty>, &[Result<!, !>]>` defined here + --> $SRC_DIR/core/src/result.rs:LL:COL + ::: $SRC_DIR/core/src/result.rs:LL:COL + | + = note: not covered + = note: the matched value is of type `Result<Box<NotSoSecretlyEmpty>, &[Result<!, !>]>` +help: ensure that all possible cases are being handled by adding a match arm with a wildcard pattern or an explicit pattern as shown + | +LL ~ Err(&[..]) => (), +LL ~ Ok(_) => todo!(), | -LL | #![deny(unreachable_patterns)] - | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/uninhabited-patterns.rs:39:9 + --> $DIR/uninhabited-patterns.rs:43:9 | LL | Err(Ok(_y)) => (), | ^^^^^^^^^^^------- @@ -24,9 +26,14 @@ LL | Err(Ok(_y)) => (), | help: remove the match arm | = note: to learn more about uninhabited types, see https://doc.rust-lang.org/nomicon/exotic-sizes.html#empty-types +note: the lint level is defined here + --> $DIR/uninhabited-patterns.rs:4:9 + | +LL | #![deny(unreachable_patterns)] + | ^^^^^^^^^^^^^^^^^^^^ error: unreachable pattern - --> $DIR/uninhabited-patterns.rs:42:15 + --> $DIR/uninhabited-patterns.rs:46:15 | LL | while let Some(_y) = foo() { | ^^^^^^^^ matches no values because `NotSoSecretlyEmpty` is uninhabited @@ -35,3 +42,4 @@ LL | while let Some(_y) = foo() { error: aborting due to 3 previous errors +For more information about this error, try `rustc --explain E0004`. diff --git a/tests/ui/union/issue-81199.stderr b/tests/ui/union/issue-81199.stderr index 8b78ddcf4a5..7deba88fc80 100644 --- a/tests/ui/union/issue-81199.stderr +++ b/tests/ui/union/issue-81199.stderr @@ -1,3 +1,15 @@ +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/issue-81199.rs:5:5 + | +LL | components: PtrComponents<T>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | components: std::mem::ManuallyDrop<PtrComponents<T>>, + | +++++++++++++++++++++++ + + error[E0277]: the trait bound `T: Pointee` is not satisfied --> $DIR/issue-81199.rs:5:17 | @@ -14,18 +26,6 @@ help: consider further restricting type parameter `T` with trait `Pointee` LL | union PtrRepr<T: ?Sized + Pointee> { | +++++++++ -error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/issue-81199.rs:5:5 - | -LL | components: PtrComponents<T>, - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` -help: wrap the field type in `ManuallyDrop<...>` - | -LL | components: std::mem::ManuallyDrop<PtrComponents<T>>, - | +++++++++++++++++++++++ + - error: aborting due to 2 previous errors Some errors have detailed explanations: E0277, E0740. diff --git a/tests/ui/union/union-unsized.stderr b/tests/ui/union/union-unsized.stderr index 851ad8939d4..89ab716071a 100644 --- a/tests/ui/union/union-unsized.stderr +++ b/tests/ui/union/union-unsized.stderr @@ -1,3 +1,15 @@ +error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union + --> $DIR/union-unsized.rs:2:5 + | +LL | a: str, + | ^^^^^^ + | + = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` +help: wrap the field type in `ManuallyDrop<...>` + | +LL | a: std::mem::ManuallyDrop<str>, + | +++++++++++++++++++++++ + + error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/union-unsized.rs:2:8 | @@ -17,15 +29,15 @@ LL | a: Box<str>, | ++++ + error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/union-unsized.rs:2:5 + --> $DIR/union-unsized.rs:11:5 | -LL | a: str, +LL | b: str, | ^^^^^^ | = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` help: wrap the field type in `ManuallyDrop<...>` | -LL | a: std::mem::ManuallyDrop<str>, +LL | b: std::mem::ManuallyDrop<str>, | +++++++++++++++++++++++ + error[E0277]: the size for values of type `str` cannot be known at compilation time @@ -46,18 +58,6 @@ help: the `Box` type always has a statically known size and allocates its conten LL | b: Box<str>, | ++++ + -error[E0740]: field must implement `Copy` or be wrapped in `ManuallyDrop<...>` to be used in a union - --> $DIR/union-unsized.rs:11:5 - | -LL | b: str, - | ^^^^^^ - | - = note: union fields must not have drop side-effects, which is currently enforced via either `Copy` or `ManuallyDrop<...>` -help: wrap the field type in `ManuallyDrop<...>` - | -LL | b: std::mem::ManuallyDrop<str>, - | +++++++++++++++++++++++ + - error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0740. diff --git a/tests/ui/unpretty/ast-const-trait-bound.rs b/tests/ui/unpretty/ast-const-trait-bound.rs index f4de86bb0d0..761bff87a62 100644 --- a/tests/ui/unpretty/ast-const-trait-bound.rs +++ b/tests/ui/unpretty/ast-const-trait-bound.rs @@ -1,4 +1,4 @@ //@ compile-flags: -Zunpretty=normal //@ check-pass -fn foo() where T: ~const Bar {} +fn foo() where T: [const] Bar {} diff --git a/tests/ui/unpretty/ast-const-trait-bound.stdout b/tests/ui/unpretty/ast-const-trait-bound.stdout index f4de86bb0d0..761bff87a62 100644 --- a/tests/ui/unpretty/ast-const-trait-bound.stdout +++ b/tests/ui/unpretty/ast-const-trait-bound.stdout @@ -1,4 +1,4 @@ //@ compile-flags: -Zunpretty=normal //@ check-pass -fn foo() where T: ~const Bar {} +fn foo() where T: [const] Bar {} diff --git a/tests/ui/unpretty/deprecated-attr.rs b/tests/ui/unpretty/deprecated-attr.rs index 0c80203e965..e2ab5efb5d8 100644 --- a/tests/ui/unpretty/deprecated-attr.rs +++ b/tests/ui/unpretty/deprecated-attr.rs @@ -16,3 +16,8 @@ pub struct SinceAndNote; #[deprecated(note = "here's why this is deprecated", since = "1.2.3")] pub struct FlippedOrder; + +pub fn f() { + // Attribute is ignored here (with a warning), but still preserved in HIR + #[deprecated] 0 +} diff --git a/tests/ui/unpretty/deprecated-attr.stdout b/tests/ui/unpretty/deprecated-attr.stdout index 97d863b2e94..042c2f61bd4 100644 --- a/tests/ui/unpretty/deprecated-attr.stdout +++ b/tests/ui/unpretty/deprecated-attr.stdout @@ -9,12 +9,12 @@ extern crate std; #[attr = Deprecation {deprecation: Deprecation {since: Unspecified}}] struct PlainDeprecated; -#[attr = Deprecation {deprecation: Deprecation {since: Unspecified, note: -"here's why this is deprecated"}}] +#[attr = Deprecation {deprecation: Deprecation {since: Unspecified, +note: "here's why this is deprecated"}}] struct DirectNote; -#[attr = Deprecation {deprecation: Deprecation {since: Unspecified, note: -"here's why this is deprecated"}}] +#[attr = Deprecation {deprecation: Deprecation {since: Unspecified, +note: "here's why this is deprecated"}}] struct ExplicitNote; #[attr = Deprecation {deprecation: Deprecation {since: NonStandard("1.2.3"), @@ -24,3 +24,10 @@ struct SinceAndNote; #[attr = Deprecation {deprecation: Deprecation {since: NonStandard("1.2.3"), note: "here's why this is deprecated"}}] struct FlippedOrder; + +fn f() { + + // Attribute is ignored here (with a warning), but still preserved in HIR + #[attr = Deprecation {deprecation: Deprecation {since: Unspecified}}] + 0 +} diff --git a/tests/ui/unpretty/diagnostic-attr.stdout b/tests/ui/unpretty/diagnostic-attr.stdout index 81d71b91d81..3b15a845d68 100644 --- a/tests/ui/unpretty/diagnostic-attr.stdout +++ b/tests/ui/unpretty/diagnostic-attr.stdout @@ -12,6 +12,4 @@ extern crate std; trait ImportantTrait<A> { } #[diagnostic::do_not_recommend] -impl <T> ImportantTrait<T> for T where T: Clone - {#![diagnostic::do_not_recommend] -} +impl <T> ImportantTrait<T> for T where T: Clone { } diff --git a/tests/ui/unpretty/exhaustive-asm.hir.stdout b/tests/ui/unpretty/exhaustive-asm.hir.stdout index 810db69bff1..ec9bda57331 100644 --- a/tests/ui/unpretty/exhaustive-asm.hir.stdout +++ b/tests/ui/unpretty/exhaustive-asm.hir.stdout @@ -26,7 +26,7 @@ mod expressions { mod items { /// ItemKind::GlobalAsm - mod item_global_asm {/// ItemKind::GlobalAsm + mod item_global_asm { global_asm! (".globl my_asm_func"); } } diff --git a/tests/ui/unpretty/exhaustive.expanded.stdout b/tests/ui/unpretty/exhaustive.expanded.stdout index cd1a5d0af08..53ca3c8e391 100644 --- a/tests/ui/unpretty/exhaustive.expanded.stdout +++ b/tests/ui/unpretty/exhaustive.expanded.stdout @@ -12,11 +12,9 @@ #![feature(auto_traits)] #![feature(box_patterns)] #![feature(builtin_syntax)] -#![feature(concat_idents)] #![feature(const_trait_impl)] #![feature(decl_macro)] #![feature(deref_patterns)] -#![feature(dyn_star)] #![feature(explicit_tail_calls)] #![feature(gen_blocks)] #![feature(more_qualified_paths)] @@ -309,7 +307,6 @@ mod expressions { - // concat_idents is deprecated @@ -598,7 +595,6 @@ mod types { let _: dyn Send + 'static; let _: dyn 'static + Send; let _: dyn for<'a> Send; - let _: dyn* Send; } /// TyKind::ImplTrait const fn ty_impl_trait() { @@ -606,7 +602,7 @@ mod types { let _: impl Send + 'static; let _: impl 'static + Send; let _: impl ?Sized; - let _: impl ~const Clone; + let _: impl [const] Clone; let _: impl for<'a> Send; } /// TyKind::Paren @@ -622,8 +618,12 @@ mod types { /*! there is no syntax for this */ } /// TyKind::MacCall - #[expect(deprecated)] - fn ty_mac_call() { let _: T; let _: T; let _: T; } + fn ty_mac_call() { + macro_rules! ty { ($ty:ty) => { $ty } } + let _: T; + let _: T; + let _: T; + } /// TyKind::CVarArgs fn ty_c_var_args() { /*! FIXME: todo */ diff --git a/tests/ui/unpretty/exhaustive.hir.stderr b/tests/ui/unpretty/exhaustive.hir.stderr index 58f7ff0f598..aa411ce81eb 100644 --- a/tests/ui/unpretty/exhaustive.hir.stderr +++ b/tests/ui/unpretty/exhaustive.hir.stderr @@ -1,17 +1,17 @@ error[E0697]: closures cannot be static - --> $DIR/exhaustive.rs:211:9 + --> $DIR/exhaustive.rs:209:9 | LL | static || value; | ^^^^^^^^^ error[E0697]: closures cannot be static - --> $DIR/exhaustive.rs:212:9 + --> $DIR/exhaustive.rs:210:9 | LL | static move || value; | ^^^^^^^^^^^^^^ error[E0728]: `await` is only allowed inside `async` functions and blocks - --> $DIR/exhaustive.rs:241:13 + --> $DIR/exhaustive.rs:239:13 | LL | fn expr_await() { | --------------- this is not `async` @@ -20,19 +20,19 @@ LL | fut.await; | ^^^^^ only allowed inside `async` functions and blocks error: in expressions, `_` can only be used on the left-hand side of an assignment - --> $DIR/exhaustive.rs:290:9 + --> $DIR/exhaustive.rs:288:9 | LL | _; | ^ `_` not allowed here error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:300:9 + --> $DIR/exhaustive.rs:298:9 | LL | x::(); | ^^^^^ only `Fn` traits may use parentheses error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:301:9 + --> $DIR/exhaustive.rs:299:9 | LL | x::(T, T) -> T; | ^^^^^^^^^^^^^^ only `Fn` traits may use parentheses @@ -44,31 +44,31 @@ LL + x::<T, T> -> T; | error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:302:9 + --> $DIR/exhaustive.rs:300:9 | LL | crate::() -> ()::expressions::() -> ()::expr_path; | ^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:302:26 + --> $DIR/exhaustive.rs:300:26 | LL | crate::() -> ()::expressions::() -> ()::expr_path; | ^^^^^^^^^^^^^^^^^^^^^ only `Fn` traits may use parentheses error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:305:9 + --> $DIR/exhaustive.rs:303:9 | LL | core::()::marker::()::PhantomData; | ^^^^^^^^ only `Fn` traits may use parentheses error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:305:19 + --> $DIR/exhaustive.rs:303:19 | LL | core::()::marker::()::PhantomData; | ^^^^^^^^^^ only `Fn` traits may use parentheses error: `yield` can only be used in `#[coroutine]` closures, or `gen` blocks - --> $DIR/exhaustive.rs:392:9 + --> $DIR/exhaustive.rs:390:9 | LL | yield; | ^^^^^ @@ -79,7 +79,7 @@ LL | #[coroutine] fn expr_yield() { | ++++++++++++ error[E0703]: invalid ABI: found `C++` - --> $DIR/exhaustive.rs:472:23 + --> $DIR/exhaustive.rs:470:23 | LL | unsafe extern "C++" {} | ^^^^^ invalid ABI @@ -87,7 +87,7 @@ LL | unsafe extern "C++" {} = note: invoke `rustc --print=calling-conventions` for a full list of supported calling conventions error: `..` patterns are not allowed here - --> $DIR/exhaustive.rs:679:13 + --> $DIR/exhaustive.rs:677:13 | LL | let ..; | ^^ @@ -95,13 +95,13 @@ LL | let ..; = note: only allowed in tuple, tuple struct, and slice patterns error[E0214]: parenthesized type parameters may only be used with a `Fn` trait - --> $DIR/exhaustive.rs:794:16 + --> $DIR/exhaustive.rs:792:16 | LL | let _: T() -> !; | ^^^^^^^^ only `Fn` traits may use parentheses error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:809:16 + --> $DIR/exhaustive.rs:806:16 | LL | let _: impl Send; | ^^^^^^^^^ @@ -112,7 +112,7 @@ LL | let _: impl Send; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:810:16 + --> $DIR/exhaustive.rs:807:16 | LL | let _: impl Send + 'static; | ^^^^^^^^^^^^^^^^^^^ @@ -123,7 +123,7 @@ LL | let _: impl Send + 'static; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:811:16 + --> $DIR/exhaustive.rs:808:16 | LL | let _: impl 'static + Send; | ^^^^^^^^^^^^^^^^^^^ @@ -134,7 +134,7 @@ LL | let _: impl 'static + Send; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:812:16 + --> $DIR/exhaustive.rs:809:16 | LL | let _: impl ?Sized; | ^^^^^^^^^^^ @@ -145,10 +145,10 @@ LL | let _: impl ?Sized; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:813:16 + --> $DIR/exhaustive.rs:810:16 | -LL | let _: impl ~const Clone; - | ^^^^^^^^^^^^^^^^^ +LL | let _: impl [const] Clone; + | ^^^^^^^^^^^^^^^^^^ | = note: `impl Trait` is only allowed in arguments and return types of functions and methods = note: see issue #63065 <https://github.com/rust-lang/rust/issues/63065> for more information @@ -156,7 +156,7 @@ LL | let _: impl ~const Clone; = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0562]: `impl Trait` is not allowed in the type of variable bindings - --> $DIR/exhaustive.rs:814:16 + --> $DIR/exhaustive.rs:811:16 | LL | let _: impl for<'a> Send; | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/unpretty/exhaustive.hir.stdout b/tests/ui/unpretty/exhaustive.hir.stdout index 5d6e3907d75..a559d51ed5d 100644 --- a/tests/ui/unpretty/exhaustive.hir.stdout +++ b/tests/ui/unpretty/exhaustive.hir.stdout @@ -11,11 +11,9 @@ #![feature(auto_traits)] #![feature(box_patterns)] #![feature(builtin_syntax)] -#![feature(concat_idents)] #![feature(const_trait_impl)] #![feature(decl_macro)] #![feature(deref_patterns)] -#![feature(dyn_star)] #![feature(explicit_tail_calls)] #![feature(gen_blocks)] #![feature(more_qualified_paths)] @@ -50,20 +48,14 @@ mod prelude { } } -//! inner single-line doc comment -/*! +/// inner single-line doc comment +/** * inner multi-line doc comment */ #[doc = "inner doc attribute"] #[allow(dead_code, unused_variables)] #[no_std] -mod attributes {//! inner single-line doc comment - /*! - * inner multi-line doc comment - */ - #![doc = "inner doc attribute"] - #![allow(dead_code, unused_variables)] - #![no_std] +mod attributes { /// outer single-line doc comment /** @@ -72,7 +64,7 @@ mod attributes {//! inner single-line doc comment #[doc = "outer doc attribute"] #[doc = "macro"] #[allow()] - #[attr = Repr([ReprC])] + #[attr = Repr {reprs: [ReprC]}] struct Struct; } @@ -349,7 +341,6 @@ mod expressions { - // concat_idents is deprecated @@ -413,25 +404,25 @@ mod expressions { } mod items { /// ItemKind::ExternCrate - mod item_extern_crate {/// ItemKind::ExternCrate + mod item_extern_crate { extern crate core; extern crate self as unpretty; extern crate core as _; } /// ItemKind::Use - mod item_use {/// ItemKind::Use + mod item_use { use ::{}; use crate::expressions; use crate::items::item_use; use core::*; } /// ItemKind::Static - mod item_static {/// ItemKind::Static + mod item_static { static A: () = { }; static mut B: () = { }; } /// ItemKind::Const - mod item_const {/// ItemKind::Const + mod item_const { const A: () = { }; trait TraitItems { const @@ -445,7 +436,7 @@ mod items { } } /// ItemKind::Fn - mod item_fn {/// ItemKind::Fn + mod item_fn { const unsafe extern "C" fn f() { } async unsafe extern "C" fn g() -> @@ -460,21 +451,19 @@ mod items { } } /// ItemKind::Mod - mod item_mod {/// ItemKind::Mod - } + mod item_mod { } /// ItemKind::ForeignMod - mod item_foreign_mod {/// ItemKind::ForeignMod + mod item_foreign_mod { extern "Rust" { } extern "C" { } } /// ItemKind::GlobalAsm: see exhaustive-asm.rs /// ItemKind::TyAlias - mod item_ty_alias {/// ItemKind::GlobalAsm: see exhaustive-asm.rs - /// ItemKind::TyAlias + mod item_ty_alias { type Type<'a> where T: 'a = T; } /// ItemKind::Enum - mod item_enum {/// ItemKind::Enum + mod item_enum { enum Void { } enum Empty { Unit, @@ -490,7 +479,7 @@ mod items { } } /// ItemKind::Struct - mod item_struct {/// ItemKind::Struct + mod item_struct { struct Unit; struct Tuple(); struct Newtype(Unit); @@ -501,45 +490,40 @@ mod items { } } /// ItemKind::Union - mod item_union {/// ItemKind::Union + mod item_union { union Generic<'a, T> where T: 'a { t: T, } } /// ItemKind::Trait - mod item_trait {/// ItemKind::Trait + mod item_trait { auto unsafe trait Send { } trait Trait<'a>: Sized where Self: 'a { } } /// ItemKind::TraitAlias - mod item_trait_alias {/// ItemKind::TraitAlias + mod item_trait_alias { trait Trait<T> = Sized where for<'a> T: 'a; } /// ItemKind::Impl - mod item_impl {/// ItemKind::Impl + mod item_impl { impl () { } impl <T> () { } impl Default for () { } impl const <T> Default for () { } } /// ItemKind::MacCall - mod item_mac_call {/// ItemKind::MacCall - } + mod item_mac_call { } /// ItemKind::MacroDef - mod item_macro_def {/// ItemKind::MacroDef + mod item_macro_def { macro_rules! mac { () => {...}; } macro stringify { () => {} } } /// ItemKind::Delegation - /*! FIXME: todo */ - mod item_delegation {/// ItemKind::Delegation - /*! FIXME: todo */ - } + /** FIXME: todo */ + mod item_delegation { } /// ItemKind::DelegationMac - /*! FIXME: todo */ - mod item_delegation_mac {/// ItemKind::DelegationMac - /*! FIXME: todo */ - } + /** FIXME: todo */ + mod item_delegation_mac { } } mod patterns { /// PatKind::Missing @@ -676,7 +660,6 @@ mod types { let _: dyn Send + 'static; let _: dyn Send + 'static; let _: dyn for<'a> Send; - let _: dyn* Send; } /// TyKind::ImplTrait const fn ty_impl_trait() { @@ -690,29 +673,33 @@ mod types { /// TyKind::Paren fn ty_paren() { let _: T; } /// TyKind::Typeof - /*! unused for now */ + /** unused for now */ fn ty_typeof() { } /// TyKind::Infer fn ty_infer() { let _: _; } /// TyKind::ImplicitSelf - /*! there is no syntax for this */ + /** there is no syntax for this */ fn ty_implicit_self() { } /// TyKind::MacCall - #[expect(deprecated)] - fn ty_mac_call() { let _: T; let _: T; let _: T; } + fn ty_mac_call() { + macro_rules! ty { ($ty:ty) => { $ty } } + let _: T; + let _: T; + let _: T; + } /// TyKind::CVarArgs - /*! FIXME: todo */ + /** FIXME: todo */ fn ty_c_var_args() { } /// TyKind::Pat fn ty_pat() { let _: u32 is 1..=RangeMax; } } mod visibilities { /// VisibilityKind::Public - mod visibility_public {/// VisibilityKind::Public + mod visibility_public { struct Pub; } /// VisibilityKind::Restricted - mod visibility_restricted {/// VisibilityKind::Restricted + mod visibility_restricted { struct PubCrate; struct PubSelf; struct PubSuper; diff --git a/tests/ui/unpretty/exhaustive.rs b/tests/ui/unpretty/exhaustive.rs index 60ad3564689..5292ddad4f6 100644 --- a/tests/ui/unpretty/exhaustive.rs +++ b/tests/ui/unpretty/exhaustive.rs @@ -11,11 +11,9 @@ #![feature(auto_traits)] #![feature(box_patterns)] #![feature(builtin_syntax)] -#![feature(concat_idents)] #![feature(const_trait_impl)] #![feature(decl_macro)] #![feature(deref_patterns)] -#![feature(dyn_star)] #![feature(explicit_tail_calls)] #![feature(gen_blocks)] #![feature(more_qualified_paths)] @@ -801,7 +799,6 @@ mod types { let _: dyn Send + 'static; let _: dyn 'static + Send; let _: dyn for<'a> Send; - let _: dyn* Send; } /// TyKind::ImplTrait @@ -810,7 +807,7 @@ mod types { let _: impl Send + 'static; //[hir]~ ERROR `impl Trait` is not allowed let _: impl 'static + Send; //[hir]~ ERROR `impl Trait` is not allowed let _: impl ?Sized; //[hir]~ ERROR `impl Trait` is not allowed - let _: impl ~const Clone; //[hir]~ ERROR `impl Trait` is not allowed + let _: impl [const] Clone; //[hir]~ ERROR `impl Trait` is not allowed let _: impl for<'a> Send; //[hir]~ ERROR `impl Trait` is not allowed } @@ -835,11 +832,13 @@ mod types { } /// TyKind::MacCall - #[expect(deprecated)] // concat_idents is deprecated fn ty_mac_call() { - let _: concat_idents!(T); - let _: concat_idents![T]; - let _: concat_idents! { T }; + macro_rules! ty { + ($ty:ty) => { $ty } + } + let _: ty!(T); + let _: ty![T]; + let _: ty! { T }; } /// TyKind::CVarArgs diff --git a/tests/ui/unsized-locals/yote.rs b/tests/ui/unsized-locals/yote.rs index aa5b68a3078..1de75a6ce61 100644 --- a/tests/ui/unsized-locals/yote.rs +++ b/tests/ui/unsized-locals/yote.rs @@ -1,4 +1,2 @@ -//@ normalize-stderr: "you are using [0-9]+\.[0-9]+\.[0-9]+(-[a-zA-Z0-9]+)?( \([^)]*\))?" -> "you are using $$RUSTC_VERSION" - #![feature(unsized_locals)] //~ERROR feature has been removed #![crate_type = "lib"] diff --git a/tests/ui/unsized-locals/yote.stderr b/tests/ui/unsized-locals/yote.stderr index 655aad5360c..f08a0b4aa60 100644 --- a/tests/ui/unsized-locals/yote.stderr +++ b/tests/ui/unsized-locals/yote.stderr @@ -1,10 +1,10 @@ error[E0557]: feature has been removed - --> $DIR/yote.rs:3:12 + --> $DIR/yote.rs:1:12 | LL | #![feature(unsized_locals)] | ^^^^^^^^^^^^^^ feature has been removed | - = note: removed in CURRENT_RUSTC_VERSION (you are using $RUSTC_VERSION) + = note: removed in 1.89.0 = note: removed due to implementation concerns; see https://github.com/rust-lang/rust/issues/111942 error: aborting due to 1 previous error diff --git a/tests/ui/unsized/unsized-trait-impl-self-type.stderr b/tests/ui/unsized/unsized-trait-impl-self-type.stderr index 3b684193b4a..61165d49b2d 100644 --- a/tests/ui/unsized/unsized-trait-impl-self-type.stderr +++ b/tests/ui/unsized/unsized-trait-impl-self-type.stderr @@ -1,3 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/unsized-trait-impl-self-type.rs:10:1 + | +LL | fn foo(&self, z: &Z); + | --------------------- `foo` from trait +... +LL | impl<X: ?Sized> T3<X> for S5<X> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized-trait-impl-self-type.rs:10:27 | @@ -24,15 +33,6 @@ LL - impl<X: ?Sized> T3<X> for S5<X> { LL + impl<X> T3<X> for S5<X> { | -error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/unsized-trait-impl-self-type.rs:10:1 - | -LL | fn foo(&self, z: &Z); - | --------------------- `foo` from trait -... -LL | impl<X: ?Sized> T3<X> for S5<X> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation - error: aborting due to 2 previous errors Some errors have detailed explanations: E0046, E0277. diff --git a/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr b/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr index 79fc9567dae..f46a6f678a9 100644 --- a/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr +++ b/tests/ui/unsized/unsized-trait-impl-trait-arg.stderr @@ -1,3 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `foo` + --> $DIR/unsized-trait-impl-trait-arg.rs:8:1 + | +LL | fn foo(&self, z: Z); + | -------------------- `foo` from trait +... +LL | impl<X: ?Sized> T2<X> for S4<X> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation + error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized-trait-impl-trait-arg.rs:8:17 | @@ -21,15 +30,6 @@ help: consider relaxing the implicit `Sized` restriction LL | trait T2<Z: ?Sized> { | ++++++++ -error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/unsized-trait-impl-trait-arg.rs:8:1 - | -LL | fn foo(&self, z: Z); - | -------------------- `foo` from trait -... -LL | impl<X: ?Sized> T2<X> for S4<X> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `foo` in implementation - error: aborting due to 2 previous errors Some errors have detailed explanations: E0046, E0277. diff --git a/tests/ui/unsized/unsized7.stderr b/tests/ui/unsized/unsized7.stderr index 6e9c052a070..2e65c8c3357 100644 --- a/tests/ui/unsized/unsized7.stderr +++ b/tests/ui/unsized/unsized7.stderr @@ -1,3 +1,12 @@ +error[E0046]: not all trait items implemented, missing: `dummy` + --> $DIR/unsized7.rs:12:1 + | +LL | fn dummy(&self) -> Z; + | --------------------- `dummy` from trait +... +LL | impl<X: ?Sized + T> T1<X> for S3<X> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `dummy` in implementation + error[E0277]: the size for values of type `X` cannot be known at compilation time --> $DIR/unsized7.rs:12:21 | @@ -21,15 +30,6 @@ help: consider relaxing the implicit `Sized` restriction LL | trait T1<Z: T + ?Sized> { | ++++++++ -error[E0046]: not all trait items implemented, missing: `dummy` - --> $DIR/unsized7.rs:12:1 - | -LL | fn dummy(&self) -> Z; - | --------------------- `dummy` from trait -... -LL | impl<X: ?Sized + T> T1<X> for S3<X> { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ missing `dummy` in implementation - error: aborting due to 2 previous errors Some errors have detailed explanations: E0046, E0277. diff --git a/tests/ui/variance/variance-regions-unused-indirect.stderr b/tests/ui/variance/variance-regions-unused-indirect.stderr index 8cdbb3c0f5e..f942c51b05b 100644 --- a/tests/ui/variance/variance-regions-unused-indirect.stderr +++ b/tests/ui/variance/variance-regions-unused-indirect.stderr @@ -1,3 +1,11 @@ +error[E0392]: lifetime parameter `'a` is never used + --> $DIR/variance-regions-unused-indirect.rs:3:10 + | +LL | enum Foo<'a> { + | ^^ unused lifetime parameter + | + = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` + error[E0072]: recursive types `Foo` and `Bar` have infinite size --> $DIR/variance-regions-unused-indirect.rs:3:1 | @@ -22,14 +30,6 @@ LL ~ Bar1(Box<Foo<'a>>) | error[E0392]: lifetime parameter `'a` is never used - --> $DIR/variance-regions-unused-indirect.rs:3:10 - | -LL | enum Foo<'a> { - | ^^ unused lifetime parameter - | - = help: consider removing `'a`, referring to it in a field, or using a marker such as `PhantomData` - -error[E0392]: lifetime parameter `'a` is never used --> $DIR/variance-regions-unused-indirect.rs:8:10 | LL | enum Bar<'a> { diff --git a/tests/ui/wf/hir-wf-check-erase-regions.stderr b/tests/ui/wf/hir-wf-check-erase-regions.stderr index e4d48bf82c0..07304cd448e 100644 --- a/tests/ui/wf/hir-wf-check-erase-regions.stderr +++ b/tests/ui/wf/hir-wf-check-erase-regions.stderr @@ -11,10 +11,10 @@ note: required by a bound in `std::iter::IntoIterator::IntoIter` --> $SRC_DIR/core/src/iter/traits/collect.rs:LL:COL error[E0277]: `&'a T` is not an iterator - --> $DIR/hir-wf-check-erase-regions.rs:7:21 + --> $DIR/hir-wf-check-erase-regions.rs:7:5 | LL | type IntoIter = std::iter::Flatten<std::slice::Iter<'a, T>>; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `&'a T` is not an iterator + | ^^^^^^^^^^^^^ `&'a T` is not an iterator | = help: the trait `Iterator` is not implemented for `&'a T` = help: the trait `Iterator` is implemented for `&mut I` diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs index 53f07a94fd1..ad7d972879f 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.rs @@ -5,7 +5,6 @@ trait Trait<const N: dyn Trait = bar> { //~^ ERROR the name `N` is already used for a generic parameter in this item's generic parameters //~| ERROR expected value, found builtin type `u32` //~| ERROR defaults for const parameters are only allowed in `struct`, `enum`, `type`, or `trait` definitions - //~| ERROR associated item referring to unboxed trait object for its own trait bar //~^ ERROR cannot find value `bar` in this scope } diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr index a085dd6ac57..dc5a1cf3485 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122199.stderr @@ -20,7 +20,7 @@ LL | fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait { | ^^^ not a value error[E0425]: cannot find value `bar` in this scope - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:9:9 + --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:8:9 | LL | bar | ^^^ not found in this scope @@ -32,7 +32,7 @@ LL | trait Trait<const N: dyn Trait = bar> { | ^^^^^ | = note: ...which immediately requires computing type of `Trait::N` again -note: cycle used when computing explicit predicates of trait `Trait` +note: cycle used when checking that `Trait` is well-formed --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:1:1 | LL | trait Trait<const N: dyn Trait = bar> { @@ -45,22 +45,7 @@ error: defaults for const parameters are only allowed in `struct`, `enum`, `type LL | fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait { | ^^^^^^^^^^^^^^^^^^^^^^^^ -error: associated item referring to unboxed trait object for its own trait - --> $DIR/ice-hir-wf-check-anon-const-issue-122199.rs:4:48 - | -LL | trait Trait<const N: dyn Trait = bar> { - | ----- in this trait -... -LL | fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait { - | ^^^^^^^^^ - | -help: you might have meant to use `Self` to refer to the implementing type - | -LL - fn fnc<const N: dyn Trait = u32>(&self) -> dyn Trait { -LL + fn fnc<const N: dyn Trait = u32>(&self) -> Self { - | - -error: aborting due to 7 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0391, E0403, E0423, E0425. For more information about an error, try `rustc --explain E0391`. diff --git a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr index a381f2acdce..a99728f4b66 100644 --- a/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr +++ b/tests/ui/wf/ice-hir-wf-check-anon-const-issue-122989.stderr @@ -37,7 +37,7 @@ note: ...which requires computing type of `Bar::M`... LL | trait Bar<const M: Foo<2>> {} | ^^^^^^^^^^^^^^^ = note: ...which again requires computing type of `Foo::N`, completing the cycle -note: cycle used when computing explicit predicates of trait `Foo` +note: cycle used when checking that `Foo` is well-formed --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:1 | LL | trait Foo<const N: Bar<2>> { @@ -56,7 +56,7 @@ note: ...which requires computing type of `Bar::M`... LL | trait Bar<const M: Foo<2>> {} | ^^^^^^^^^^^^^^^ = note: ...which again requires computing type of `Foo::N`, completing the cycle -note: cycle used when computing explicit predicates of trait `Foo` +note: cycle used when checking that `Foo` is well-formed --> $DIR/ice-hir-wf-check-anon-const-issue-122989.rs:2:1 | LL | trait Foo<const N: Bar<2>> { diff --git a/tests/ui/wf/issue-87495.stderr b/tests/ui/wf/issue-87495.stderr index 0c293e3576d..bf79535df11 100644 --- a/tests/ui/wf/issue-87495.stderr +++ b/tests/ui/wf/issue-87495.stderr @@ -13,6 +13,11 @@ LL | trait T { LL | const CONST: (bool, dyn T); | ^^^^^ ...because it contains this associated `const` = help: consider moving `CONST` to another trait +help: you might have meant to use `Self` to refer to the implementing type + | +LL - const CONST: (bool, dyn T); +LL + const CONST: (bool, Self); + | error: aborting due to 1 previous error diff --git a/tests/ui/wf/wf-impl-associated-type-region.stderr b/tests/ui/wf/wf-impl-associated-type-region.stderr index f17d33474f4..86e35b86fb1 100644 --- a/tests/ui/wf/wf-impl-associated-type-region.stderr +++ b/tests/ui/wf/wf-impl-associated-type-region.stderr @@ -1,10 +1,10 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-impl-associated-type-region.rs:10:16 + --> $DIR/wf-impl-associated-type-region.rs:10:5 | LL | impl<'a, T> Foo<'a> for T { | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | type Bar = &'a T; - | ^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at + | ^^^^^^^^ ...so that the reference type `&'a T` does not outlive the data it points at | help: consider adding an explicit lifetime bound | diff --git a/tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr b/tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr index e0cf42fd10c..f2989ae97b5 100644 --- a/tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr +++ b/tests/ui/wf/wf-outlives-ty-in-fn-or-trait.stderr @@ -1,10 +1,10 @@ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:9:16 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:9:5 | LL | impl<'a, T> Trait<'a, T> for usize { | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | type Out = &'a fn(T); - | ^^^^^^^^^ ...so that the reference type `&'a fn(T)` does not outlive the data it points at + | ^^^^^^^^ ...so that the reference type `&'a fn(T)` does not outlive the data it points at | help: consider adding an explicit lifetime bound | @@ -12,12 +12,12 @@ LL | impl<'a, T: 'a> Trait<'a, T> for usize { | ++++ error[E0309]: the parameter type `T` may not live long enough - --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:16 + --> $DIR/wf-outlives-ty-in-fn-or-trait.rs:19:5 | LL | impl<'a, T> Trait<'a, T> for u32 { | -- the parameter type `T` must be valid for the lifetime `'a` as defined here... LL | type Out = &'a dyn Baz<T>; - | ^^^^^^^^^^^^^^ ...so that the reference type `&'a (dyn Baz<T> + 'a)` does not outlive the data it points at + | ^^^^^^^^ ...so that the reference type `&'a (dyn Baz<T> + 'a)` does not outlive the data it points at | help: consider adding an explicit lifetime bound | diff --git a/tests/ui/wf/wf-trait-associated-type-region.stderr b/tests/ui/wf/wf-trait-associated-type-region.stderr index d6647b2cb96..9589e1d7853 100644 --- a/tests/ui/wf/wf-trait-associated-type-region.stderr +++ b/tests/ui/wf/wf-trait-associated-type-region.stderr @@ -1,11 +1,11 @@ error[E0309]: the associated type `<Self as SomeTrait<'a>>::Type1` may not live long enough - --> $DIR/wf-trait-associated-type-region.rs:9:18 + --> $DIR/wf-trait-associated-type-region.rs:9:5 | LL | trait SomeTrait<'a> { | -- the associated type `<Self as SomeTrait<'a>>::Type1` must be valid for the lifetime `'a` as defined here... LL | type Type1; LL | type Type2 = &'a Self::Type1; - | ^^^^^^^^^^^^^^^ ...so that the reference type `&'a <Self as SomeTrait<'a>>::Type1` does not outlive the data it points at + | ^^^^^^^^^^ ...so that the reference type `&'a <Self as SomeTrait<'a>>::Type1` does not outlive the data it points at | help: consider adding an explicit lifetime bound | diff --git a/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr b/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr index 0d8ec5f8928..89a91a1f1ad 100644 --- a/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr +++ b/tests/ui/where-clauses/higher-ranked-fn-type.verbose.stderr @@ -1,10 +1,10 @@ -error[E0277]: the trait bound `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b))> fn(&'^1_0.Named(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), "'b") ()): Foo` is not satisfied +error[E0277]: the trait bound `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b)))> fn(&'^1_0.Named(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b)) ()): Foo` is not satisfied --> $DIR/higher-ranked-fn-type.rs:20:5 | LL | called() | ^^^^^^^^ unsatisfied trait bound | - = help: the trait `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), 'b))> Foo` is not implemented for `fn(&'^1_0.Named(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b), "'b") ())` + = help: the trait `for<Region(BrNamed(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b)))> Foo` is not implemented for `fn(&'^1_0.Named(DefId(0:6 ~ higher_ranked_fn_type[9e51]::called::'b)) ())` help: this trait has no implementations, consider adding one --> $DIR/higher-ranked-fn-type.rs:6:1 | |
