diff options
Diffstat (limited to 'tests')
56 files changed, 656 insertions, 230 deletions
diff --git a/tests/assembly/nvptx-arch-default.rs b/tests/assembly/nvptx-arch-default.rs index bac09574f17..a621fd6dcb2 100644 --- a/tests/assembly/nvptx-arch-default.rs +++ b/tests/assembly/nvptx-arch-default.rs @@ -1,7 +1,6 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib +//@ compile-flags: --crate-type cdylib -Z unstable-options -Clinker-flavor=llbc //@ only-nvptx64 -//@ ignore-nvptx64 #![no_std] diff --git a/tests/assembly/nvptx-arch-emit-asm.rs b/tests/assembly/nvptx-arch-emit-asm.rs index d24035cc831..e47f8e78e36 100644 --- a/tests/assembly/nvptx-arch-emit-asm.rs +++ b/tests/assembly/nvptx-arch-emit-asm.rs @@ -1,7 +1,6 @@ //@ assembly-output: emit-asm //@ compile-flags: --crate-type rlib //@ only-nvptx64 -//@ ignore-nvptx64 #![no_std] diff --git a/tests/assembly/nvptx-arch-target-cpu.rs b/tests/assembly/nvptx-arch-target-cpu.rs index 212af20f4de..609ab297e63 100644 --- a/tests/assembly/nvptx-arch-target-cpu.rs +++ b/tests/assembly/nvptx-arch-target-cpu.rs @@ -1,7 +1,6 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -C target-cpu=sm_50 +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_50 -Z unstable-options -Clinker-flavor=llbc //@ only-nvptx64 -//@ ignore-nvptx64 #![no_std] diff --git a/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs b/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs index a42d5dd3569..ce1d732f367 100644 --- a/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs +++ b/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs @@ -1,7 +1,6 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 +//@ compile-flags: --crate-type cdylib -C target-cpu=sm_86 -Z unstable-options -Clinker-flavor=llbc //@ only-nvptx64 -//@ ignore-nvptx64 // The following ABI tests are made with nvcc 11.6 does. // @@ -226,10 +225,11 @@ pub unsafe extern "ptx-kernel" fn f_byte_array_arg(_a: [u8; 5]) {} #[no_mangle] pub unsafe extern "ptx-kernel" fn f_float_array_arg(_a: [f32; 5]) {} -// CHECK: .visible .entry f_u128_array_arg( -// CHECK: .param .align 16 .b8 f_u128_array_arg_param_0[80] -#[no_mangle] -pub unsafe extern "ptx-kernel" fn f_u128_array_arg(_a: [u128; 5]) {} +// FIXME: u128 started to break compilation with disabled CI +// NO_CHECK: .visible .entry f_u128_array_arg( +// NO_CHECK: .param .align 16 .b8 f_u128_array_arg_param_0[80] +//#[no_mangle] +//pub unsafe extern "ptx-kernel" fn f_u128_array_arg(_a: [u128; 5]) {} // CHECK: .visible .entry f_u32_slice_arg( // CHECK: .param .u64 f_u32_slice_arg_param_0 @@ -247,7 +247,6 @@ pub unsafe extern "ptx-kernel" fn f_tuple_u8_u8_arg(_a: (u8, u8)) {} #[no_mangle] pub unsafe extern "ptx-kernel" fn f_tuple_u32_u32_arg(_a: (u32, u32)) {} - // CHECK: .visible .entry f_tuple_u8_u8_u32_arg( // CHECK: .param .align 4 .b8 f_tuple_u8_u8_u32_arg_param_0[8] #[no_mangle] diff --git a/tests/assembly/nvptx-safe-naming.rs b/tests/assembly/nvptx-safe-naming.rs index 59fd527be3c..d7b46aadd9c 100644 --- a/tests/assembly/nvptx-safe-naming.rs +++ b/tests/assembly/nvptx-safe-naming.rs @@ -1,7 +1,6 @@ //@ assembly-output: ptx-linker -//@ compile-flags: --crate-type cdylib +//@ compile-flags: --crate-type cdylib -Z unstable-options -Clinker-flavor=llbc //@ only-nvptx64 -//@ ignore-nvptx64 #![feature(abi_ptx)] #![no_std] @@ -10,7 +9,7 @@ extern crate breakpoint_panic_handler; // Verify function name doesn't contain unacceaptable characters. -// CHECK: .func (.param .b32 func_retval0) [[IMPL_FN:[a-zA-Z0-9$_]+square[a-zA-Z0-9$_]+]]( +// CHECK: .func (.param .b32 func_retval0) [[IMPL_FN:[a-zA-Z0-9$_]+square[a-zA-Z0-9$_]+]] // CHECK-LABEL: .visible .entry top_kernel( #[no_mangle] diff --git a/tests/codegen/align-byval-vector.rs b/tests/codegen/align-byval-vector.rs index 6596792ec88..02b7d6b0c5e 100644 --- a/tests/codegen/align-byval-vector.rs +++ b/tests/codegen/align-byval-vector.rs @@ -37,12 +37,12 @@ pub struct DoubleFoo { } extern "C" { - // x86-linux: declare void @f({{.*}}byval(%Foo) align 4{{.*}}) - // x86-darwin: declare void @f({{.*}}byval(%Foo) align 16{{.*}}) + // x86-linux: declare void @f({{.*}}byval([32 x i8]) align 4{{.*}}) + // x86-darwin: declare void @f({{.*}}byval([32 x i8]) align 16{{.*}}) fn f(foo: Foo); - // x86-linux: declare void @g({{.*}}byval(%DoubleFoo) align 4{{.*}}) - // x86-darwin: declare void @g({{.*}}byval(%DoubleFoo) align 16{{.*}}) + // x86-linux: declare void @g({{.*}}byval([64 x i8]) align 4{{.*}}) + // x86-darwin: declare void @g({{.*}}byval([64 x i8]) align 16{{.*}}) fn g(foo: DoubleFoo); } diff --git a/tests/codegen/align-byval.rs b/tests/codegen/align-byval.rs index 1016c7903eb..c74e236f29d 100644 --- a/tests/codegen/align-byval.rs +++ b/tests/codegen/align-byval.rs @@ -107,20 +107,20 @@ pub unsafe fn call_na1(x: NaturalAlign1) { // CHECK: start: // m68k: [[ALLOCA:%[a-z0-9+]]] = alloca %NaturalAlign1, align 1 - // m68k: call void @natural_align_1({{.*}}byval(%NaturalAlign1) align 1{{.*}} [[ALLOCA]]) + // m68k: call void @natural_align_1({{.*}}byval([2 x i8]) align 1{{.*}} [[ALLOCA]]) // wasm: [[ALLOCA:%[a-z0-9+]]] = alloca %NaturalAlign1, align 1 - // wasm: call void @natural_align_1({{.*}}byval(%NaturalAlign1) align 1{{.*}} [[ALLOCA]]) + // wasm: call void @natural_align_1({{.*}}byval([2 x i8]) align 1{{.*}} [[ALLOCA]]) // x86_64-linux: call void @natural_align_1(i16 // x86_64-windows: call void @natural_align_1(i16 // i686-linux: [[ALLOCA:%[a-z0-9+]]] = alloca %NaturalAlign1, align 4 - // i686-linux: call void @natural_align_1({{.*}}byval(%NaturalAlign1) align 4{{.*}} [[ALLOCA]]) + // i686-linux: call void @natural_align_1({{.*}}byval([2 x i8]) align 4{{.*}} [[ALLOCA]]) // i686-windows: [[ALLOCA:%[a-z0-9+]]] = alloca %NaturalAlign1, align 4 - // i686-windows: call void @natural_align_1({{.*}}byval(%NaturalAlign1) align 4{{.*}} [[ALLOCA]]) + // i686-windows: call void @natural_align_1({{.*}}byval([2 x i8]) align 4{{.*}} [[ALLOCA]]) natural_align_1(x); } @@ -135,10 +135,10 @@ pub unsafe fn call_na2(x: NaturalAlign2) { // x86_64-windows-NEXT: call void @natural_align_2 // i686-linux: [[ALLOCA:%[0-9]+]] = alloca %NaturalAlign2, align 4 - // i686-linux: call void @natural_align_2({{.*}}byval(%NaturalAlign2) align 4{{.*}} [[ALLOCA]]) + // i686-linux: call void @natural_align_2({{.*}}byval([34 x i8]) align 4{{.*}} [[ALLOCA]]) // i686-windows: [[ALLOCA:%[0-9]+]] = alloca %NaturalAlign2, align 4 - // i686-windows: call void @natural_align_2({{.*}}byval(%NaturalAlign2) align 4{{.*}} [[ALLOCA]]) + // i686-windows: call void @natural_align_2({{.*}}byval([34 x i8]) align 4{{.*}} [[ALLOCA]]) natural_align_2(x); } @@ -199,141 +199,141 @@ pub unsafe fn call_fa16(x: ForceAlign16) { } extern "C" { - // m68k: declare void @natural_align_1({{.*}}byval(%NaturalAlign1) align 1{{.*}}) + // m68k: declare void @natural_align_1({{.*}}byval([2 x i8]) align 1{{.*}}) - // wasm: declare void @natural_align_1({{.*}}byval(%NaturalAlign1) align 1{{.*}}) + // wasm: declare void @natural_align_1({{.*}}byval([2 x i8]) align 1{{.*}}) // x86_64-linux: declare void @natural_align_1(i16) // x86_64-windows: declare void @natural_align_1(i16) - // i686-linux: declare void @natural_align_1({{.*}}byval(%NaturalAlign1) align 4{{.*}}) + // i686-linux: declare void @natural_align_1({{.*}}byval([2 x i8]) align 4{{.*}}) - // i686-windows: declare void @natural_align_1({{.*}}byval(%NaturalAlign1) align 4{{.*}}) + // i686-windows: declare void @natural_align_1({{.*}}byval([2 x i8]) align 4{{.*}}) fn natural_align_1(x: NaturalAlign1); - // m68k: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 2{{.*}}) + // m68k: declare void @natural_align_2({{.*}}byval([34 x i8]) align 2{{.*}}) - // wasm: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 2{{.*}}) + // wasm: declare void @natural_align_2({{.*}}byval([34 x i8]) align 2{{.*}}) - // x86_64-linux: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 2{{.*}}) + // x86_64-linux: declare void @natural_align_2({{.*}}byval([34 x i8]) align 2{{.*}}) // x86_64-windows: declare void @natural_align_2( // x86_64-windows-NOT: byval // x86_64-windows-SAME: align 2{{.*}}) - // i686-linux: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 4{{.*}}) + // i686-linux: declare void @natural_align_2({{.*}}byval([34 x i8]) align 4{{.*}}) - // i686-windows: declare void @natural_align_2({{.*}}byval(%NaturalAlign2) align 4{{.*}}) + // i686-windows: declare void @natural_align_2({{.*}}byval([34 x i8]) align 4{{.*}}) fn natural_align_2(x: NaturalAlign2); - // m68k: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}}) + // m68k: declare void @force_align_4({{.*}}byval([20 x i8]) align 4{{.*}}) - // wasm: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}}) + // wasm: declare void @force_align_4({{.*}}byval([20 x i8]) align 4{{.*}}) - // x86_64-linux: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}}) + // x86_64-linux: declare void @force_align_4({{.*}}byval([20 x i8]) align 4{{.*}}) // x86_64-windows: declare void @force_align_4( // x86_64-windows-NOT: byval // x86_64-windows-SAME: align 4{{.*}}) - // i686-linux: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}}) + // i686-linux: declare void @force_align_4({{.*}}byval([20 x i8]) align 4{{.*}}) - // i686-windows: declare void @force_align_4({{.*}}byval(%ForceAlign4) align 4{{.*}}) + // i686-windows: declare void @force_align_4({{.*}}byval([20 x i8]) align 4{{.*}}) fn force_align_4(x: ForceAlign4); - // m68k: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 4{{.*}}) + // m68k: declare void @natural_align_8({{.*}}byval([24 x i8]) align 4{{.*}}) - // wasm: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 8{{.*}}) + // wasm: declare void @natural_align_8({{.*}}byval([24 x i8]) align 8{{.*}}) - // x86_64-linux: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 8{{.*}}) + // x86_64-linux: declare void @natural_align_8({{.*}}byval([24 x i8]) align 8{{.*}}) // x86_64-windows: declare void @natural_align_8( // x86_64-windows-NOT: byval // x86_64-windows-SAME: align 8{{.*}}) - // i686-linux: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 4{{.*}}) + // i686-linux: declare void @natural_align_8({{.*}}byval([24 x i8]) align 4{{.*}}) - // i686-windows: declare void @natural_align_8({{.*}}byval(%NaturalAlign8) align 4{{.*}}) + // i686-windows: declare void @natural_align_8({{.*}}byval([24 x i8]) align 4{{.*}}) fn natural_align_8(x: NaturalAlign8); - // m68k: declare void @force_align_8({{.*}}byval(%ForceAlign8) align 8{{.*}}) + // m68k: declare void @force_align_8({{.*}}byval([24 x i8]) align 8{{.*}}) - // wasm: declare void @force_align_8({{.*}}byval(%ForceAlign8) align 8{{.*}}) + // wasm: declare void @force_align_8({{.*}}byval([24 x i8]) align 8{{.*}}) - // x86_64-linux: declare void @force_align_8({{.*}}byval(%ForceAlign8) align 8{{.*}}) + // x86_64-linux: declare void @force_align_8({{.*}}byval([24 x i8]) align 8{{.*}}) // x86_64-windows: declare void @force_align_8( // x86_64-windows-NOT: byval // x86_64-windows-SAME: align 8{{.*}}) - // i686-linux: declare void @force_align_8({{.*}}byval(%ForceAlign8) align 4{{.*}}) + // i686-linux: declare void @force_align_8({{.*}}byval([24 x i8]) align 4{{.*}}) // i686-windows: declare void @force_align_8( // i686-windows-NOT: byval // i686-windows-SAME: align 8{{.*}}) fn force_align_8(x: ForceAlign8); - // m68k: declare void @lower_fa8({{.*}}byval(%LowerFA8) align 4{{.*}}) + // m68k: declare void @lower_fa8({{.*}}byval([24 x i8]) align 4{{.*}}) - // wasm: declare void @lower_fa8({{.*}}byval(%LowerFA8) align 8{{.*}}) + // wasm: declare void @lower_fa8({{.*}}byval([24 x i8]) align 8{{.*}}) - // x86_64-linux: declare void @lower_fa8({{.*}}byval(%LowerFA8) align 8{{.*}}) + // x86_64-linux: declare void @lower_fa8({{.*}}byval([24 x i8]) align 8{{.*}}) // x86_64-windows: declare void @lower_fa8( // x86_64-windows-NOT: byval // x86_64-windows-SAME: align 8{{.*}}) - // i686-linux: declare void @lower_fa8({{.*}}byval(%LowerFA8) align 4{{.*}}) + // i686-linux: declare void @lower_fa8({{.*}}byval([24 x i8]) align 4{{.*}}) - // i686-windows: declare void @lower_fa8({{.*}}byval(%LowerFA8) align 4{{.*}}) + // i686-windows: declare void @lower_fa8({{.*}}byval([24 x i8]) align 4{{.*}}) fn lower_fa8(x: LowerFA8); - // m68k: declare void @wrapped_fa8({{.*}}byval(%WrappedFA8) align 8{{.*}}) + // m68k: declare void @wrapped_fa8({{.*}}byval([24 x i8]) align 8{{.*}}) - // wasm: declare void @wrapped_fa8({{.*}}byval(%WrappedFA8) align 8{{.*}}) + // wasm: declare void @wrapped_fa8({{.*}}byval([24 x i8]) align 8{{.*}}) - // x86_64-linux: declare void @wrapped_fa8({{.*}}byval(%WrappedFA8) align 8{{.*}}) + // x86_64-linux: declare void @wrapped_fa8({{.*}}byval([24 x i8]) align 8{{.*}}) // x86_64-windows: declare void @wrapped_fa8( // x86_64-windows-NOT: byval // x86_64-windows-SAME: align 8{{.*}}) - // i686-linux: declare void @wrapped_fa8({{.*}}byval(%WrappedFA8) align 4{{.*}}) + // i686-linux: declare void @wrapped_fa8({{.*}}byval([24 x i8]) align 4{{.*}}) // i686-windows: declare void @wrapped_fa8( // i686-windows-NOT: byval // i686-windows-SAME: align 8{{.*}}) fn wrapped_fa8(x: WrappedFA8); - // m68k: declare void @transparent_fa8({{.*}}byval(%TransparentFA8) align 8{{.*}}) + // m68k: declare void @transparent_fa8({{.*}}byval([24 x i8]) align 8{{.*}}) - // wasm: declare void @transparent_fa8({{.*}}byval(%TransparentFA8) align 8{{.*}}) + // wasm: declare void @transparent_fa8({{.*}}byval([24 x i8]) align 8{{.*}}) - // x86_64-linux: declare void @transparent_fa8({{.*}}byval(%TransparentFA8) align 8{{.*}}) + // x86_64-linux: declare void @transparent_fa8({{.*}}byval([24 x i8]) align 8{{.*}}) // x86_64-windows: declare void @transparent_fa8( // x86_64-windows-NOT: byval // x86_64-windows-SAME: align 8{{.*}}) - // i686-linux: declare void @transparent_fa8({{.*}}byval(%TransparentFA8) align 4{{.*}}) + // i686-linux: declare void @transparent_fa8({{.*}}byval([24 x i8]) align 4{{.*}}) // i686-windows: declare void @transparent_fa8( // i686-windows-NOT: byval // i686-windows-SAME: align 8{{.*}}) fn transparent_fa8(x: TransparentFA8); - // m68k: declare void @force_align_16({{.*}}byval(%ForceAlign16) align 16{{.*}}) + // m68k: declare void @force_align_16({{.*}}byval([80 x i8]) align 16{{.*}}) - // wasm: declare void @force_align_16({{.*}}byval(%ForceAlign16) align 16{{.*}}) + // wasm: declare void @force_align_16({{.*}}byval([80 x i8]) align 16{{.*}}) - // x86_64-linux: declare void @force_align_16({{.*}}byval(%ForceAlign16) align 16{{.*}}) + // x86_64-linux: declare void @force_align_16({{.*}}byval([80 x i8]) align 16{{.*}}) // x86_64-windows: declare void @force_align_16( // x86_64-windows-NOT: byval // x86_64-windows-SAME: align 16{{.*}}) - // i686-linux: declare void @force_align_16({{.*}}byval(%ForceAlign16) align 4{{.*}}) + // i686-linux: declare void @force_align_16({{.*}}byval([80 x i8]) align 4{{.*}}) // i686-windows: declare void @force_align_16( // i686-windows-NOT: byval diff --git a/tests/codegen/align-enum.rs b/tests/codegen/align-enum.rs index 17bf2cf7256..b40168d77a4 100644 --- a/tests/codegen/align-enum.rs +++ b/tests/codegen/align-enum.rs @@ -8,7 +8,6 @@ pub enum Align64 { A(u32), B(u32), } -// CHECK: %Align64 = type { i32, [15 x i32] } pub struct Nested64 { a: u8, diff --git a/tests/codegen/align-struct.rs b/tests/codegen/align-struct.rs index 31859152830..dbbb85bee6f 100644 --- a/tests/codegen/align-struct.rs +++ b/tests/codegen/align-struct.rs @@ -5,7 +5,6 @@ #[repr(align(64))] pub struct Align64(i32); -// CHECK: %Align64 = type { i32, [15 x i32] } pub struct Nested64 { a: Align64, @@ -13,19 +12,16 @@ pub struct Nested64 { c: i32, d: i8, } -// CHECK: %Nested64 = type { %Align64, i32, i32, i8, [55 x i8] } pub enum Enum4 { A(i32), B(i32), } -// No Aggregate type, and hence nothing in LLVM IR. pub enum Enum64 { A(Align64), B(i32), } -// CHECK: %Enum64 = type { i32, [31 x i32] } // CHECK-LABEL: @align64 #[no_mangle] diff --git a/tests/codegen/function-arguments-noopt.rs b/tests/codegen/function-arguments-noopt.rs index e99ceddfb72..0d42915893b 100644 --- a/tests/codegen/function-arguments-noopt.rs +++ b/tests/codegen/function-arguments-noopt.rs @@ -42,7 +42,7 @@ pub fn borrow_call(x: &i32, f: fn(&i32) -> &i32) -> &i32 { f(x) } -// CHECK: void @struct_(ptr sret(%S) align 4{{( %_0)?}}, ptr align 4 %x) +// CHECK: void @struct_(ptr sret([32 x i8]) align 4{{( %_0)?}}, ptr align 4 %x) #[no_mangle] pub fn struct_(x: S) -> S { x @@ -51,7 +51,7 @@ pub fn struct_(x: S) -> S { // CHECK-LABEL: @struct_call #[no_mangle] pub fn struct_call(x: S, f: fn(S) -> S) -> S { - // CHECK: call void %f(ptr sret(%S) align 4{{( %_0)?}}, ptr align 4 %{{.+}}) + // CHECK: call void %f(ptr sret([32 x i8]) align 4{{( %_0)?}}, ptr align 4 %{{.+}}) f(x) } diff --git a/tests/codegen/function-arguments.rs b/tests/codegen/function-arguments.rs index e6e2f645714..468ec0a7753 100644 --- a/tests/codegen/function-arguments.rs +++ b/tests/codegen/function-arguments.rs @@ -198,7 +198,7 @@ pub fn notunpin_box(x: Box<NotUnpin>) -> Box<NotUnpin> { x } -// CHECK: @struct_return(ptr noalias nocapture noundef sret(%S) align 4 dereferenceable(32){{( %_0)?}}) +// CHECK: @struct_return(ptr noalias nocapture noundef sret([32 x i8]) align 4 dereferenceable(32){{( %_0)?}}) #[no_mangle] pub fn struct_return() -> S { S { diff --git a/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs b/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs index 3c895eb9531..c9be4f6d383 100644 --- a/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs +++ b/tests/codegen/loongarch-abi/loongarch64-lp64d-abi.rs @@ -1,8 +1,14 @@ -//@ compile-flags: -C no-prepopulate-passes -//@ only-loongarch64 -//@ only-linux +//@ compile-flags: -O -C no-prepopulate-passes --target loongarch64-unknown-linux-gnu +//@ needs-llvm-components: loongarch +#![feature(no_core, lang_items)] #![crate_type = "lib"] +#![no_std] +#![no_core] + +#[lang="sized"] trait Sized { } +#[lang="freeze"] trait Freeze { } +#[lang="copy"] trait Copy { } // CHECK: define void @f_fpr_tracking(double %0, double %1, double %2, double %3, double %4, double %5, double %6, double %7, i8 noundef zeroext %i) #[no_mangle] @@ -254,7 +260,7 @@ pub struct IntDoubleInt { #[no_mangle] pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {} -// CHECK: define void @f_ret_int_double_int_s(ptr noalias nocapture noundef sret(%IntDoubleInt) align 8 dereferenceable(24) %_0) +// CHECK: define void @f_ret_int_double_int_s(ptr noalias nocapture noundef sret([24 x i8]) align 8 dereferenceable(24) %_0) #[no_mangle] pub extern "C" fn f_ret_int_double_int_s() -> IntDoubleInt { IntDoubleInt { a: 1, b: 2., c: 3 } diff --git a/tests/codegen/mem-replace-big-type.rs b/tests/codegen/mem-replace-big-type.rs index c71cbbd08f9..d5eadda4469 100644 --- a/tests/codegen/mem-replace-big-type.rs +++ b/tests/codegen/mem-replace-big-type.rs @@ -23,7 +23,7 @@ pub fn replace_big(dst: &mut Big, src: Big) -> Big { // CHECK-NOT: call void @llvm.memcpy // For a large type, we expect exactly three `memcpy`s -// CHECK-LABEL: define internal void @{{.+}}mem{{.+}}replace{{.+}}sret(%Big) +// CHECK-LABEL: define internal void @{{.+}}mem{{.+}}replace{{.+}}sret([56 x i8]) // CHECK-NOT: call void @llvm.memcpy // CHECK: call void @llvm.memcpy.{{.+}}(ptr align 8 %result, ptr align 8 %dest, i{{.*}} 56, i1 false) // CHECK-NOT: call void @llvm.memcpy diff --git a/tests/codegen/repr/transparent-imm-array.rs b/tests/codegen/repr/transparent-imm-array.rs index 842e36ca13d..917a2c6ef52 100644 --- a/tests/codegen/repr/transparent-imm-array.rs +++ b/tests/codegen/repr/transparent-imm-array.rs @@ -1,22 +1,40 @@ -//@ revisions: arm mips thumb wasm32 -//@ compile-flags: -C no-prepopulate-passes -// -//@[arm] only-arm -//@[mips] only-mips -//@[thumb] only-thumb -//@[wasm32] only-wasm32 -//@ ignore-emscripten +//@ revisions: arm-linux arm-android armv7-linux armv7-android mips thumb sparc +//@ compile-flags: -O -C no-prepopulate-passes + +//@[arm-linux] compile-flags: --target arm-unknown-linux-gnueabi +//@[arm-linux] needs-llvm-components: arm +//@[arm-android] compile-flags: --target arm-linux-androideabi +//@[arm-android] needs-llvm-components: arm +//@[armv7-linux] compile-flags: --target armv7-unknown-linux-gnueabi +//@[armv7-linux] needs-llvm-components: arm +//@[armv7-android] compile-flags: --target armv7-linux-androideabi +//@[armv7-android] needs-llvm-components: arm +//@[mips] compile-flags: --target mips-unknown-linux-gnu +//@[mips] needs-llvm-components: mips +//@[thumb] compile-flags: --target thumbv7neon-linux-androideabi +//@[thumb] needs-llvm-components: arm +//@[sparc] compile-flags: --target sparc-unknown-linux-gnu +//@[sparc] needs-llvm-components: sparc + // See ./transparent.rs // Some platforms pass large aggregates using immediate arrays in LLVMIR // Other platforms pass large aggregates using struct pointer in LLVMIR // This covers the "immediate array" case. -#![feature(transparent_unions)] +#![feature(no_core, lang_items, transparent_unions)] +#![crate_type = "lib"] +#![no_std] +#![no_core] + +#[lang="sized"] trait Sized { } +#[lang="freeze"] trait Freeze { } +#[lang="copy"] trait Copy { } -#![crate_type="lib"] +impl Copy for [u32; 16] {} +impl Copy for BigS {} +impl Copy for BigU {} -#[derive(Clone, Copy)] #[repr(C)] pub struct BigS([u32; 16]); @@ -33,24 +51,23 @@ pub enum TeBigS { Variant(BigS), } -// CHECK: define void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], [16 x i32] +// CHECK: define void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGS_RET_ATTRS2:.*]], [16 x i32] #[no_mangle] pub extern fn test_BigS(_: BigS) -> BigS { loop {} } -// CHECK: define void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], [16 x i32] +// CHECK: define void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [16 x i32] #[no_mangle] pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } -// CHECK: define void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], [16 x i32] +// CHECK: define void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [16 x i32] #[no_mangle] pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } -// CHECK: define void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], [16 x i32] +// CHECK: define void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [16 x i32] #[no_mangle] pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } -#[derive(Clone, Copy)] #[repr(C)] pub union BigU { foo: [u32; 16], @@ -69,18 +86,18 @@ pub enum TeBigU { Variant(BigU), } -// CHECK: define void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], [16 x i32] +// CHECK: define void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], [16 x i32] #[no_mangle] pub extern fn test_BigU(_: BigU) -> BigU { loop {} } -// CHECK: define void @test_TsBigU(ptr [[BIGU_RET_ATTRS1]] sret(%TsBigU) [[BIGU_RET_ATTRS2]], [16 x i32] +// CHECK: define void @test_TsBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [16 x i32] #[no_mangle] pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } -// CHECK: define void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2]], [16 x i32] +// CHECK: define void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [16 x i32] #[no_mangle] pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } -// CHECK: define void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2]], [16 x i32] +// CHECK: define void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [16 x i32] #[no_mangle] pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/tests/codegen/repr/transparent-mips64.rs b/tests/codegen/repr/transparent-mips64.rs index 55090e6bd80..ebed8d7989f 100644 --- a/tests/codegen/repr/transparent-mips64.rs +++ b/tests/codegen/repr/transparent-mips64.rs @@ -1,15 +1,26 @@ -//@ compile-flags: -C no-prepopulate-passes -// +//@ revisions: mips64 mips64el +//@ compile-flags: -O -C no-prepopulate-passes + +//@[mips64] compile-flags: --target mips64-unknown-linux-gnuabi64 +//@[mips64] needs-llvm-components: mips +//@[mips64el] compile-flags: --target mips64el-unknown-linux-gnuabi64 +//@[mips64el] needs-llvm-components: mips -//@ only-mips64 // See ./transparent.rs -#![feature(transparent_unions)] +#![feature(no_core, lang_items, transparent_unions)] +#![crate_type = "lib"] +#![no_std] +#![no_core] -#![crate_type="lib"] +#[lang="sized"] trait Sized { } +#[lang="freeze"] trait Freeze { } +#[lang="copy"] trait Copy { } +impl Copy for [u32; 16] {} +impl Copy for BigS {} +impl Copy for BigU {} -#[derive(Clone, Copy)] #[repr(C)] pub struct BigS([u32; 16]); @@ -26,24 +37,23 @@ pub enum TeBigS { Variant(BigS), } -// CHECK: define void @test_BigS(%BigS* [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], [8 x i64] +// CHECK: define void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGS_RET_ATTRS2:.*]], [8 x i64] #[no_mangle] pub extern fn test_BigS(_: BigS) -> BigS { loop {} } -// CHECK: define void @test_TsBigS(%TsBigS* [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], [8 x i64] +// CHECK: define void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [8 x i64] #[no_mangle] pub extern fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } -// CHECK: define void @test_TuBigS(%TuBigS* [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], [8 x i64] +// CHECK: define void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [8 x i64] #[no_mangle] pub extern fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } -// CHECK: define void @test_TeBigS(%"TeBigS::Variant"* [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], [8 x i64] +// CHECK: define void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], [8 x i64] #[no_mangle] pub extern fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } -#[derive(Clone, Copy)] #[repr(C)] pub union BigU { foo: [u32; 16], @@ -62,18 +72,18 @@ pub enum TeBigU { Variant(BigU), } -// CHECK: define void @test_BigU(%BigU* [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], [8 x i64] +// CHECK: define void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], [8 x i64] #[no_mangle] pub extern fn test_BigU(_: BigU) -> BigU { loop {} } -// CHECK: define void @test_TsBigU(%TsBigU* [[BIGU_RET_ATTRS1]] sret(%TsBigU) [[BIGU_RET_ATTRS2]], [8 x i64] +// CHECK: define void @test_TsBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [8 x i64] #[no_mangle] pub extern fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } -// CHECK: define void @test_TuBigU(%TuBigU* [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2]], [8 x i64] +// CHECK: define void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [8 x i64] #[no_mangle] pub extern fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } -// CHECK: define void @test_TeBigU(%"TeBigU::Variant"* [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2]], [8 x i64] +// CHECK: define void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2]], [8 x i64] #[no_mangle] pub extern fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/tests/codegen/repr/transparent-sparc64.rs b/tests/codegen/repr/transparent-sparc64.rs new file mode 100644 index 00000000000..7005a07f554 --- /dev/null +++ b/tests/codegen/repr/transparent-sparc64.rs @@ -0,0 +1,101 @@ +//@ compile-flags: -O -C no-prepopulate-passes --target sparc64-unknown-linux-gnu +//@ needs-llvm-components: sparc + +// See ./transparent.rs + +#![feature(no_core, lang_items, transparent_unions)] +#![crate_type = "lib"] +#![no_std] +#![no_core] + +#[lang="sized"] trait Sized { } +#[lang="freeze"] trait Freeze { } +#[lang="copy"] trait Copy { } + +impl Copy for [u32; 16] {} +impl Copy for BigS {} +impl Copy for BigU {} + + +#[repr(C)] +pub struct BigS([u32; 16]); + +#[repr(transparent)] +pub struct TsBigS(BigS); + +#[repr(transparent)] +pub union TuBigS { + field: BigS, +} + +#[repr(transparent)] +pub enum TeBigS { + Variant(BigS), +} + +// CHECK: define{{.*}}void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGS_RET_ATTRS2:.*]], ptr +// CHECK-NOT: byval +// CHECK-SAME: %{{[0-9a-z_]+}}) +#[no_mangle] +pub extern "C" fn test_BigS(_: BigS) -> BigS { loop {} } + +// CHECK: define{{.*}}void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr +// CHECK-NOT: byval +// CHECK-SAME: %{{[0-9a-z_]+}}) +#[no_mangle] +pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } + +// CHECK: define{{.*}}void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr +// CHECK-NOT: byval +// CHECK-SAME: %{{[0-9a-z_]+}}) +#[no_mangle] +pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } + +// CHECK: define{{.*}}void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr +// CHECK-NOT: byval +// CHECK-SAME: %{{[0-9a-z_]+}}) +#[no_mangle] +pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } + + +#[repr(C)] +pub union BigU { + foo: [u32; 16], +} + +#[repr(transparent)] +pub struct TsBigU(BigU); + +#[repr(transparent)] +pub union TuBigU { + field: BigU, +} + +#[repr(transparent)] +pub enum TeBigU { + Variant(BigU), +} + +// CHECK: define{{.*}}void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr +// CHECK-NOT: byval +// CHECK-SAME: %{{[0-9a-z_]+}}) +#[no_mangle] +pub extern "C" fn test_BigU(_: BigU) -> BigU { loop {} } + +// CHECK: define{{.*}}void @test_TsBigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr +// CHECK-NOT: byval +// CHECK-SAME: %{{[0-9a-z_]+}}) +#[no_mangle] +pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } + +// CHECK: define{{.*}}void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr +// CHECK-NOT: byval +// CHECK-SAME: %{{[0-9a-z_]+}}) +#[no_mangle] +pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } + +// CHECK: define{{.*}}void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr +// CHECK-NOT: byval +// CHECK-SAME: %{{[0-9a-z_]+}}) +#[no_mangle] +pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/tests/codegen/repr/transparent-struct-ptr.rs b/tests/codegen/repr/transparent-struct-ptr.rs index ff531029e04..26f0120752f 100644 --- a/tests/codegen/repr/transparent-struct-ptr.rs +++ b/tests/codegen/repr/transparent-struct-ptr.rs @@ -1,23 +1,36 @@ -//@ revisions: x32 x64 sparc sparc64 +//@ revisions: i686-linux i686-freebsd x64-linux x64-apple wasm32 //@ compile-flags: -O -C no-prepopulate-passes -// -//@[x32] only-x86 -//@[x64] only-x86_64 -//@[sparc] only-sparc -//@[sparc64] only-sparc64 -//@ ignore-windows + +//@[i686-linux] compile-flags: --target i686-unknown-linux-gnu +//@[i686-linux] needs-llvm-components: x86 +//@[i686-freebsd] compile-flags: --target i686-unknown-freebsd +//@[i686-freebsd] needs-llvm-components: x86 +//@[x64-linux] compile-flags: --target x86_64-unknown-linux-gnu +//@[x64-linux] needs-llvm-components: x86 +//@[x64-apple] compile-flags: --target x86_64-apple-darwin +//@[x64-apple] needs-llvm-components: x86 +//@[wasm32] compile-flags: --target wasm32-wasi +//@[wasm32] needs-llvm-components: webassembly + // See ./transparent.rs // Some platforms pass large aggregates using immediate arrays in LLVMIR // Other platforms pass large aggregates using struct pointer in LLVMIR // This covers the "struct pointer" case. +#![feature(no_core, lang_items, transparent_unions)] +#![crate_type = "lib"] +#![no_std] +#![no_core] -#![feature(transparent_unions)] +#[lang="sized"] trait Sized { } +#[lang="freeze"] trait Freeze { } +#[lang="copy"] trait Copy { } -#![crate_type="lib"] +impl Copy for [u32; 16] {} +impl Copy for BigS {} +impl Copy for BigU {} -#[derive(Clone, Copy)] #[repr(C)] pub struct BigS([u32; 16]); @@ -34,24 +47,23 @@ pub enum TeBigS { Variant(BigS), } -// CHECK: define{{.*}}void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret(%BigS) [[BIGS_RET_ATTRS2:.*]], ptr [[BIGS_ARG_ATTRS1:.*]] byval(%BigS) [[BIGS_ARG_ATTRS2:.*]]) +// CHECK: define{{.*}}void @test_BigS(ptr [[BIGS_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGS_RET_ATTRS2:.*]], ptr [[BIGS_ARG_ATTRS1:.*]] byval([64 x i8]) [[BIGS_ARG_ATTRS2:.*]]) #[no_mangle] pub extern "C" fn test_BigS(_: BigS) -> BigS { loop {} } -// CHECK: define{{.*}}void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TsBigS) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval(%TsBigS) [[BIGS_ARG_ATTRS2:.*]]) +// CHECK: define{{.*}}void @test_TsBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval([64 x i8]) [[BIGS_ARG_ATTRS2:.*]]) #[no_mangle] pub extern "C" fn test_TsBigS(_: TsBigS) -> TsBigS { loop {} } -// CHECK: define{{.*}}void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret(%TuBigS) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval(%TuBigS) [[BIGS_ARG_ATTRS2:.*]]) +// CHECK: define{{.*}}void @test_TuBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval([64 x i8]) [[BIGS_ARG_ATTRS2:.*]]) #[no_mangle] pub extern "C" fn test_TuBigS(_: TuBigS) -> TuBigS { loop {} } -// CHECK: define{{.*}}void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret(%"TeBigS::Variant") [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval(%"TeBigS::Variant") [[BIGS_ARG_ATTRS2]]) +// CHECK: define{{.*}}void @test_TeBigS(ptr [[BIGS_RET_ATTRS1]] sret([64 x i8]) [[BIGS_RET_ATTRS2]], ptr [[BIGS_ARG_ATTRS1]] byval([64 x i8]) [[BIGS_ARG_ATTRS2]]) #[no_mangle] pub extern "C" fn test_TeBigS(_: TeBigS) -> TeBigS { loop {} } -#[derive(Clone, Copy)] #[repr(C)] pub union BigU { foo: [u32; 16], @@ -70,18 +82,18 @@ pub enum TeBigU { Variant(BigU), } -// CHECK: define{{.*}}void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret(%BigU) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1:.*]] byval(%BigU) [[BIGU_ARG_ATTRS2:.*]]) +// CHECK: define{{.*}}void @test_BigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1:.*]] byval([64 x i8]) [[BIGU_ARG_ATTRS2:.*]]) #[no_mangle] pub extern "C" fn test_BigU(_: BigU) -> BigU { loop {} } -// CHECK: define{{.*}}void @test_TsBigU(ptr [[BIGU_RET_ATTRS1:.*]] sret(%TsBigU) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval(%TsBigU) [[BIGU_ARG_ATTRS2]]) +// CHECK: define{{.*}}void @test_TsBigU(ptr [[BIGU_RET_ATTRS1:.*]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval([64 x i8]) [[BIGU_ARG_ATTRS2]]) #[no_mangle] pub extern "C" fn test_TsBigU(_: TsBigU) -> TsBigU { loop {} } -// CHECK: define{{.*}}void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret(%TuBigU) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval(%TuBigU) [[BIGU_ARG_ATTRS2]]) +// CHECK: define{{.*}}void @test_TuBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval([64 x i8]) [[BIGU_ARG_ATTRS2]]) #[no_mangle] pub extern "C" fn test_TuBigU(_: TuBigU) -> TuBigU { loop {} } -// CHECK: define{{.*}}void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret(%"TeBigU::Variant") [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval(%"TeBigU::Variant") [[BIGU_ARG_ATTRS2]]) +// CHECK: define{{.*}}void @test_TeBigU(ptr [[BIGU_RET_ATTRS1]] sret([64 x i8]) [[BIGU_RET_ATTRS2:.*]], ptr [[BIGU_ARG_ATTRS1]] byval([64 x i8]) [[BIGU_ARG_ATTRS2]]) #[no_mangle] pub extern "C" fn test_TeBigU(_: TeBigU) -> TeBigU { loop {} } diff --git a/tests/codegen/repr/transparent-sysv64.rs b/tests/codegen/repr/transparent-sysv64.rs index 10524adf7d7..1c7bca7ee40 100644 --- a/tests/codegen/repr/transparent-sysv64.rs +++ b/tests/codegen/repr/transparent-sysv64.rs @@ -1,8 +1,21 @@ -//@ only-x86_64 - -//@ compile-flags: -C no-prepopulate-passes - -#![crate_type="lib"] +//@ revisions: linux apple windows +//@ compile-flags: -O -C no-prepopulate-passes + +//@[linux] compile-flags: --target x86_64-unknown-linux-gnu +//@[linux] needs-llvm-components: x86 +//@[apple] compile-flags: --target x86_64-apple-darwin +//@[apple] needs-llvm-components: x86 +//@[windows] compile-flags: --target x86_64-pc-windows-msvc +//@[windows] needs-llvm-components: x86 + +#![feature(no_core, lang_items)] +#![crate_type = "lib"] +#![no_std] +#![no_core] + +#[lang="sized"] trait Sized { } +#[lang="freeze"] trait Freeze { } +#[lang="copy"] trait Copy { } #[repr(C)] pub struct Rgb8 { r: u8, g: u8, b: u8 } diff --git a/tests/codegen/simd/unpadded-simd.rs b/tests/codegen/simd/unpadded-simd.rs index 797bca38ffa..66d9298c006 100644 --- a/tests/codegen/simd/unpadded-simd.rs +++ b/tests/codegen/simd/unpadded-simd.rs @@ -3,7 +3,7 @@ // See #87254. #![crate_type = "lib"] -#![feature(repr_simd)] +#![feature(repr_simd, abi_unadjusted)] #[derive(Copy, Clone)] #[repr(simd)] @@ -14,6 +14,6 @@ pub struct int16x4x2_t(pub int16x4_t, pub int16x4_t); // CHECK: %int16x4x2_t = type { <4 x i16>, <4 x i16> } #[no_mangle] -fn takes_int16x4x2_t(t: int16x4x2_t) -> int16x4x2_t { +extern "unadjusted" fn takes_int16x4x2_t(t: int16x4x2_t) -> int16x4x2_t { t } diff --git a/tests/run-make/min-global-align/min_global_align.rs b/tests/run-make/min-global-align/min_global_align.rs index 135792e9372..cd1ef8cb351 100644 --- a/tests/run-make/min-global-align/min_global_align.rs +++ b/tests/run-make/min-global-align/min_global_align.rs @@ -1,4 +1,4 @@ -#![feature(no_core, lang_items)] +#![feature(no_core, lang_items, freeze_impls)] #![crate_type = "rlib"] #![no_core] diff --git a/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs b/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs index 0663ed5fc81..7d9133b85a6 100644 --- a/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs +++ b/tests/rustdoc/auto-trait-bounds-by-associated-type-50159.rs @@ -1,5 +1,5 @@ // https://github.com/rust-lang/rust/issues/50159 -#![crate_name="foo"] +#![crate_name = "foo"] pub trait Signal { type Item; @@ -9,7 +9,10 @@ pub trait Signal2 { type Item2; } -impl<B, C> Signal2 for B where B: Signal<Item = C> { +impl<B, C> Signal2 for B +where + B: Signal<Item = C>, +{ type Item2 = C; } @@ -17,7 +20,7 @@ impl<B, C> Signal2 for B where B: Signal<Item = C> { // @has - '//h3[@class="code-header"]' 'impl<B> Send for Switch<B>where <B as Signal>::Item: Send' // @has - '//h3[@class="code-header"]' 'impl<B> Sync for Switch<B>where <B as Signal>::Item: Sync' // @count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 -// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 5 +// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6 pub struct Switch<B: Signal> { pub inner: <B as Signal2>::Item2, } diff --git a/tests/rustdoc/empty-section.rs b/tests/rustdoc/empty-section.rs index d8241ab96f6..0d6afb0e444 100644 --- a/tests/rustdoc/empty-section.rs +++ b/tests/rustdoc/empty-section.rs @@ -1,6 +1,5 @@ #![crate_name = "foo"] - -#![feature(negative_impls)] +#![feature(negative_impls, freeze_impls, freeze)] pub struct Foo; @@ -8,6 +7,7 @@ pub struct Foo; // @!hasraw - 'Auto Trait Implementations' impl !Send for Foo {} impl !Sync for Foo {} +impl !std::marker::Freeze for Foo {} impl !std::marker::Unpin for Foo {} impl !std::panic::RefUnwindSafe for Foo {} impl !std::panic::UnwindSafe for Foo {} diff --git a/tests/rustdoc/synthetic_auto/basic.rs b/tests/rustdoc/synthetic_auto/basic.rs index 043ac241488..16b8cce490c 100644 --- a/tests/rustdoc/synthetic_auto/basic.rs +++ b/tests/rustdoc/synthetic_auto/basic.rs @@ -2,7 +2,7 @@ // @has - '//h3[@class="code-header"]' 'impl<T> Send for Foo<T>where T: Send' // @has - '//h3[@class="code-header"]' 'impl<T> Sync for Foo<T>where T: Sync' // @count - '//*[@id="implementations-list"]//*[@class="impl"]' 0 -// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 5 +// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 6 pub struct Foo<T> { field: T, } diff --git a/tests/rustdoc/synthetic_auto/manual.rs b/tests/rustdoc/synthetic_auto/manual.rs index 7fc8447df3e..692d68294a7 100644 --- a/tests/rustdoc/synthetic_auto/manual.rs +++ b/tests/rustdoc/synthetic_auto/manual.rs @@ -6,7 +6,7 @@ // 'impl<T> Send for Foo<T>' // // @count - '//*[@id="trait-implementations-list"]//*[@class="impl"]' 1 -// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 4 +// @count - '//*[@id="synthetic-implementations-list"]//*[@class="impl"]' 5 pub struct Foo<T> { field: T, } diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.rs b/tests/ui-fulldeps/internal-lints/diagnostics.rs index f73fdc0882f..1d7417be58c 100644 --- a/tests/ui-fulldeps/internal-lints/diagnostics.rs +++ b/tests/ui-fulldeps/internal-lints/diagnostics.rs @@ -14,8 +14,8 @@ extern crate rustc_session; extern crate rustc_span; use rustc_errors::{ - AddToDiagnostic, DecorateLint, Diag, DiagCtxt, DiagInner, DiagMessage, EmissionGuarantee, - IntoDiagnostic, Level, SubdiagMessageOp, + Diag, DiagCtxt, DiagInner, DiagMessage, Diagnostic, EmissionGuarantee, Level, LintDiagnostic, + SubdiagMessageOp, SubdiagMessage, Subdiagnostic, }; use rustc_macros::{Diagnostic, Subdiagnostic}; use rustc_span::Span; @@ -36,27 +36,27 @@ struct Note { span: Span, } -pub struct UntranslatableInIntoDiagnostic; +pub struct UntranslatableInDiagnostic; -impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for UntranslatableInIntoDiagnostic { - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { +impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for UntranslatableInDiagnostic { + fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { Diag::new(dcx, level, "untranslatable diagnostic") //~^ ERROR diagnostics should be created using translatable messages } } -pub struct TranslatableInIntoDiagnostic; +pub struct TranslatableInDiagnostic; -impl<'a, G: EmissionGuarantee> IntoDiagnostic<'a, G> for TranslatableInIntoDiagnostic { - fn into_diagnostic(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { +impl<'a, G: EmissionGuarantee> Diagnostic<'a, G> for TranslatableInDiagnostic { + fn into_diag(self, dcx: &'a DiagCtxt, level: Level) -> Diag<'a, G> { Diag::new(dcx, level, crate::fluent_generated::no_crate_example) } } -pub struct UntranslatableInAddToDiagnostic; +pub struct UntranslatableInAddtoDiag; -impl AddToDiagnostic for UntranslatableInAddToDiagnostic { - fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>( +impl Subdiagnostic for UntranslatableInAddtoDiag { + fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>( self, diag: &mut Diag<'_, G>, f: F, @@ -66,10 +66,10 @@ impl AddToDiagnostic for UntranslatableInAddToDiagnostic { } } -pub struct TranslatableInAddToDiagnostic; +pub struct TranslatableInAddtoDiag; -impl AddToDiagnostic for TranslatableInAddToDiagnostic { - fn add_to_diagnostic_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>( +impl Subdiagnostic for TranslatableInAddtoDiag { + fn add_to_diag_with<G: EmissionGuarantee, F: SubdiagMessageOp<G>>( self, diag: &mut Diag<'_, G>, f: F, @@ -78,9 +78,9 @@ impl AddToDiagnostic for TranslatableInAddToDiagnostic { } } -pub struct UntranslatableInDecorateLint; +pub struct UntranslatableInLintDiagnostic; -impl<'a> DecorateLint<'a, ()> for UntranslatableInDecorateLint { +impl<'a> LintDiagnostic<'a, ()> for UntranslatableInLintDiagnostic { fn decorate_lint<'b, >(self, diag: &'b mut Diag<'a, ()>) { diag.note("untranslatable diagnostic"); //~^ ERROR diagnostics should be created using translatable messages @@ -91,9 +91,9 @@ impl<'a> DecorateLint<'a, ()> for UntranslatableInDecorateLint { } } -pub struct TranslatableInDecorateLint; +pub struct TranslatableInLintDiagnostic; -impl<'a> DecorateLint<'a, ()> for TranslatableInDecorateLint { +impl<'a> LintDiagnostic<'a, ()> for TranslatableInLintDiagnostic { fn decorate_lint<'b>(self, diag: &'b mut Diag<'a, ()>) { diag.note(crate::fluent_generated::no_crate_note); } @@ -105,18 +105,24 @@ impl<'a> DecorateLint<'a, ()> for TranslatableInDecorateLint { pub fn make_diagnostics<'a>(dcx: &'a DiagCtxt) { let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example); - //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls + //~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls let _diag = dcx.struct_err("untranslatable diagnostic"); - //~^ ERROR diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls + //~^ ERROR diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls //~^^ ERROR diagnostics should be created using translatable messages } // Check that `rustc_lint_diagnostics`-annotated functions aren't themselves linted for // `diagnostic_outside_of_impl`. - #[rustc_lint_diagnostics] pub fn skipped_because_of_annotation<'a>(dcx: &'a DiagCtxt) { #[allow(rustc::untranslatable_diagnostic)] let _diag = dcx.struct_err("untranslatable diagnostic"); // okay! } + +// Check that multiple translatable params are allowed in a single function (at one point they +// weren't). +fn f(_x: impl Into<DiagMessage>, _y: impl Into<SubdiagMessage>) {} +fn g() { + f(crate::fluent_generated::no_crate_example, crate::fluent_generated::no_crate_example); +} diff --git a/tests/ui-fulldeps/internal-lints/diagnostics.stderr b/tests/ui-fulldeps/internal-lints/diagnostics.stderr index b8fbee1ff00..ee5400f6f95 100644 --- a/tests/ui-fulldeps/internal-lints/diagnostics.stderr +++ b/tests/ui-fulldeps/internal-lints/diagnostics.stderr @@ -22,7 +22,7 @@ error: diagnostics should be created using translatable messages LL | diag.note("untranslatable diagnostic"); | ^^^^ -error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls +error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls --> $DIR/diagnostics.rs:107:21 | LL | let _diag = dcx.struct_err(crate::fluent_generated::no_crate_example); @@ -34,7 +34,7 @@ note: the lint level is defined here LL | #![deny(rustc::diagnostic_outside_of_impl)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -error: diagnostics should only be created in `IntoDiagnostic`/`AddToDiagnostic` impls +error: diagnostics should only be created in `Diagnostic`/`Subdiagnostic`/`LintDiagnostic` impls --> $DIR/diagnostics.rs:110:21 | LL | let _diag = dcx.struct_err("untranslatable diagnostic"); diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs index 40df9cc5dca..432ede89826 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.rs @@ -1,6 +1,6 @@ //@ check-fail // Tests that a doc comment will not preclude a field from being considered a diagnostic argument -//@ normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr" +//@ normalize-stderr-test "the following other types implement trait `IntoDiagArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr" //@ normalize-stderr-test "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC" // The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, @@ -25,7 +25,7 @@ use rustc_span::Span; rustc_fluent_macro::fluent_messages! { "./example.ftl" } -struct NotIntoDiagnosticArg; +struct NotIntoDiagArg; #[derive(Diagnostic)] #[diag(no_crate_example)] @@ -33,8 +33,8 @@ struct Test { #[primary_span] span: Span, /// A doc comment - arg: NotIntoDiagnosticArg, - //~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied + arg: NotIntoDiagArg, + //~^ ERROR the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied } #[derive(Subdiagnostic)] @@ -43,6 +43,6 @@ struct SubTest { #[primary_span] span: Span, /// A doc comment - arg: NotIntoDiagnosticArg, - //~^ ERROR the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied + arg: NotIntoDiagArg, + //~^ ERROR the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied } diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr index 98600d28229..7377b0dfd0a 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive-doc-comment-field.stderr @@ -1,25 +1,25 @@ -error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied +error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied --> $DIR/diagnostic-derive-doc-comment-field.rs:36:10 | LL | #[derive(Diagnostic)] | ---------- required by a bound introduced by this call ... -LL | arg: NotIntoDiagnosticArg, - | ^^^^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg` +LL | arg: NotIntoDiagArg, + | ^^^^^^^^^^^^^^ the trait `IntoDiagArg` is not implemented for `NotIntoDiagArg` | = help: normalized in stderr note: required by a bound in `Diag::<'a, G>::arg` --> $COMPILER_DIR/rustc_errors/src/diagnostic.rs:LL:CC = note: this error originates in the macro `with_fn` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `NotIntoDiagnosticArg: IntoDiagnosticArg` is not satisfied +error[E0277]: the trait bound `NotIntoDiagArg: IntoDiagArg` is not satisfied --> $DIR/diagnostic-derive-doc-comment-field.rs:46:10 | LL | #[derive(Subdiagnostic)] | ------------- required by a bound introduced by this call ... -LL | arg: NotIntoDiagnosticArg, - | ^^^^^^^^^^^^^^^^^^^^ the trait `IntoDiagnosticArg` is not implemented for `NotIntoDiagnosticArg` +LL | arg: NotIntoDiagArg, + | ^^^^^^^^^^^^^^ the trait `IntoDiagArg` is not implemented for `NotIntoDiagArg` | = help: normalized in stderr note: required by a bound in `Diag::<'a, G>::arg` diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs index 11070972394..043c7c16654 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.rs @@ -1,6 +1,6 @@ //@ check-fail // Tests error conditions for specifying diagnostics using #[derive(Diagnostic)] -//@ normalize-stderr-test "the following other types implement trait `IntoDiagnosticArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr" +//@ normalize-stderr-test "the following other types implement trait `IntoDiagArg`:(?:.*\n){0,9}\s+and \d+ others" -> "normalized in stderr" //@ normalize-stderr-test "(COMPILER_DIR/.*\.rs):[0-9]+:[0-9]+" -> "$1:LL:CC" // The proc_macro2 crate handles spans differently when on beta/stable release rather than nightly, @@ -347,7 +347,7 @@ struct ArgFieldWithoutSkip { #[primary_span] span: Span, other: Hello, - //~^ ERROR the trait bound `Hello: IntoDiagnosticArg` is not satisfied + //~^ ERROR the trait bound `Hello: IntoDiagArg` is not satisfied } #[derive(Diagnostic)] @@ -355,7 +355,7 @@ struct ArgFieldWithoutSkip { struct ArgFieldWithSkip { #[primary_span] span: Span, - // `Hello` does not implement `IntoDiagnosticArg` so this would result in an error if + // `Hello` does not implement `IntoDiagArg` so this would result in an error if // not for `#[skip_arg]`. #[skip_arg] other: Hello, diff --git a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr index 058c88d315b..1266430e2f7 100644 --- a/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr +++ b/tests/ui-fulldeps/session-diagnostic/diagnostic-derive.stderr @@ -618,14 +618,14 @@ LL | #[derive(Diagnostic)] | = note: this error originates in the derive macro `Diagnostic` (in Nightly builds, run with -Z macro-backtrace for more info) -error[E0277]: the trait bound `Hello: IntoDiagnosticArg` is not satisfied +error[E0277]: the trait bound `Hello: IntoDiagArg` is not satisfied --> $DIR/diagnostic-derive.rs:349:12 | LL | #[derive(Diagnostic)] | ---------- required by a bound introduced by this call ... LL | other: Hello, - | ^^^^^ the trait `IntoDiagnosticArg` is not implemented for `Hello` + | ^^^^^ the trait `IntoDiagArg` is not implemented for `Hello` | = help: normalized in stderr note: required by a bound in `Diag::<'a, G>::arg` diff --git a/tests/ui/associated-consts/assoc-const-eq-supertraits.rs b/tests/ui/associated-consts/assoc-const-eq-supertraits.rs new file mode 100644 index 00000000000..d5d724c9b15 --- /dev/null +++ b/tests/ui/associated-consts/assoc-const-eq-supertraits.rs @@ -0,0 +1,16 @@ +// Regression test for issue #118040. +// Ensure that we support assoc const eq bounds where the assoc const comes from a supertrait. + +//@ check-pass + +#![feature(associated_const_equality)] + +trait Trait: SuperTrait {} +trait SuperTrait: SuperSuperTrait<i32> {} +trait SuperSuperTrait<T> { + const K: T; +} + +fn take(_: impl Trait<K = 0>) {} + +fn main() {} diff --git a/tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs b/tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs index 4ff05112897..76df014ccd9 100644 --- a/tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs +++ b/tests/ui/associated-consts/assoc-const-eq-ty-alias-noninteracting.rs @@ -1,21 +1,25 @@ // Regression test for issue #112560. // Respect the fact that (associated) types and constants live in different namespaces and // therefore equality bounds involving identically named associated items don't conflict if -// their kind (type vs. const) differs. - -// FIXME(fmease): Extend this test to cover supertraits again -// once #118040 is fixed. See initial version of PR #118360. +// their kind (type vs. const) differs. This obviously extends to supertraits. //@ check-pass #![feature(associated_const_equality)] -trait Trait { +trait Trait: SuperTrait { type N; + type Q; const N: usize; } -fn take(_: impl Trait<N = 0, N = ()>) {} +trait SuperTrait { + const Q: &'static str; +} + +fn take0(_: impl Trait<N = 0, N = ()>) {} + +fn take1(_: impl Trait<Q = "...", Q = [()]>) {} fn main() {} diff --git a/tests/ui/associated-consts/freeze.rs b/tests/ui/associated-consts/freeze.rs new file mode 100644 index 00000000000..2364ee1f495 --- /dev/null +++ b/tests/ui/associated-consts/freeze.rs @@ -0,0 +1,12 @@ +#![feature(freeze)] + +//@ check-pass + +use std::marker::Freeze; + +trait Trait<T: Freeze + 'static> { + const VALUE: T; + const VALUE_REF: &'static T = &Self::VALUE; +} + +fn main() {} diff --git a/tests/ui/consts/enclosing-scope-rule.rs b/tests/ui/consts/enclosing-scope-rule.rs new file mode 100644 index 00000000000..7041ad9af34 --- /dev/null +++ b/tests/ui/consts/enclosing-scope-rule.rs @@ -0,0 +1,16 @@ +//@build-pass +// Some code that looks like it might be relying on promotion, but actually this is using the +// enclosing-scope rule, meaning the reference is "extended" to outlive its block and live as long +// as the surrounding block (which in this case is the entire program). There are multiple +// allocations being interned at once. + +struct Gen<T>(T); +impl<'a, T> Gen<&'a T> { + // Can't be promoted because `T` might not be `'static`. + const C: &'a [T] = &[]; +} + +// Can't be promoted because of `Drop`. +const V: &Vec<i32> = &Vec::new(); + +fn main() {} diff --git a/tests/ui/consts/promote-not.rs b/tests/ui/consts/promote-not.rs index 47a06e8a72b..9b16f32532a 100644 --- a/tests/ui/consts/promote-not.rs +++ b/tests/ui/consts/promote-not.rs @@ -3,6 +3,7 @@ #![allow(unconditional_panic)] use std::cell::Cell; +use std::mem::ManuallyDrop; // We do not promote mutable references. static mut TEST1: Option<&mut [i32]> = Some(&mut [1, 2, 3]); //~ ERROR temporary value dropped while borrowed @@ -39,7 +40,16 @@ const TEST_INTERIOR_MUT: () = { let _val: &'static _ = &(Cell::new(1), 2).1; //~ ERROR temporary value dropped while borrowed }; -const TEST_DROP: String = String::new(); +// This gets accepted by the "outer scope" rule, not promotion. +const TEST_DROP_OUTER_SCOPE: &String = &String::new(); +// To demonstrate that, we can rewrite it as follows. If this was promotion it would still work. +const TEST_DROP_NOT_PROMOTE: &String = { + let x = &String::new(); //~ ERROR destructor of `String` cannot be evaluated at compile-time + // The "dropped while borrowed" error seems to be suppressed, but the key point is that this + // fails to compile. + x +}; + fn main() { // We must not promote things with interior mutability. Not even if we "project it away". @@ -58,6 +68,7 @@ fn main() { let _val: &'static _ = &([1,2,3][4]+1); //~ ERROR temporary value dropped while borrowed // No promotion of temporaries that need to be dropped. + const TEST_DROP: String = String::new(); let _val: &'static _ = &TEST_DROP; //~^ ERROR temporary value dropped while borrowed let _val: &'static _ = &&TEST_DROP; @@ -69,4 +80,12 @@ fn main() { let _val: &'static _ = &[&TEST_DROP; 1]; //~^ ERROR temporary value dropped while borrowed //~| ERROR temporary value dropped while borrowed + + // Make sure there is no value-based reasoning for unions. + union UnionWithCell { + f1: i32, + f2: ManuallyDrop<Cell<i32>>, + } + let x: &'static _ = &UnionWithCell { f1: 0 }; + //~^ ERROR temporary value dropped while borrowed } diff --git a/tests/ui/consts/promote-not.stderr b/tests/ui/consts/promote-not.stderr index 67ac5922efd..07d4a135ed4 100644 --- a/tests/ui/consts/promote-not.stderr +++ b/tests/ui/consts/promote-not.stderr @@ -1,5 +1,5 @@ error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:8:50 + --> $DIR/promote-not.rs:9:50 | LL | static mut TEST1: Option<&mut [i32]> = Some(&mut [1, 2, 3]); | ----------^^^^^^^^^- @@ -9,7 +9,7 @@ LL | static mut TEST1: Option<&mut [i32]> = Some(&mut [1, 2, 3]); | using this value as a static requires that borrow lasts for `'static` error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:11:18 + --> $DIR/promote-not.rs:12:18 | LL | let x = &mut [1,2,3]; | ^^^^^^^ creates a temporary value which is freed while still in use @@ -19,7 +19,7 @@ LL | }; | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:33:29 + --> $DIR/promote-not.rs:34:29 | LL | let _x: &'static i32 = &unsafe { U { x: 0 }.x }; | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -29,7 +29,7 @@ LL | }; | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:39:29 + --> $DIR/promote-not.rs:40:29 | LL | let _val: &'static _ = &(Cell::new(1), 2).1; | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -38,8 +38,17 @@ LL | let _val: &'static _ = &(Cell::new(1), 2).1; LL | }; | - temporary value is freed at the end of this statement +error[E0493]: destructor of `String` cannot be evaluated at compile-time + --> $DIR/promote-not.rs:47:14 + | +LL | let x = &String::new(); + | ^^^^^^^^^^^^^ the destructor for this type cannot be evaluated in constants +... +LL | }; + | - value is dropped here + error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:20:32 + --> $DIR/promote-not.rs:21:32 | LL | let _x: &'static () = &foo(); | ----------- ^^^^^ creates a temporary value which is freed while still in use @@ -49,7 +58,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:28:29 + --> $DIR/promote-not.rs:29:29 | LL | let _x: &'static i32 = &unsafe { U { x: 0 }.x }; | ------------ ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -59,7 +68,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:46:29 + --> $DIR/promote-not.rs:56:29 | LL | let _val: &'static _ = &(Cell::new(1), 2).0; | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -70,7 +79,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:47:29 + --> $DIR/promote-not.rs:57:29 | LL | let _val: &'static _ = &(Cell::new(1), 2).1; | ---------- ^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -81,7 +90,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:50:29 + --> $DIR/promote-not.rs:60:29 | LL | let _val: &'static _ = &(1/0); | ---------- ^^^^^ creates a temporary value which is freed while still in use @@ -92,7 +101,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:51:29 + --> $DIR/promote-not.rs:61:29 | LL | let _val: &'static _ = &(1/(1-1)); | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -103,7 +112,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:52:29 + --> $DIR/promote-not.rs:62:29 | LL | let _val: &'static _ = &((1+1)/(1-1)); | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -114,7 +123,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:53:29 + --> $DIR/promote-not.rs:63:29 | LL | let _val: &'static _ = &(i32::MIN/-1); | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -125,7 +134,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:54:29 + --> $DIR/promote-not.rs:64:29 | LL | let _val: &'static _ = &(i32::MIN/(0-1)); | ---------- ^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -136,7 +145,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:55:29 + --> $DIR/promote-not.rs:65:29 | LL | let _val: &'static _ = &(-128i8/-1); | ---------- ^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -147,7 +156,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:56:29 + --> $DIR/promote-not.rs:66:29 | LL | let _val: &'static _ = &(1%0); | ---------- ^^^^^ creates a temporary value which is freed while still in use @@ -158,7 +167,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:57:29 + --> $DIR/promote-not.rs:67:29 | LL | let _val: &'static _ = &(1%(1-1)); | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -169,7 +178,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:58:29 + --> $DIR/promote-not.rs:68:29 | LL | let _val: &'static _ = &([1,2,3][4]+1); | ---------- ^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -180,7 +189,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:61:29 + --> $DIR/promote-not.rs:72:29 | LL | let _val: &'static _ = &TEST_DROP; | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -191,7 +200,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:63:29 + --> $DIR/promote-not.rs:74:29 | LL | let _val: &'static _ = &&TEST_DROP; | ---------- ^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -202,7 +211,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:63:30 + --> $DIR/promote-not.rs:74:30 | LL | let _val: &'static _ = &&TEST_DROP; | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -213,7 +222,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:66:29 + --> $DIR/promote-not.rs:77:29 | LL | let _val: &'static _ = &(&TEST_DROP,); | ---------- ^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -224,7 +233,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:66:31 + --> $DIR/promote-not.rs:77:31 | LL | let _val: &'static _ = &(&TEST_DROP,); | ---------- ^^^^^^^^^ creates a temporary value which is freed while still in use @@ -235,7 +244,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:69:29 + --> $DIR/promote-not.rs:80:29 | LL | let _val: &'static _ = &[&TEST_DROP; 1]; | ---------- ^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use @@ -246,7 +255,7 @@ LL | } | - temporary value is freed at the end of this statement error[E0716]: temporary value dropped while borrowed - --> $DIR/promote-not.rs:69:31 + --> $DIR/promote-not.rs:80:31 | LL | let _val: &'static _ = &[&TEST_DROP; 1]; | ---------- ^^^^^^^^^ - temporary value is freed at the end of this statement @@ -254,6 +263,18 @@ LL | let _val: &'static _ = &[&TEST_DROP; 1]; | | creates a temporary value which is freed while still in use | type annotation requires that borrow lasts for `'static` -error: aborting due to 24 previous errors +error[E0716]: temporary value dropped while borrowed + --> $DIR/promote-not.rs:89:26 + | +LL | let x: &'static _ = &UnionWithCell { f1: 0 }; + | ---------- ^^^^^^^^^^^^^^^^^^^^^^^ creates a temporary value which is freed while still in use + | | + | type annotation requires that borrow lasts for `'static` +LL | +LL | } + | - temporary value is freed at the end of this statement + +error: aborting due to 26 previous errors -For more information about this error, try `rustc --explain E0716`. +Some errors have detailed explanations: E0493, E0716. +For more information about an error, try `rustc --explain E0493`. diff --git a/tests/ui/consts/refs-to-cell-in-final.rs b/tests/ui/consts/refs-to-cell-in-final.rs index 6a849ff0df9..ada56a82a5d 100644 --- a/tests/ui/consts/refs-to-cell-in-final.rs +++ b/tests/ui/consts/refs-to-cell-in-final.rs @@ -15,4 +15,27 @@ static RAW_SYNC_S: SyncPtr<Cell<i32>> = SyncPtr { x: &Cell::new(42) }; const RAW_SYNC_C: SyncPtr<Cell<i32>> = SyncPtr { x: &Cell::new(42) }; //~^ ERROR: cannot refer to interior mutable data +// 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 +// <https://github.com/rust-lang/rust/issues/121610>. Value-based reasoning for interior mutability +// is questionable (https://github.com/rust-lang/unsafe-code-guidelines/issues/493) so for now we +// reject this, though not with a great error message. +pub enum JsValue { + Undefined, + Object(Cell<bool>), +} +impl Drop for JsValue { + fn drop(&mut self) {} +} +const UNDEFINED: &JsValue = &JsValue::Undefined; +//~^ERROR: mutable pointer in final value of constant + +// In contrast, this one works since it is being promoted. +const NONE: &'static Option<Cell<i32>> = &None; +// Making it clear that this is promotion, not "outer scope". +const NONE_EXPLICIT_PROMOTED: &'static Option<Cell<i32>> = { + let x = &None; + x +}; + fn main() {} diff --git a/tests/ui/consts/refs-to-cell-in-final.stderr b/tests/ui/consts/refs-to-cell-in-final.stderr index fae16fa0125..b06db3e116c 100644 --- a/tests/ui/consts/refs-to-cell-in-final.stderr +++ b/tests/ui/consts/refs-to-cell-in-final.stderr @@ -12,6 +12,12 @@ error[E0492]: constants cannot refer to interior mutable data 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 -error: aborting due to 2 previous errors +error: encountered mutable pointer in final value of constant + --> $DIR/refs-to-cell-in-final.rs:30:1 + | +LL | const UNDEFINED: &JsValue = &JsValue::Undefined; + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 3 previous errors For more information about this error, try `rustc --explain E0492`. diff --git a/tests/ui/feature-gates/feature-gate-freeze-impls.rs b/tests/ui/feature-gates/feature-gate-freeze-impls.rs new file mode 100644 index 00000000000..c14c9494874 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-freeze-impls.rs @@ -0,0 +1,15 @@ +#![feature(freeze, negative_impls)] + +use std::marker::Freeze; + +struct Foo; + +unsafe impl Freeze for Foo {} +//~^ explicit impls for the `Freeze` trait are not permitted + +struct Bar; + +impl !Freeze for Bar {} +//~^ explicit impls for the `Freeze` trait are not permitted + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-freeze-impls.stderr b/tests/ui/feature-gates/feature-gate-freeze-impls.stderr new file mode 100644 index 00000000000..eef524fe78e --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-freeze-impls.stderr @@ -0,0 +1,23 @@ +error[E0658]: explicit impls for the `Freeze` trait are not permitted + --> $DIR/feature-gate-freeze-impls.rs:7:1 + | +LL | unsafe impl Freeze for Foo {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ impl of `Freeze` not allowed + | + = note: see issue #121675 <https://github.com/rust-lang/rust/issues/121675> for more information + = help: add `#![feature(freeze_impls)]` 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]: explicit impls for the `Freeze` trait are not permitted + --> $DIR/feature-gate-freeze-impls.rs:12:1 + | +LL | impl !Freeze for Bar {} + | ^^^^^^^^^^^^^^^^^^^^ impl of `Freeze` not allowed + | + = note: see issue #121675 <https://github.com/rust-lang/rust/issues/121675> for more information + = help: add `#![feature(freeze_impls)]` 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/generic-const-items/associated-const-equality.rs b/tests/ui/generic-const-items/associated-const-equality.rs index 3c727097e2b..c0179f02fd2 100644 --- a/tests/ui/generic-const-items/associated-const-equality.rs +++ b/tests/ui/generic-const-items/associated-const-equality.rs @@ -1,22 +1,31 @@ //@ check-pass -#![feature(generic_const_items, associated_const_equality)] +#![feature(generic_const_items, associated_const_equality, adt_const_params)] #![allow(incomplete_features)] trait Owner { const C<const N: u32>: u32; const K<const N: u32>: u32; + const Q<T>: Maybe<T>; } impl Owner for () { const C<const N: u32>: u32 = N; const K<const N: u32>: u32 = N + 1; + const Q<T>: Maybe<T> = Maybe::Nothing; } fn take0<const N: u32>(_: impl Owner<C<N> = { N }>) {} fn take1(_: impl Owner<K<99> = 100>) {} +fn take2(_: impl Owner<Q<()> = { Maybe::Just(()) }>) {} fn main() { take0::<128>(()); take1(()); } + +#[derive(PartialEq, Eq, std::marker::ConstParamTy)] +enum Maybe<T> { + Nothing, + Just(T), +} diff --git a/tests/ui/hygiene/panic-location.rs b/tests/ui/hygiene/panic-location.rs index a98960d74b0..b2f9bfe4f9a 100644 --- a/tests/ui/hygiene/panic-location.rs +++ b/tests/ui/hygiene/panic-location.rs @@ -1,6 +1,7 @@ //@ run-fail //@ check-run-results //@ exec-env:RUST_BACKTRACE=0 +//@ normalize-stderr-test ".rs:\d+:\d+" -> ".rs:LL:CC" // // Regression test for issue #70963 // The captured stderr from this test reports a location diff --git a/tests/ui/hygiene/panic-location.run.stderr b/tests/ui/hygiene/panic-location.run.stderr index ec0ce18c3df..5c1778bc485 100644 --- a/tests/ui/hygiene/panic-location.run.stderr +++ b/tests/ui/hygiene/panic-location.run.stderr @@ -1,3 +1,3 @@ -thread 'main' panicked at library/alloc/src/raw_vec.rs:26:5: +thread 'main' panicked at library/alloc/src/raw_vec.rs:LL:CC: capacity overflow note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace diff --git a/tests/ui/lint/dead-code/issue-41883.stderr b/tests/ui/lint/dead-code/issue-41883.stderr index cf079e4dda3..47ccef9a530 100644 --- a/tests/ui/lint/dead-code/issue-41883.stderr +++ b/tests/ui/lint/dead-code/issue-41883.stderr @@ -29,8 +29,6 @@ error: struct `UnusedStruct` is never constructed | LL | struct UnusedStruct; | ^^^^^^^^^^^^ - | - = note: `UnusedStruct` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis error: aborting due to 4 previous errors diff --git a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr index b992005318f..25a7d96cb89 100644 --- a/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr +++ b/tests/ui/lint/dead-code/multiple-dead-codes-in-the-same-struct.stderr @@ -56,8 +56,6 @@ warning: struct `Foo` is never constructed | LL | struct Foo(usize, #[allow(unused)] usize); | ^^^ - | - = note: `Foo` has a derived impl for the trait `Debug`, but this is intentionally ignored during dead code analysis error: aborting due to 2 previous errors; 2 warnings emitted diff --git a/tests/ui/lint/dead-code/unused-adt-impls-pub-trait.rs b/tests/ui/lint/dead-code/unused-adt-impls-pub-trait.rs new file mode 100644 index 00000000000..10d6c728c2d --- /dev/null +++ b/tests/ui/lint/dead-code/unused-adt-impls-pub-trait.rs @@ -0,0 +1,17 @@ +#![deny(dead_code)] + +enum Foo {} //~ ERROR enum `Foo` is never used + +impl Clone for Foo { + fn clone(&self) -> Foo { loop {} } +} + +pub trait PubTrait { + fn unused_method(&self) -> Self; +} + +impl PubTrait for Foo { + fn unused_method(&self) -> Foo { loop {} } +} + +fn main() {} diff --git a/tests/ui/lint/dead-code/unused-adt-impls-pub-trait.stderr b/tests/ui/lint/dead-code/unused-adt-impls-pub-trait.stderr new file mode 100644 index 00000000000..f0d0cc50f7d --- /dev/null +++ b/tests/ui/lint/dead-code/unused-adt-impls-pub-trait.stderr @@ -0,0 +1,14 @@ +error: enum `Foo` is never used + --> $DIR/unused-adt-impls-pub-trait.rs:3:6 + | +LL | enum Foo {} + | ^^^ + | +note: the lint level is defined here + --> $DIR/unused-adt-impls-pub-trait.rs:1:9 + | +LL | #![deny(dead_code)] + | ^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.rs b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.rs new file mode 100644 index 00000000000..5de3b401ab4 --- /dev/null +++ b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.rs @@ -0,0 +1,14 @@ +fn main() { + foo::( //~ HELP: consider removing the `::` here to call the expression + //~^ NOTE: while parsing this parenthesized list of type arguments starting + bar(x, y, z), + bar(x, y, z), + bar(x, y, z), + bar(x, y, z), + bar(x, y, z), + bar(x, y, z), + bar(x, y, z), + baz("test"), //~ ERROR: expected type, found `"test"` + //~^ NOTE: expected type + ) +} diff --git a/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.stderr b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.stderr new file mode 100644 index 00000000000..60e57a3629c --- /dev/null +++ b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-1.stderr @@ -0,0 +1,17 @@ +error: expected type, found `"test"` + --> $DIR/diagnostics-parenthesized-type-arguments-issue-120892-1.rs:11:9 + | +LL | foo::( + | --- while parsing this parenthesized list of type arguments starting here +... +LL | baz("test"), + | ^^^^^^ expected type + | +help: consider removing the `::` here to call the expression + | +LL - foo::( +LL + foo( + | + +error: aborting due to 1 previous error + diff --git a/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.rs b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.rs new file mode 100644 index 00000000000..2876a9afe00 --- /dev/null +++ b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.rs @@ -0,0 +1,5 @@ +fn main() { + foo::/* definitely not harmful comment */(123, "foo") -> (u32); //~ ERROR: expected type, found `123` + //~^ NOTE: while parsing this parenthesized list of type arguments starting + //~^^ NOTE: expected type +} diff --git a/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.stderr b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.stderr new file mode 100644 index 00000000000..7fd2b6b18e3 --- /dev/null +++ b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-2.stderr @@ -0,0 +1,10 @@ +error: expected type, found `123` + --> $DIR/diagnostics-parenthesized-type-arguments-issue-120892-2.rs:2:45 + | +LL | foo::/* definitely not harmful comment */(123, "foo") -> (u32); + | ---------------------------------------^^^ expected type + | | + | while parsing this parenthesized list of type arguments starting here + +error: aborting due to 1 previous error + diff --git a/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.rs b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.rs new file mode 100644 index 00000000000..402afac46de --- /dev/null +++ b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.rs @@ -0,0 +1,14 @@ +struct Foo(u32, u32); +impl Foo { + fn foo(&self) { + match *self { + Foo::(1, 2) => {}, //~ HELP: consider removing the `::` here to turn this into a tuple struct pattern + //~^ NOTE: while parsing this parenthesized list of type arguments starting + //~^^ ERROR: expected type, found `1` + //~^^^ NOTE: expected type + _ => {}, + } + } +} + +fn main() {} diff --git a/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.stderr b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.stderr new file mode 100644 index 00000000000..72770ca265d --- /dev/null +++ b/tests/ui/parser/issues/diagnostics-parenthesized-type-arguments-issue-120892-3.stderr @@ -0,0 +1,16 @@ +error: expected type, found `1` + --> $DIR/diagnostics-parenthesized-type-arguments-issue-120892-3.rs:5:19 + | +LL | Foo::(1, 2) => {}, + | ---^ expected type + | | + | while parsing this parenthesized list of type arguments starting here + | +help: consider removing the `::` here to turn this into a tuple struct pattern + | +LL - Foo::(1, 2) => {}, +LL + Foo(1, 2) => {}, + | + +error: aborting due to 1 previous error + diff --git a/tests/ui/rust-2018/uniform-paths/issue-55779.rs b/tests/ui/rust-2018/uniform-paths/issue-55779.rs index 246b8dd82c5..f90054e6b1d 100644 --- a/tests/ui/rust-2018/uniform-paths/issue-55779.rs +++ b/tests/ui/rust-2018/uniform-paths/issue-55779.rs @@ -1,4 +1,4 @@ -//@ run-pass +//@ check-pass //@ edition:2018 //@ aux-crate:issue_55779_extern_trait=issue-55779-extern-trait.rs diff --git a/tests/ui/traits/augmented-assignments-trait.rs b/tests/ui/traits/augmented-assignments-trait.rs index 37fe42ce1c6..a0f8b39eb7a 100644 --- a/tests/ui/traits/augmented-assignments-trait.rs +++ b/tests/ui/traits/augmented-assignments-trait.rs @@ -1,4 +1,4 @@ -//@ run-pass +//@ check-pass use std::ops::AddAssign; struct Int(#[allow(dead_code)] i32); diff --git a/tests/ui/traits/issue-33187.rs b/tests/ui/traits/issue-33187.rs index 6a039527b3b..6ae7e150c51 100644 --- a/tests/ui/traits/issue-33187.rs +++ b/tests/ui/traits/issue-33187.rs @@ -1,4 +1,4 @@ -//@ run-pass +//@ check-pass struct Foo<A: Repr>(<A as Repr>::Data); |
