diff options
Diffstat (limited to 'tests')
682 files changed, 7150 insertions, 1873 deletions
diff --git a/tests/assembly-llvm/loongarch-float-struct-abi.rs b/tests/assembly-llvm/loongarch-float-struct-abi.rs new file mode 100644 index 00000000000..4991004fc05 --- /dev/null +++ b/tests/assembly-llvm/loongarch-float-struct-abi.rs @@ -0,0 +1,134 @@ +//@ add-core-stubs +//@ assembly-output: emit-asm +//@ compile-flags: -Copt-level=3 --target loongarch64-unknown-linux-gnu +//@ needs-llvm-components: loongarch + +#![feature(no_core, lang_items)] +#![no_std] +#![no_core] +#![crate_type = "lib"] + +extern crate minicore; +use minicore::*; + +#[repr(C, align(64))] +struct Aligned(f64); + +#[repr(C)] +struct Padded(u8, Aligned); + +#[repr(C, packed)] +struct Packed(u8, f32); + +impl Copy for Aligned {} +impl Copy for Padded {} +impl Copy for Packed {} + +extern "C" { + fn take_padded(x: Padded); + fn get_padded() -> Padded; + fn take_packed(x: Packed); + fn get_packed() -> Packed; +} + +// CHECK-LABEL: pass_padded +#[unsafe(no_mangle)] +extern "C" fn pass_padded(out: &mut Padded, x: Padded) { + // CHECK: st.b $a1, $a0, 0 + // CHECK-NEXT: fst.d $fa0, $a0, 64 + // CHECK-NEXT: ret + *out = x; +} + +// CHECK-LABEL: ret_padded +#[unsafe(no_mangle)] +extern "C" fn ret_padded(x: &Padded) -> Padded { + // CHECK: fld.d $fa0, $a0, 64 + // CHECK-NEXT: ld.b $a0, $a0, 0 + // CHECK-NEXT: ret + *x +} + +#[unsafe(no_mangle)] +extern "C" fn call_padded(x: &Padded) { + // CHECK: fld.d $fa0, $a0, 64 + // CHECK-NEXT: ld.b $a0, $a0, 0 + // CHECK-NEXT: pcaddu18i $t8, %call36(take_padded) + // CHECK-NEXT: jr $t8 + unsafe { + take_padded(*x); + } +} + +#[unsafe(no_mangle)] +extern "C" fn receive_padded(out: &mut Padded) { + // CHECK: addi.d $sp, $sp, -16 + // CHECK-NEXT: .cfi_def_cfa_offset 16 + // CHECK-NEXT: st.d $ra, $sp, [[#%d,RA_SPILL:]] + // CHECK-NEXT: st.d [[TEMP:.*]], $sp, [[#%d,TEMP_SPILL:]] + // CHECK-NEXT: .cfi_offset 1, [[#%d,RA_SPILL - 16]] + // CHECK-NEXT: .cfi_offset [[#%d,TEMP_NUM:]], [[#%d,TEMP_SPILL - 16]] + // CHECK-NEXT: move [[TEMP]], $a0 + // CHECK-NEXT: pcaddu18i $ra, %call36(get_padded) + // CHECK-NEXT: jirl $ra, $ra, 0 + // CHECK-NEXT: st.b $a0, [[TEMP]], 0 + // CHECK-NEXT: fst.d $fa0, [[TEMP]], 64 + // CHECK-NEXT: ld.d [[TEMP]], $sp, [[#%d,TEMP_SPILL]] + // CHECK-NEXT: ld.d $ra, $sp, [[#%d,RA_SPILL]] + // CHECK: addi.d $sp, $sp, 16 + // CHECK: ret + unsafe { + *out = get_padded(); + } +} + +// CHECK-LABEL: pass_packed +#[unsafe(no_mangle)] +extern "C" fn pass_packed(out: &mut Packed, x: Packed) { + // CHECK: st.b $a1, $a0, 0 + // CHECK-NEXT: fst.s $fa0, $a0, 1 + // CHECK-NEXT: ret + *out = x; +} + +// CHECK-LABEL: ret_packed +#[unsafe(no_mangle)] +extern "C" fn ret_packed(x: &Packed) -> Packed { + // CHECK: fld.s $fa0, $a0, 1 + // CHECK-NEXT: ld.b $a0, $a0, 0 + // CHECK-NEXT: ret + *x +} + +#[unsafe(no_mangle)] +extern "C" fn call_packed(x: &Packed) { + // CHECK: fld.s $fa0, $a0, 1 + // CHECK-NEXT: ld.b $a0, $a0, 0 + // CHECK-NEXT: pcaddu18i $t8, %call36(take_packed) + // CHECK-NEXT: jr $t8 + unsafe { + take_packed(*x); + } +} + +#[unsafe(no_mangle)] +extern "C" fn receive_packed(out: &mut Packed) { + // CHECK: addi.d $sp, $sp, -16 + // CHECK-NEXT: .cfi_def_cfa_offset 16 + // CHECK-NEXT: st.d $ra, $sp, [[#%d,RA_SPILL:]] + // CHECK-NEXT: st.d [[TEMP:.*]], $sp, [[#%d,TEMP_SPILL:]] + // CHECK-NEXT: .cfi_offset 1, [[#%d,RA_SPILL - 16]] + // CHECK-NEXT: .cfi_offset [[#%d,TEMP_NUM:]], [[#%d,TEMP_SPILL - 16]] + // CHECK-NEXT: move [[TEMP]], $a0 + // CHECK-NEXT: pcaddu18i $ra, %call36(get_packed) + // CHECK-NEXT: jirl $ra, $ra, 0 + // CHECK-NEXT: st.b $a0, [[TEMP]], 0 + // CHECK-NEXT: fst.s $fa0, [[TEMP]], 1 + // CHECK-NEXT: ld.d [[TEMP]], $sp, [[#%d,TEMP_SPILL]] + // CHECK-NEXT: ld.d $ra, $sp, [[#%d,RA_SPILL]] + // CHECK: addi.d $sp, $sp, 16 + // CHECK: ret + unsafe { + *out = get_packed(); + } +} diff --git a/tests/assembly-llvm/reg-struct-return.rs b/tests/assembly-llvm/reg-struct-return.rs new file mode 100644 index 00000000000..b251d791d51 --- /dev/null +++ b/tests/assembly-llvm/reg-struct-return.rs @@ -0,0 +1,143 @@ +//! Tests that -Zreg-struct-return changes ABI for small struct returns +//! from hidden-pointer convention to register-return on x86_32. +//! This test covers: +//! * Callee side, verifying that the structs are correctly loaded into registers when +//! `-Zreg-struct-return` is activated +//! * Caller side, verifying callers do receive returned structs in registers when +//! `-Zreg-struct-return` is activated +//@ add-core-stubs +//@ assembly-output: emit-asm +//@ compile-flags: -O --target=i686-unknown-linux-gnu -Crelocation-model=static +//@ revisions: WITH WITHOUT +//@[WITH] compile-flags: -Zreg-struct-return +//@ needs-llvm-components: x86 + +#![feature(no_core)] +#![no_std] +#![no_core] +#![crate_type = "lib"] + +extern crate minicore; +use minicore::*; + +// Verifies ABI changes for small structs, where both fields fit into one register. +// WITH is expected to use register return, WITHOUT should use hidden pointer. +mod Small { + struct SmallStruct { + a: i8, + b: i8, + } + + unsafe extern "C" { + fn small() -> SmallStruct; + } + + #[unsafe(no_mangle)] + pub unsafe extern "C" fn small_callee() -> SmallStruct { + // (42 << 8) | 42 = 10794 + + // WITH-LABEL: small_callee + // WITH: movw $10794, %ax + // WITH: retl + + // WITHOUT-LABEL: small_callee + // WITHOUT: movl 4(%esp), %e{{.*}} + // WITHOUT: movw $10794, (%e{{.*}}) + // WITHOUT: retl $4 + SmallStruct { a: 42, b: 42 } + } + + #[unsafe(no_mangle)] + pub unsafe extern "C" fn small_caller(dst: &mut SmallStruct) { + // WITH-LABEL: small_caller + // WITH: calll small + // WITH: movw %ax, (%e{{.*}}) + + // WITHOUT-LABEL: small_caller + // WITHOUT: calll small + // WITHOUT: movzwl {{.*}}(%esp), %e[[TMP:..]] + // WITHOUT: movw %[[TMP]], (%e{{..}}) + *dst = small(); + } +} + +// Verifies ABI changes for a struct of size 8, which is the maximum size +// for reg-struct-return. +// WITH is expected to still use register return, WITHOUT should use hidden +// pointer. +mod Pivot { + struct PivotStruct { + a: i32, + b: i32, + } + + unsafe extern "C" { + fn pivot() -> PivotStruct; + } + + #[unsafe(no_mangle)] + pub unsafe extern "C" fn pivot_callee() -> PivotStruct { + // WITH-LABEL: pivot_callee + // WITH: movl $42, %e{{.*}} + // WITH: movl $42, %e{{.*}} + // WITH: retl + + // WITHOUT-LABEL: pivot_callee + // WITHOUT: movl 4(%esp), %e{{.*}} + // WITHOUT-DAG: movl $42, (%e{{.*}}) + // WITHOUT-DAG: movl $42, 4(%e{{.*}}) + // WITHOUT: retl $4 + PivotStruct { a: 42, b: 42 } + } + + #[unsafe(no_mangle)] + pub unsafe extern "C" fn pivot_caller(dst: &mut PivotStruct) { + // WITH-LABEL: pivot_caller + // WITH: calll pivot + // WITH-DAG: movl %e{{.*}}, 4(%e{{.*}}) + // WITH-DAG: movl %e{{.*}}, (%e{{.*}}) + + // WITHOUT-LABEL: pivot_caller + // WITHOUT: calll pivot + // WITHOUT: movsd {{.*}}(%esp), %[[TMP:xmm.]] + // WITHOUT: movsd %[[TMP]], (%e{{..}}) + *dst = pivot(); + } +} + +// Verifies ABI changes for a struct of size 12, which is larger than the +// maximum size for reg-struct-return (8 bytes). +// Here, the hidden pointer convention should be used even when `-Zreg-struct-return` is set. +mod Large { + struct LargeStruct { + a: i32, + b: i32, + c: i32, + } + + unsafe extern "C" { + fn large() -> LargeStruct; + } + + #[unsafe(no_mangle)] + pub unsafe extern "C" fn large_callee() -> LargeStruct { + // CHECK-LABEL: large_callee + // CHECK: movl 4(%esp), %e{{.*}} + // CHECK-DAG: movl $42, (%e{{.*}}) + // CHECK-DAG: movl $42, 4(%e{{.*}}) + // CHECK-DAG: movl $42, 8(%e{{.*}}) + // CHECK: retl $4 + LargeStruct { a: 42, b: 42, c: 42 } + } + + #[unsafe(no_mangle)] + pub unsafe extern "C" fn large_caller(dst: &mut LargeStruct) { + // CHECK-LABEL: large_caller + // CHECK: calll large + // CHECK-DAG: movl {{.*}}(%esp), %[[TMP1:e..]] + // CHECK-DAG: movl %[[TMP1]], {{.*}}(%e{{..}}) + // CHECK-DAG: movsd {{.*}}(%esp), %[[TMP2:xmm.]] + // CHECK-DAG: movsd %[[TMP2]], {{.*}}(%e{{..}}) + *dst = large(); + } +} diff --git a/tests/assembly-llvm/targets/targets-elf.rs b/tests/assembly-llvm/targets/targets-elf.rs index 79347d0bbf6..b5c116cdfef 100644 --- a/tests/assembly-llvm/targets/targets-elf.rs +++ b/tests/assembly-llvm/targets/targets-elf.rs @@ -10,6 +10,9 @@ //@ revisions: aarch64_be_unknown_linux_gnu_ilp32 //@ [aarch64_be_unknown_linux_gnu_ilp32] compile-flags: --target aarch64_be-unknown-linux-gnu_ilp32 //@ [aarch64_be_unknown_linux_gnu_ilp32] needs-llvm-components: aarch64 +//@ revisions: aarch64_be_unknown_linux_musl +//@ [aarch64_be_unknown_linux_musl] compile-flags: --target aarch64_be-unknown-linux-musl +//@ [aarch64_be_unknown_linux_musl] needs-llvm-components: aarch64 //@ revisions: aarch64_be_unknown_netbsd //@ [aarch64_be_unknown_netbsd] compile-flags: --target aarch64_be-unknown-netbsd //@ [aarch64_be_unknown_netbsd] needs-llvm-components: aarch64 @@ -49,6 +52,9 @@ //@ revisions: aarch64_unknown_linux_ohos //@ [aarch64_unknown_linux_ohos] compile-flags: --target aarch64-unknown-linux-ohos //@ [aarch64_unknown_linux_ohos] needs-llvm-components: aarch64 +//@ revisions: aarch64_unknown_managarm_mlibc +//@ [aarch64_unknown_managarm_mlibc] compile-flags: --target aarch64-unknown-managarm-mlibc +//@ [aarch64_unknown_managarm_mlibc] needs-llvm-components: aarch64 //@ revisions: aarch64_unknown_netbsd //@ [aarch64_unknown_netbsd] compile-flags: --target aarch64-unknown-netbsd //@ [aarch64_unknown_netbsd] needs-llvm-components: aarch64 @@ -481,9 +487,15 @@ //@ revisions: riscv64gc_unknown_linux_gnu //@ [riscv64gc_unknown_linux_gnu] compile-flags: --target riscv64gc-unknown-linux-gnu //@ [riscv64gc_unknown_linux_gnu] needs-llvm-components: riscv +//@ revisions: riscv64a23_unknown_linux_gnu +//@ [riscv64a23_unknown_linux_gnu] compile-flags: --target riscv64a23-unknown-linux-gnu +//@ [riscv64a23_unknown_linux_gnu] needs-llvm-components: riscv //@ revisions: riscv64gc_unknown_linux_musl //@ [riscv64gc_unknown_linux_musl] compile-flags: --target riscv64gc-unknown-linux-musl //@ [riscv64gc_unknown_linux_musl] needs-llvm-components: riscv +//@ revisions: riscv64gc_unknown_managarm_mlibc +//@ [riscv64gc_unknown_managarm_mlibc] compile-flags: --target riscv64gc-unknown-managarm-mlibc +//@ [riscv64gc_unknown_managarm_mlibc] needs-llvm-components: riscv //@ revisions: riscv64gc_unknown_netbsd //@ [riscv64gc_unknown_netbsd] compile-flags: --target riscv64gc-unknown-netbsd //@ [riscv64gc_unknown_netbsd] needs-llvm-components: riscv @@ -643,6 +655,9 @@ //@ revisions: x86_64_unknown_linux_none //@ [x86_64_unknown_linux_none] compile-flags: --target x86_64-unknown-linux-none //@ [x86_64_unknown_linux_none] needs-llvm-components: x86 +//@ revisions: x86_64_unknown_managarm_mlibc +//@ [x86_64_unknown_managarm_mlibc] compile-flags: --target x86_64-unknown-managarm-mlibc +//@ [x86_64_unknown_managarm_mlibc] needs-llvm-components: x86 //@ revisions: x86_64_unknown_netbsd //@ [x86_64_unknown_netbsd] compile-flags: --target x86_64-unknown-netbsd //@ [x86_64_unknown_netbsd] needs-llvm-components: x86 diff --git a/tests/assembly-llvm/x86_64-mcount.rs b/tests/assembly-llvm/x86_64-mcount.rs new file mode 100644 index 00000000000..0428272cfc5 --- /dev/null +++ b/tests/assembly-llvm/x86_64-mcount.rs @@ -0,0 +1,24 @@ +//@ assembly-output: emit-asm +//@ compile-flags: -Zinstrument-mcount=y -Cllvm-args=-x86-asm-syntax=intel + +//@ revisions: x86_64-linux +//@[x86_64-linux] compile-flags: --target=x86_64-unknown-linux-gnu +//@[x86_64-linux] needs-llvm-components: x86 +//@[x86_64-linux] only-x86_64-unknown-linux-gnu + +//@ revisions: x86_64-darwin +//@[x86_64-darwin] compile-flags: --target=x86_64-apple-darwin +//@[x86_64-darwin] needs-llvm-components: x86 +//@[x86_64-darwin] only-x86_64-apple-darwin + +#![crate_type = "lib"] + +// CHECK-LABEL: mcount_func: +#[no_mangle] +pub fn mcount_func() { + // CHECK: call mcount + + std::hint::black_box(()); + + // CHECK: ret +} diff --git a/tests/auxiliary/minicore.rs b/tests/auxiliary/minicore.rs index da880100a10..4f4c653cb46 100644 --- a/tests/auxiliary/minicore.rs +++ b/tests/auxiliary/minicore.rs @@ -179,7 +179,14 @@ impl Add<isize> for isize { #[lang = "sync"] trait Sync {} -impl Sync for u8 {} +impl_marker_trait!( + Sync => [ + char, bool, + isize, i8, i16, i32, i64, i128, + usize, u8, u16, u32, u64, u128, + f16, f32, f64, f128, + ] +); #[lang = "drop_in_place"] fn drop_in_place<T>(_: *mut T) {} diff --git a/tests/codegen-llvm/addr-of-mutate.rs b/tests/codegen-llvm/addr-of-mutate.rs index 71669065289..36d6bf555d1 100644 --- a/tests/codegen-llvm/addr-of-mutate.rs +++ b/tests/codegen-llvm/addr-of-mutate.rs @@ -5,7 +5,7 @@ // Test for the absence of `readonly` on the argument when it is mutated via `&raw const`. // See <https://github.com/rust-lang/rust/issues/111502>. -// CHECK: i8 @foo(ptr{{( dead_on_return)?}} noalias{{( nocapture)?}} noundef align 1{{( captures\(none\))?}} dereferenceable(128) %x) +// CHECK: i8 @foo(ptr{{( dead_on_return)?}} noalias noundef align 1{{( captures\(address\))?}} dereferenceable(128) %x) #[no_mangle] pub fn foo(x: [u8; 128]) -> u8 { let ptr = core::ptr::addr_of!(x).cast_mut(); @@ -15,7 +15,7 @@ pub fn foo(x: [u8; 128]) -> u8 { x[0] } -// CHECK: i1 @second(ptr{{( dead_on_return)?}} noalias{{( nocapture)?}} noundef align {{[0-9]+}}{{( captures\(none\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) +// CHECK: i1 @second(ptr{{( dead_on_return)?}} noalias noundef align {{[0-9]+}}{{( captures\(address\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) #[no_mangle] pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { let b_bool_ptr = core::ptr::addr_of!(a_ptr_and_b.1.1).cast_mut(); @@ -24,7 +24,7 @@ pub unsafe fn second(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { } // If going through a deref (and there are no other mutating accesses), then `readonly` is fine. -// CHECK: i1 @third(ptr{{( dead_on_return)?}} noalias{{( nocapture)?}} noundef readonly align {{[0-9]+}}{{( captures\(none\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) +// CHECK: i1 @third(ptr{{( dead_on_return)?}} noalias noundef readonly align {{[0-9]+}}{{( captures\(address\))?}} dereferenceable({{[0-9]+}}) %a_ptr_and_b) #[no_mangle] pub unsafe fn third(a_ptr_and_b: (*mut (i32, bool), (i64, bool))) -> bool { let b_bool_ptr = core::ptr::addr_of!((*a_ptr_and_b.0).1).cast_mut(); diff --git a/tests/codegen-llvm/amdgpu-addrspacecast.rs b/tests/codegen-llvm/amdgpu-addrspacecast.rs index 7fe630a7efa..829133de00d 100644 --- a/tests/codegen-llvm/amdgpu-addrspacecast.rs +++ b/tests/codegen-llvm/amdgpu-addrspacecast.rs @@ -16,3 +16,12 @@ pub fn ref_of_local(f: fn(&i32)) { let i = 0; f(&i); } + +// CHECK-LABEL: @ref_of_global +// CHECK: addrspacecast (ptr addrspace(1) @I to ptr) +#[no_mangle] +pub fn ref_of_global(f: fn(&i32)) { + #[no_mangle] + static I: i32 = 0; + f(&I); +} diff --git a/tests/codegen-llvm/array-repeat.rs b/tests/codegen-llvm/array-repeat.rs index 4c755df9390..1c45341d764 100644 --- a/tests/codegen-llvm/array-repeat.rs +++ b/tests/codegen-llvm/array-repeat.rs @@ -1,7 +1,6 @@ //@ compile-flags: -Copt-level=3 #![crate_type = "lib"] -#![feature(array_repeat)] use std::array::repeat; diff --git a/tests/codegen-llvm/async-fn-debug-awaitee-field.rs b/tests/codegen-llvm/async-fn-debug-awaitee-field.rs index 50860c90662..b9d3d9ee66e 100644 --- a/tests/codegen-llvm/async-fn-debug-awaitee-field.rs +++ b/tests/codegen-llvm/async-fn-debug-awaitee-field.rs @@ -18,11 +18,11 @@ pub async fn async_fn_test() { pub async fn foo() {} +// NONMSVC: [[AWAITEE_TYPE:![0-9]*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}", scope: [[AWAITEE_SCOPE:![0-9]*]], +// MSVC: [[AWAITEE_TYPE:![0-9]*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<async_fn_debug_awaitee_field::foo::async_fn_env$0>", +// NONMSVC: [[AWAITEE_SCOPE]] = !DINamespace(name: "foo", // NONMSVC: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}", scope: [[GEN_SCOPE:![0-9]*]], // MSVC: [[GEN:!.*]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<async_fn_debug_awaitee_field::async_fn_test::async_fn_env$0>", // NONMSVC: [[GEN_SCOPE:!.*]] = !DINamespace(name: "async_fn_test", // CHECK: [[SUSPEND_STRUCT:!.*]] = !DICompositeType(tag: DW_TAG_structure_type, name: "Suspend0", scope: [[GEN]], -// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "__awaitee", scope: [[SUSPEND_STRUCT]], {{.*}}, baseType: [[AWAITEE_TYPE:![0-9]*]], -// NONMSVC: [[AWAITEE_TYPE]] = !DICompositeType(tag: DW_TAG_structure_type, name: "{async_fn_env#0}", scope: [[AWAITEE_SCOPE:![0-9]*]], -// MSVC: [[AWAITEE_TYPE]] = !DICompositeType(tag: DW_TAG_union_type, name: "enum2$<async_fn_debug_awaitee_field::foo::async_fn_env$0>", -// NONMSVC: [[AWAITEE_SCOPE]] = !DINamespace(name: "foo", +// CHECK: !DIDerivedType(tag: DW_TAG_member, name: "__awaitee", scope: [[SUSPEND_STRUCT]], {{.*}}, baseType: [[AWAITEE_TYPE]], diff --git a/tests/codegen-llvm/atomicptr.rs b/tests/codegen-llvm/atomicptr.rs index ce6c4aa0d2b..9d5e618fe76 100644 --- a/tests/codegen-llvm/atomicptr.rs +++ b/tests/codegen-llvm/atomicptr.rs @@ -6,7 +6,6 @@ //@ compile-flags: -Copt-level=3 -Cno-prepopulate-passes #![crate_type = "lib"] -#![feature(strict_provenance_atomic_ptr)] use std::ptr::without_provenance_mut; use std::sync::atomic::AtomicPtr; diff --git a/tests/codegen-llvm/cast-target-abi.rs b/tests/codegen-llvm/cast-target-abi.rs index 28d3ad5f61c..090de00df93 100644 --- a/tests/codegen-llvm/cast-target-abi.rs +++ b/tests/codegen-llvm/cast-target-abi.rs @@ -171,7 +171,15 @@ pub extern "C" fn receives_doubledouble(x: DoubleDouble) { // CHECK: [[RUST_ALLOCA:%.+]] = alloca [16 x i8], align [[RUST_ALIGN:8]] - // CHECK: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // aarch64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_VALUE_0:%.+]] = extractvalue [[ABI_TYPE]] [[ABI_VALUE:%.+]], 0 + // loongarch64: [[ABI_VALUE_1:%.+]] = extractvalue [[ABI_TYPE]] [[ABI_VALUE:%.+]], 1 + // loongarch64: store double [[ABI_VALUE_0]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_ALLOCA_1:%.+]] = getelementptr inbounds i8, ptr [[ABI_ALLOCA]], i64 8 + // loongarch64: store double [[ABI_VALUE_1]], ptr [[ABI_ALLOCA_1]], align [[ABI_ALIGN]] + // powerpc64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // sparc64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // x86_64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // CHECK: call void @llvm.memcpy.{{.+}}(ptr align [[RUST_ALIGN]] [[RUST_ALLOCA]], ptr align [[ABI_ALIGN]] [[ABI_ALLOCA]], i64 16, i1 false) } @@ -190,7 +198,11 @@ pub extern "C" fn returns_doubledouble() -> DoubleDouble { // x86_64: [[ABI_ALLOCA:%.+]] = alloca [16 x i8], align [[ABI_ALIGN:8]] // aarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x double\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] - // loongarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ double, double }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_VALUE_0:%.+]] = load double, ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_ALLOCA_1:%.+]] = getelementptr inbounds i8, ptr [[ABI_ALLOCA]], i64 8 + // loongarch64: [[ABI_VALUE_1:%.+]] = load double, ptr [[ABI_ALLOCA_1]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_VALUE_2:%.+]] = insertvalue [[ABI_TYPE:{ double, double }]] poison, double [[ABI_VALUE_0]], 0 + // loongarch64: [[ABI_VALUE:%.+]] = insertvalue { double, double } [[ABI_VALUE_2]], double [[ABI_VALUE_1]], 1 // sparc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ double, double }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // x86_64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ double, double }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] @@ -269,7 +281,11 @@ pub extern "C" fn receives_doublefloat(x: DoubleFloat) { // x86_64: [[RUST_ALLOCA:%.+]] = alloca [16 x i8], align [[RUST_ALIGN:8]] // aarch64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] - // loongarch64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_VALUE_0:%.+]] = extractvalue { double, float } [[ABI_VALUE]], 0 + // loongarch64: [[ABI_VALUE_1:%.+]] = extractvalue { double, float } [[ABI_VALUE]], 1 + // loongarch64: store double [[ABI_VALUE_0]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_ALLOCA_1:%.+]] = getelementptr inbounds i8, ptr [[ABI_ALLOCA]], i64 8 + // loongarch64: store float [[ABI_VALUE_1]], ptr [[ABI_ALLOCA_1]], align [[ABI_ALIGN]] // powerpc64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // x86_64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] @@ -297,7 +313,11 @@ pub extern "C" fn returns_doublefloat() -> DoubleFloat { // x86_64: [[ABI_ALLOCA:%.+]] = alloca [16 x i8], align [[ABI_ALIGN:8]] // aarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] - // loongarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ double, float }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_VALUE_0:%.+]] = load double, ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_ALLOCA_1:%.+]] = getelementptr inbounds i8, ptr [[ABI_ALLOCA]], i64 8 + // loongarch64: [[ABI_VALUE_1:%.+]] = load float, ptr [[ABI_ALLOCA_1]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_VALUE_2:%.+]] = insertvalue [[ABI_TYPE:{ double, float }]] poison, double [[ABI_VALUE_0]], 0 + // loongarch64: [[ABI_VALUE:%.+]] = insertvalue { double, float } [[ABI_VALUE_2]], float [[ABI_VALUE_1]], 1 // x86_64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ double, double }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // aarch64: ret [[ABI_TYPE]] [[ABI_VALUE]] @@ -429,7 +449,11 @@ pub fn call_doubledouble() { // CHECK: call void @llvm.memcpy.{{.+}}(ptr align [[ABI_ALIGN]] [[ABI_ALLOCA]], ptr align [[RUST_ALIGN]] [[RUST_ALLOCA]], i64 16, i1 false) // aarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x double\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] - // loongarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ double, double }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_VALUE_0:%.+]] = load double, ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_ALLOCA_1:%.+]] = getelementptr inbounds i8, ptr [[ABI_ALLOCA]], i64 8 + // loongarch64: [[ABI_VALUE_1:%.+]] = load double, ptr [[ABI_ALLOCA_1]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_VALUE_2:%.+]] = insertvalue [[ABI_TYPE:{ double, double }]] poison, double [[ABI_VALUE_0]], 0 + // loongarch64: [[ABI_VALUE:%.+]] = insertvalue { double, double } [[ABI_VALUE_2]], double [[ABI_VALUE_1]], 1 // powerpc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // sparc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ double, double }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // x86_64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ double, double }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] @@ -465,7 +489,11 @@ pub fn return_doubledouble() -> DoubleDouble { // x86_64: [[ABI_VALUE:%.+]] = call [[ABI_TYPE:{ double, double }]] @returns_doubledouble() // aarch64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] - // loongarch64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_VALUE_0:%.+]] = extractvalue { double, double } [[ABI_VALUE]], 0 + // loongarch64: [[ABI_VALUE_1:%.+]] = extractvalue { double, double } [[ABI_VALUE]], 1 + // loongarch64: store double [[ABI_VALUE_0]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_ALLOCA_1:%.+]] = getelementptr inbounds i8, ptr [[ABI_ALLOCA]], i64 8 + // loongarch64: store double [[ABI_VALUE_1]], ptr [[ABI_ALLOCA_1]], align [[ABI_ALIGN]] // sparc64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // x86_64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] @@ -500,7 +528,11 @@ pub fn call_doublefloat() { // x86_64: call void @llvm.memcpy.{{.+}}(ptr align [[ABI_ALIGN]] [[ABI_ALLOCA]], ptr align [[RUST_ALIGN]] [[RUST_ALLOCA]], i64 16, i1 false) // aarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] - // loongarch64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ double, float }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_VALUE_0:%.+]] = load double, ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_ALLOCA_1:%.+]] = getelementptr inbounds i8, ptr [[ABI_ALLOCA]], i64 8 + // loongarch64: [[ABI_VALUE_1:%.+]] = load float, ptr [[ABI_ALLOCA_1]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_VALUE_2:%.+]] = insertvalue [[ABI_TYPE:{ double, float }]] poison, double [[ABI_VALUE_0]], 0 + // loongarch64: [[ABI_VALUE:%.+]] = insertvalue { double, float } [[ABI_VALUE_2]], float [[ABI_VALUE_1]], 1 // powerpc64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:\[2 x i64\]]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // x86_64: [[ABI_VALUE:%.+]] = load [[ABI_TYPE:{ double, double }]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] @@ -540,7 +572,11 @@ pub fn return_doublefloat() -> DoubleFloat { // x86_64: [[ABI_VALUE:%.+]] = call [[ABI_TYPE:{ double, double }]] @returns_doublefloat() // aarch64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] - // loongarch64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_VALUE_0:%.+]] = extractvalue { double, float } [[ABI_VALUE]], 0 + // loongarch64: [[ABI_VALUE_1:%.+]] = extractvalue { double, float } [[ABI_VALUE]], 1 + // loongarch64: store double [[ABI_VALUE_0]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] + // loongarch64: [[ABI_ALLOCA_1:%.+]] = getelementptr inbounds i8, ptr [[ABI_ALLOCA]], i64 8 + // loongarch64: store float [[ABI_VALUE_1]], ptr [[ABI_ALLOCA_1]], align [[ABI_ALIGN]] // x86_64: store [[ABI_TYPE]] [[ABI_VALUE]], ptr [[ABI_ALLOCA]], align [[ABI_ALIGN]] // aarch64: call void @llvm.memcpy.{{.+}}(ptr align [[RUST_ALIGN]] [[RUST_ALLOCA]], ptr align [[ABI_ALIGN]] [[ABI_ALLOCA]], i64 16, i1 false) diff --git a/tests/codegen-llvm/cffi/c-variadic-ffi.rs b/tests/codegen-llvm/cffi/c-variadic-ffi.rs index 3e99c9fb84e..1dee477e9ed 100644 --- a/tests/codegen-llvm/cffi/c-variadic-ffi.rs +++ b/tests/codegen-llvm/cffi/c-variadic-ffi.rs @@ -14,7 +14,7 @@ //@[arm32] needs-llvm-components: arm #![crate_type = "lib"] #![feature(no_core)] -#![feature(extended_varargs_abi_support, extern_system_varargs)] +#![feature(extern_system_varargs)] #![no_core] extern crate minicore; diff --git a/tests/codegen-llvm/function-arguments.rs b/tests/codegen-llvm/function-arguments.rs index db508682862..a0744e44c61 100644 --- a/tests/codegen-llvm/function-arguments.rs +++ b/tests/codegen-llvm/function-arguments.rs @@ -134,7 +134,7 @@ pub fn mutable_notunpin_borrow(_: &mut NotUnpin) {} #[no_mangle] pub fn notunpin_borrow(_: &NotUnpin) {} -// CHECK: @indirect_struct(ptr{{( dead_on_return)?}} noalias{{( nocapture)?}} noundef readonly align 4{{( captures\(none\))?}} dereferenceable(32) %_1) +// CHECK: @indirect_struct(ptr{{( dead_on_return)?}} noalias noundef readonly align 4{{( captures\(address\))?}} dereferenceable(32) %_1) #[no_mangle] pub fn indirect_struct(_: S) {} @@ -197,7 +197,7 @@ pub fn notunpin_box(x: Box<NotUnpin>) -> Box<NotUnpin> { x } -// CHECK: @struct_return(ptr{{( dead_on_unwind)?}} noalias{{( nocapture)?}} noundef{{( writable)?}} sret([32 x i8]) align 4{{( captures\(none\))?}} dereferenceable(32){{( %_0)?}}) +// CHECK: @struct_return(ptr{{( dead_on_unwind)?}} noalias noundef{{( writable)?}} sret([32 x i8]) align 4{{( captures\(address\))?}} dereferenceable(32){{( %_0)?}}) #[no_mangle] pub fn struct_return() -> S { S { _field: [0, 0, 0, 0, 0, 0, 0, 0] } diff --git a/tests/codegen-llvm/gpu-kernel-abi.rs b/tests/codegen-llvm/gpu-kernel-abi.rs index 8ac376d9338..d5a357ef655 100644 --- a/tests/codegen-llvm/gpu-kernel-abi.rs +++ b/tests/codegen-llvm/gpu-kernel-abi.rs @@ -1,7 +1,9 @@ // Checks that the gpu-kernel calling convention correctly translates to LLVM calling conventions. //@ add-core-stubs -//@ revisions: nvptx +//@ revisions: amdgpu nvptx +//@ [amdgpu] compile-flags: --crate-type=rlib --target=amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 +//@ [amdgpu] needs-llvm-components: amdgpu //@ [nvptx] compile-flags: --crate-type=rlib --target=nvptx64-nvidia-cuda //@ [nvptx] needs-llvm-components: nvptx #![feature(no_core, lang_items, abi_gpu_kernel)] @@ -10,6 +12,7 @@ extern crate minicore; use minicore::*; +// amdgpu: define amdgpu_kernel void @fun(i32 // nvptx: define ptx_kernel void @fun(i32 #[no_mangle] pub extern "gpu-kernel" fn fun(_: i32) {} diff --git a/tests/codegen-llvm/issues/issue-118306.rs b/tests/codegen-llvm/issues/issue-118306.rs index f12dc7cdfe2..934a7687b60 100644 --- a/tests/codegen-llvm/issues/issue-118306.rs +++ b/tests/codegen-llvm/issues/issue-118306.rs @@ -11,7 +11,7 @@ pub fn branchy(input: u64) -> u64 { // CHECK-LABEL: @branchy( // CHECK-NEXT: start: // CHECK-NEXT: [[_2:%.*]] = and i64 [[INPUT:%.*]], 3 - // CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds{{( nuw)?}} [4 x i64], ptr @switch.table.branchy, i64 0, i64 [[_2]] + // CHECK-NEXT: [[SWITCH_GEP:%.*]] = getelementptr inbounds{{( nuw)?}} {{\[4 x i64\]|i64}}, ptr @switch.table.branchy{{(, i64 0)?}}, i64 [[_2]] // CHECK-NEXT: [[SWITCH_LOAD:%.*]] = load i64, ptr [[SWITCH_GEP]] // CHECK-NEXT: ret i64 [[SWITCH_LOAD]] match input % 4 { diff --git a/tests/codegen-llvm/iter-repeat-n-trivial-drop.rs b/tests/codegen-llvm/iter-repeat-n-trivial-drop.rs index 28173530324..6f340978428 100644 --- a/tests/codegen-llvm/iter-repeat-n-trivial-drop.rs +++ b/tests/codegen-llvm/iter-repeat-n-trivial-drop.rs @@ -4,7 +4,6 @@ #![crate_type = "lib"] #![feature(iter_repeat_n)] -#![feature(array_repeat)] #[derive(Clone)] pub struct NotCopy(u16); diff --git a/tests/codegen-llvm/loongarch-abi/cast-local-large-enough.rs b/tests/codegen-llvm/loongarch-abi/cast-local-large-enough.rs new file mode 100644 index 00000000000..e5a0e4cd3a2 --- /dev/null +++ b/tests/codegen-llvm/loongarch-abi/cast-local-large-enough.rs @@ -0,0 +1,44 @@ +//@ add-core-stubs +//@ compile-flags: -Copt-level=0 -Cdebuginfo=0 --target loongarch64-unknown-linux-gnu +//@ needs-llvm-components: loongarch + +#![feature(no_core, lang_items)] +#![no_std] +#![no_core] +#![crate_type = "lib"] + +extern crate minicore; +use minicore::*; + +#[repr(C, align(64))] +struct Aligned(f64); + +#[repr(C, align(64))] +struct AlignedPair(f32, f64); + +impl Copy for Aligned {} +impl Copy for AlignedPair {} + +// CHECK-LABEL: define double @read_aligned +#[unsafe(no_mangle)] +pub extern "C" fn read_aligned(x: &Aligned) -> Aligned { + // CHECK: %[[TEMP:.*]] = alloca [64 x i8], align 64 + // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 64 %[[TEMP]], ptr align 64 %[[PTR:.*]], i64 64, i1 false) + // CHECK-NEXT: %[[RES:.*]] = load double, ptr %[[TEMP]], align 64 + // CHECK-NEXT: ret double %[[RES]] + *x +} + +// CHECK-LABEL: define { float, double } @read_aligned_pair +#[unsafe(no_mangle)] +pub extern "C" fn read_aligned_pair(x: &AlignedPair) -> AlignedPair { + // CHECK: %[[TEMP:.*]] = alloca [64 x i8], align 64 + // CHECK-NEXT: call void @llvm.memcpy.p0.p0.i64(ptr align 64 %[[TEMP]], ptr align 64 %[[PTR:.*]], i64 64, i1 false) + // CHECK-NEXT: %[[FIRST:.*]] = load float, ptr %[[TEMP]], align 64 + // CHECK-NEXT: %[[SECOND_PTR:.*]] = getelementptr inbounds i8, ptr %[[TEMP]], i64 8 + // CHECK-NEXT: %[[SECOND:.*]] = load double, ptr %[[SECOND_PTR]], align 8 + // CHECK-NEXT: %[[RES1:.*]] = insertvalue { float, double } poison, float %[[FIRST]], 0 + // CHECK-NEXT: %[[RES2:.*]] = insertvalue { float, double } %[[RES1]], double %[[SECOND]], 1 + // CHECK-NEXT: ret { float, double } %[[RES2]] + *x +} diff --git a/tests/codegen-llvm/loongarch-abi/loongarch64-lp64d-abi.rs b/tests/codegen-llvm/loongarch-abi/loongarch64-lp64d-abi.rs index 4666342a16a..7ea08a1a8f7 100644 --- a/tests/codegen-llvm/loongarch-abi/loongarch64-lp64d-abi.rs +++ b/tests/codegen-llvm/loongarch-abi/loongarch64-lp64d-abi.rs @@ -256,11 +256,11 @@ pub struct IntDoubleInt { c: i32, } -// CHECK: define void @f_int_double_int_s_arg(ptr{{( dead_on_return)?}} noalias{{( nocapture)?}} noundef align 8{{( captures\(none\))?}} dereferenceable(24) %a) +// CHECK: define void @f_int_double_int_s_arg(ptr{{( dead_on_return)?}} noalias noundef align 8{{( captures\(address\))?}} dereferenceable(24) %a) #[no_mangle] pub extern "C" fn f_int_double_int_s_arg(a: IntDoubleInt) {} -// CHECK: define void @f_ret_int_double_int_s(ptr{{( dead_on_unwind)?}} noalias{{( nocapture)?}} noundef{{( writable)?}} sret([24 x i8]) align 8{{( captures\(none\))?}} dereferenceable(24) %_0) +// CHECK: define void @f_ret_int_double_int_s(ptr{{( dead_on_unwind)?}} noalias noundef{{( writable)?}} sret([24 x i8]) align 8{{( captures\(address\))?}} 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-llvm/sanitizer/address-sanitizer-globals-tracking.rs b/tests/codegen-llvm/sanitizer/address-sanitizer-globals-tracking.rs index 642bf5e7576..ada525b6c80 100644 --- a/tests/codegen-llvm/sanitizer/address-sanitizer-globals-tracking.rs +++ b/tests/codegen-llvm/sanitizer/address-sanitizer-globals-tracking.rs @@ -19,7 +19,7 @@ //@ only-linux // //@ revisions:ASAN ASAN-FAT-LTO -//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static +//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer // [ASAN] no extra compile-flags //@[ASAN-FAT-LTO] compile-flags: -Cprefer-dynamic=false -Clto=fat diff --git a/tests/codegen-llvm/sanitizer/cfi/add-canonical-jump-tables-flag.rs b/tests/codegen-llvm/sanitizer/cfi/add-canonical-jump-tables-flag.rs index 22577e2a3c4..77857ca4ccb 100644 --- a/tests/codegen-llvm/sanitizer/cfi/add-canonical-jump-tables-flag.rs +++ b/tests/codegen-llvm/sanitizer/cfi/add-canonical-jump-tables-flag.rs @@ -1,7 +1,7 @@ // Verifies that "CFI Canonical Jump Tables" module flag is added. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/add-cfi-normalize-integers-flag.rs b/tests/codegen-llvm/sanitizer/cfi/add-cfi-normalize-integers-flag.rs index a54a6d84a80..6cf9a72b748 100644 --- a/tests/codegen-llvm/sanitizer/cfi/add-cfi-normalize-integers-flag.rs +++ b/tests/codegen-llvm/sanitizer/cfi/add-cfi-normalize-integers-flag.rs @@ -1,7 +1,7 @@ // Verifies that "cfi-normalize-integers" module flag is added. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers +//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -C unsafe-allow-abi-mismatch=sanitizer,sanitizer-cfi-normalize-integers #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/add-enable-split-lto-unit-flag.rs b/tests/codegen-llvm/sanitizer/cfi/add-enable-split-lto-unit-flag.rs index 283b8f26102..0bfdbfba5d2 100644 --- a/tests/codegen-llvm/sanitizer/cfi/add-enable-split-lto-unit-flag.rs +++ b/tests/codegen-llvm/sanitizer/cfi/add-enable-split-lto-unit-flag.rs @@ -1,7 +1,7 @@ // Verifies that "EnableSplitLTOUnit" module flag is added. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/dbg-location-on-cfi-blocks.rs b/tests/codegen-llvm/sanitizer/cfi/dbg-location-on-cfi-blocks.rs index df65960dfe0..2a18e30e2b0 100644 --- a/tests/codegen-llvm/sanitizer/cfi/dbg-location-on-cfi-blocks.rs +++ b/tests/codegen-llvm/sanitizer/cfi/dbg-location-on-cfi-blocks.rs @@ -1,7 +1,7 @@ // Verifies that the parent block's debug information are assigned to the inserted cfi block. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -Cdebuginfo=1 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -Cdebuginfo=1 -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-checks-attr-sanitize-off.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-checks-attr-sanitize-off.rs index 651afb33228..c49438f4318 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-checks-attr-sanitize-off.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-checks-attr-sanitize-off.rs @@ -1,7 +1,7 @@ // Verifies that pointer type membership tests for indirect calls are omitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] #![feature(sanitize)] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-checks.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-checks.rs index ebc66a015df..9cad88f6518 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-checks.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-checks.rs @@ -1,7 +1,7 @@ // Verifies that pointer type membership tests for indirect calls are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-attr-cfi-encoding.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-attr-cfi-encoding.rs index 9bc2e42db0f..cd9088f58af 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-attr-cfi-encoding.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-attr-cfi-encoding.rs @@ -1,7 +1,7 @@ // Verifies that user-defined CFI encoding for types are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] #![feature(cfi_encoding, extern_types)] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-const-generics.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-const-generics.rs index 9048c6a1f18..cf26c17af1e 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-const-generics.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-const-generics.rs @@ -2,7 +2,7 @@ // for const generics. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] #![feature(type_alias_impl_trait)] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs index 8fec275fd06..279350d20c5 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-drop-in-place.rs @@ -5,7 +5,7 @@ // future. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs index 7e60aafff68..047b532e994 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-function-types.rs @@ -2,7 +2,7 @@ // for function types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs index 36d2e8c9f25..92b2ab32ea0 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-lifetimes.rs @@ -2,7 +2,7 @@ // for lifetimes/regions. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] #![feature(type_alias_impl_trait)] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs index 9d611777ff0..5de39dc85c1 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-method-secondary-typeid.rs @@ -2,7 +2,7 @@ // self so they can be used as function pointers. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs index a8ba8db1be3..f5846713bd5 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-paths.rs @@ -2,7 +2,7 @@ // for paths. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] #![feature(type_alias_impl_trait)] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs index d37bb740f55..ad4fe11d087 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-pointer-types.rs @@ -2,7 +2,7 @@ // for pointer types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs index 7d9e4d05872..93845d05195 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-primitive-types.rs @@ -2,7 +2,7 @@ // for primitive types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs index 0f97c70f3f9..025aa902658 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-repr-transparent-types.rs @@ -2,7 +2,7 @@ // for repr transparent types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs index bdee3f47a83..76c8150b778 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-sequence-types.rs @@ -2,7 +2,7 @@ // for sequence types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs index 55e816178f8..4fafdd2f040 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-trait-types.rs @@ -2,7 +2,7 @@ // for trait types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs index c1f3ca61afe..91351096ca2 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-id-itanium-cxx-abi-user-defined-types.rs @@ -2,7 +2,7 @@ // for user-defined types. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] #![feature(extern_types)] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs index 32637b64b3e..22d518cca74 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-generalized.rs @@ -1,7 +1,7 @@ // Verifies that generalized type metadata for functions are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs index 51121b0aef1..7639ce7b104 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized-generalized.rs @@ -1,7 +1,7 @@ // Verifies that normalized and generalized type metadata for functions are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Zsanitizer-cfi-generalize-pointers -C unsafe-allow-abi-mismatch=sanitizer,sanitizer-cfi-normalize-integers #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs index 1cfdd23006e..acd72b0ca3c 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi-normalized.rs @@ -1,7 +1,7 @@ // Verifies that normalized type metadata for functions are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -C unsafe-allow-abi-mismatch=sanitizer,sanitizer-cfi-normalize-integers #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs index 56ab1ce4b35..fa5cd471466 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-itanium-cxx-abi.rs @@ -1,7 +1,7 @@ // Verifies that type metadata for functions are emitted. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-trait-objects.rs b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-trait-objects.rs index 0e57ce322d1..82873e935b2 100644 --- a/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-trait-objects.rs +++ b/tests/codegen-llvm/sanitizer/cfi/emit-type-metadata-trait-objects.rs @@ -1,7 +1,7 @@ // Verifies that type metadata identifiers for trait objects are emitted correctly. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Clto -Cno-prepopulate-passes -Copt-level=0 -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/external_weak_symbols.rs b/tests/codegen-llvm/sanitizer/cfi/external_weak_symbols.rs index b3cb6dfdd37..893b0167693 100644 --- a/tests/codegen-llvm/sanitizer/cfi/external_weak_symbols.rs +++ b/tests/codegen-llvm/sanitizer/cfi/external_weak_symbols.rs @@ -2,7 +2,7 @@ // emitted correctly. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clinker-plugin-lto -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Clinker-plugin-lto -Copt-level=0 -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "bin"] #![feature(linkage)] diff --git a/tests/codegen-llvm/sanitizer/cfi/generalize-pointers.rs b/tests/codegen-llvm/sanitizer/cfi/generalize-pointers.rs index 57004da6f8e..caa2f258f8f 100644 --- a/tests/codegen-llvm/sanitizer/cfi/generalize-pointers.rs +++ b/tests/codegen-llvm/sanitizer/cfi/generalize-pointers.rs @@ -1,7 +1,7 @@ // Verifies that pointer types are generalized. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/cfi/normalize-integers.rs b/tests/codegen-llvm/sanitizer/cfi/normalize-integers.rs index 770ee4e64e0..16f76adafb8 100644 --- a/tests/codegen-llvm/sanitizer/cfi/normalize-integers.rs +++ b/tests/codegen-llvm/sanitizer/cfi/normalize-integers.rs @@ -1,7 +1,7 @@ // Verifies that integer types are normalized. // //@ needs-sanitizer-cfi -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Copt-level=0 +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer,sanitizer-cfi-normalize-integers #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/dataflow-instrument-functions.rs b/tests/codegen-llvm/sanitizer/dataflow-instrument-functions.rs index a2d0d63cc17..cd8c2c48ea4 100644 --- a/tests/codegen-llvm/sanitizer/dataflow-instrument-functions.rs +++ b/tests/codegen-llvm/sanitizer/dataflow-instrument-functions.rs @@ -1,7 +1,7 @@ // Verifies that functions are instrumented. // //@ needs-sanitizer-dataflow -//@ compile-flags: -Copt-level=0 -Zsanitizer=dataflow +//@ compile-flags: -Copt-level=0 -Zsanitizer=dataflow -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/memory-track-origins.rs b/tests/codegen-llvm/sanitizer/memory-track-origins.rs index 5eb5b356b05..a72e523c4e1 100644 --- a/tests/codegen-llvm/sanitizer/memory-track-origins.rs +++ b/tests/codegen-llvm/sanitizer/memory-track-origins.rs @@ -4,7 +4,7 @@ //@ needs-sanitizer-memory //@ revisions:MSAN-0 MSAN-1 MSAN-2 MSAN-1-LTO MSAN-2-LTO // -//@ compile-flags: -Zsanitizer=memory -Ctarget-feature=-crt-static +//@ compile-flags: -Zsanitizer=memory -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer // [MSAN-0] no extra compile-flags //@[MSAN-1] compile-flags: -Zsanitizer-memory-track-origins=1 //@[MSAN-2] compile-flags: -Zsanitizer-memory-track-origins diff --git a/tests/codegen-llvm/sanitizer/memtag-attr-check.rs b/tests/codegen-llvm/sanitizer/memtag-attr-check.rs index ffe3a2322a2..fc430f3a570 100644 --- a/tests/codegen-llvm/sanitizer/memtag-attr-check.rs +++ b/tests/codegen-llvm/sanitizer/memtag-attr-check.rs @@ -2,7 +2,7 @@ // applied when enabling the memtag sanitizer. // //@ needs-sanitizer-memtag -//@ compile-flags: -Zsanitizer=memtag -Ctarget-feature=+mte -Copt-level=0 +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer -Zsanitizer=memtag -Ctarget-feature=+mte -Copt-level=0 #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/safestack-attr-check.rs b/tests/codegen-llvm/sanitizer/safestack-attr-check.rs index 050a60333af..414dd89a580 100644 --- a/tests/codegen-llvm/sanitizer/safestack-attr-check.rs +++ b/tests/codegen-llvm/sanitizer/safestack-attr-check.rs @@ -1,7 +1,7 @@ // This tests that the safestack attribute is applied when enabling the safe-stack sanitizer. // //@ needs-sanitizer-safestack -//@ compile-flags: -Zsanitizer=safestack -Copt-level=0 +//@ compile-flags: -Zsanitizer=safestack -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] diff --git a/tests/codegen-llvm/sanitizer/sanitize-off-inlining.rs b/tests/codegen-llvm/sanitizer/sanitize-off-inlining.rs index 69771827c3a..0f43e6b8393 100644 --- a/tests/codegen-llvm/sanitizer/sanitize-off-inlining.rs +++ b/tests/codegen-llvm/sanitizer/sanitize-off-inlining.rs @@ -1,9 +1,9 @@ // Verifies that sanitize(xyz = "off") attribute prevents inlining when // given sanitizer is enabled, but has no effect on inlining otherwise. -// //@ needs-sanitizer-address //@ needs-sanitizer-leak //@ revisions: ASAN LSAN +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer //@ compile-flags: -Copt-level=3 -Zmir-opt-level=4 -Ctarget-feature=-crt-static //@[ASAN] compile-flags: -Zsanitizer=address //@[LSAN] compile-flags: -Zsanitizer=leak diff --git a/tests/codegen-llvm/sanitizer/sanitize-off-kasan-asan.rs b/tests/codegen-llvm/sanitizer/sanitize-off-kasan-asan.rs index 94945f2b2e6..61ad0ba7d90 100644 --- a/tests/codegen-llvm/sanitizer/sanitize-off-kasan-asan.rs +++ b/tests/codegen-llvm/sanitizer/sanitize-off-kasan-asan.rs @@ -2,7 +2,7 @@ // the address sanitizer. // //@ needs-sanitizer-address -//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static -Copt-level=0 +//@ compile-flags: -Zsanitizer=address -Ctarget-feature=-crt-static -Copt-level=0 -C unsafe-allow-abi-mismatch=sanitizer #![crate_type = "lib"] #![feature(sanitize)] diff --git a/tests/codegen-llvm/sanitizer/sanitizer-recover.rs b/tests/codegen-llvm/sanitizer/sanitizer-recover.rs index 6b659320481..b8a24e31c30 100644 --- a/tests/codegen-llvm/sanitizer/sanitizer-recover.rs +++ b/tests/codegen-llvm/sanitizer/sanitizer-recover.rs @@ -5,7 +5,7 @@ //@ needs-sanitizer-memory //@ revisions:ASAN ASAN-RECOVER MSAN MSAN-RECOVER MSAN-RECOVER-LTO //@ no-prefer-dynamic -// +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer //@ compile-flags: -Ctarget-feature=-crt-static //@[ASAN] compile-flags: -Zsanitizer=address -Copt-level=0 //@[ASAN-RECOVER] compile-flags: -Zsanitizer=address -Zsanitizer-recover=address -Copt-level=0 diff --git a/tests/codegen-units/item-collection/async-fn-impl.rs b/tests/codegen-units/item-collection/async-fn-impl.rs new file mode 100644 index 00000000000..540fa0b3228 --- /dev/null +++ b/tests/codegen-units/item-collection/async-fn-impl.rs @@ -0,0 +1,10 @@ +//@ edition: 2024 +// When pub async fn is monomorphized, its implementation coroutine is also monomorphized +//@ compile-flags: --crate-type=lib + +//~ MONO_ITEM fn async_fn @@ +//~ MONO_ITEM fn async_fn::{closure#0} @@ +#[unsafe(no_mangle)] +pub async fn async_fn(x: u64) -> bool { + true +} diff --git a/tests/codegen-units/item-collection/opaque-return-impls.rs b/tests/codegen-units/item-collection/opaque-return-impls.rs new file mode 100644 index 00000000000..7d5f4f5b669 --- /dev/null +++ b/tests/codegen-units/item-collection/opaque-return-impls.rs @@ -0,0 +1,89 @@ +//@ only-x86_64-unknown-linux-gnu +//@ compile-flags: -C panic=abort -Zinline-mir=no -Copt-level=0 -Zcross-crate-inline-threshold=never -Zmir-opt-level=0 -Cno-prepopulate-passes +//@ no-prefer-dynamic +//@ edition:2024 +#![crate_type = "lib"] + +trait TestTrait { + fn test_func(&self); +} + +struct TestStruct {} + +impl TestTrait for TestStruct { + fn test_func(&self) { + println!("TestStruct::test_func"); + } +} + +#[inline(never)] +pub fn foo() -> impl TestTrait { + TestStruct {} +} + +//~ MONO_ITEM fn foo +//~ MONO_ITEM fn <TestStruct as TestTrait>::test_func + +trait TestTrait2 { + fn test_func2(&self); +} + +struct TestStruct2 {} + +impl TestTrait2 for TestStruct2 { + fn test_func2(&self) { + println!("TestStruct2::test_func2"); + } +} + +#[inline(never)] +pub fn foo2() -> Box<dyn TestTrait2> { + Box::new(TestStruct2 {}) +} + +//~ MONO_ITEM fn <TestStruct2 as TestTrait2>::test_func2 +//~ MONO_ITEM fn alloc::alloc::exchange_malloc +//~ MONO_ITEM fn foo2 +//~ MONO_ITEM fn std::alloc::Global::alloc_impl +//~ MONO_ITEM fn std::boxed::Box::<TestStruct2>::new +//~ MONO_ITEM fn std::alloc::Layout::from_size_align_unchecked::precondition_check +//~ MONO_ITEM fn std::ptr::NonNull::<T>::new_unchecked::precondition_check + +struct Counter { + count: usize, +} + +impl Counter { + fn new() -> Counter { + Counter { count: 0 } + } +} + +impl Iterator for Counter { + type Item = usize; + + fn next(&mut self) -> Option<Self::Item> { + self.count += 1; + if self.count < 6 { Some(self.count) } else { None } + } +} + +#[inline(never)] +pub fn foo3() -> Box<dyn Iterator<Item = usize>> { + Box::new(Counter::new()) +} + +//~ MONO_ITEM fn <Counter as std::iter::Iterator::advance_by::SpecAdvanceBy>::spec_advance_by +//~ MONO_ITEM fn <Counter as std::iter::Iterator::advance_by::SpecAdvanceBy>::spec_advance_by::{closure#0} +//~ MONO_ITEM fn <Counter as std::iter::Iterator>::advance_by +//~ MONO_ITEM fn <Counter as std::iter::Iterator>::next +//~ MONO_ITEM fn <Counter as std::iter::Iterator>::nth +//~ MONO_ITEM fn <Counter as std::iter::Iterator>::size_hint +//~ MONO_ITEM fn <Counter as std::iter::Iterator>::try_fold::<std::num::NonZero<usize>, {closure@<Counter as std::iter::Iterator::advance_by::SpecAdvanceBy>::spec_advance_by::{closure#0}}, std::option::Option<std::num::NonZero<usize>>> +//~ MONO_ITEM fn <std::option::Option<std::num::NonZero<usize>> as std::ops::FromResidual<std::option::Option<std::convert::Infallible>>>::from_residual +//~ MONO_ITEM fn <std::option::Option<std::num::NonZero<usize>> as std::ops::Try>::branch +//~ MONO_ITEM fn <std::option::Option<std::num::NonZero<usize>> as std::ops::Try>::from_output +//~ MONO_ITEM fn foo3 +//~ MONO_ITEM fn std::boxed::Box::<Counter>::new +//~ MONO_ITEM fn Counter::new +//~ MONO_ITEM fn core::fmt::rt::<impl std::fmt::Arguments<'_>>::new_const::<1> diff --git a/tests/coverage/async.cov-map b/tests/coverage/async.cov-map index c528ad525b5..d75c4b5981a 100644 --- a/tests/coverage/async.cov-map +++ b/tests/coverage/async.cov-map @@ -103,21 +103,21 @@ Number of file 0 mappings: 3 Highest counter ID seen: (none) Function name: async::g -Raw bytes (9): 0x[01, 01, 00, 01, 01, 1b, 01, 00, 16] +Raw bytes (9): 0x[01, 01, 00, 01, 01, 1b, 01, 00, 12] Number of files: 1 - file 0 => $DIR/async.rs Number of expressions: 0 Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 27, 1) to (start + 0, 22) +- Code(Counter(0)) at (prev + 27, 1) to (start + 0, 18) Highest counter ID seen: c0 Function name: async::g::{closure#0} (unused) -Raw bytes (64): 0x[01, 01, 00, 0c, 00, 1b, 17, 00, 18, 00, 01, 0b, 00, 0c, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] +Raw bytes (64): 0x[01, 01, 00, 0c, 00, 1b, 13, 00, 14, 00, 01, 0b, 00, 0c, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 09, 00, 0a, 00, 00, 0e, 00, 17, 00, 00, 1b, 00, 1c, 00, 00, 20, 00, 22, 00, 01, 0e, 00, 10, 00, 02, 01, 00, 02] Number of files: 1 - file 0 => $DIR/async.rs Number of expressions: 0 Number of file 0 mappings: 12 -- Code(Zero) at (prev + 27, 23) to (start + 0, 24) +- Code(Zero) at (prev + 27, 19) to (start + 0, 20) - Code(Zero) at (prev + 1, 11) to (start + 0, 12) - Code(Zero) at (prev + 1, 9) to (start + 0, 10) - Code(Zero) at (prev + 0, 14) to (start + 0, 23) diff --git a/tests/coverage/async.coverage b/tests/coverage/async.coverage index 9fca1b6997d..9409e6b1deb 100644 --- a/tests/coverage/async.coverage +++ b/tests/coverage/async.coverage @@ -24,8 +24,8 @@ LL| | LL| 0|async fn foo() -> [bool; 10] { [false; 10] } // unused function; executor does not block on `h()` LL| | - LL| 1|pub async fn g(x: u8) { - ^0 + LL| 1|async fn g(x: u8) { + ^0 LL| 0| match x { LL| 0| y if e().await == y => (), LL| 0| y if f().await == y => (), diff --git a/tests/coverage/async.rs b/tests/coverage/async.rs index da0a1c0b6f0..777ad7ce7c0 100644 --- a/tests/coverage/async.rs +++ b/tests/coverage/async.rs @@ -24,7 +24,7 @@ async fn f() -> u8 { 1 } async fn foo() -> [bool; 10] { [false; 10] } // unused function; executor does not block on `h()` -pub async fn g(x: u8) { +async fn g(x: u8) { match x { y if e().await == y => (), y if f().await == y => (), diff --git a/tests/coverage/closure.cov-map b/tests/coverage/closure.cov-map index 5f7e4ce58e9..ee8934f0a84 100644 --- a/tests/coverage/closure.cov-map +++ b/tests/coverage/closure.cov-map @@ -118,21 +118,23 @@ Number of file 0 mappings: 4 Highest counter ID seen: (none) Function name: closure::main::{closure#12} (unused) -Raw bytes (10): 0x[01, 01, 00, 01, 00, a7, 01, 0a, 00, 16] +Raw bytes (15): 0x[01, 01, 00, 02, 00, a7, 01, 01, 00, 09, 00, 00, 0a, 00, 16] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Zero) at (prev + 167, 10) to (start + 0, 22) +Number of file 0 mappings: 2 +- Code(Zero) at (prev + 167, 1) to (start + 0, 9) +- Code(Zero) at (prev + 0, 10) to (start + 0, 22) Highest counter ID seen: (none) Function name: closure::main::{closure#13} (unused) -Raw bytes (10): 0x[01, 01, 00, 01, 00, ad, 01, 11, 00, 1d] +Raw bytes (15): 0x[01, 01, 00, 02, 00, ac, 01, 0d, 00, 15, 00, 01, 11, 00, 1d] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Zero) at (prev + 173, 17) to (start + 0, 29) +Number of file 0 mappings: 2 +- Code(Zero) at (prev + 172, 13) to (start + 0, 21) +- Code(Zero) at (prev + 1, 17) to (start + 0, 29) Highest counter ID seen: (none) Function name: closure::main::{closure#14} @@ -289,30 +291,33 @@ Number of file 0 mappings: 7 Highest counter ID seen: (none) Function name: closure::main::{closure#5} -Raw bytes (10): 0x[01, 01, 00, 01, 01, 8c, 01, 46, 00, 4e] +Raw bytes (15): 0x[01, 01, 00, 02, 01, 8c, 01, 3d, 00, 45, 01, 00, 46, 00, 4e] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 140, 70) to (start + 0, 78) +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 140, 61) to (start + 0, 69) +- Code(Counter(0)) at (prev + 0, 70) to (start + 0, 78) Highest counter ID seen: c0 Function name: closure::main::{closure#6} -Raw bytes (10): 0x[01, 01, 00, 01, 01, 8d, 01, 4a, 00, 56] +Raw bytes (15): 0x[01, 01, 00, 02, 01, 8d, 01, 41, 00, 49, 01, 00, 4a, 00, 56] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 141, 74) to (start + 0, 86) +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 141, 65) to (start + 0, 73) +- Code(Counter(0)) at (prev + 0, 74) to (start + 0, 86) Highest counter ID seen: c0 Function name: closure::main::{closure#7} (unused) -Raw bytes (10): 0x[01, 01, 00, 01, 00, 8e, 01, 44, 00, 50] +Raw bytes (15): 0x[01, 01, 00, 02, 00, 8e, 01, 3b, 00, 43, 00, 00, 44, 00, 50] Number of files: 1 - file 0 => $DIR/closure.rs Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Zero) at (prev + 142, 68) to (start + 0, 80) +Number of file 0 mappings: 2 +- Code(Zero) at (prev + 142, 59) to (start + 0, 67) +- Code(Zero) at (prev + 0, 68) to (start + 0, 80) Highest counter ID seen: (none) Function name: closure::main::{closure#8} (unused) diff --git a/tests/coverage/closure.coverage b/tests/coverage/closure.coverage index 14285269228..d44ecf5a69e 100644 --- a/tests/coverage/closure.coverage +++ b/tests/coverage/closure.coverage @@ -139,9 +139,9 @@ LL| | LL| 1| let short_used_covered_closure_macro = | used_arg: u8 | println!("called"); LL| 1| let short_used_not_covered_closure_macro = | used_arg: u8 | println!("not called"); - ^0 + ^0 ^0 LL| 1| let _short_unused_closure_macro = | _unused_arg: u8 | println!("not called"); - ^0 + ^0 ^0 LL| | LL| | LL| | @@ -173,7 +173,7 @@ LL| | LL| 1| let _short_unused_closure_line_break_no_block2 = LL| | | _unused_arg: u8 | - LL| | println!( + LL| 0| println!( LL| 0| "not called" LL| | ) LL| | ; diff --git a/tests/coverage/macro_in_closure.cov-map b/tests/coverage/macro_in_closure.cov-map index 4544aa50143..3529d0c4c32 100644 --- a/tests/coverage/macro_in_closure.cov-map +++ b/tests/coverage/macro_in_closure.cov-map @@ -1,10 +1,11 @@ Function name: macro_in_closure::NO_BLOCK::{closure#0} -Raw bytes (9): 0x[01, 01, 00, 01, 01, 07, 25, 00, 2c] +Raw bytes (14): 0x[01, 01, 00, 02, 01, 07, 1c, 00, 24, 01, 00, 25, 00, 2c] Number of files: 1 - file 0 => $DIR/macro_in_closure.rs Number of expressions: 0 -Number of file 0 mappings: 1 -- Code(Counter(0)) at (prev + 7, 37) to (start + 0, 44) +Number of file 0 mappings: 2 +- Code(Counter(0)) at (prev + 7, 28) to (start + 0, 36) +- Code(Counter(0)) at (prev + 0, 37) to (start + 0, 44) Highest counter ID seen: c0 Function name: macro_in_closure::WITH_BLOCK::{closure#0} diff --git a/tests/coverage/rustfmt-skip.cov-map b/tests/coverage/rustfmt-skip.cov-map new file mode 100644 index 00000000000..bb673a411bf --- /dev/null +++ b/tests/coverage/rustfmt-skip.cov-map @@ -0,0 +1,12 @@ +Function name: rustfmt_skip::main +Raw bytes (24): 0x[01, 01, 00, 04, 01, 0a, 01, 00, 0a, 01, 02, 05, 00, 0d, 01, 03, 09, 00, 10, 01, 02, 01, 00, 02] +Number of files: 1 +- file 0 => $DIR/rustfmt-skip.rs +Number of expressions: 0 +Number of file 0 mappings: 4 +- Code(Counter(0)) at (prev + 10, 1) to (start + 0, 10) +- Code(Counter(0)) at (prev + 2, 5) to (start + 0, 13) +- Code(Counter(0)) at (prev + 3, 9) to (start + 0, 16) +- Code(Counter(0)) at (prev + 2, 1) to (start + 0, 2) +Highest counter ID seen: c0 + diff --git a/tests/coverage/rustfmt-skip.coverage b/tests/coverage/rustfmt-skip.coverage new file mode 100644 index 00000000000..b7276cf0ee8 --- /dev/null +++ b/tests/coverage/rustfmt-skip.coverage @@ -0,0 +1,18 @@ + LL| |//@ edition: 2024 + LL| | + LL| |// The presence of `#[rustfmt::skip]` on a function should not cause macros + LL| |// within that function to mysteriously not be instrumented. + LL| |// + LL| |// This test detects problems that can occur when building an expansion tree + LL| |// based on `ExpnData::parent` instead of `ExpnData::call_site`, for example. + LL| | + LL| |#[rustfmt::skip] + LL| 1|fn main() { + LL| | // Ensure a gap between the body start and the first statement. + LL| 1| println!( + LL| | // Keep this on a separate line, to distinguish instrumentation of + LL| | // `println!` from instrumentation of its arguments. + LL| 1| "hello" + LL| | ); + LL| 1|} + diff --git a/tests/coverage/rustfmt-skip.rs b/tests/coverage/rustfmt-skip.rs new file mode 100644 index 00000000000..6f6874c9aa0 --- /dev/null +++ b/tests/coverage/rustfmt-skip.rs @@ -0,0 +1,17 @@ +//@ edition: 2024 + +// The presence of `#[rustfmt::skip]` on a function should not cause macros +// within that function to mysteriously not be instrumented. +// +// This test detects problems that can occur when building an expansion tree +// based on `ExpnData::parent` instead of `ExpnData::call_site`, for example. + +#[rustfmt::skip] +fn main() { + // Ensure a gap between the body start and the first statement. + println!( + // Keep this on a separate line, to distinguish instrumentation of + // `println!` from instrumentation of its arguments. + "hello" + ); +} diff --git a/tests/crashes/120175.rs b/tests/crashes/120175.rs index c6e7203ff98..e441454bed2 100644 --- a/tests/crashes/120175.rs +++ b/tests/crashes/120175.rs @@ -2,8 +2,9 @@ //@ needs-rustc-debug-assertions #![feature(extern_types)] +#![feature(raw_dylib_elf)] -#[link(name = "bar", import_name_type = "decorated", kind = "raw-dylib")] +#[link(name = "bar", kind = "raw-dylib")] extern "C" { pub type CrossCrate; } diff --git a/tests/crashes/124352.rs b/tests/crashes/124352.rs deleted file mode 100644 index e9eb4419e6a..00000000000 --- a/tests/crashes/124352.rs +++ /dev/null @@ -1,4 +0,0 @@ -//@ known-bug: #124352 -#![rustc_never_type_options(: Unsize<U> = "hi")] - -fn main() {} diff --git a/tests/crashes/137580.rs b/tests/crashes/137580.rs deleted file mode 100644 index 246c80ef556..00000000000 --- a/tests/crashes/137580.rs +++ /dev/null @@ -1,4 +0,0 @@ -//@ known-bug: #137580 -fn main() { - println!("%65536$", 1); -} diff --git a/tests/crashes/140479.rs b/tests/crashes/140479.rs deleted file mode 100644 index ed3ca887546..00000000000 --- a/tests/crashes/140479.rs +++ /dev/null @@ -1,5 +0,0 @@ -//@ known-bug: #140479 -macro_rules! a { ( $( { $ [ $b:c ] } )) => ( $(${ concat(d, $b)} ))} -fn e() { - a!({}) -} diff --git a/tests/debuginfo/basic-stepping.rs b/tests/debuginfo/basic-stepping.rs index e7a70c8b087..f6399814a43 100644 --- a/tests/debuginfo/basic-stepping.rs +++ b/tests/debuginfo/basic-stepping.rs @@ -4,6 +4,7 @@ //@ ignore-aarch64: Doesn't work yet. //@ ignore-loongarch64: Doesn't work yet. +//@ ignore-riscv64: Doesn't work yet. //@ compile-flags: -g // gdb-command: run diff --git a/tests/mir-opt/building/async_await.rs b/tests/mir-opt/building/async_await.rs index 6c44570d109..2d14a1fb0c6 100644 --- a/tests/mir-opt/building/async_await.rs +++ b/tests/mir-opt/building/async_await.rs @@ -4,7 +4,7 @@ // related to `yield` are `&mut Context`, and its return type is `Poll`. //@ edition:2018 -//@ compile-flags: -C panic=abort +//@ compile-flags: -Zmir-opt-level=0 -C panic=abort #![crate_type = "lib"] diff --git a/tests/mir-opt/building/dump_mir_cycle.rs b/tests/mir-opt/building/dump_mir_cycle.rs index 8e13420aed7..ab0f2ea6db8 100644 --- a/tests/mir-opt/building/dump_mir_cycle.rs +++ b/tests/mir-opt/building/dump_mir_cycle.rs @@ -1,3 +1,5 @@ +//@ compile-flags: -Zmir-opt-level=0 + #[derive(Debug)] pub struct Thing { pub next: &'static Thing, diff --git a/tests/mir-opt/building/enum_cast.rs b/tests/mir-opt/building/enum_cast.rs index eaf5537e0ab..07025f572ab 100644 --- a/tests/mir-opt/building/enum_cast.rs +++ b/tests/mir-opt/building/enum_cast.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zmir-opt-level=0 // skip-filecheck // EMIT_MIR enum_cast.foo.built.after.mir // EMIT_MIR enum_cast.bar.built.after.mir diff --git a/tests/mir-opt/building/eq_never_type.rs b/tests/mir-opt/building/eq_never_type.rs index 90e2e697535..486e2f9fb8d 100644 --- a/tests/mir-opt/building/eq_never_type.rs +++ b/tests/mir-opt/building/eq_never_type.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zmir-opt-level=0 // skip-filecheck #![feature(never_type)] #![allow(unreachable_code)] diff --git a/tests/mir-opt/building/index_array_and_slice.rs b/tests/mir-opt/building/index_array_and_slice.rs index 42ede66d92b..47d8255ef57 100644 --- a/tests/mir-opt/building/index_array_and_slice.rs +++ b/tests/mir-opt/building/index_array_and_slice.rs @@ -1,36 +1,42 @@ -//@ compile-flags: -C opt-level=0 +//@ compile-flags: -Zmir-opt-level=0 -C opt-level=0 // EMIT_MIR index_array_and_slice.index_array.built.after.mir fn index_array(array: &[i32; 7], index: usize) -> &i32 { // CHECK: bb0: - // CHECK: [[LT:_.+]] = Lt(copy _2, const 7_usize); - // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", const 7_usize, copy _2) -> [success: bb1, unwind + // CHECK: _3 = copy _2; + // CHECK: [[LT:_.+]] = Lt(copy _3, const 7_usize); + // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", const 7_usize, copy _3) -> [success: bb1, unwind // CHECK: bb1: - // CHECK: _0 = &(*_1)[_2]; + // CHECK: _5 = &(*_1)[_3]; + // CHECK: _0 = &(*_5); &array[index] } // EMIT_MIR index_array_and_slice.index_const_generic_array.built.after.mir fn index_const_generic_array<const N: usize>(array: &[i32; N], index: usize) -> &i32 { // CHECK: bb0: - // CHECK: [[LT:_.+]] = Lt(copy _2, const N); - // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", const N, copy _2) -> [success: bb1, unwind + // CHECK: _3 = copy _2; + // CHECK: [[LT:_.+]] = Lt(copy _3, const N); + // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", const N, copy _3) -> [success: bb1, unwind // CHECK: bb1: - // CHECK: _0 = &(*_1)[_2]; + // CHECK: _5 = &(*_1)[_3]; + // CHECK: _0 = &(*_5); &array[index] } // EMIT_MIR index_array_and_slice.index_slice.built.after.mir fn index_slice(slice: &[i32], index: usize) -> &i32 { // CHECK: bb0: + // CHECK: _3 = copy _2; // CHECK: [[LEN:_.+]] = PtrMetadata(copy _1); - // CHECK: [[LT:_.+]] = Lt(copy _2, copy [[LEN]]); - // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", move [[LEN]], copy _2) -> [success: bb1, + // CHECK: [[LT:_.+]] = Lt(copy _3, copy [[LEN]]); + // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", move [[LEN]], copy _3) -> [success: bb1, // CHECK: bb1: - // CHECK: _0 = &(*_1)[_2]; + // CHECK: _6 = &(*_1)[_3]; + // CHECK: _0 = &(*_6); &slice[index] } @@ -40,12 +46,15 @@ fn index_mut_slice(slice: &mut [i32], index: usize) -> &i32 { // This cannot `copy _1` in the *built* MIR, only in the *runtime* MIR. // CHECK: bb0: - // CHECK: [[LEN:_.+]] = PtrMetadata(copy _1); - // CHECK: [[LT:_.+]] = Lt(copy _2, copy [[LEN]]); - // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", move [[LEN]], copy _2) -> [success: bb1, + // CHECK: _3 = copy _2; + // CHECK: _4 = &raw const (fake) (*_1); + // CHECK: [[LEN:_.+]] = PtrMetadata(move _4); + // CHECK: [[LT:_.+]] = Lt(copy _3, copy [[LEN]]); + // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", move [[LEN]], copy _3) -> [success: bb1, // CHECK: bb1: - // CHECK: _0 = &(*_1)[_2]; + // CHECK: _7 = &(*_1)[_3]; + // CHECK: _0 = &(*_7); &slice[index] } @@ -54,13 +63,15 @@ struct WithSliceTail(f64, [i32]); // EMIT_MIR index_array_and_slice.index_custom.built.after.mir fn index_custom(custom: &WithSliceTail, index: usize) -> &i32 { // CHECK: bb0: + // CHECK: _3 = copy _2; // CHECK: [[PTR:_.+]] = &raw const (fake) ((*_1).1: [i32]); - // CHECK: [[LEN:_.+]] = PtrMetadata(copy [[PTR]]); - // CHECK: [[LT:_.+]] = Lt(copy _2, copy [[LEN]]); - // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", move [[LEN]], copy _2) -> [success: bb1, + // CHECK: [[LEN:_.+]] = PtrMetadata(move [[PTR]]); + // CHECK: [[LT:_.+]] = Lt(copy _3, copy [[LEN]]); + // CHECK: assert(move [[LT]], "index out of bounds{{.+}}", move [[LEN]], copy _3) -> [success: bb1, // CHECK: bb1: - // CHECK: _0 = &((*_1).1: [i32])[_2]; + // CHECK: _7 = &((*_1).1: [i32])[_3]; + // CHECK: _0 = &(*_7); &custom.1[index] } diff --git a/tests/mir-opt/building/issue_101867.main.built.after.mir b/tests/mir-opt/building/issue_101867.main.built.after.mir index 8a36c901eed..fa35658a16d 100644 --- a/tests/mir-opt/building/issue_101867.main.built.after.mir +++ b/tests/mir-opt/building/issue_101867.main.built.after.mir @@ -1,8 +1,8 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:4:12: 4:22, inferred_ty: std::option::Option<u8> -| 1: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:4:12: 4:22, inferred_ty: std::option::Option<u8> +| 0: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:5:12: 5:22, inferred_ty: std::option::Option<u8> +| 1: user_ty: Canonical { value: Ty(std::option::Option<u8>), max_universe: U0, variables: [] }, span: $DIR/issue_101867.rs:5:12: 5:22, inferred_ty: std::option::Option<u8> | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/building/issue_101867.rs b/tests/mir-opt/building/issue_101867.rs index f8a531e8982..a00bc13b3fe 100644 --- a/tests/mir-opt/building/issue_101867.rs +++ b/tests/mir-opt/building/issue_101867.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zmir-opt-level=0 // skip-filecheck // EMIT_MIR issue_101867.main.built.after.mir fn main() { diff --git a/tests/mir-opt/building/issue_110508.rs b/tests/mir-opt/building/issue_110508.rs index e597cd5d06b..aa8a7b1d08f 100644 --- a/tests/mir-opt/building/issue_110508.rs +++ b/tests/mir-opt/building/issue_110508.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zmir-opt-level=0 // skip-filecheck // EMIT_MIR issue_110508.{impl#0}-BAR.built.after.mir // EMIT_MIR issue_110508.{impl#0}-SELF_BAR.built.after.mir diff --git a/tests/mir-opt/building/issue_110508.{impl#0}-BAR.built.after.mir b/tests/mir-opt/building/issue_110508.{impl#0}-BAR.built.after.mir index c3d28fae518..0cefb9c8fd1 100644 --- a/tests/mir-opt/building/issue_110508.{impl#0}-BAR.built.after.mir +++ b/tests/mir-opt/building/issue_110508.{impl#0}-BAR.built.after.mir @@ -1,6 +1,6 @@ -// MIR for `<impl at $DIR/issue_110508.rs:9:1: 9:9>::BAR` after built +// MIR for `<impl at $DIR/issue_110508.rs:10:1: 10:9>::BAR` after built -const <impl at $DIR/issue_110508.rs:9:1: 9:9>::BAR: Foo = { +const <impl at $DIR/issue_110508.rs:10:1: 10:9>::BAR: Foo = { let mut _0: Foo; let mut _1: (); diff --git a/tests/mir-opt/building/issue_110508.{impl#0}-SELF_BAR.built.after.mir b/tests/mir-opt/building/issue_110508.{impl#0}-SELF_BAR.built.after.mir index 177518c30af..0e0e9149385 100644 --- a/tests/mir-opt/building/issue_110508.{impl#0}-SELF_BAR.built.after.mir +++ b/tests/mir-opt/building/issue_110508.{impl#0}-SELF_BAR.built.after.mir @@ -1,6 +1,6 @@ -// MIR for `<impl at $DIR/issue_110508.rs:9:1: 9:9>::SELF_BAR` after built +// MIR for `<impl at $DIR/issue_110508.rs:10:1: 10:9>::SELF_BAR` after built -const <impl at $DIR/issue_110508.rs:9:1: 9:9>::SELF_BAR: Foo = { +const <impl at $DIR/issue_110508.rs:10:1: 10:9>::SELF_BAR: Foo = { let mut _0: Foo; let mut _1: (); diff --git a/tests/mir-opt/building/issue_49232.rs b/tests/mir-opt/building/issue_49232.rs index ac06e02778f..f17e3e955a4 100644 --- a/tests/mir-opt/building/issue_49232.rs +++ b/tests/mir-opt/building/issue_49232.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zmir-opt-level=0 // skip-filecheck // We must mark a variable whose initialization fails due to an // abort statement as StorageDead. diff --git a/tests/mir-opt/building/logical_or_in_conditional.rs b/tests/mir-opt/building/logical_or_in_conditional.rs index 249ccf72804..d1c1ea2896a 100644 --- a/tests/mir-opt/building/logical_or_in_conditional.rs +++ b/tests/mir-opt/building/logical_or_in_conditional.rs @@ -1,5 +1,5 @@ // skip-filecheck -//@ compile-flags: -Z validate-mir +//@ compile-flags: -Zmir-opt-level=0 -Z validate-mir //@ edition: 2024 struct Droppy(u8); impl Drop for Droppy { diff --git a/tests/mir-opt/building/loop_match_diverges.break_to_block_unit.built.after.mir b/tests/mir-opt/building/loop_match_diverges.break_to_block_unit.built.after.mir new file mode 100644 index 00000000000..6d779e46146 --- /dev/null +++ b/tests/mir-opt/building/loop_match_diverges.break_to_block_unit.built.after.mir @@ -0,0 +1,63 @@ +// MIR for `break_to_block_unit` after built + +fn break_to_block_unit() -> u8 { + let mut _0: u8; + let mut _1: i32; + let mut _2: !; + scope 1 { + debug state => _1; + } + + bb0: { + StorageLive(_1); + _1 = const 0_i32; + FakeRead(ForLet(None), _1); + StorageLive(_2); + goto -> bb1; + } + + bb1: { + falseUnwind -> [real: bb2, unwind: bb10]; + } + + bb2: { + PlaceMention(_1); + _1 = const 2_i32; + goto -> bb5; + } + + bb3: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb4: { + goto -> bb6; + } + + bb5: { + goto -> bb6; + } + + bb6: { + goto -> bb7; + } + + bb7: { + goto -> bb1; + } + + bb8: { + unreachable; + } + + bb9: { + StorageDead(_2); + StorageDead(_1); + return; + } + + bb10 (cleanup): { + resume; + } +} diff --git a/tests/mir-opt/building/loop_match_diverges.infinite_a.built.after.mir b/tests/mir-opt/building/loop_match_diverges.infinite_a.built.after.mir new file mode 100644 index 00000000000..e3766744790 --- /dev/null +++ b/tests/mir-opt/building/loop_match_diverges.infinite_a.built.after.mir @@ -0,0 +1,51 @@ +// MIR for `infinite_a` after built + +fn infinite_a(_1: u8) -> () { + debug state => _1; + let mut _0: (); + let mut _2: !; + let _3: u8; + scope 1 { + debug a => _3; + } + + bb0: { + StorageLive(_2); + goto -> bb1; + } + + bb1: { + falseUnwind -> [real: bb2, unwind: bb7]; + } + + bb2: { + PlaceMention(_1); + StorageLive(_3); + _3 = copy _1; + _1 = copy _3; + StorageDead(_3); + goto -> bb4; + } + + bb3: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb4: { + goto -> bb1; + } + + bb5: { + unreachable; + } + + bb6: { + StorageDead(_2); + return; + } + + bb7 (cleanup): { + resume; + } +} diff --git a/tests/mir-opt/building/loop_match_diverges.rs b/tests/mir-opt/building/loop_match_diverges.rs new file mode 100644 index 00000000000..774e195c33c --- /dev/null +++ b/tests/mir-opt/building/loop_match_diverges.rs @@ -0,0 +1,68 @@ +// skip-filecheck +#![allow(incomplete_features)] +#![feature(loop_match)] +#![crate_type = "lib"] + +// Test that a #[loop_match] without an explicit break from the loop generates valid MIR. + +enum State { + A, + B, + C, +} + +// EMIT_MIR loop_match_diverges.simple.built.after.mir +fn simple(mut state: State) -> State { + #[loop_match] + 'a: loop { + state = 'blk: { + match state { + State::A => { + #[const_continue] + break 'blk State::B; + } + State::B => { + if true { + #[const_continue] + break 'blk State::C; + } else { + #[const_continue] + break 'blk State::A; + } + } + State::C => break 'a, + } + }; + } + + state +} + +// EMIT_MIR loop_match_diverges.break_to_block_unit.built.after.mir +#[unsafe(no_mangle)] +fn break_to_block_unit() -> u8 { + let mut state = 0; + #[loop_match] + loop { + state = 'blk: { + match state { + _ => 'b: { + break 'b 2; + } + } + } + } +} + +// EMIT_MIR loop_match_diverges.infinite_a.built.after.mir +#[unsafe(no_mangle)] +fn infinite_a(mut state: u8) { + #[loop_match] + loop { + state = 'blk: { + match state { + a => a, + } + } + } +} diff --git a/tests/mir-opt/building/loop_match_diverges.simple.built.after.mir b/tests/mir-opt/building/loop_match_diverges.simple.built.after.mir new file mode 100644 index 00000000000..26476ad7762 --- /dev/null +++ b/tests/mir-opt/building/loop_match_diverges.simple.built.after.mir @@ -0,0 +1,187 @@ +// MIR for `simple` after built + +fn simple(_1: State) -> State { + debug state => _1; + let mut _0: State; + let _2: (); + let mut _3: isize; + let mut _4: !; + let mut _5: isize; + let mut _6: bool; + let mut _7: !; + let mut _8: isize; + let mut _9: !; + let mut _10: isize; + let mut _11: !; + + bb0: { + StorageLive(_2); + goto -> bb1; + } + + bb1: { + falseUnwind -> [real: bb2, unwind: bb37]; + } + + bb2: { + PlaceMention(_1); + _3 = discriminant(_1); + switchInt(move _3) -> [0: bb4, 1: bb6, 2: bb8, otherwise: bb3]; + } + + bb3: { + FakeRead(ForMatchedPlace(None), _1); + unreachable; + } + + bb4: { + falseEdge -> [real: bb11, imaginary: bb6]; + } + + bb5: { + goto -> bb3; + } + + bb6: { + falseEdge -> [real: bb10, imaginary: bb8]; + } + + bb7: { + goto -> bb3; + } + + bb8: { + _2 = const (); + goto -> bb36; + } + + bb9: { + goto -> bb3; + } + + bb10: { + StorageLive(_6); + _6 = const true; + switchInt(move _6) -> [0: bb17, otherwise: bb16]; + } + + bb11: { + _1 = State::B; + _5 = discriminant(_1); + falseEdge -> [real: bb12, imaginary: bb13]; + } + + bb12: { + goto -> bb10; + } + + bb13: { + goto -> bb34; + } + + bb14: { + unreachable; + } + + bb15: { + goto -> bb32; + } + + bb16: { + _1 = State::C; + _8 = discriminant(_1); + falseEdge -> [real: bb18, imaginary: bb19]; + } + + bb17: { + goto -> bb23; + } + + bb18: { + goto -> bb20; + } + + bb19: { + goto -> bb33; + } + + bb20: { + StorageDead(_6); + goto -> bb8; + } + + bb21: { + unreachable; + } + + bb22: { + goto -> bb29; + } + + bb23: { + _1 = State::A; + _10 = discriminant(_1); + falseEdge -> [real: bb24, imaginary: bb25]; + } + + bb24: { + goto -> bb26; + } + + bb25: { + goto -> bb33; + } + + bb26: { + StorageDead(_6); + goto -> bb11; + } + + bb27: { + unreachable; + } + + bb28: { + goto -> bb29; + } + + bb29: { + StorageDead(_6); + goto -> bb32; + } + + bb30: { + unreachable; + } + + bb31: { + goto -> bb32; + } + + bb32: { + goto -> bb35; + } + + bb33: { + StorageDead(_6); + goto -> bb34; + } + + bb34: { + goto -> bb35; + } + + bb35: { + goto -> bb1; + } + + bb36: { + StorageDead(_2); + _0 = move _1; + return; + } + + bb37 (cleanup): { + resume; + } +} diff --git a/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir b/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir index 744553c7cd2..5cf182c21c3 100644 --- a/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir +++ b/tests/mir-opt/building/receiver_ptr_mutability.main.built.after.mir @@ -1,10 +1,10 @@ // MIR for `main` after built | User Type Annotations -| 0: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:15:14: 15:23, inferred_ty: *mut Test -| 1: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:15:14: 15:23, inferred_ty: *mut Test -| 2: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [Region(U0), Region(U0), Region(U0), Region(U0)] }, span: $DIR/receiver_ptr_mutability.rs:19:18: 19:31, inferred_ty: &&&&*mut Test -| 3: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [Region(U0), Region(U0), Region(U0), Region(U0)] }, span: $DIR/receiver_ptr_mutability.rs:19:18: 19:31, inferred_ty: &&&&*mut Test +| 0: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:16:14: 16:23, inferred_ty: *mut Test +| 1: user_ty: Canonical { value: Ty(*mut Test), max_universe: U0, variables: [] }, span: $DIR/receiver_ptr_mutability.rs:16:14: 16:23, inferred_ty: *mut Test +| 2: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [Region(U0), Region(U0), Region(U0), Region(U0)] }, span: $DIR/receiver_ptr_mutability.rs:20:18: 20:31, inferred_ty: &&&&*mut Test +| 3: user_ty: Canonical { value: Ty(&&&&*mut Test), max_universe: U0, variables: [Region(U0), Region(U0), Region(U0), Region(U0)] }, span: $DIR/receiver_ptr_mutability.rs:20:18: 20:31, inferred_ty: &&&&*mut Test | fn main() -> () { let mut _0: (); diff --git a/tests/mir-opt/building/receiver_ptr_mutability.rs b/tests/mir-opt/building/receiver_ptr_mutability.rs index 1ddb8b71a5a..37b142f1d8a 100644 --- a/tests/mir-opt/building/receiver_ptr_mutability.rs +++ b/tests/mir-opt/building/receiver_ptr_mutability.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zmir-opt-level=0 // skip-filecheck // EMIT_MIR receiver_ptr_mutability.main.built.after.mir diff --git a/tests/mir-opt/building/shifts.rs b/tests/mir-opt/building/shifts.rs index d7747bb2f78..165b388bc18 100644 --- a/tests/mir-opt/building/shifts.rs +++ b/tests/mir-opt/building/shifts.rs @@ -1,5 +1,5 @@ // skip-filecheck -//@ compile-flags: -C debug-assertions=yes +//@ compile-flags: -Zmir-opt-level=0 -C debug-assertions=yes // EMIT_MIR shifts.shift_signed.built.after.mir fn shift_signed(small: i8, big: u128, a: i8, b: i32, c: i128) -> ([i8; 3], [u128; 3]) { diff --git a/tests/mir-opt/building/storage_live_dead_in_statics.rs b/tests/mir-opt/building/storage_live_dead_in_statics.rs index 7cb74acbf06..868f4a8f559 100644 --- a/tests/mir-opt/building/storage_live_dead_in_statics.rs +++ b/tests/mir-opt/building/storage_live_dead_in_statics.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zmir-opt-level=0 // skip-filecheck // Check that when we compile the static `XXX` into MIR, we do not // generate `StorageStart` or `StorageEnd` statements. diff --git a/tests/mir-opt/building/uniform_array_move_out.rs b/tests/mir-opt/building/uniform_array_move_out.rs index aff5996d0b6..36245273fe1 100644 --- a/tests/mir-opt/building/uniform_array_move_out.rs +++ b/tests/mir-opt/building/uniform_array_move_out.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zmir-opt-level=0 // skip-filecheck #![feature(liballoc_internals, rustc_attrs)] diff --git a/tests/mir-opt/building/user_type_annotations.let_else.built.after.mir b/tests/mir-opt/building/user_type_annotations.let_else.built.after.mir index 3d26fe24ac9..bbf504d311f 100644 --- a/tests/mir-opt/building/user_type_annotations.let_else.built.after.mir +++ b/tests/mir-opt/building/user_type_annotations.let_else.built.after.mir @@ -1,8 +1,8 @@ // MIR for `let_else` after built | User Type Annotations -| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:35:20: 35:45, inferred_ty: (u32, u64, &char) -| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:35:20: 35:45, inferred_ty: (u32, u64, &char) +| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:36:20: 36:45, inferred_ty: (u32, u64, &char) +| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:36:20: 36:45, inferred_ty: (u32, u64, &char) | fn let_else() -> () { let mut _0: (); diff --git a/tests/mir-opt/building/user_type_annotations.let_else_bindless.built.after.mir b/tests/mir-opt/building/user_type_annotations.let_else_bindless.built.after.mir index b2a06ae53a8..7bf2551e99f 100644 --- a/tests/mir-opt/building/user_type_annotations.let_else_bindless.built.after.mir +++ b/tests/mir-opt/building/user_type_annotations.let_else_bindless.built.after.mir @@ -1,8 +1,8 @@ // MIR for `let_else_bindless` after built | User Type Annotations -| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:40:20: 40:45, inferred_ty: (u32, u64, &char) -| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:40:20: 40:45, inferred_ty: (u32, u64, &char) +| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:41:20: 41:45, inferred_ty: (u32, u64, &char) +| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:41:20: 41:45, inferred_ty: (u32, u64, &char) | fn let_else_bindless() -> () { let mut _0: (); diff --git a/tests/mir-opt/building/user_type_annotations.let_init.built.after.mir b/tests/mir-opt/building/user_type_annotations.let_init.built.after.mir index d1b8f823e9b..0cf681d8ab2 100644 --- a/tests/mir-opt/building/user_type_annotations.let_init.built.after.mir +++ b/tests/mir-opt/building/user_type_annotations.let_init.built.after.mir @@ -1,8 +1,8 @@ // MIR for `let_init` after built | User Type Annotations -| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:25:20: 25:45, inferred_ty: (u32, u64, &char) -| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:25:20: 25:45, inferred_ty: (u32, u64, &char) +| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:26:20: 26:45, inferred_ty: (u32, u64, &char) +| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:26:20: 26:45, inferred_ty: (u32, u64, &char) | fn let_init() -> () { let mut _0: (); diff --git a/tests/mir-opt/building/user_type_annotations.let_init_bindless.built.after.mir b/tests/mir-opt/building/user_type_annotations.let_init_bindless.built.after.mir index 6702f930060..968813c826e 100644 --- a/tests/mir-opt/building/user_type_annotations.let_init_bindless.built.after.mir +++ b/tests/mir-opt/building/user_type_annotations.let_init_bindless.built.after.mir @@ -1,8 +1,8 @@ // MIR for `let_init_bindless` after built | User Type Annotations -| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:30:20: 30:45, inferred_ty: (u32, u64, &char) -| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:30:20: 30:45, inferred_ty: (u32, u64, &char) +| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:31:20: 31:45, inferred_ty: (u32, u64, &char) +| 1: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:31:20: 31:45, inferred_ty: (u32, u64, &char) | fn let_init_bindless() -> () { let mut _0: (); diff --git a/tests/mir-opt/building/user_type_annotations.let_uninit.built.after.mir b/tests/mir-opt/building/user_type_annotations.let_uninit.built.after.mir index 76b5938b87d..b6fdc4ff46d 100644 --- a/tests/mir-opt/building/user_type_annotations.let_uninit.built.after.mir +++ b/tests/mir-opt/building/user_type_annotations.let_uninit.built.after.mir @@ -1,7 +1,7 @@ // MIR for `let_uninit` after built | User Type Annotations -| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:15:20: 15:45, inferred_ty: (u32, u64, &char) +| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:16:20: 16:45, inferred_ty: (u32, u64, &char) | fn let_uninit() -> () { let mut _0: (); diff --git a/tests/mir-opt/building/user_type_annotations.let_uninit_bindless.built.after.mir b/tests/mir-opt/building/user_type_annotations.let_uninit_bindless.built.after.mir index 0cd12558771..472dbfb6304 100644 --- a/tests/mir-opt/building/user_type_annotations.let_uninit_bindless.built.after.mir +++ b/tests/mir-opt/building/user_type_annotations.let_uninit_bindless.built.after.mir @@ -1,7 +1,7 @@ // MIR for `let_uninit_bindless` after built | User Type Annotations -| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:20:20: 20:45, inferred_ty: (u32, u64, &char) +| 0: user_ty: Canonical { value: Ty((u32, u64, &'static char)), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:21:20: 21:45, inferred_ty: (u32, u64, &char) | fn let_uninit_bindless() -> () { let mut _0: (); diff --git a/tests/mir-opt/building/user_type_annotations.match_assoc_const.built.after.mir b/tests/mir-opt/building/user_type_annotations.match_assoc_const.built.after.mir index c0ce6f1d06b..ff4b0bf7600 100644 --- a/tests/mir-opt/building/user_type_annotations.match_assoc_const.built.after.mir +++ b/tests/mir-opt/building/user_type_annotations.match_assoc_const.built.after.mir @@ -1,8 +1,8 @@ // MIR for `match_assoc_const` after built | User Type Annotations -| 0: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:54:9: 54:44, inferred_ty: u32 -| 1: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:54:9: 54:44, inferred_ty: u32 +| 0: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:55:9: 55:44, inferred_ty: u32 +| 1: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:55:9: 55:44, inferred_ty: u32 | fn match_assoc_const() -> () { let mut _0: (); diff --git a/tests/mir-opt/building/user_type_annotations.match_assoc_const_range.built.after.mir b/tests/mir-opt/building/user_type_annotations.match_assoc_const_range.built.after.mir index 3a6aa5b7c2c..4cc433f475f 100644 --- a/tests/mir-opt/building/user_type_annotations.match_assoc_const_range.built.after.mir +++ b/tests/mir-opt/building/user_type_annotations.match_assoc_const_range.built.after.mir @@ -1,10 +1,10 @@ // MIR for `match_assoc_const_range` after built | User Type Annotations -| 0: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:62:11: 62:46, inferred_ty: u32 -| 1: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:62:11: 62:46, inferred_ty: u32 -| 2: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:63:9: 63:44, inferred_ty: u32 -| 3: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:63:9: 63:44, inferred_ty: u32 +| 0: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:63:11: 63:46, inferred_ty: u32 +| 1: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:63:11: 63:46, inferred_ty: u32 +| 2: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:64:9: 64:44, inferred_ty: u32 +| 3: user_ty: Canonical { value: TypeOf(DefId(0:11 ~ user_type_annotations[ee8e]::MyTrait::FOO), UserArgs { args: [MyStruct, 'static], user_self_ty: None }), max_universe: U0, variables: [] }, span: $DIR/user_type_annotations.rs:64:9: 64:44, inferred_ty: u32 | fn match_assoc_const_range() -> () { let mut _0: (); diff --git a/tests/mir-opt/building/user_type_annotations.rs b/tests/mir-opt/building/user_type_annotations.rs index d55c678d5ae..527bf62f7dc 100644 --- a/tests/mir-opt/building/user_type_annotations.rs +++ b/tests/mir-opt/building/user_type_annotations.rs @@ -1,3 +1,4 @@ +//@ compile-flags: -Zmir-opt-level=0 //@ edition: 2024 // skip-filecheck diff --git a/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-abort.diff b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-abort.diff index 5d8aaedae37..a2f10be31a9 100644 --- a/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-abort.diff +++ b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-abort.diff @@ -8,25 +8,23 @@ let _5: (); let mut _6: i32; scope 1 { -- debug x => _1; -+ debug x => _6; + debug x => _1; let _2: i32; scope 2 { - debug y => _2; -+ debug y => _6; ++ debug y => _1; let _3: i32; scope 3 { - debug z => _3; -+ debug z => _6; ++ debug z => _1; } } } bb0: { - StorageLive(_1); -- _1 = val() -> [return: bb1, unwind unreachable]; + nop; -+ _6 = val() -> [return: bb1, unwind unreachable]; + _1 = val() -> [return: bb1, unwind unreachable]; } bb1: { @@ -49,9 +47,10 @@ StorageLive(_5); - StorageLive(_6); - _6 = copy _1; +- _5 = std::mem::drop::<i32>(move _6) -> [return: bb2, unwind unreachable]; + nop; + nop; - _5 = std::mem::drop::<i32>(move _6) -> [return: bb2, unwind unreachable]; ++ _5 = std::mem::drop::<i32>(move _1) -> [return: bb2, unwind unreachable]; } bb2: { diff --git a/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-unwind.diff b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-unwind.diff index 05c9bcc1d73..a08488615b1 100644 --- a/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-unwind.diff +++ b/tests/mir-opt/dest-prop/cycle.main.DestinationPropagation.panic-unwind.diff @@ -8,25 +8,23 @@ let _5: (); let mut _6: i32; scope 1 { -- debug x => _1; -+ debug x => _6; + debug x => _1; let _2: i32; scope 2 { - debug y => _2; -+ debug y => _6; ++ debug y => _1; let _3: i32; scope 3 { - debug z => _3; -+ debug z => _6; ++ debug z => _1; } } } bb0: { - StorageLive(_1); -- _1 = val() -> [return: bb1, unwind continue]; + nop; -+ _6 = val() -> [return: bb1, unwind continue]; + _1 = val() -> [return: bb1, unwind continue]; } bb1: { @@ -49,9 +47,10 @@ StorageLive(_5); - StorageLive(_6); - _6 = copy _1; +- _5 = std::mem::drop::<i32>(move _6) -> [return: bb2, unwind continue]; + nop; + nop; - _5 = std::mem::drop::<i32>(move _6) -> [return: bb2, unwind continue]; ++ _5 = std::mem::drop::<i32>(move _1) -> [return: bb2, unwind continue]; } bb2: { diff --git a/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-abort.mir b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-abort.mir index eb4209731c6..15061da8120 100644 --- a/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-abort.mir +++ b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-abort.mir @@ -7,16 +7,16 @@ fn f(_1: usize) -> usize { let mut _3: usize; let mut _4: usize; scope 1 { - debug b => _3; + debug b => _2; } bb0: { nop; - _3 = copy _1; + _2 = copy _1; _1 = const 5_usize; nop; nop; - _1 = move _3; + _1 = move _2; nop; nop; nop; diff --git a/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-unwind.mir b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-unwind.mir index fe9a7376a58..ddfe4dc5b3e 100644 --- a/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-unwind.mir +++ b/tests/mir-opt/dest-prop/dead_stores_79191.f.DestinationPropagation.after.panic-unwind.mir @@ -7,16 +7,16 @@ fn f(_1: usize) -> usize { let mut _3: usize; let mut _4: usize; scope 1 { - debug b => _3; + debug b => _2; } bb0: { nop; - _3 = copy _1; + _2 = copy _1; _1 = const 5_usize; nop; nop; - _1 = move _3; + _1 = move _2; nop; nop; nop; diff --git a/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-abort.mir b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-abort.mir index eb4209731c6..15061da8120 100644 --- a/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-abort.mir +++ b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-abort.mir @@ -7,16 +7,16 @@ fn f(_1: usize) -> usize { let mut _3: usize; let mut _4: usize; scope 1 { - debug b => _3; + debug b => _2; } bb0: { nop; - _3 = copy _1; + _2 = copy _1; _1 = const 5_usize; nop; nop; - _1 = move _3; + _1 = move _2; nop; nop; nop; diff --git a/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-unwind.mir b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-unwind.mir index fe9a7376a58..ddfe4dc5b3e 100644 --- a/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-unwind.mir +++ b/tests/mir-opt/dest-prop/dead_stores_better.f.DestinationPropagation.after.panic-unwind.mir @@ -7,16 +7,16 @@ fn f(_1: usize) -> usize { let mut _3: usize; let mut _4: usize; scope 1 { - debug b => _3; + debug b => _2; } bb0: { nop; - _3 = copy _1; + _2 = copy _1; _1 = const 5_usize; nop; nop; - _1 = move _3; + _1 = move _2; nop; nop; nop; diff --git a/tests/mir-opt/gvn_overlapping.fields.GVN.diff b/tests/mir-opt/gvn_overlapping.fields.GVN.diff new file mode 100644 index 00000000000..0548f4e42e4 --- /dev/null +++ b/tests/mir-opt/gvn_overlapping.fields.GVN.diff @@ -0,0 +1,14 @@ +- // MIR for `fields` before GVN ++ // MIR for `fields` after GVN + + fn fields(_1: (Adt, Adt)) -> () { + let mut _0: (); + let mut _2: u32; + + bb0: { + _2 = copy (((_1.0: Adt) as variant#1).0: u32); + (_1.1: Adt) = Adt::Some(copy _2); + return; + } + } + diff --git a/tests/mir-opt/gvn_overlapping.rs b/tests/mir-opt/gvn_overlapping.rs index 99113445e68..f148a843561 100644 --- a/tests/mir-opt/gvn_overlapping.rs +++ b/tests/mir-opt/gvn_overlapping.rs @@ -2,11 +2,10 @@ #![feature(custom_mir, core_intrinsics)] -// Check that we do not create overlapping assignments. - use std::intrinsics::mir::*; // EMIT_MIR gvn_overlapping.overlapping.GVN.diff +/// Check that we do not create overlapping assignments. #[custom_mir(dialect = "runtime")] fn overlapping(_17: Adt) { // CHECK-LABEL: fn overlapping( @@ -26,6 +25,45 @@ fn overlapping(_17: Adt) { } } +// EMIT_MIR gvn_overlapping.stable_projection.GVN.diff +/// Check that we allow dereferences in the RHS if the LHS is a stable projection. +#[custom_mir(dialect = "runtime")] +fn stable_projection(_1: (Adt,)) { + // CHECK-LABEL: fn stable_projection( + // CHECK: let mut _2: *mut Adt; + // CHECK: let mut _4: &Adt; + // CHECK: (_1.0: Adt) = copy (*_4); + mir! { + let _2: *mut Adt; + let _3: u32; + let _4: &Adt; + { + _2 = core::ptr::addr_of_mut!(_1.0); + _4 = &(*_2); + _3 = Field(Variant((*_4), 1), 0); + _1.0 = Adt::Some(_3); + Return() + } + } +} + +// EMIT_MIR gvn_overlapping.fields.GVN.diff +/// Check that we do not create assignments between different fields of the same local. +#[custom_mir(dialect = "runtime")] +fn fields(_1: (Adt, Adt)) { + // CHECK-LABEL: fn fields( + // CHECK: _2 = copy (((_1.0: Adt) as variant#1).0: u32); + // CHECK-NEXT: (_1.1: Adt) = Adt::Some(copy _2); + mir! { + let _2: u32; + { + _2 = Field(Variant(_1.0, 1), 0); + _1.1 = Adt::Some(_2); + Return() + } + } +} + fn main() { overlapping(Adt::Some(0)); } diff --git a/tests/mir-opt/gvn_overlapping.stable_projection.GVN.diff b/tests/mir-opt/gvn_overlapping.stable_projection.GVN.diff new file mode 100644 index 00000000000..08835456591 --- /dev/null +++ b/tests/mir-opt/gvn_overlapping.stable_projection.GVN.diff @@ -0,0 +1,19 @@ +- // MIR for `stable_projection` before GVN ++ // MIR for `stable_projection` after GVN + + fn stable_projection(_1: (Adt,)) -> () { + let mut _0: (); + let mut _2: *mut Adt; + let mut _3: u32; + let mut _4: &Adt; + + bb0: { + _2 = &raw mut (_1.0: Adt); + _4 = &(*_2); + _3 = copy (((*_4) as variant#1).0: u32); +- (_1.0: Adt) = Adt::Some(copy _3); ++ (_1.0: Adt) = copy (*_4); + return; + } + } + diff --git a/tests/mir-opt/nrvo_miscompile_111005.rs b/tests/mir-opt/nrvo_miscompile_111005.rs index 03008fa8191..131f7b8f6f9 100644 --- a/tests/mir-opt/nrvo_miscompile_111005.rs +++ b/tests/mir-opt/nrvo_miscompile_111005.rs @@ -1,4 +1,3 @@ -// skip-filecheck // This is a miscompilation, #111005 to track //@ test-mir-pass: RenameReturnPlace @@ -10,6 +9,11 @@ use core::intrinsics::mir::*; // EMIT_MIR nrvo_miscompile_111005.wrong.RenameReturnPlace.diff #[custom_mir(dialect = "runtime", phase = "initial")] pub fn wrong(arg: char) -> char { + // CHECK-LABEL: fn wrong( + // CHECK: _0 = copy _1; + // FIXME: This is wrong: + // CHECK-NEXT: _0 = const 'b'; + // CHECK-NEXT: return; mir! { { let temp = arg; diff --git a/tests/mir-opt/pre-codegen/clone_as_copy.enum_clone_as_copy.PreCodegen.after.mir b/tests/mir-opt/pre-codegen/clone_as_copy.enum_clone_as_copy.PreCodegen.after.mir index 9f88e1961ec..e67f362ee04 100644 --- a/tests/mir-opt/pre-codegen/clone_as_copy.enum_clone_as_copy.PreCodegen.after.mir +++ b/tests/mir-opt/pre-codegen/clone_as_copy.enum_clone_as_copy.PreCodegen.after.mir @@ -6,8 +6,8 @@ fn enum_clone_as_copy(_1: &Enum1) -> Enum1 { scope 1 (inlined <Enum1 as Clone>::clone) { debug self => _1; let mut _2: isize; - let mut _3: &AllCopy; - let mut _4: &NestCopy; + let _3: &AllCopy; + let _4: &NestCopy; scope 2 { debug __self_0 => _3; scope 6 (inlined <AllCopy as Clone>::clone) { diff --git a/tests/run-make/apple-slow-tls/rmake.rs b/tests/run-make-cargo/apple-slow-tls/rmake.rs index 231e0b1668e..231e0b1668e 100644 --- a/tests/run-make/apple-slow-tls/rmake.rs +++ b/tests/run-make-cargo/apple-slow-tls/rmake.rs diff --git a/tests/run-make/apple-slow-tls/tls_test/Cargo.toml b/tests/run-make-cargo/apple-slow-tls/tls_test/Cargo.toml index c8e5a228eef..c8e5a228eef 100644 --- a/tests/run-make/apple-slow-tls/tls_test/Cargo.toml +++ b/tests/run-make-cargo/apple-slow-tls/tls_test/Cargo.toml diff --git a/tests/run-make/apple-slow-tls/tls_test/src/main.rs b/tests/run-make-cargo/apple-slow-tls/tls_test/src/main.rs index d48d22bb3d1..d48d22bb3d1 100644 --- a/tests/run-make/apple-slow-tls/tls_test/src/main.rs +++ b/tests/run-make-cargo/apple-slow-tls/tls_test/src/main.rs diff --git a/tests/run-make/compiler-builtins/Cargo.toml b/tests/run-make-cargo/compiler-builtins/Cargo.toml index 869210c4a68..869210c4a68 100644 --- a/tests/run-make/compiler-builtins/Cargo.toml +++ b/tests/run-make-cargo/compiler-builtins/Cargo.toml diff --git a/tests/run-make/compiler-builtins/lib.rs b/tests/run-make-cargo/compiler-builtins/lib.rs index 0c9ac1ac8e4..0c9ac1ac8e4 100644 --- a/tests/run-make/compiler-builtins/lib.rs +++ b/tests/run-make-cargo/compiler-builtins/lib.rs diff --git a/tests/run-make/compiler-builtins/rmake.rs b/tests/run-make-cargo/compiler-builtins/rmake.rs index 10093db2258..10093db2258 100644 --- a/tests/run-make/compiler-builtins/rmake.rs +++ b/tests/run-make-cargo/compiler-builtins/rmake.rs diff --git a/tests/run-make/rustc-crates-on-stable/rmake.rs b/tests/run-make-cargo/rustc-crates-on-stable/rmake.rs index cbc1f24b8c1..cbc1f24b8c1 100644 --- a/tests/run-make/rustc-crates-on-stable/rmake.rs +++ b/tests/run-make-cargo/rustc-crates-on-stable/rmake.rs diff --git a/tests/run-make/rustdoc-scrape-examples-paths/foo/Cargo.toml b/tests/run-make-cargo/rustdoc-scrape-examples-paths/foo/Cargo.toml index 6962028375b..6962028375b 100644 --- a/tests/run-make/rustdoc-scrape-examples-paths/foo/Cargo.toml +++ b/tests/run-make-cargo/rustdoc-scrape-examples-paths/foo/Cargo.toml diff --git a/tests/run-make/rustdoc-scrape-examples-paths/foo/examples/complex.rs b/tests/run-make-cargo/rustdoc-scrape-examples-paths/foo/examples/complex.rs index 1cda7e098f4..1cda7e098f4 100644 --- a/tests/run-make/rustdoc-scrape-examples-paths/foo/examples/complex.rs +++ b/tests/run-make-cargo/rustdoc-scrape-examples-paths/foo/examples/complex.rs diff --git a/tests/run-make/rustdoc-scrape-examples-paths/foo/examples/tester.rs b/tests/run-make-cargo/rustdoc-scrape-examples-paths/foo/examples/tester.rs index fbd1906ec09..fbd1906ec09 100644 --- a/tests/run-make/rustdoc-scrape-examples-paths/foo/examples/tester.rs +++ b/tests/run-make-cargo/rustdoc-scrape-examples-paths/foo/examples/tester.rs diff --git a/tests/run-make/rustdoc-scrape-examples-paths/foo/src/lib.rs b/tests/run-make-cargo/rustdoc-scrape-examples-paths/foo/src/lib.rs index a9bb0272c78..a9bb0272c78 100644 --- a/tests/run-make/rustdoc-scrape-examples-paths/foo/src/lib.rs +++ b/tests/run-make-cargo/rustdoc-scrape-examples-paths/foo/src/lib.rs diff --git a/tests/run-make/rustdoc-scrape-examples-paths/rmake.rs b/tests/run-make-cargo/rustdoc-scrape-examples-paths/rmake.rs index 6784e438762..6784e438762 100644 --- a/tests/run-make/rustdoc-scrape-examples-paths/rmake.rs +++ b/tests/run-make-cargo/rustdoc-scrape-examples-paths/rmake.rs diff --git a/tests/run-make/thumb-none-cortex-m/rmake.rs b/tests/run-make-cargo/thumb-none-cortex-m/rmake.rs index 27afef874da..6158b9c36da 100644 --- a/tests/run-make/thumb-none-cortex-m/rmake.rs +++ b/tests/run-make-cargo/thumb-none-cortex-m/rmake.rs @@ -4,7 +4,7 @@ //! //! How to run this //! $ ./x.py clean -//! $ ./x.py test --target thumbv6m-none-eabi,thumbv7m-none-eabi tests/run-make +//! $ ./x.py test --target thumbv6m-none-eabi,thumbv7m-none-eabi tests/run-make-cargo //! //! Supported targets: //! - thumbv6m-none-eabi (Bare Cortex-M0, M0+, M1) diff --git a/tests/run-make/thumb-none-qemu/example/.cargo/config.toml b/tests/run-make-cargo/thumb-none-qemu/example/.cargo/config.toml index 7152e81b502..7152e81b502 100644 --- a/tests/run-make/thumb-none-qemu/example/.cargo/config.toml +++ b/tests/run-make-cargo/thumb-none-qemu/example/.cargo/config.toml diff --git a/tests/run-make/thumb-none-qemu/example/Cargo.lock b/tests/run-make-cargo/thumb-none-qemu/example/Cargo.lock index 687b962a8b6..687b962a8b6 100644 --- a/tests/run-make/thumb-none-qemu/example/Cargo.lock +++ b/tests/run-make-cargo/thumb-none-qemu/example/Cargo.lock diff --git a/tests/run-make/thumb-none-qemu/example/Cargo.toml b/tests/run-make-cargo/thumb-none-qemu/example/Cargo.toml index 63eb5f90aec..63eb5f90aec 100644 --- a/tests/run-make/thumb-none-qemu/example/Cargo.toml +++ b/tests/run-make-cargo/thumb-none-qemu/example/Cargo.toml diff --git a/tests/run-make/thumb-none-qemu/example/memory.x b/tests/run-make-cargo/thumb-none-qemu/example/memory.x index dc7ad967a42..dc7ad967a42 100644 --- a/tests/run-make/thumb-none-qemu/example/memory.x +++ b/tests/run-make-cargo/thumb-none-qemu/example/memory.x diff --git a/tests/run-make/thumb-none-qemu/example/src/main.rs b/tests/run-make-cargo/thumb-none-qemu/example/src/main.rs index 4b8162c4120..4b8162c4120 100644 --- a/tests/run-make/thumb-none-qemu/example/src/main.rs +++ b/tests/run-make-cargo/thumb-none-qemu/example/src/main.rs diff --git a/tests/run-make/thumb-none-qemu/rmake.rs b/tests/run-make-cargo/thumb-none-qemu/rmake.rs index 9d4b426f4a1..9d4b426f4a1 100644 --- a/tests/run-make/thumb-none-qemu/rmake.rs +++ b/tests/run-make-cargo/thumb-none-qemu/rmake.rs diff --git a/tests/run-make/uefi-qemu/rmake.rs b/tests/run-make-cargo/uefi-qemu/rmake.rs index 55d42fba5e7..55d42fba5e7 100644 --- a/tests/run-make/uefi-qemu/rmake.rs +++ b/tests/run-make-cargo/uefi-qemu/rmake.rs diff --git a/tests/run-make/uefi-qemu/uefi_qemu_test/Cargo.lock b/tests/run-make-cargo/uefi-qemu/uefi_qemu_test/Cargo.lock index 8b6a664ad93..8b6a664ad93 100644 --- a/tests/run-make/uefi-qemu/uefi_qemu_test/Cargo.lock +++ b/tests/run-make-cargo/uefi-qemu/uefi_qemu_test/Cargo.lock diff --git a/tests/run-make/uefi-qemu/uefi_qemu_test/Cargo.toml b/tests/run-make-cargo/uefi-qemu/uefi_qemu_test/Cargo.toml index 1a8d0d94368..1a8d0d94368 100644 --- a/tests/run-make/uefi-qemu/uefi_qemu_test/Cargo.toml +++ b/tests/run-make-cargo/uefi-qemu/uefi_qemu_test/Cargo.toml diff --git a/tests/run-make/uefi-qemu/uefi_qemu_test/src/main.rs b/tests/run-make-cargo/uefi-qemu/uefi_qemu_test/src/main.rs index f8e1212a9f6..f8e1212a9f6 100644 --- a/tests/run-make/uefi-qemu/uefi_qemu_test/src/main.rs +++ b/tests/run-make-cargo/uefi-qemu/uefi_qemu_test/src/main.rs diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_asm.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_asm.checks index d2e53bee08f..d2e53bee08f 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_asm.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_asm.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_c.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_c.checks index b93b33afb3f..b93b33afb3f 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_c.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_c.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_c_asm.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_c_asm.checks index 0a3d1dced42..0a3d1dced42 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_c_asm.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_c_asm.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_cxx.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_cxx.checks index f96f152c02f..f96f152c02f 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_cxx.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_cxx.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_cxx_asm.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_cxx_asm.checks index 0126cd8ee64..0126cd8ee64 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_cxx_asm.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cc_plus_one_cxx_asm.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_asm.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_asm.checks index 61567548848..61567548848 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_asm.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_asm.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c.checks index f551356b2ff..f551356b2ff 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c_asm.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c_asm.checks index 17312b9126a..17312b9126a 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c_asm.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c_asm.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c_global_asm.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c_global_asm.checks index 4b66cc5bc83..4b66cc5bc83 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c_global_asm.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_c_global_asm.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx.checks index 0f403e0203c..0f403e0203c 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx_asm.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx_asm.checks index 222e4ef7983..222e4ef7983 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx_asm.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx_asm.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx_global_asm.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx_global_asm.checks index 1d8fc96ad50..1d8fc96ad50 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx_global_asm.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/cmake_plus_one_cxx_global_asm.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/Cargo.toml b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/Cargo.toml index 3a97c37e951..3a97c37e951 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/Cargo.toml +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/Cargo.toml diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs index f1fb5803948..f1fb5803948 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/build.rs diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/foo.c b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/foo.c index dd76d4f303a..dd76d4f303a 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/foo.c +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/foo.c diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/foo_asm.s b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/foo_asm.s index 6d56214e87e..6d56214e87e 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/foo_asm.s +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/foo_asm.s diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/foo_cxx.cpp b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/foo_cxx.cpp index ac6f64ac413..ac6f64ac413 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/foo_cxx.cpp +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/foo_cxx.cpp diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/CMakeLists.txt b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/CMakeLists.txt index 27cdf2ecf82..27cdf2ecf82 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/CMakeLists.txt +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/CMakeLists.txt diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo.c b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo.c index c3b731a2d50..c3b731a2d50 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo.c +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo.c diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_asm.s b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_asm.s index 64b6b430eea..64b6b430eea 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_asm.s +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_asm.s diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_cxx.cpp b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_cxx.cpp index 824e2afebcc..824e2afebcc 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_cxx.cpp +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/libcmake_foo/src/foo_cxx.cpp diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/src/main.rs b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/src/main.rs index cde38aacf7f..cde38aacf7f 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/enclave/src/main.rs +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/enclave/src/main.rs diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/jumpto.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/jumpto.checks index 885bf461bf3..885bf461bf3 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/jumpto.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/jumpto.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.with_frame_pointers.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/print.with_frame_pointers.checks index 485e20e3111..485e20e3111 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.with_frame_pointers.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/print.with_frame_pointers.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.without_frame_pointers.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/print.without_frame_pointers.checks index e02fe094889..e02fe094889 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/print.without_frame_pointers.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/print.without_frame_pointers.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/rmake.rs b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/rmake.rs index 89754cdaf90..89754cdaf90 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/rmake.rs +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/rmake.rs diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/rust_plus_one_global_asm.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/rust_plus_one_global_asm.checks index fe6777537fb..fe6777537fb 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/rust_plus_one_global_asm.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/rust_plus_one_global_asm.checks diff --git a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/unw_getcontext.checks b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/unw_getcontext.checks index b46cf758384..b46cf758384 100644 --- a/tests/run-make/x86_64-fortanix-unknown-sgx-lvi/unw_getcontext.checks +++ b/tests/run-make-cargo/x86_64-fortanix-unknown-sgx-lvi/unw_getcontext.checks diff --git a/tests/run-make/apple-c-available-links/foo.c b/tests/run-make/apple-c-available-links/foo.c new file mode 100644 index 00000000000..eff99a8b12a --- /dev/null +++ b/tests/run-make/apple-c-available-links/foo.c @@ -0,0 +1,22 @@ +int foo(void) { + // Act as if using some API that's a lot newer than the deployment target. + // + // This forces Clang to insert a call to __isPlatformVersionAtLeast, + // and linking will fail if that is not present. + if (__builtin_available( + macos 1000.0, + ios 1000.0, + tvos 1000.0, + watchos 1000.0, + // CI runs below Xcode 15, where `visionos` wasn't a valid key in + // `__builtin_available`. +#ifdef TARGET_OS_VISION + visionos 1000.0, +#endif + * + )) { + return 1; + } else { + return 0; + } +} diff --git a/tests/run-make/apple-c-available-links/main.rs b/tests/run-make/apple-c-available-links/main.rs new file mode 100644 index 00000000000..4ffada43c1b --- /dev/null +++ b/tests/run-make/apple-c-available-links/main.rs @@ -0,0 +1,7 @@ +unsafe extern "C" { + safe fn foo() -> core::ffi::c_int; +} + +fn main() { + assert_eq!(foo(), 0); +} diff --git a/tests/run-make/apple-c-available-links/rmake.rs b/tests/run-make/apple-c-available-links/rmake.rs new file mode 100644 index 00000000000..44a5ee94d57 --- /dev/null +++ b/tests/run-make/apple-c-available-links/rmake.rs @@ -0,0 +1,14 @@ +//! Test that using `__builtin_available` in C (`@available` in Objective-C) +//! successfully links (because `std` provides the required symbols). + +//@ only-apple __builtin_available is (mostly) specific to Apple platforms. + +use run_make_support::{cc, rustc, target}; + +fn main() { + // Invoke the C compiler to generate an object file. + cc().arg("-c").input("foo.c").output("foo.o").run(); + + // Link the object file together with a Rust program. + rustc().target(target()).input("main.rs").link_arg("foo.o").run(); +} diff --git a/tests/run-make/multiline-args-value/cfg-frontmatter.stderr b/tests/run-make/multiline-args-value/cfg-frontmatter.stderr new file mode 100644 index 00000000000..9b06f84be48 --- /dev/null +++ b/tests/run-make/multiline-args-value/cfg-frontmatter.stderr @@ -0,0 +1,4 @@ +error: invalid `--cfg` argument: `--- + --- + key` (expected `key` or `key="value"`) + diff --git a/tests/run-make/multiline-args-value/cfg-shebang.stderr b/tests/run-make/multiline-args-value/cfg-shebang.stderr new file mode 100644 index 00000000000..09baf3b5123 --- /dev/null +++ b/tests/run-make/multiline-args-value/cfg-shebang.stderr @@ -0,0 +1,3 @@ +error: invalid `--cfg` argument: `#!/usr/bin/shebang + key` (expected `key` or `key="value"`) + diff --git a/tests/run-make/multiline-args-value/check-cfg-frontmatter.stderr b/tests/run-make/multiline-args-value/check-cfg-frontmatter.stderr new file mode 100644 index 00000000000..4a499cc0a1e --- /dev/null +++ b/tests/run-make/multiline-args-value/check-cfg-frontmatter.stderr @@ -0,0 +1,7 @@ +error: invalid `--check-cfg` argument: `--- + --- + cfg(key)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details + diff --git a/tests/run-make/multiline-args-value/check-cfg-shebang.stderr b/tests/run-make/multiline-args-value/check-cfg-shebang.stderr new file mode 100644 index 00000000000..5bf18dc2b14 --- /dev/null +++ b/tests/run-make/multiline-args-value/check-cfg-shebang.stderr @@ -0,0 +1,6 @@ +error: invalid `--check-cfg` argument: `#!/usr/bin/shebang + cfg(key)` + | + = note: expected `cfg(name, values("value1", "value2", ... "valueN"))` + = note: visit <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more details + diff --git a/tests/run-make/multiline-args-value/rmake.rs b/tests/run-make/multiline-args-value/rmake.rs new file mode 100644 index 00000000000..3964cbbc1e6 --- /dev/null +++ b/tests/run-make/multiline-args-value/rmake.rs @@ -0,0 +1,51 @@ +use run_make_support::{cwd, diff, rustc}; + +fn test_and_compare(test_name: &str, flag: &str, val: &str) { + let mut cmd = rustc(); + + let output = cmd.input("").arg("--crate-type=lib").arg(flag).arg(val).run_fail(); + + assert_eq!(output.stdout_utf8(), ""); + diff() + .expected_file(format!("{test_name}.stderr")) + .actual_text("stderr", output.stderr_utf8()) + .run(); +} + +fn main() { + // Verify that frontmatter isn't allowed in `--cfg` arguments. + // https://github.com/rust-lang/rust/issues/146130 + test_and_compare( + "cfg-frontmatter", + "--cfg", + r#"--- +--- +key"#, + ); + + // Verify that frontmatter isn't allowed in `--check-cfg` arguments. + // https://github.com/rust-lang/rust/issues/146130 + test_and_compare( + "check-cfg-frontmatter", + "--check-cfg", + r#"--- +--- +cfg(key)"#, + ); + + // Verify that shebang isn't allowed in `--cfg` arguments. + test_and_compare( + "cfg-shebang", + "--cfg", + r#"#!/usr/bin/shebang +key"#, + ); + + // Verify that shebang isn't allowed in `--check-cfg` arguments. + test_and_compare( + "check-cfg-shebang", + "--check-cfg", + r#"#!/usr/bin/shebang +cfg(key)"#, + ); +} diff --git a/tests/run-make/rust-lld-custom-target/custom-target.json b/tests/run-make/rust-lld-custom-target/custom-target.json index e2c64cbdb43..28c3dc6f387 100644 --- a/tests/run-make/rust-lld-custom-target/custom-target.json +++ b/tests/run-make/rust-lld-custom-target/custom-target.json @@ -53,5 +53,5 @@ "target-family": [ "unix" ], - "target-pointer-width": "64" + "target-pointer-width": 64 } diff --git a/tests/run-make/rustdoc-dep-info/rmake.rs b/tests/run-make/rustdoc-dep-info/rmake.rs index 625f81fd428..166e8d5702f 100644 --- a/tests/run-make/rustdoc-dep-info/rmake.rs +++ b/tests/run-make/rustdoc-dep-info/rmake.rs @@ -33,4 +33,16 @@ fn main() { // Now we check that we can provide a file name to the `dep-info` argument. rustdoc().input("lib.rs").arg("-Zunstable-options").emit("dep-info=bla.d").run(); assert!(path("bla.d").exists()); + + // The last emit-type wins. The same behavior as rustc. + rustdoc() + .input("lib.rs") + .arg("-Zunstable-options") + .emit("dep-info=precedence1.d") + .emit("dep-info=precedence2.d") + .emit("dep-info=precedence3.d") + .run(); + assert!(!path("precedence1.d").exists()); + assert!(!path("precedence2.d").exists()); + assert!(path("precedence3.d").exists()); } diff --git a/tests/run-make/rustdoc-search-load-itemtype/bar.rs b/tests/run-make/rustdoc-search-load-itemtype/bar.rs new file mode 100644 index 00000000000..0416b1b75b5 --- /dev/null +++ b/tests/run-make/rustdoc-search-load-itemtype/bar.rs @@ -0,0 +1,27 @@ +#![crate_type = "proc-macro"] + +extern crate proc_macro; +use proc_macro::*; + +//@ has bar/macro.a_procmacro.html +//@ hasraw search.index/name/*.js a_procmacro +#[proc_macro] +pub fn a_procmacro(_: TokenStream) -> TokenStream { + unimplemented!() +} + +//@ has bar/attr.a_procattribute.html +//@ hasraw search.index/name/*.js a_procattribute +#[proc_macro_attribute] +pub fn a_procattribute(_: TokenStream, _: TokenStream) -> TokenStream { + unimplemented!() +} + +//@ has bar/derive.AProcDerive.html +//@ !has bar/derive.a_procderive.html +//@ hasraw search.index/name/*.js AProcDerive +//@ !hasraw search.index/name/*.js a_procderive +#[proc_macro_derive(AProcDerive)] +pub fn a_procderive(_: TokenStream) -> TokenStream { + unimplemented!() +} diff --git a/tests/run-make/rustdoc-search-load-itemtype/baz.rs b/tests/run-make/rustdoc-search-load-itemtype/baz.rs new file mode 100644 index 00000000000..4d1f5430fc6 --- /dev/null +++ b/tests/run-make/rustdoc-search-load-itemtype/baz.rs @@ -0,0 +1,3 @@ +//@ has baz/struct.Baz.html +//@ hasraw search.index/name/*.js Baz +pub struct Baz; diff --git a/tests/run-make/rustdoc-search-load-itemtype/foo.rs b/tests/run-make/rustdoc-search-load-itemtype/foo.rs new file mode 100644 index 00000000000..93b372d10cb --- /dev/null +++ b/tests/run-make/rustdoc-search-load-itemtype/foo.rs @@ -0,0 +1,119 @@ +#![feature(extern_types, rustc_attrs, rustdoc_internals, trait_alias)] +#![allow(internal_features)] +#![no_std] + +//@ has foo/keyword.while.html +//@ hasraw search.index/name/*.js while +//@ !hasraw search.index/name/*.js w_keyword +#[doc(keyword = "while")] +mod w_keyword {} + +//@ has foo/primitive.u32.html +//@ hasraw search.index/name/*.js u32 +//@ !hasraw search.index/name/*.js u_primitive +#[rustc_doc_primitive = "u32"] +mod u_primitive {} + +//@ has foo/x_mod/index.html +//@ hasraw search.index/name/*.js x_mod +pub mod x_mod {} + +//@ hasraw foo/index.html y_crate +//@ hasraw search.index/name/*.js y_crate +#[doc(no_inline)] +pub extern crate core as y_crate; + +//@ hasraw foo/index.html z_import +//@ hasraw search.index/name/*.js z_import +#[doc(no_inline)] +pub use core::option as z_import; + +//@ has foo/struct.AStruct.html +//@ hasraw search.index/name/*.js AStruct +pub struct AStruct { + //@ hasraw foo/struct.AStruct.html a_structfield + //@ hasraw search.index/name/*.js a_structfield + pub a_structfield: i32, +} + +//@ has foo/enum.AEnum.html +//@ hasraw search.index/name/*.js AEnum +pub enum AEnum { + //@ hasraw foo/enum.AEnum.html AVariant + //@ hasraw search.index/name/*.js AVariant + AVariant, +} + +//@ has foo/fn.a_fn.html +//@ hasraw search.index/name/*.js a_fn +pub fn a_fn() {} + +//@ has foo/type.AType.html +//@ hasraw search.index/name/*.js AType +pub type AType = AStruct; + +//@ has foo/static.a_static.html +//@ hasraw search.index/name/*.js a_static +pub static a_static: i32 = 1; + +//@ has foo/trait.ATrait.html +//@ hasraw search.index/name/*.js ATrait +pub trait ATrait { + //@ hasraw foo/trait.ATrait.html a_tymethod + //@ hasraw search.index/name/*.js a_tymethod + fn a_tymethod(); + //@ hasraw foo/trait.ATrait.html AAssocType + //@ hasraw search.index/name/*.js AAssocType + type AAssocType; + //@ hasraw foo/trait.ATrait.html AAssocConst + //@ hasraw search.index/name/*.js AAssocConst + const AAssocConst: bool; +} + +// skip ItemType::Impl, since impls are anonymous +// and have no search entry + +impl AStruct { + //@ hasraw foo/struct.AStruct.html a_method + //@ hasraw search.index/name/*.js a_method + pub fn a_method() {} +} + +//@ has foo/macro.a_macro.html +//@ hasraw search.index/name/*.js a_macro +#[macro_export] +macro_rules! a_macro { + () => {}; +} + +//@ has foo/constant.A_CONSTANT.html +//@ hasraw search.index/name/*.js A_CONSTANT +pub const A_CONSTANT: i32 = 1; + +//@ has foo/union.AUnion.html +//@ hasraw search.index/name/*.js AUnion +pub union AUnion { + //@ hasraw foo/union.AUnion.html a_unionfield + //@ hasraw search.index/name/*.js a_unionfield + pub a_unionfield: i32, +} + +extern "C" { + //@ has foo/foreigntype.AForeignType.html + //@ hasraw search.index/name/*.js AForeignType + pub type AForeignType; +} + +// procattribute and procderive are defined in +// bar.rs, because they only work with proc_macro +// crate type. + +//@ has foo/traitalias.ATraitAlias.html +//@ hasraw search.index/name/*.js ATraitAlias +pub trait ATraitAlias = ATrait; + +//@ has foo/attribute.doc.html +//@ hasraw search.index/name/*.js doc +//@ !hasraw search.index/name/*.js aa_mod +#[doc(attribute = "doc")] +mod aa_mod {} diff --git a/tests/run-make/rustdoc-search-load-itemtype/rmake.rs b/tests/run-make/rustdoc-search-load-itemtype/rmake.rs new file mode 100644 index 00000000000..803eb8a61da --- /dev/null +++ b/tests/run-make/rustdoc-search-load-itemtype/rmake.rs @@ -0,0 +1,21 @@ +//@ ignore-cross-compile +//@ needs-crate-type: proc-macro + +// Test that rustdoc can deserialize a search index with every itemtype. +// https://github.com/rust-lang/rust/pull/146117 + +use std::path::Path; + +use run_make_support::{htmldocck, rfs, rustdoc, source_root}; + +fn main() { + let out_dir = Path::new("rustdoc-search-load-itemtype"); + + rfs::create_dir_all(&out_dir); + rustdoc().out_dir(&out_dir).input("foo.rs").run(); + rustdoc().out_dir(&out_dir).input("bar.rs").arg("--crate-type=proc-macro").run(); + rustdoc().out_dir(&out_dir).input("baz.rs").run(); + htmldocck().arg(out_dir).arg("foo.rs").run(); + htmldocck().arg(out_dir).arg("bar.rs").run(); + htmldocck().arg(out_dir).arg("baz.rs").run(); +} diff --git a/tests/run-make/rustdoc-target-spec-json-path/target.json b/tests/run-make/rustdoc-target-spec-json-path/target.json index d7e4cac57ae..6d8fe8528c8 100644 --- a/tests/run-make/rustdoc-target-spec-json-path/target.json +++ b/tests/run-make/rustdoc-target-spec-json-path/target.json @@ -33,5 +33,5 @@ "thread" ], "target-family": "unix", - "target-pointer-width": "64" + "target-pointer-width": 64 } diff --git a/tests/run-make/sanitizer-cdylib-link/rmake.rs b/tests/run-make/sanitizer-cdylib-link/rmake.rs index f9d7fd98789..8ff58594d10 100644 --- a/tests/run-make/sanitizer-cdylib-link/rmake.rs +++ b/tests/run-make/sanitizer-cdylib-link/rmake.rs @@ -8,6 +8,8 @@ //@ needs-sanitizer-support //@ needs-sanitizer-address +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer + use run_make_support::{run_fail, rustc}; fn main() { diff --git a/tests/run-make/sanitizer-dylib-link/rmake.rs b/tests/run-make/sanitizer-dylib-link/rmake.rs index b43420adc72..bae3240a236 100644 --- a/tests/run-make/sanitizer-dylib-link/rmake.rs +++ b/tests/run-make/sanitizer-dylib-link/rmake.rs @@ -7,6 +7,8 @@ //@ needs-sanitizer-support //@ needs-sanitizer-address +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer + use run_make_support::{run_fail, rustc}; fn main() { diff --git a/tests/run-make/sanitizer-staticlib-link/rmake.rs b/tests/run-make/sanitizer-staticlib-link/rmake.rs index e38d15a8a3c..dda92626189 100644 --- a/tests/run-make/sanitizer-staticlib-link/rmake.rs +++ b/tests/run-make/sanitizer-staticlib-link/rmake.rs @@ -11,6 +11,8 @@ //@ needs-sanitizer-support //@ needs-sanitizer-address +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer + use run_make_support::{cc, extra_c_flags, extra_cxx_flags, run_fail, rustc, static_lib_name}; fn main() { diff --git a/tests/run-make/separate-link-fail/rmake.rs b/tests/run-make/separate-link-fail/rmake.rs index b5d5300de68..ba24f777395 100644 --- a/tests/run-make/separate-link-fail/rmake.rs +++ b/tests/run-make/separate-link-fail/rmake.rs @@ -11,5 +11,5 @@ fn main() { .arg("-Zlink-only") .input("foo.rs") .run_fail() - .assert_stderr_contains("The input does not look like a .rlink file"); + .assert_stderr_contains("the input does not look like a .rlink file"); } diff --git a/tests/run-make/target-specs/endianness-mismatch.json b/tests/run-make/target-specs/endianness-mismatch.json index cc03becc59a..d73ea1cbcfe 100644 --- a/tests/run-make/target-specs/endianness-mismatch.json +++ b/tests/run-make/target-specs/endianness-mismatch.json @@ -4,7 +4,7 @@ "linker-flavor": "gcc", "llvm-target": "x86_64-unknown-linux-gnu", "target-endian": "big", - "target-pointer-width": "64", + "target-pointer-width": 64, "arch": "x86_64", "os": "linux" } diff --git a/tests/run-make/target-specs/mismatching-data-layout.json b/tests/run-make/target-specs/mismatching-data-layout.json index d12caaad14a..e948d4d2f99 100644 --- a/tests/run-make/target-specs/mismatching-data-layout.json +++ b/tests/run-make/target-specs/mismatching-data-layout.json @@ -2,5 +2,5 @@ "arch": "x86_64", "data-layout": "e-m:e-i64:16:32:64", "llvm-target": "x86_64-unknown-unknown-gnu", - "target-pointer-width": "64" + "target-pointer-width": 64 } diff --git a/tests/run-make/target-specs/my-awesome-platform.json b/tests/run-make/target-specs/my-awesome-platform.json index d41038b84a8..732a6bacd15 100644 --- a/tests/run-make/target-specs/my-awesome-platform.json +++ b/tests/run-make/target-specs/my-awesome-platform.json @@ -3,7 +3,7 @@ "linker-flavor": "gcc", "llvm-target": "i686-unknown-linux-gnu", "target-endian": "little", - "target-pointer-width": "32", + "target-pointer-width": 32, "arch": "x86", "os": "linux" } diff --git a/tests/run-make/target-specs/my-incomplete-platform.json b/tests/run-make/target-specs/my-incomplete-platform.json index 8bdc4108f49..68dbfc62d1c 100644 --- a/tests/run-make/target-specs/my-incomplete-platform.json +++ b/tests/run-make/target-specs/my-incomplete-platform.json @@ -2,7 +2,7 @@ "data-layout": "e-p:32:32-f64:32:64-i64:32:64-f80:32:32-n8:16:32", "linker-flavor": "gcc", "target-endian": "little", - "target-pointer-width": "32", + "target-pointer-width": 32, "arch": "x86", "os": "foo" } diff --git a/tests/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json b/tests/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json index 27833f1abdd..008ea548383 100644 --- a/tests/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json +++ b/tests/run-make/target-specs/my-x86_64-unknown-linux-gnu-platform.json @@ -4,7 +4,7 @@ "linker-flavor": "gcc", "llvm-target": "x86_64-unknown-linux-gnu", "target-endian": "little", - "target-pointer-width": "64", + "target-pointer-width": 64, "arch": "x86_64", "os": "linux" } diff --git a/tests/run-make/target-specs/require-explicit-cpu.json b/tests/run-make/target-specs/require-explicit-cpu.json index 9744bca168e..4f23b644d8c 100644 --- a/tests/run-make/target-specs/require-explicit-cpu.json +++ b/tests/run-make/target-specs/require-explicit-cpu.json @@ -3,7 +3,7 @@ "linker-flavor": "gcc", "llvm-target": "i686-unknown-linux-gnu", "target-endian": "little", - "target-pointer-width": "32", + "target-pointer-width": 32, "arch": "x86", "os": "linux", "need-explicit-cpu": true diff --git a/tests/rustdoc-gui/links-color.goml b/tests/rustdoc-gui/links-color.goml index f11920cdd8c..a363175c1dd 100644 --- a/tests/rustdoc-gui/links-color.goml +++ b/tests/rustdoc-gui/links-color.goml @@ -9,7 +9,7 @@ show-text: true define-function: ( "check-colors", [theme, mod, macro, struct, enum, trait, fn, type, union, keyword, - sidebar, sidebar_current, sidebar_current_background], + attribute, sidebar, sidebar_current, sidebar_current_background], block { call-function: ("switch-theme", {"theme": |theme|}) // Checking results colors. @@ -22,6 +22,7 @@ define-function: ( assert-css: (".item-table .type", {"color": |type|}, ALL) assert-css: (".item-table .union", {"color": |union|}, ALL) assert-css: (".item-table .keyword", {"color": |keyword|}, ALL) + assert-css: (".item-table .attribute", {"color": |attribute|}, ALL) // Checking sidebar elements. assert-css: ( ".sidebar-elems li:not(.current) a", @@ -58,6 +59,7 @@ call-function: ( "type": "#ffa0a5", "union": "#ffa0a5", "keyword": "#39afd7", + "attribute": "#39afd7", "sidebar": "#53b1db", "sidebar_current": "#ffb44c", "sidebar_current_background": "transparent", @@ -76,6 +78,7 @@ call-function: ( "type": "#2dbfb8", "union": "#2dbfb8", "keyword": "#d2991d", + "attribute": "#d2991d", "sidebar": "#fdbf35", "sidebar_current": "#fdbf35", "sidebar_current_background": "#444", @@ -94,6 +97,7 @@ call-function: ( "type": "#ad378a", "union": "#ad378a", "keyword": "#3873ad", + "attribute": "#3873ad", "sidebar": "#356da4", "sidebar_current": "#356da4", "sidebar_current_background": "#fff", diff --git a/tests/rustdoc-gui/module-items-font.goml b/tests/rustdoc-gui/module-items-font.goml index 0e6dd81c05b..bed95b378c6 100644 --- a/tests/rustdoc-gui/module-items-font.goml +++ b/tests/rustdoc-gui/module-items-font.goml @@ -65,3 +65,12 @@ assert-css: ( "#keywords + .item-table dd", {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, ) +// attributes +assert-css: ( + "#attributes + .item-table dt a", + {"font-family": '"Fira Sans", Arial, NanumBarunGothic, sans-serif'}, +) +assert-css: ( + "#attributes + .item-table dd", + {"font-family": '"Source Serif 4", NanumBarunGothic, serif'}, +) diff --git a/tests/rustdoc-gui/scrape-examples-ice-links.goml b/tests/rustdoc-gui/scrape-examples-ice-links.goml new file mode 100644 index 00000000000..0a159621935 --- /dev/null +++ b/tests/rustdoc-gui/scrape-examples-ice-links.goml @@ -0,0 +1,8 @@ +// Check that the line number column has the correct layout. +go-to: "file://" + |DOC_PATH| + "/scrape_ice/struct.ObscurelyNamedType1.html" +wait-for: ".scraped-example-title" +assert-attribute: (".scraped-example-title a", {"href": "../src/bar/bar.rs.html#2"}) +click: ".scraped-example-title a" +wait-for-property: ("h1", {"innerText": "bar/\nbar.rs"}) +// Ensure that the `--html-after-content` option was correctly handled. +assert: "#outer-html" diff --git a/tests/rustdoc-gui/search-result-color.goml b/tests/rustdoc-gui/search-result-color.goml index e136eab6a7d..fe0f6401089 100644 --- a/tests/rustdoc-gui/search-result-color.goml +++ b/tests/rustdoc-gui/search-result-color.goml @@ -7,7 +7,8 @@ define-function: ( [ theme, count_color, desc_color, path_color, bottom_border_color, keyword_color, struct_color, associatedtype_color, tymethod_color, method_color, structfield_color, - structfield_hover_color, macro_color, fn_color, hover_path_color, hover_background, grey + structfield_hover_color, macro_color, fn_color, hover_path_color, hover_background, + attribute_color, grey ], block { call-function: ("switch-theme", {"theme": |theme|}) @@ -47,6 +48,11 @@ define-function: ( "hover_color": |keyword_color|, }) call-function: ("check-result-color", { + "result_kind": "attribute", + "color": |attribute_color|, + "hover_color": |attribute_color|, + }) + call-function: ("check-result-color", { "result_kind": "struct", "color": |struct_color|, "hover_color": |struct_color|, @@ -155,6 +161,7 @@ call-function: ("check-search-color", { "path_color": "#0096cf", "bottom_border_color": "#aaa3", "keyword_color": "#39afd7", + "attribute_color": "#39afd7", "struct_color": "#ffa0a5", "associatedtype_color": "#39afd7", "tymethod_color": "#fdd687", @@ -176,6 +183,7 @@ call-function: ("check-search-color", { "path_color": "#ddd", "bottom_border_color": "#aaa3", "keyword_color": "#d2991d", + "attribute_color": "#d2991d", "struct_color": "#2dbfb8", "associatedtype_color": "#d2991d", "tymethod_color": "#2bab63", @@ -197,6 +205,7 @@ call-function: ("check-search-color", { "path_color": "#000", "bottom_border_color": "#aaa3", "keyword_color": "#3873ad", + "attribute_color": "#3873ad", "struct_color": "#ad378a", "associatedtype_color": "#3873ad", "tymethod_color": "#ad7c37", diff --git a/tests/rustdoc-gui/sidebar-links-color.goml b/tests/rustdoc-gui/sidebar-links-color.goml index 57c45555a76..9a398655f8f 100644 --- a/tests/rustdoc-gui/sidebar-links-color.goml +++ b/tests/rustdoc-gui/sidebar-links-color.goml @@ -12,6 +12,7 @@ define-function: ( enum_hover_background, union, union_hover, union_hover_background, trait, trait_hover, trait_hover_background, fn, fn_hover, fn_hover_background, type, type_hover, type_hover_background, keyword, keyword_hover, keyword_hover_background, + attribute, attribute_hover, attribute_hover_background, ], block { call-function: ("switch-theme", {"theme": |theme|}) @@ -85,6 +86,16 @@ define-function: ( ".sidebar .block.keyword a:hover", {"color": |keyword_hover|, "background-color": |keyword_hover_background|}, ) + // Attribute + assert-css: ( + ".sidebar .block.attribute a", + {"color": |attribute|, "background-color": "rgba(0, 0, 0, 0)"}, + ) + move-cursor-to: ".sidebar .block.attribute a" + assert-css: ( + ".sidebar .block.attribute a:hover", + {"color": |attribute_hover|, "background-color": |attribute_hover_background|}, + ) } ) @@ -113,6 +124,9 @@ call-function: ( "keyword": "#53b1db", "keyword_hover": "#ffb44c", "keyword_hover_background": "transparent", + "attribute": "#53b1db", + "attribute_hover": "#ffb44c", + "attribute_hover_background": "transparent", } ) call-function: ( @@ -140,6 +154,9 @@ call-function: ( "keyword": "#fdbf35", "keyword_hover": "#fdbf35", "keyword_hover_background": "#444", + "attribute": "#fdbf35", + "attribute_hover": "#fdbf35", + "attribute_hover_background": "#444", } ) call-function: ( @@ -167,5 +184,8 @@ call-function: ( "keyword": "#356da4", "keyword_hover": "#356da4", "keyword_hover_background": "#fff", + "attribute": "#356da4", + "attribute_hover": "#356da4", + "attribute_hover_background": "#fff", } ) diff --git a/tests/rustdoc-gui/sidebar-source-code.goml b/tests/rustdoc-gui/sidebar-source-code.goml index 3f6914a89d6..a3c19d8c6d0 100644 --- a/tests/rustdoc-gui/sidebar-source-code.goml +++ b/tests/rustdoc-gui/sidebar-source-code.goml @@ -71,7 +71,7 @@ assert: "//*[@class='dir-entry' and @open]/*[normalize-space()='sub_mod']" // Only "another_folder" should be "open" in "lib2". assert: "//*[@class='dir-entry' and not(@open)]/*[normalize-space()='another_mod']" // All other trees should be collapsed. -assert-count: ("//*[@id='src-sidebar']/details[not(normalize-space()='lib2') and not(@open)]", 12) +assert-count: ("//*[@id='src-sidebar']/details[not(normalize-space()='lib2') and not(@open)]", 13) // We now switch to mobile mode. set-window-size: (600, 600) diff --git a/tests/rustdoc-gui/src/scrape_examples_ice/Cargo.lock b/tests/rustdoc-gui/src/scrape_examples_ice/Cargo.lock new file mode 100644 index 00000000000..03410a0da12 --- /dev/null +++ b/tests/rustdoc-gui/src/scrape_examples_ice/Cargo.lock @@ -0,0 +1,7 @@ +# This file is automatically @generated by Cargo. +# It is not intended for manual editing. +version = 4 + +[[package]] +name = "scrape_ice" +version = "0.1.0" diff --git a/tests/rustdoc-gui/src/scrape_examples_ice/Cargo.toml b/tests/rustdoc-gui/src/scrape_examples_ice/Cargo.toml new file mode 100644 index 00000000000..076ff38ad23 --- /dev/null +++ b/tests/rustdoc-gui/src/scrape_examples_ice/Cargo.toml @@ -0,0 +1,9 @@ +[package] +name = "scrape_ice" +version = "0.1.0" +edition = "2024" + +[[example]] +name = "bar" +path = "examples/bar.rs" +doc-scrape-examples = true diff --git a/tests/rustdoc-gui/src/scrape_examples_ice/examples/bar.rs b/tests/rustdoc-gui/src/scrape_examples_ice/examples/bar.rs new file mode 100644 index 00000000000..9f05f9e46e8 --- /dev/null +++ b/tests/rustdoc-gui/src/scrape_examples_ice/examples/bar.rs @@ -0,0 +1,3 @@ +fn main() { + let mut bar = scrape_ice::ObscurelyNamedType1::new(); +} diff --git a/tests/rustdoc-gui/src/scrape_examples_ice/extra.html b/tests/rustdoc-gui/src/scrape_examples_ice/extra.html new file mode 100644 index 00000000000..e7a420154a6 --- /dev/null +++ b/tests/rustdoc-gui/src/scrape_examples_ice/extra.html @@ -0,0 +1 @@ +<span id="outer-html"></span> diff --git a/tests/rustdoc-gui/src/scrape_examples_ice/src/lib.rs b/tests/rustdoc-gui/src/scrape_examples_ice/src/lib.rs new file mode 100644 index 00000000000..7d910c6de7d --- /dev/null +++ b/tests/rustdoc-gui/src/scrape_examples_ice/src/lib.rs @@ -0,0 +1,9 @@ +//@ run-flags:-Zrustdoc-scrape-examples +//@ compile-flags: --html-after-content extra.html +pub struct ObscurelyNamedType1; + +impl ObscurelyNamedType1 { + pub fn new() -> Self { + ObscurelyNamedType1 + } +} diff --git a/tests/rustdoc-gui/src/test_docs/lib.rs b/tests/rustdoc-gui/src/test_docs/lib.rs index 623f5b33e9b..42f2fbd93b1 100644 --- a/tests/rustdoc-gui/src/test_docs/lib.rs +++ b/tests/rustdoc-gui/src/test_docs/lib.rs @@ -161,6 +161,10 @@ pub enum AnEnum { /// Some keyword. pub mod keyword {} +#[doc(attribute = "forbid")] +/// Some attribute. +pub mod repr {} + /// Just some type alias. pub type SomeType = u32; diff --git a/tests/rustdoc-json/doc_attribute.rs b/tests/rustdoc-json/doc_attribute.rs new file mode 100644 index 00000000000..9e1a711f0b7 --- /dev/null +++ b/tests/rustdoc-json/doc_attribute.rs @@ -0,0 +1,18 @@ +// Doc attributes (`#[doc(attribute = "...")]` should not be generated in rustdoc JSON output +// and this test ensures it. + +#![feature(rustdoc_internals)] +#![no_std] + +//@ !has "$.index[?(@.name=='repr')]" +//@ has "$.index[?(@.name=='foo')]" + +#[doc(attribute = "repr")] +/// this is a test! +pub mod foo {} + +//@ !has "$.index[?(@.name=='forbid')]" +//@ !has "$.index[?(@.name=='bar')]" +#[doc(attribute = "forbid")] +/// hello +mod bar {} diff --git a/tests/rustdoc-ui/doc-attribute-unsupported.rs b/tests/rustdoc-ui/doc-attribute-unsupported.rs new file mode 100644 index 00000000000..3bd153117a9 --- /dev/null +++ b/tests/rustdoc-ui/doc-attribute-unsupported.rs @@ -0,0 +1,7 @@ +// This is currently not supported but should be! + +#![feature(rustdoc_internals)] + +#[doc(attribute = "diagnostic::do_not_recommend")] //~ ERROR +/// bla +mod yup {} diff --git a/tests/rustdoc-ui/doc-attribute-unsupported.stderr b/tests/rustdoc-ui/doc-attribute-unsupported.stderr new file mode 100644 index 00000000000..e2480a548ac --- /dev/null +++ b/tests/rustdoc-ui/doc-attribute-unsupported.stderr @@ -0,0 +1,10 @@ +error: nonexistent builtin attribute `diagnostic::do_not_recommend` used in `#[doc(attribute = "...")]` + --> $DIR/doc-attribute-unsupported.rs:5:19 + | +LL | #[doc(attribute = "diagnostic::do_not_recommend")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: only existing builtin attributes are allowed in core/std + +error: aborting due to 1 previous error + diff --git a/tests/rustdoc-ui/invalid-attribute.rs b/tests/rustdoc-ui/invalid-attribute.rs new file mode 100644 index 00000000000..2fc7be2cf34 --- /dev/null +++ b/tests/rustdoc-ui/invalid-attribute.rs @@ -0,0 +1,10 @@ +// Testing the output when an invalid builtin attribute is passed as value +// to `doc(attribute = "...")`. + +#![feature(rustdoc_internals)] + +#[doc(attribute = "foo df")] //~ ERROR +mod foo {} + +#[doc(attribute = "fooyi")] //~ ERROR +mod foo2 {} diff --git a/tests/rustdoc-ui/invalid-attribute.stderr b/tests/rustdoc-ui/invalid-attribute.stderr new file mode 100644 index 00000000000..66e68ce44b4 --- /dev/null +++ b/tests/rustdoc-ui/invalid-attribute.stderr @@ -0,0 +1,18 @@ +error: nonexistent builtin attribute `foo df` used in `#[doc(attribute = "...")]` + --> $DIR/invalid-attribute.rs:6:19 + | +LL | #[doc(attribute = "foo df")] + | ^^^^^^^^ + | + = help: only existing builtin attributes are allowed in core/std + +error: nonexistent builtin attribute `fooyi` used in `#[doc(attribute = "...")]` + --> $DIR/invalid-attribute.rs:9:19 + | +LL | #[doc(attribute = "fooyi")] + | ^^^^^^^ + | + = help: only existing builtin attributes are allowed in core/std + +error: aborting due to 2 previous errors + diff --git a/tests/rustdoc-ui/lints/invalid-html-tags.rs b/tests/rustdoc-ui/lints/invalid-html-tags.rs index 317f1fd1d46..8003e5efdd5 100644 --- a/tests/rustdoc-ui/lints/invalid-html-tags.rs +++ b/tests/rustdoc-ui/lints/invalid-html-tags.rs @@ -43,7 +43,7 @@ pub fn b() {} /// <h3> //~^ ERROR unclosed HTML tag `h3` /// <script -//~^ ERROR unclosed HTML tag `script` +//~^ ERROR incomplete HTML tag `script` pub fn c() {} // Unclosed tags shouldn't warn if they are nested inside a <script> elem. @@ -72,6 +72,7 @@ pub fn e() {} /// <div></div > /// <div></div //~^ ERROR unclosed HTML tag `div` +//~| ERROR incomplete HTML tag `div` pub fn f() {} /// <!----> @@ -105,7 +106,7 @@ pub fn j() {} /// uiapp.run(&env::args().collect::<Vec<_>>()); /// ``` /// -/// <Vec<_> shouldn't warn! +// <Vec<_> shouldn't warn! /// `````` pub fn k() {} @@ -121,3 +122,92 @@ pub fn no_error_1() {} /// backslashed \<<a href=""> //~^ ERROR unclosed HTML tag `a` pub fn p() {} + +/// <svg width="512" height="512" viewBox="0 0 512" fill="none" xmlns="http://www.w3.org/2000/svg"> +/// <rect +/// width="256" +/// height="256" +/// fill="#5064C8" +/// stroke="black" +/// /> +/// </svg> +pub fn no_error_2() {} + +/// <div> +/// <img +/// src="https://example.com/ferris.png" +/// width="512" +/// height="512" +/// /> +/// </div> +pub fn no_error_3() {} + +/// > <div +/// > class="foo"> +/// > </div> +pub fn no_error_4() {} + +/// unfinished ALLOWED_UNCLOSED +/// +/// note: CommonMark doesn't allow an html block to start with a multiline tag, +/// so we use `<br>` a bunch to force these to be parsed as html blocks. +/// +/// <br> +/// <img +//~^ ERROR incomplete HTML tag `img` +pub fn q() {} + +/// nested unfinished ALLOWED_UNCLOSED +/// <p><img</p> +//~^ ERROR incomplete HTML tag `img` +pub fn r() {} + +/// > <br> +/// > <img +//~^ ERROR incomplete HTML tag `img` +/// > href="#broken" +pub fn s() {} + +/// <br> +/// <br<br> +//~^ ERROR incomplete HTML tag `br` +pub fn t() {} + +/// <br> +/// <br +//~^ ERROR incomplete HTML tag `br` +pub fn u() {} + +/// <a href=">" alt="<">html5 allows this</a> +pub fn no_error_5() {} + +/// <br> +/// <img title=" +/// html5 +/// allows +/// multiline +/// attr +/// values +/// these are just text, not tags: +/// </div> +/// <p/> +/// <div> +/// "> +pub fn no_error_6() {} + +/// <br> +/// <a href="data:text/html,<!DOCTYPE> +/// <html> +/// <body><b>this is allowed for some reason</b></body> +/// </html> +/// ">what</a> +pub fn no_error_7() {} + +/// Technically this is allowed per the html5 spec, +/// but there's basically no legitemate reason to do it, +/// so we don't allow it. +/// +/// <p <!-->foobar</p> +//~^ ERROR Unclosed HTML comment +//~| ERROR incomplete HTML tag `p` +pub fn v() {} diff --git a/tests/rustdoc-ui/lints/invalid-html-tags.stderr b/tests/rustdoc-ui/lints/invalid-html-tags.stderr index 9c2bfcf2c3d..b6ec22c2479 100644 --- a/tests/rustdoc-ui/lints/invalid-html-tags.stderr +++ b/tests/rustdoc-ui/lints/invalid-html-tags.stderr @@ -52,6 +52,12 @@ error: unclosed HTML tag `p` LL | /// <br/> <p> | ^^^ +error: incomplete HTML tag `script` + --> $DIR/invalid-html-tags.rs:45:5 + | +LL | /// <script + | ^^^^^^^ + error: unclosed HTML tag `div` --> $DIR/invalid-html-tags.rs:41:5 | @@ -64,11 +70,11 @@ error: unclosed HTML tag `h3` LL | /// <h3> | ^^^^ -error: unclosed HTML tag `script` - --> $DIR/invalid-html-tags.rs:45:5 +error: incomplete HTML tag `div` + --> $DIR/invalid-html-tags.rs:73:10 | -LL | /// <script - | ^^^^^^ +LL | /// <div></div + | ^^^^^ error: unclosed HTML tag `div` --> $DIR/invalid-html-tags.rs:73:5 @@ -77,28 +83,73 @@ LL | /// <div></div | ^^^^^ error: Unclosed HTML comment - --> $DIR/invalid-html-tags.rs:87:5 + --> $DIR/invalid-html-tags.rs:88:5 | LL | /// <!-- - | ^^^ + | ^^^^ error: unopened HTML tag `unopened-tag` - --> $DIR/invalid-html-tags.rs:114:26 + --> $DIR/invalid-html-tags.rs:115:26 | LL | /// Web Components style </unopened-tag> | ^^^^^^^^^^^^^^^ error: unclosed HTML tag `dashed-tags` - --> $DIR/invalid-html-tags.rs:112:26 + --> $DIR/invalid-html-tags.rs:113:26 | LL | /// Web Components style <dashed-tags> | ^^^^^^^^^^^^^ error: unclosed HTML tag `a` - --> $DIR/invalid-html-tags.rs:121:19 + --> $DIR/invalid-html-tags.rs:122:19 | LL | /// backslashed \<<a href=""> | ^^ -error: aborting due to 16 previous errors +error: incomplete HTML tag `img` + --> $DIR/invalid-html-tags.rs:156:5 + | +LL | /// <img + | ^^^^ + +error: incomplete HTML tag `img` + --> $DIR/invalid-html-tags.rs:161:8 + | +LL | /// <p><img</p> + | ^^^^ + +error: incomplete HTML tag `img` + --> $DIR/invalid-html-tags.rs:166:7 + | +LL | /// > <img + | _______^ +LL | | +LL | | /// > href="#broken" + | |____________________^ + +error: incomplete HTML tag `br` + --> $DIR/invalid-html-tags.rs:172:5 + | +LL | /// <br<br> + | ^^^ + +error: incomplete HTML tag `br` + --> $DIR/invalid-html-tags.rs:177:5 + | +LL | /// <br + | ^^^ + +error: incomplete HTML tag `p` + --> $DIR/invalid-html-tags.rs:210:5 + | +LL | /// <p <!-->foobar</p> + | ^^^ + +error: Unclosed HTML comment + --> $DIR/invalid-html-tags.rs:210:8 + | +LL | /// <p <!-->foobar</p> + | ^^^^ + +error: aborting due to 24 previous errors diff --git a/tests/rustdoc/doc-attribute.rs b/tests/rustdoc/doc-attribute.rs new file mode 100644 index 00000000000..92e603ae6e5 --- /dev/null +++ b/tests/rustdoc/doc-attribute.rs @@ -0,0 +1,24 @@ +// Test checking the `#[doc(attribute = "...")]` attribute. + +#![crate_name = "foo"] + +#![feature(rustdoc_internals)] + +//@ has foo/index.html '//h2[@id="attributes"]' 'Attributes' +//@ has foo/index.html '//a[@href="attribute.no_mangle.html"]' 'no_mangle' +//@ has foo/index.html '//div[@class="sidebar-elems"]//li/a' 'Attributes' +//@ has foo/index.html '//div[@class="sidebar-elems"]//li/a/@href' '#attributes' +//@ has foo/attribute.no_mangle.html '//h1' 'Attribute no_mangle' +//@ has foo/attribute.no_mangle.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'this is a test!' +//@ has foo/index.html '//a/@href' '../foo/index.html' +//@ !has foo/foo/index.html +//@ !has-dir foo/foo +//@ !has foo/index.html '//span' '🔒' +#[doc(attribute = "no_mangle")] +/// this is a test! +mod foo{} + +//@ has foo/attribute.repr.html '//section[@id="main-content"]//div[@class="docblock"]//p' 'hello' +#[doc(attribute = "repr")] +/// hello +mod bar {} diff --git a/tests/rustdoc/sanitizer-option.rs b/tests/rustdoc/sanitizer-option.rs index 2adf1be51fd..7b0038138f0 100644 --- a/tests/rustdoc/sanitizer-option.rs +++ b/tests/rustdoc/sanitizer-option.rs @@ -1,6 +1,6 @@ //@ needs-sanitizer-support //@ needs-sanitizer-address -//@ compile-flags: --test -Z sanitizer=address +//@ compile-flags: --test -Z sanitizer=address -C unsafe-allow-abi-mismatch=sanitizer // // #43031: Verify that rustdoc passes `-Z` options to rustc. Use an extern // function that is provided by the sanitizer runtime, if flag is not passed diff --git a/tests/ui-fulldeps/internal-lints/import-of-type-ir-traits.rs b/tests/ui-fulldeps/internal-lints/import-of-type-ir-traits.rs index 3fdd65d6c87..965fd832722 100644 --- a/tests/ui-fulldeps/internal-lints/import-of-type-ir-traits.rs +++ b/tests/ui-fulldeps/internal-lints/import-of-type-ir-traits.rs @@ -8,7 +8,7 @@ extern crate rustc_type_ir; use rustc_type_ir::Interner; -fn foo<I: Interner>(cx: I, did: I::DefId) { +fn foo<I: Interner>(cx: I, did: I::TraitId) { let _ = cx.trait_is_unsafe(did); //~^ ERROR do not use `rustc_type_ir::Interner` or `rustc_type_ir::InferCtxtLike` unless you're inside of the trait solver } diff --git a/tests/ui/.gitattributes b/tests/ui/.gitattributes index 9ea3d3fb0e1..4923ac100e1 100644 --- a/tests/ui/.gitattributes +++ b/tests/ui/.gitattributes @@ -3,4 +3,5 @@ json-bom-plus-crlf.rs -text json-bom-plus-crlf-multifile.rs -text json-bom-plus-crlf-multifile-aux.rs -text trailing-carriage-return-in-string.rs -text +frontmatter-crlf.rs -text *.bin -text diff --git a/tests/ui/abi/c-zst.powerpc-linux.stderr b/tests/ui/abi/c-zst.powerpc-linux.stderr index b8d6c632b97..ec6b9b8f027 100644 --- a/tests/ui/abi/c-zst.powerpc-linux.stderr +++ b/tests/ui/abi/c-zst.powerpc-linux.stderr @@ -27,7 +27,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, mode: Indirect { attrs: ArgAttributes { - regular: NoAlias | NoCapture | NonNull | NoUndef, + regular: NoAlias | CapturesAddress | NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some( diff --git a/tests/ui/abi/c-zst.s390x-linux.stderr b/tests/ui/abi/c-zst.s390x-linux.stderr index b8d6c632b97..ec6b9b8f027 100644 --- a/tests/ui/abi/c-zst.s390x-linux.stderr +++ b/tests/ui/abi/c-zst.s390x-linux.stderr @@ -27,7 +27,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, mode: Indirect { attrs: ArgAttributes { - regular: NoAlias | NoCapture | NonNull | NoUndef, + regular: NoAlias | CapturesAddress | NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some( diff --git a/tests/ui/abi/c-zst.sparc64-linux.stderr b/tests/ui/abi/c-zst.sparc64-linux.stderr index b8d6c632b97..ec6b9b8f027 100644 --- a/tests/ui/abi/c-zst.sparc64-linux.stderr +++ b/tests/ui/abi/c-zst.sparc64-linux.stderr @@ -27,7 +27,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, mode: Indirect { attrs: ArgAttributes { - regular: NoAlias | NoCapture | NonNull | NoUndef, + regular: NoAlias | CapturesAddress | NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some( diff --git a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr index b8d6c632b97..ec6b9b8f027 100644 --- a/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr +++ b/tests/ui/abi/c-zst.x86_64-pc-windows-gnu.stderr @@ -27,7 +27,7 @@ error: fn_abi_of(pass_zst) = FnAbi { }, mode: Indirect { attrs: ArgAttributes { - regular: NoAlias | NoCapture | NonNull | NoUndef, + regular: NoAlias | CapturesAddress | NonNull | NoUndef, arg_ext: None, pointee_size: Size(0 bytes), pointee_align: Some( diff --git a/tests/ui/abi/debug.generic.stderr b/tests/ui/abi/debug.generic.stderr index 0fec35dabdd..47341da221f 100644 --- a/tests/ui/abi/debug.generic.stderr +++ b/tests/ui/abi/debug.generic.stderr @@ -454,7 +454,7 @@ error: ABIs are not compatible }, mode: Indirect { attrs: ArgAttributes { - regular: NoAlias | NoCapture | NonNull | NoUndef, + regular: NoAlias | CapturesAddress | NonNull | NoUndef, arg_ext: None, pointee_size: Size(32 bytes), pointee_align: Some( @@ -527,7 +527,7 @@ error: ABIs are not compatible }, mode: Indirect { attrs: ArgAttributes { - regular: NoAlias | NoCapture | NonNull | NoUndef, + regular: NoAlias | CapturesAddress | NonNull | NoUndef, arg_ext: None, pointee_size: Size(128 bytes), pointee_align: Some( diff --git a/tests/ui/abi/debug.loongarch64.stderr b/tests/ui/abi/debug.loongarch64.stderr index ce8bd41f045..94a01a80873 100644 --- a/tests/ui/abi/debug.loongarch64.stderr +++ b/tests/ui/abi/debug.loongarch64.stderr @@ -454,7 +454,7 @@ error: ABIs are not compatible }, mode: Indirect { attrs: ArgAttributes { - regular: NoAlias | NoCapture | NonNull | NoUndef, + regular: NoAlias | CapturesAddress | NonNull | NoUndef, arg_ext: None, pointee_size: Size(32 bytes), pointee_align: Some( @@ -527,7 +527,7 @@ error: ABIs are not compatible }, mode: Indirect { attrs: ArgAttributes { - regular: NoAlias | NoCapture | NonNull | NoUndef, + regular: NoAlias | CapturesAddress | NonNull | NoUndef, arg_ext: None, pointee_size: Size(128 bytes), pointee_align: Some( diff --git a/tests/ui/abi/debug.riscv64.stderr b/tests/ui/abi/debug.riscv64.stderr index ce8bd41f045..94a01a80873 100644 --- a/tests/ui/abi/debug.riscv64.stderr +++ b/tests/ui/abi/debug.riscv64.stderr @@ -454,7 +454,7 @@ error: ABIs are not compatible }, mode: Indirect { attrs: ArgAttributes { - regular: NoAlias | NoCapture | NonNull | NoUndef, + regular: NoAlias | CapturesAddress | NonNull | NoUndef, arg_ext: None, pointee_size: Size(32 bytes), pointee_align: Some( @@ -527,7 +527,7 @@ error: ABIs are not compatible }, mode: Indirect { attrs: ArgAttributes { - regular: NoAlias | NoCapture | NonNull | NoUndef, + regular: NoAlias | CapturesAddress | NonNull | NoUndef, arg_ext: None, pointee_size: Size(128 bytes), pointee_align: Some( diff --git a/tests/ui/abi/unsupported-varargs-fnptr.rs b/tests/ui/abi/unsupported-varargs-fnptr.rs index 1d23916d039..ac3913b3ef8 100644 --- a/tests/ui/abi/unsupported-varargs-fnptr.rs +++ b/tests/ui/abi/unsupported-varargs-fnptr.rs @@ -6,8 +6,6 @@ // 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 diff --git a/tests/ui/abi/unsupported-varargs-fnptr.stderr b/tests/ui/abi/unsupported-varargs-fnptr.stderr index 238f2b31330..c05c55df82e 100644 --- a/tests/ui/abi/unsupported-varargs-fnptr.stderr +++ b/tests/ui/abi/unsupported-varargs-fnptr.stderr @@ -1,5 +1,5 @@ error[E0570]: "aapcs" is not a supported ABI for the current target - --> $DIR/unsupported-varargs-fnptr.rs:14:20 + --> $DIR/unsupported-varargs-fnptr.rs:12:20 | LL | fn aapcs(f: extern "aapcs" fn(usize, ...)) { | ^^^^^^^ diff --git a/tests/ui/array-slice-vec/pattern-matching-fixed-length-vectors-7784.rs b/tests/ui/array-slice-vec/fixed-length-vector-pattern-matching-7784.rs index 7d987e92b63..7d987e92b63 100644 --- a/tests/ui/array-slice-vec/pattern-matching-fixed-length-vectors-7784.rs +++ b/tests/ui/array-slice-vec/fixed-length-vector-pattern-matching-7784.rs diff --git a/tests/ui/array-slice-vec/matching-on-vector-slice-option-8498.rs b/tests/ui/array-slice-vec/vector-slice-matching-8498.rs index e243a247ed5..e243a247ed5 100644 --- a/tests/ui/array-slice-vec/matching-on-vector-slice-option-8498.rs +++ b/tests/ui/array-slice-vec/vector-slice-matching-8498.rs diff --git a/tests/ui/asm/global-asm-isnt-really-a-mir-body.rs b/tests/ui/asm/global-asm-isnt-really-a-mir-body.rs index b7636d116ec..aef25d057d4 100644 --- a/tests/ui/asm/global-asm-isnt-really-a-mir-body.rs +++ b/tests/ui/asm/global-asm-isnt-really-a-mir-body.rs @@ -1,5 +1,7 @@ //@ revisions: emit_mir instrument cfi +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer + // Make sure we don't try to emit MIR for it. //@[emit_mir] compile-flags: --emit=mir diff --git a/tests/ui/associated-inherent-types/issue-111404-1.stderr b/tests/ui/associated-inherent-types/issue-111404-1.stderr index ce49126c316..9a5b69497c0 100644 --- a/tests/ui/associated-inherent-types/issue-111404-1.stderr +++ b/tests/ui/associated-inherent-types/issue-111404-1.stderr @@ -32,12 +32,10 @@ LL | fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {} = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: higher-ranked subtype error - --> $DIR/issue-111404-1.rs:10:1 + --> $DIR/issue-111404-1.rs:10:8 | LL | fn bar(_: fn(Foo<for<'b> fn(Foo<fn(&'b ())>::Assoc)>::Assoc)) {} - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + | ^ error: aborting due to 5 previous errors diff --git a/tests/ui/async-await/dont-suggest-await-on-method-return-mismatch.stderr b/tests/ui/async-await/dont-suggest-await-on-method-return-mismatch.stderr index 1faaf4ddce2..aa2343e48a6 100644 --- a/tests/ui/async-await/dont-suggest-await-on-method-return-mismatch.stderr +++ b/tests/ui/async-await/dont-suggest-await-on-method-return-mismatch.stderr @@ -3,6 +3,11 @@ error[E0599]: no method named `test` found for opaque type `impl Future<Output = | LL | let x: u32 = foo().test(); | ^^^^ method not found in `impl Future<Output = A>` + | +help: consider `await`ing on the `Future` and calling the method on its `Output` + | +LL | let x: u32 = foo().await.test(); + | ++++++ error: aborting due to 1 previous error diff --git a/tests/ui/async-await/future-sizes/async-awaiting-fut.rs b/tests/ui/async-await/future-sizes/async-awaiting-fut.rs index a3f0bdc8514..b5f59069f85 100644 --- a/tests/ui/async-await/future-sizes/async-awaiting-fut.rs +++ b/tests/ui/async-await/future-sizes/async-awaiting-fut.rs @@ -1,7 +1,9 @@ -//@ compile-flags: -Z print-type-sizes --crate-type lib +//@ compile-flags: -C panic=abort -Z print-type-sizes --crate-type lib +//@ needs-deterministic-layouts //@ edition:2021 //@ build-pass //@ ignore-pass +//@ only-x86_64 async fn wait() {} diff --git a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout index 642e27b2a57..b30c15bcbe6 100644 --- a/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout +++ b/tests/ui/async-await/future-sizes/async-awaiting-fut.stdout @@ -48,6 +48,39 @@ print-type-size variant `Returned`: 1024 bytes print-type-size upvar `.arg`: 1024 bytes print-type-size variant `Panicked`: 1024 bytes print-type-size upvar `.arg`: 1024 bytes +print-type-size type: `std::task::Context<'_>`: 32 bytes, alignment: 8 bytes +print-type-size field `.waker`: 8 bytes +print-type-size field `.local_waker`: 8 bytes +print-type-size field `.ext`: 16 bytes +print-type-size field `._marker`: 0 bytes +print-type-size field `._marker2`: 0 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.filename`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size field `._filename`: 0 bytes +print-type-size type: `core::task::wake::ExtData<'_>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::panic::AssertUnwindSafe<core::task::wake::ExtData<'_>>`: 16 bytes, alignment: 8 bytes +print-type-size field `.0`: 16 bytes +print-type-size type: `std::ptr::NonNull<str>`: 16 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 16 bytes +print-type-size type: `std::pin::Pin<&mut {async fn body of big_fut()}>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::pin::Pin<&mut {async fn body of calls_fut<{async fn body of big_fut()}>()}>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::pin::Pin<&mut {async fn body of test()}>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::pin::Pin<&mut {async fn body of wait()}>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::ptr::DynMetadata<dyn std::any::Any>`: 8 bytes, alignment: 8 bytes +print-type-size field `._vtable_ptr`: 8 bytes +print-type-size field `._phantom`: 0 bytes +print-type-size type: `std::ptr::NonNull<std::ptr::metadata::VTable>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes print-type-size type: `std::mem::ManuallyDrop<bool>`: 1 bytes, alignment: 1 bytes print-type-size field `.value`: 1 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes @@ -70,3 +103,7 @@ print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes +print-type-size type: `std::marker::PhantomData<&str>`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData<*mut ()>`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData<dyn std::any::Any>`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData<fn(&()) -> &()>`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/async-await/future-sizes/large-arg.rs b/tests/ui/async-await/future-sizes/large-arg.rs index 5fbae22a771..809f7cf1f93 100644 --- a/tests/ui/async-await/future-sizes/large-arg.rs +++ b/tests/ui/async-await/future-sizes/large-arg.rs @@ -1,7 +1,9 @@ -//@ compile-flags: -Z print-type-sizes --crate-type=lib +//@ compile-flags: -C panic=abort -Z print-type-sizes --crate-type=lib +//@ needs-deterministic-layouts //@ edition: 2021 //@ build-pass //@ ignore-pass +//@ only-x86_64 pub async fn test() { let _ = a([0u8; 1024]).await; diff --git a/tests/ui/async-await/future-sizes/large-arg.stdout b/tests/ui/async-await/future-sizes/large-arg.stdout index 67168a3d6ef..e00420d1493 100644 --- a/tests/ui/async-await/future-sizes/large-arg.stdout +++ b/tests/ui/async-await/future-sizes/large-arg.stdout @@ -58,3 +58,45 @@ print-type-size variant `Returned`: 1024 bytes print-type-size upvar `.t`: 1024 bytes print-type-size variant `Panicked`: 1024 bytes print-type-size upvar `.t`: 1024 bytes +print-type-size type: `std::task::Context<'_>`: 32 bytes, alignment: 8 bytes +print-type-size field `.waker`: 8 bytes +print-type-size field `.local_waker`: 8 bytes +print-type-size field `.ext`: 16 bytes +print-type-size field `._marker`: 0 bytes +print-type-size field `._marker2`: 0 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.filename`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size field `._filename`: 0 bytes +print-type-size type: `core::task::wake::ExtData<'_>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::panic::AssertUnwindSafe<core::task::wake::ExtData<'_>>`: 16 bytes, alignment: 8 bytes +print-type-size field `.0`: 16 bytes +print-type-size type: `std::ptr::NonNull<str>`: 16 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 16 bytes +print-type-size type: `std::pin::Pin<&mut {async fn body of a<[u8; 1024]>()}>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::pin::Pin<&mut {async fn body of b<[u8; 1024]>()}>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::pin::Pin<&mut {async fn body of c<[u8; 1024]>()}>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::pin::Pin<&mut {async fn body of test()}>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::ptr::DynMetadata<dyn std::any::Any>`: 8 bytes, alignment: 8 bytes +print-type-size field `._vtable_ptr`: 8 bytes +print-type-size field `._phantom`: 0 bytes +print-type-size type: `std::ptr::NonNull<std::ptr::metadata::VTable>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::task::Poll<()>`: 1 bytes, alignment: 1 bytes +print-type-size discriminant: 1 bytes +print-type-size variant `Ready`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size variant `Pending`: 0 bytes +print-type-size type: `std::marker::PhantomData<&str>`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData<*mut ()>`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData<dyn std::any::Any>`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData<fn(&()) -> &()>`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr index 3d82f572a1a..823d8d5b92f 100644 --- a/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr +++ b/tests/ui/async-await/in-trait/dont-project-to-specializable-projection.stderr @@ -25,6 +25,7 @@ error[E0599]: no method named `poll` found for struct `Pin<&mut impl Future<Outp | LL | match fut.as_mut().poll(ctx) { | ^^^^ method not found in `Pin<&mut impl Future<Output = ()>>` + | --> $SRC_DIR/core/src/future/future.rs:LL:COL | = note: the method is available for `Pin<&mut impl Future<Output = ()>>` here diff --git a/tests/ui/attributes/attr-on-mac-call.rs b/tests/ui/attributes/attr-on-mac-call.rs new file mode 100644 index 00000000000..a23ced123ef --- /dev/null +++ b/tests/ui/attributes/attr-on-mac-call.rs @@ -0,0 +1,73 @@ +//@ check-pass +// Regression test for https://github.com/rust-lang/rust/issues/145779 +#![warn(unused_attributes)] + +fn main() { + #[export_name = "x"] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[unsafe(naked)] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[track_caller] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[used] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[target_feature(enable = "x")] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[deprecated] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[inline] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[link_name = "x"] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[link_section = "x"] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[link_ordinal(42)] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[non_exhaustive] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[proc_macro] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[cold] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[no_mangle] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[deprecated] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[automatically_derived] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[macro_use] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[must_use] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[no_implicit_prelude] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[path = ""] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[ignore] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + #[should_panic] + //~^ WARN attribute cannot be used on macro calls + //~| WARN previously accepted + unreachable!(); +} diff --git a/tests/ui/attributes/attr-on-mac-call.stderr b/tests/ui/attributes/attr-on-mac-call.stderr new file mode 100644 index 00000000000..a08d3059168 --- /dev/null +++ b/tests/ui/attributes/attr-on-mac-call.stderr @@ -0,0 +1,205 @@ +warning: `#[export_name]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:6:5 + | +LL | #[export_name = "x"] + | ^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[export_name]` can be applied to functions and statics +note: the lint level is defined here + --> $DIR/attr-on-mac-call.rs:3:9 + | +LL | #![warn(unused_attributes)] + | ^^^^^^^^^^^^^^^^^ + +warning: `#[naked]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:9:5 + | +LL | #[unsafe(naked)] + | ^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[naked]` can only be applied to functions + +warning: `#[track_caller]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:12:5 + | +LL | #[track_caller] + | ^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[track_caller]` can only be applied to functions + +warning: `#[used]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:15:5 + | +LL | #[used] + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[used]` can only be applied to statics + +warning: `#[target_feature]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:18:5 + | +LL | #[target_feature(enable = "x")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[target_feature]` can only be applied to functions + +warning: `#[deprecated]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:21:5 + | +LL | #[deprecated] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, foreign statics, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, and crates + +warning: `#[inline]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:24:5 + | +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! + = help: `#[inline]` can only be applied to functions + +warning: `#[link_name]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:27:5 + | +LL | #[link_name = "x"] + | ^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_name]` can be applied to foreign functions and foreign statics + +warning: `#[link_section]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:30:5 + | +LL | #[link_section = "x"] + | ^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_section]` can be applied to statics and functions + +warning: `#[link_ordinal]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:33:5 + | +LL | #[link_ordinal(42)] + | ^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[link_ordinal]` can be applied to foreign functions and foreign statics + +warning: `#[non_exhaustive]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:36:5 + | +LL | #[non_exhaustive] + | ^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[non_exhaustive]` can be applied to data types and enum variants + +warning: `#[proc_macro]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:39:5 + | +LL | #[proc_macro] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[proc_macro]` can only be applied to functions + +warning: `#[cold]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:42:5 + | +LL | #[cold] + | ^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[cold]` can only be applied to functions + +warning: `#[no_mangle]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:45:5 + | +LL | #[no_mangle] + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_mangle]` can be applied to functions and statics + +warning: `#[deprecated]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:48:5 + | +LL | #[deprecated] + | ^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[deprecated]` can be applied to functions, data types, modules, unions, constants, statics, macro defs, type aliases, use statements, foreign statics, struct fields, traits, associated types, associated consts, enum variants, inherent impl blocks, and crates + +warning: `#[automatically_derived]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:51:5 + | +LL | #[automatically_derived] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[automatically_derived]` can only be applied to trait impl blocks + +warning: `#[macro_use]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:54:5 + | +LL | #[macro_use] + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[macro_use]` can be applied to modules, extern crates, and crates + +warning: `#[must_use]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:57:5 + | +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! + = help: `#[must_use]` can be applied to functions, data types, unions, and traits + +warning: `#[no_implicit_prelude]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:60:5 + | +LL | #[no_implicit_prelude] + | ^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[no_implicit_prelude]` can be applied to modules and crates + +warning: `#[path]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:63:5 + | +LL | #[path = ""] + | ^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[path]` can only be applied to modules + +warning: `#[ignore]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:66:5 + | +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! + = help: `#[ignore]` can only be applied to functions + +warning: `#[should_panic]` attribute cannot be used on macro calls + --> $DIR/attr-on-mac-call.rs:69:5 + | +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! + = help: `#[should_panic]` can only be applied to functions + +warning: 22 warnings emitted + diff --git a/tests/ui/attributes/auxiliary/used_pre_main_constructor.rs b/tests/ui/attributes/auxiliary/used_pre_main_constructor.rs index 8ea7a9cb4b5..f93a2aae5a1 100644 --- a/tests/ui/attributes/auxiliary/used_pre_main_constructor.rs +++ b/tests/ui/attributes/auxiliary/used_pre_main_constructor.rs @@ -20,6 +20,7 @@ target_os = "nto", target_os = "openbsd", target_os = "fuchsia", + target_os = "managarm", ), link_section = ".init_array" )] diff --git a/tests/ui/attributes/crate-only-as-outer.rs b/tests/ui/attributes/crate-only-as-outer.rs new file mode 100644 index 00000000000..5a7d916c90d --- /dev/null +++ b/tests/ui/attributes/crate-only-as-outer.rs @@ -0,0 +1,10 @@ +#![deny(unused)] +#[crate_name = "owo"] +//~^ ERROR: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` + +fn main() {} + +mod inner { + #![crate_name = "iwi"] + //~^ ERROR: the `#![crate_name]` attribute can only be used at the crate root +} diff --git a/tests/ui/attributes/crate-only-as-outer.stderr b/tests/ui/attributes/crate-only-as-outer.stderr new file mode 100644 index 00000000000..270f02af987 --- /dev/null +++ b/tests/ui/attributes/crate-only-as-outer.stderr @@ -0,0 +1,26 @@ +error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` + --> $DIR/crate-only-as-outer.rs:2:1 + | +LL | #[crate_name = "owo"] + | ^^^^^^^^^^^^^^^^^^^^^ + | +note: This attribute does not have an `!`, which means it is applied to this function + --> $DIR/crate-only-as-outer.rs:5:1 + | +LL | fn main() {} + | ^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/crate-only-as-outer.rs:1:9 + | +LL | #![deny(unused)] + | ^^^^^^ + = note: `#[deny(unused_attributes)]` implied by `#[deny(unused)]` + +error: the `#![crate_name]` attribute can only be used at the crate root + --> $DIR/crate-only-as-outer.rs:8:5 + | +LL | #![crate_name = "iwi"] + | ^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/attributes/malformed-attrs.rs b/tests/ui/attributes/malformed-attrs.rs index 90ca007451e..932aaf7a9e2 100644 --- a/tests/ui/attributes/malformed-attrs.rs +++ b/tests/ui/attributes/malformed-attrs.rs @@ -81,8 +81,7 @@ #[export_stable = 1] //~^ ERROR malformed #[link] -//~^ ERROR valid forms for the attribute are -//~| WARN this was previously accepted by the compiler +//~^ ERROR malformed #[link_name] //~^ ERROR malformed #[link_section] diff --git a/tests/ui/attributes/malformed-attrs.stderr b/tests/ui/attributes/malformed-attrs.stderr index 69f9a18c179..b85864b401e 100644 --- a/tests/ui/attributes/malformed-attrs.stderr +++ b/tests/ui/attributes/malformed-attrs.stderr @@ -1,5 +1,5 @@ error[E0539]: malformed `cfg` attribute input - --> $DIR/malformed-attrs.rs:102:1 + --> $DIR/malformed-attrs.rs:101:1 | LL | #[cfg] | ^^^^^^ @@ -10,7 +10,7 @@ LL | #[cfg] = note: for more information, visit <https://doc.rust-lang.org/reference/conditional-compilation.html#the-cfg-attribute> error: malformed `cfg_attr` attribute input - --> $DIR/malformed-attrs.rs:104:1 + --> $DIR/malformed-attrs.rs:103:1 | LL | #[cfg_attr] | ^^^^^^^^^^^ @@ -22,7 +22,7 @@ LL | #[cfg_attr(condition, attribute, other_attribute, ...)] | ++++++++++++++++++++++++++++++++++++++++++++ error[E0463]: can't find crate for `wloop` - --> $DIR/malformed-attrs.rs:211:1 + --> $DIR/malformed-attrs.rs:210:1 | LL | extern crate wloop; | ^^^^^^^^^^^^^^^^^^^ can't find crate @@ -42,7 +42,7 @@ LL | #![windows_subsystem = "windows"] | +++++++++++ error: malformed `instruction_set` attribute input - --> $DIR/malformed-attrs.rs:106:1 + --> $DIR/malformed-attrs.rs:105:1 | LL | #[instruction_set] | ^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[instruction_set(set)]` @@ -50,13 +50,13 @@ LL | #[instruction_set] = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/codegen.html#the-instruction_set-attribute> error: malformed `patchable_function_entry` attribute input - --> $DIR/malformed-attrs.rs:108:1 + --> $DIR/malformed-attrs.rs:107:1 | LL | #[patchable_function_entry] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[patchable_function_entry(prefix_nops = m, entry_nops = n)]` error: malformed `must_not_suspend` attribute input - --> $DIR/malformed-attrs.rs:132:1 + --> $DIR/malformed-attrs.rs:131:1 | LL | #[must_not_suspend()] | ^^^^^^^^^^^^^^^^^^^^^ @@ -71,13 +71,13 @@ LL + #[must_not_suspend] | error: malformed `cfi_encoding` attribute input - --> $DIR/malformed-attrs.rs:134:1 + --> $DIR/malformed-attrs.rs:133:1 | LL | #[cfi_encoding] | ^^^^^^^^^^^^^^^ help: must be of the form: `#[cfi_encoding = "encoding"]` error: malformed `allow` attribute input - --> $DIR/malformed-attrs.rs:178:1 + --> $DIR/malformed-attrs.rs:177:1 | LL | #[allow] | ^^^^^^^^ @@ -93,7 +93,7 @@ LL | #[allow(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `expect` attribute input - --> $DIR/malformed-attrs.rs:180:1 + --> $DIR/malformed-attrs.rs:179:1 | LL | #[expect] | ^^^^^^^^^ @@ -109,7 +109,7 @@ LL | #[expect(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `warn` attribute input - --> $DIR/malformed-attrs.rs:182:1 + --> $DIR/malformed-attrs.rs:181:1 | LL | #[warn] | ^^^^^^^ @@ -125,7 +125,7 @@ LL | #[warn(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `deny` attribute input - --> $DIR/malformed-attrs.rs:184:1 + --> $DIR/malformed-attrs.rs:183:1 | LL | #[deny] | ^^^^^^^ @@ -141,7 +141,7 @@ LL | #[deny(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `forbid` attribute input - --> $DIR/malformed-attrs.rs:186:1 + --> $DIR/malformed-attrs.rs:185:1 | LL | #[forbid] | ^^^^^^^^^ @@ -157,7 +157,7 @@ LL | #[forbid(lint1, lint2, lint3, reason = "...")] | +++++++++++++++++++++++++++++++++++++ error: malformed `debugger_visualizer` attribute input - --> $DIR/malformed-attrs.rs:188:1 + --> $DIR/malformed-attrs.rs:187:1 | LL | #[debugger_visualizer] | ^^^^^^^^^^^^^^^^^^^^^^ help: must be of the form: `#[debugger_visualizer(natvis_file = "...", gdb_script_file = "...")]` @@ -165,13 +165,13 @@ LL | #[debugger_visualizer] = note: for more information, visit <https://doc.rust-lang.org/reference/attributes/debugger.html#the-debugger_visualizer-attribute> error: malformed `thread_local` attribute input - --> $DIR/malformed-attrs.rs:203:1 + --> $DIR/malformed-attrs.rs:202:1 | LL | #[thread_local()] | ^^^^^^^^^^^^^^^^^ help: must be of the form: `#[thread_local]` error: malformed `no_link` attribute input - --> $DIR/malformed-attrs.rs:207:1 + --> $DIR/malformed-attrs.rs:206:1 | LL | #[no_link()] | ^^^^^^^^^^^^ help: must be of the form: `#[no_link]` @@ -179,7 +179,7 @@ LL | #[no_link()] = note: for more information, visit <https://doc.rust-lang.org/reference/items/extern-crates.html#the-no_link-attribute> error: malformed `macro_export` attribute input - --> $DIR/malformed-attrs.rs:214:1 + --> $DIR/malformed-attrs.rs:213:1 | LL | #[macro_export = 18] | ^^^^^^^^^^^^^^^^^^^^ @@ -195,25 +195,25 @@ LL + #[macro_export] | error: the `#[proc_macro]` attribute is only usable with crates of the `proc-macro` crate type - --> $DIR/malformed-attrs.rs:99:1 + --> $DIR/malformed-attrs.rs:98: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 + --> $DIR/malformed-attrs.rs:115: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 + --> $DIR/malformed-attrs.rs:122:1 | LL | #[proc_macro_derive] | ^^^^^^^^^^^^^^^^^^^^ error[E0658]: allow_internal_unsafe side-steps the unsafe_code lint - --> $DIR/malformed-attrs.rs:216:1 + --> $DIR/malformed-attrs.rs:215:1 | LL | #[allow_internal_unsafe = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -242,18 +242,8 @@ LL | #[doc] = note: for more information, see issue #57571 <https://github.com/rust-lang/rust/issues/57571> = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html> -error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", 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> - = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> - error: invalid argument - --> $DIR/malformed-attrs.rs:188:1 + --> $DIR/malformed-attrs.rs:187:1 | LL | #[debugger_visualizer] | ^^^^^^^^^^^^^^^^^^^^^^ @@ -494,8 +484,27 @@ LL | #[export_stable = 1] | | didn't expect any arguments here | help: must be of the form: `#[export_stable]` +error[E0539]: malformed `link` attribute input + --> $DIR/malformed-attrs.rs:83:1 + | +LL | #[link] + | ^^^^^^^ expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL | #[link(name = "...")] + | ++++++++++++++ +LL | #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +LL | #[link(name = "...", kind = "dylib|static|...")] + | +++++++++++++++++++++++++++++++++++++++++ +LL | #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + = and 1 other candidate + error[E0539]: malformed `link_name` attribute input - --> $DIR/malformed-attrs.rs:86:1 + --> $DIR/malformed-attrs.rs:85:1 | LL | #[link_name] | ^^^^^^^^^^^^ help: must be of the form: `#[link_name = "name"]` @@ -503,7 +512,7 @@ LL | #[link_name] = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_name-attribute> error[E0539]: malformed `link_section` attribute input - --> $DIR/malformed-attrs.rs:88:1 + --> $DIR/malformed-attrs.rs:87:1 | LL | #[link_section] | ^^^^^^^^^^^^^^^ help: must be of the form: `#[link_section = "name"]` @@ -511,7 +520,7 @@ LL | #[link_section] = note: for more information, visit <https://doc.rust-lang.org/reference/abi.html#the-link_section-attribute> error[E0539]: malformed `coverage` attribute input - --> $DIR/malformed-attrs.rs:90:1 + --> $DIR/malformed-attrs.rs:89:1 | LL | #[coverage] | ^^^^^^^^^^^ this attribute is only valid with either `on` or `off` as an argument @@ -524,7 +533,7 @@ LL | #[coverage(on)] | ++++ error[E0539]: malformed `sanitize` attribute input - --> $DIR/malformed-attrs.rs:92:1 + --> $DIR/malformed-attrs.rs:91:1 | LL | #[sanitize] | ^^^^^^^^^^^ expected this to be a list @@ -542,7 +551,7 @@ LL | #[sanitize(kcfi = "on|off")] = and 5 other candidates error[E0565]: malformed `no_implicit_prelude` attribute input - --> $DIR/malformed-attrs.rs:97:1 + --> $DIR/malformed-attrs.rs:96:1 | LL | #[no_implicit_prelude = 23] | ^^^^^^^^^^^^^^^^^^^^^^----^ @@ -551,7 +560,7 @@ LL | #[no_implicit_prelude = 23] | help: must be of the form: `#[no_implicit_prelude]` error[E0565]: malformed `proc_macro` attribute input - --> $DIR/malformed-attrs.rs:99:1 + --> $DIR/malformed-attrs.rs:98:1 | LL | #[proc_macro = 18] | ^^^^^^^^^^^^^----^ @@ -560,7 +569,7 @@ LL | #[proc_macro = 18] | help: must be of the form: `#[proc_macro]` error[E0565]: malformed `coroutine` attribute input - --> $DIR/malformed-attrs.rs:111:5 + --> $DIR/malformed-attrs.rs:110:5 | LL | #[coroutine = 63] || {} | ^^^^^^^^^^^^----^ @@ -569,7 +578,7 @@ LL | #[coroutine = 63] || {} | help: must be of the form: `#[coroutine]` error[E0565]: malformed `proc_macro_attribute` attribute input - --> $DIR/malformed-attrs.rs:116:1 + --> $DIR/malformed-attrs.rs:115:1 | LL | #[proc_macro_attribute = 19] | ^^^^^^^^^^^^^^^^^^^^^^^----^ @@ -578,7 +587,7 @@ LL | #[proc_macro_attribute = 19] | help: must be of the form: `#[proc_macro_attribute]` error[E0539]: malformed `must_use` attribute input - --> $DIR/malformed-attrs.rs:119:1 + --> $DIR/malformed-attrs.rs:118:1 | LL | #[must_use = 1] | ^^^^^^^^^^^^^-^ @@ -596,7 +605,7 @@ LL + #[must_use] | error[E0539]: malformed `proc_macro_derive` attribute input - --> $DIR/malformed-attrs.rs:123:1 + --> $DIR/malformed-attrs.rs:122:1 | LL | #[proc_macro_derive] | ^^^^^^^^^^^^^^^^^^^^ expected this to be a list @@ -610,7 +619,7 @@ LL | #[proc_macro_derive(TraitName, attributes(name1, name2, ...))] | ++++++++++++++++++++++++++++++++++++++++++ error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input - --> $DIR/malformed-attrs.rs:128:1 + --> $DIR/malformed-attrs.rs:127:1 | LL | #[rustc_layout_scalar_valid_range_start] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -619,7 +628,7 @@ LL | #[rustc_layout_scalar_valid_range_start] | 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 + --> $DIR/malformed-attrs.rs:129:1 | LL | #[rustc_layout_scalar_valid_range_end] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -628,7 +637,7 @@ LL | #[rustc_layout_scalar_valid_range_end] | help: must be of the form: `#[rustc_layout_scalar_valid_range_end(end)]` error[E0565]: malformed `marker` attribute input - --> $DIR/malformed-attrs.rs:155:1 + --> $DIR/malformed-attrs.rs:154:1 | LL | #[marker = 3] | ^^^^^^^^^---^ @@ -637,7 +646,7 @@ LL | #[marker = 3] | help: must be of the form: `#[marker]` error[E0565]: malformed `fundamental` attribute input - --> $DIR/malformed-attrs.rs:157:1 + --> $DIR/malformed-attrs.rs:156:1 | LL | #[fundamental()] | ^^^^^^^^^^^^^--^ @@ -646,7 +655,7 @@ LL | #[fundamental()] | help: must be of the form: `#[fundamental]` error[E0565]: malformed `ffi_pure` attribute input - --> $DIR/malformed-attrs.rs:165:5 + --> $DIR/malformed-attrs.rs:164:5 | LL | #[unsafe(ffi_pure = 1)] | ^^^^^^^^^^^^^^^^^^---^^ @@ -655,7 +664,7 @@ LL | #[unsafe(ffi_pure = 1)] | help: must be of the form: `#[ffi_pure]` error[E0539]: malformed `link_ordinal` attribute input - --> $DIR/malformed-attrs.rs:167:5 + --> $DIR/malformed-attrs.rs:166:5 | LL | #[link_ordinal] | ^^^^^^^^^^^^^^^ @@ -666,7 +675,7 @@ LL | #[link_ordinal] = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link_ordinal-attribute> error[E0565]: malformed `ffi_const` attribute input - --> $DIR/malformed-attrs.rs:171:5 + --> $DIR/malformed-attrs.rs:170:5 | LL | #[unsafe(ffi_const = 1)] | ^^^^^^^^^^^^^^^^^^^---^^ @@ -675,7 +684,7 @@ LL | #[unsafe(ffi_const = 1)] | help: must be of the form: `#[ffi_const]` error[E0539]: malformed `linkage` attribute input - --> $DIR/malformed-attrs.rs:173:5 + --> $DIR/malformed-attrs.rs:172:5 | LL | #[linkage] | ^^^^^^^^^^ expected this to be of the form `linkage = "..."` @@ -693,7 +702,7 @@ LL | #[linkage = "external"] = and 5 other candidates error[E0565]: malformed `automatically_derived` attribute input - --> $DIR/malformed-attrs.rs:191:1 + --> $DIR/malformed-attrs.rs:190:1 | LL | #[automatically_derived = 18] | ^^^^^^^^^^^^^^^^^^^^^^^^----^ @@ -702,7 +711,7 @@ LL | #[automatically_derived = 18] | help: must be of the form: `#[automatically_derived]` error[E0565]: malformed `non_exhaustive` attribute input - --> $DIR/malformed-attrs.rs:197:1 + --> $DIR/malformed-attrs.rs:196:1 | LL | #[non_exhaustive = 1] | ^^^^^^^^^^^^^^^^^---^ @@ -711,13 +720,13 @@ LL | #[non_exhaustive = 1] | help: must be of the form: `#[non_exhaustive]` error: valid forms for the attribute are `#[macro_use(name1, name2, ...)]` and `#[macro_use]` - --> $DIR/malformed-attrs.rs:209:1 + --> $DIR/malformed-attrs.rs:208:1 | LL | #[macro_use = 1] | ^^^^^^^^^^^^^^^^ error[E0565]: malformed `allow_internal_unsafe` attribute input - --> $DIR/malformed-attrs.rs:216:1 + --> $DIR/malformed-attrs.rs:215:1 | LL | #[allow_internal_unsafe = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^---^ @@ -726,7 +735,7 @@ LL | #[allow_internal_unsafe = 1] | help: must be of the form: `#[allow_internal_unsafe]` error[E0565]: malformed `type_const` attribute input - --> $DIR/malformed-attrs.rs:143:5 + --> $DIR/malformed-attrs.rs:142:5 | LL | #[type_const = 1] | ^^^^^^^^^^^^^---^ @@ -759,7 +768,7 @@ LL | #[repr] | ^^^^^^^ warning: `#[diagnostic::do_not_recommend]` does not expect any arguments - --> $DIR/malformed-attrs.rs:149:1 + --> $DIR/malformed-attrs.rs:148:1 | LL | #[diagnostic::do_not_recommend()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -767,7 +776,7 @@ LL | #[diagnostic::do_not_recommend()] = note: `#[warn(malformed_diagnostic_attributes)]` (part of `#[warn(unknown_or_malformed_diagnostic_attributes)]`) on by default warning: missing options for `on_unimplemented` attribute - --> $DIR/malformed-attrs.rs:138:1 + --> $DIR/malformed-attrs.rs:137:1 | LL | #[diagnostic::on_unimplemented] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -775,7 +784,7 @@ 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 + --> $DIR/malformed-attrs.rs:139:1 | LL | #[diagnostic::on_unimplemented = 1] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ invalid option found here @@ -792,7 +801,7 @@ LL | #[inline = 5] = 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 + --> $DIR/malformed-attrs.rs:93:1 | LL | #[ignore()] | ^^^^^^^^^^^ @@ -801,7 +810,7 @@ LL | #[ignore()] = 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 + --> $DIR/malformed-attrs.rs:222:1 | LL | #[ignore = 1] | ^^^^^^^^^^^^^ @@ -810,7 +819,7 @@ LL | #[ignore = 1] = 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 + --> $DIR/malformed-attrs.rs:110:23 | LL | fn test() { | - help: a return type might be missing here: `-> _` @@ -818,7 +827,7 @@ LL | #[coroutine = 63] || {} | ^^^^^ expected `()`, found coroutine | = note: expected unit type `()` - found coroutine `{coroutine@$DIR/malformed-attrs.rs:111:23: 111:25}` + found coroutine `{coroutine@$DIR/malformed-attrs.rs:110:23: 110:25}` error: aborting due to 77 previous errors; 3 warnings emitted @@ -849,18 +858,6 @@ LL | #[doc] = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default Future breakage diagnostic: -error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", 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> - = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> - = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default - -Future breakage diagnostic: error: valid forms for the attribute are `#[inline(always)]`, `#[inline(never)]`, and `#[inline]` --> $DIR/malformed-attrs.rs:52:1 | @@ -873,7 +870,7 @@ LL | #[inline = 5] Future breakage diagnostic: error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` - --> $DIR/malformed-attrs.rs:94:1 + --> $DIR/malformed-attrs.rs:93:1 | LL | #[ignore()] | ^^^^^^^^^^^ @@ -884,7 +881,7 @@ LL | #[ignore()] Future breakage diagnostic: error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` - --> $DIR/malformed-attrs.rs:223:1 + --> $DIR/malformed-attrs.rs:222:1 | LL | #[ignore = 1] | ^^^^^^^^^^^^^ diff --git a/tests/ui/attributes/malformed-never-type-options.rs b/tests/ui/attributes/malformed-never-type-options.rs new file mode 100644 index 00000000000..0c384be0e22 --- /dev/null +++ b/tests/ui/attributes/malformed-never-type-options.rs @@ -0,0 +1,8 @@ +//! Regression test for #124352 +//! The `rustc_*` attribute is malformed, but ICEing without a `feature(rustc_attrs)` is still bad. + +#![rustc_never_type_options(: Unsize<U> = "hi")] +//~^ ERROR expected unsuffixed literal, found `:` +//~| ERROR use of an internal attribute + +fn main() {} diff --git a/tests/ui/attributes/malformed-never-type-options.stderr b/tests/ui/attributes/malformed-never-type-options.stderr new file mode 100644 index 00000000000..0d2ff4881f2 --- /dev/null +++ b/tests/ui/attributes/malformed-never-type-options.stderr @@ -0,0 +1,19 @@ +error: expected unsuffixed literal, found `:` + --> $DIR/malformed-never-type-options.rs:4:29 + | +LL | #![rustc_never_type_options(: Unsize<U> = "hi")] + | ^ + +error[E0658]: use of an internal attribute + --> $DIR/malformed-never-type-options.rs:4:1 + | +LL | #![rustc_never_type_options(: Unsize<U> = "hi")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = help: add `#![feature(rustc_attrs)]` to the crate attributes to enable + = note: the `#[rustc_never_type_options]` attribute is an internal implementation detail that will never be stable + = note: `rustc_never_type_options` is used to experiment with never type fallback and work on never type stabilization + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/pattern/match-with-at-binding-8391.rs b/tests/ui/binding/match-with-at-binding-8391.rs index bc4e7be7989..bc4e7be7989 100644 --- a/tests/ui/pattern/match-with-at-binding-8391.rs +++ b/tests/ui/binding/match-with-at-binding-8391.rs diff --git a/tests/ui/issues/issue-7092.rs b/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.rs index fab18bd7cf7..4cb04cdf5be 100644 --- a/tests/ui/issues/issue-7092.rs +++ b/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7092 enum Whatever { } diff --git a/tests/ui/issues/issue-7092.stderr b/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.stderr index e2e57486746..1f8ff2d8df1 100644 --- a/tests/ui/issues/issue-7092.stderr +++ b/tests/ui/binding/method-call-nonsensical-pattern-binding-7092.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-7092.rs:6:9 + --> $DIR/method-call-nonsensical-pattern-binding-7092.rs:7:9 | LL | match x { | - this expression has type `Whatever` diff --git a/tests/ui/pattern/ref-in-function-parameter-patterns-8860.rs b/tests/ui/binding/ref-pattern-drop-behavior-8860.rs index 1a67caf021c..1a67caf021c 100644 --- a/tests/ui/pattern/ref-in-function-parameter-patterns-8860.rs +++ b/tests/ui/binding/ref-pattern-drop-behavior-8860.rs diff --git a/tests/ui/issues/issue-6738.rs b/tests/ui/binop/struct-field-generic-type-binary-assignment-error-6738.rs index a2f8dfe9c49..856caa2b297 100644 --- a/tests/ui/issues/issue-6738.rs +++ b/tests/ui/binop/struct-field-generic-type-binary-assignment-error-6738.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/6738 struct Foo<T> { x: T, } diff --git a/tests/ui/issues/issue-6738.stderr b/tests/ui/binop/struct-field-generic-type-binary-assignment-error-6738.stderr index f22d6a2e468..060d33079d3 100644 --- a/tests/ui/issues/issue-6738.stderr +++ b/tests/ui/binop/struct-field-generic-type-binary-assignment-error-6738.stderr @@ -1,5 +1,5 @@ error[E0368]: binary assignment operation `+=` cannot be applied to type `T` - --> $DIR/issue-6738.rs:6:9 + --> $DIR/struct-field-generic-type-binary-assignment-error-6738.rs:7:9 | LL | self.x += v.x; | ------^^^^^^^ diff --git a/tests/ui/issues/auxiliary/issue-5518.rs b/tests/ui/borrowck/auxiliary/aux-5518.rs index bfe96552a5c..bfe96552a5c 100644 --- a/tests/ui/issues/auxiliary/issue-5518.rs +++ b/tests/ui/borrowck/auxiliary/aux-5518.rs diff --git a/tests/ui/issues/issue-5884.rs b/tests/ui/borrowck/borrowed-pointer-in-struct-5884.rs index 559b897395d..d2f17cf905d 100644 --- a/tests/ui/issues/issue-5884.rs +++ b/tests/ui/borrowck/borrowed-pointer-in-struct-5884.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5884 //@ build-pass #![allow(dead_code)] diff --git a/tests/ui/issues/issue-5550.rs b/tests/ui/borrowck/incorrect-loan-error-on-local-update-5550.rs index 41de8ee5d32..2258d768657 100644 --- a/tests/ui/issues/issue-5550.rs +++ b/tests/ui/borrowck/incorrect-loan-error-on-local-update-5550.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5550 //@ run-pass #![allow(unused_assignments)] diff --git a/tests/ui/issues/issue-5708.rs b/tests/ui/borrowck/struct-with-reference-to-trait-5708.rs index 6fa3cfa4724..5157a3bf36b 100644 --- a/tests/ui/issues/issue-5708.rs +++ b/tests/ui/borrowck/struct-with-reference-to-trait-5708.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5708 //@ run-pass #![allow(unused_variables)] /* @@ -10,7 +11,6 @@ This does not occur with concrete types, only with references to traits. */ - // original trait Inner { fn print(&self); @@ -38,7 +38,6 @@ pub fn main() { outer.inner.print(); } - // minimal pub trait MyTrait<T> { fn dummy(&self, t: T) -> T { panic!() } diff --git a/tests/ui/borrowck/trait-method-lifetime-substitution-5518.rs b/tests/ui/borrowck/trait-method-lifetime-substitution-5518.rs new file mode 100644 index 00000000000..f254030a011 --- /dev/null +++ b/tests/ui/borrowck/trait-method-lifetime-substitution-5518.rs @@ -0,0 +1,7 @@ +// https://github.com/rust-lang/rust/issues/5518 +//@ run-pass +//@ aux-build:aux-5518.rs + +extern crate aux_5518 as other; + +fn main() {} diff --git a/tests/ui/issues/issue-6557.rs b/tests/ui/box/box-patterns-feature-usage-6557.rs index 64a025a294f..e0d9b25c366 100644 --- a/tests/ui/issues/issue-6557.rs +++ b/tests/ui/box/box-patterns-feature-usage-6557.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/6557 //@ check-pass #![allow(dead_code)] diff --git a/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs b/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs deleted file mode 100644 index 1e0576b2186..00000000000 --- a/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.rs +++ /dev/null @@ -1,16 +0,0 @@ -//@ only-x86_64 - -fn efiapi(f: extern "efiapi" fn(usize, ...)) { - //~^ ERROR: unstable - f(22, 44); -} -fn sysv(f: extern "sysv64" fn(usize, ...)) { - //~^ ERROR: unstable - f(22, 44); -} -fn win(f: extern "win64" fn(usize, ...)) { - //~^ ERROR: unstable - f(22, 44); -} - -fn main() {} diff --git a/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr b/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr deleted file mode 100644 index 7ef54b639ad..00000000000 --- a/tests/ui/c-variadic/feature-gate-extended_varargs_abi_support.stderr +++ /dev/null @@ -1,33 +0,0 @@ -error[E0658]: C-variadic functions with the "efiapi" calling convention are unstable - --> $DIR/feature-gate-extended_varargs_abi_support.rs:3:14 - | -LL | fn efiapi(f: extern "efiapi" fn(usize, ...)) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #100189 <https://github.com/rust-lang/rust/issues/100189> for more information - = help: add `#![feature(extended_varargs_abi_support)]` 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]: C-variadic functions with the "sysv64" calling convention are unstable - --> $DIR/feature-gate-extended_varargs_abi_support.rs:7:12 - | -LL | fn sysv(f: extern "sysv64" fn(usize, ...)) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #100189 <https://github.com/rust-lang/rust/issues/100189> for more information - = help: add `#![feature(extended_varargs_abi_support)]` 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]: C-variadic functions with the "win64" calling convention are unstable - --> $DIR/feature-gate-extended_varargs_abi_support.rs:11:11 - | -LL | fn win(f: extern "win64" fn(usize, ...)) { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #100189 <https://github.com/rust-lang/rust/issues/100189> for more information - = help: add `#![feature(extended_varargs_abi_support)]` 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/c-variadic/issue-86053-1.rs b/tests/ui/c-variadic/issue-86053-1.rs index 8eeb99a4cc1..537d0263adf 100644 --- a/tests/ui/c-variadic/issue-86053-1.rs +++ b/tests/ui/c-variadic/issue-86053-1.rs @@ -13,6 +13,6 @@ fn ordering4 < 'a , 'b > ( a : , self , self , self , //~| ERROR unexpected `self` parameter in function //~| ERROR unexpected `self` parameter in function //~| ERROR `...` must be the last argument of a C-variadic function - //~| ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + //~| ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention //~| ERROR cannot find type `F` in this scope } diff --git a/tests/ui/c-variadic/issue-86053-1.stderr b/tests/ui/c-variadic/issue-86053-1.stderr index dc323f9a234..675dfd335c4 100644 --- a/tests/ui/c-variadic/issue-86053-1.stderr +++ b/tests/ui/c-variadic/issue-86053-1.stderr @@ -46,7 +46,7 @@ error: `...` must be the last argument of a C-variadic function LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/issue-86053-1.rs:11:12 | LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { @@ -57,10 +57,10 @@ error[E0412]: cannot find type `F` in this scope | LL | self , ... , self , self , ... ) where F : FnOnce ( & 'a & 'b usize ) { | ^ + | --> $SRC_DIR/core/src/ops/function.rs:LL:COL | = note: similarly named trait `Fn` defined here - | help: a trait with a similar name exists | LL | self , ... , self , self , ... ) where Fn : FnOnce ( & 'a & 'b usize ) { diff --git a/tests/ui/c-variadic/same-program-multiple-abis-arm.rs b/tests/ui/c-variadic/same-program-multiple-abis-arm.rs index 1b0bdecabfb..1445bbb47bb 100644 --- a/tests/ui/c-variadic/same-program-multiple-abis-arm.rs +++ b/tests/ui/c-variadic/same-program-multiple-abis-arm.rs @@ -1,4 +1,3 @@ -#![feature(extended_varargs_abi_support)] //@ run-pass //@ only-arm //@ ignore-thumb (this test uses arm assembly) diff --git a/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs b/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs index b21accb999e..aff8ab613c4 100644 --- a/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs +++ b/tests/ui/c-variadic/same-program-multiple-abis-x86_64.rs @@ -1,4 +1,3 @@ -#![feature(extended_varargs_abi_support)] //@ run-pass //@ only-x86_64 diff --git a/tests/ui/issues/issue-54094.rs b/tests/ui/cast/associated-type-bounds-cast-54094.rs index 4ca7d1d81b6..c9f307e95b9 100644 --- a/tests/ui/issues/issue-54094.rs +++ b/tests/ui/cast/associated-type-bounds-cast-54094.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/54094 //@ check-pass trait Zoo { type X; diff --git a/tests/ui/issues/issue-6318.rs b/tests/ui/cast/owned-struct-to-trait-cast-6318.rs index d3f08285a93..8cfc77c4274 100644 --- a/tests/ui/issues/issue-6318.rs +++ b/tests/ui/cast/owned-struct-to-trait-cast-6318.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/6318 //@ run-pass pub enum Thing { diff --git a/tests/ui/check-cfg/cfg-crate-features.stderr b/tests/ui/check-cfg/cfg-crate-features.stderr index d69a24f3f64..6b2e628e12e 100644 --- a/tests/ui/check-cfg/cfg-crate-features.stderr +++ b/tests/ui/check-cfg/cfg-crate-features.stderr @@ -24,7 +24,7 @@ warning: unexpected `cfg` condition value: `does_not_exist` LL | #![cfg(not(target(os = "does_not_exist")))] | ^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, and `uefi` and 10 more + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, and `tvos` and 11 more = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration = note: `#[warn(unexpected_cfgs)]` on by default diff --git a/tests/ui/check-cfg/my-awesome-platform.json b/tests/ui/check-cfg/my-awesome-platform.json index 4c16d06c7b7..3a1f6b1a54c 100644 --- a/tests/ui/check-cfg/my-awesome-platform.json +++ b/tests/ui/check-cfg/my-awesome-platform.json @@ -3,7 +3,7 @@ "data-layout": "e-m:e-p270:32:32-p271:32:32-p272:64:64-i64:64-i128:128-f80:128-n8:16:32:64-S128", "arch": "x86_64", "target-endian": "little", - "target-pointer-width": "64", + "target-pointer-width": 64, "os": "ericos", "linker-flavor": "ld.lld", "linker": "rust-lld", diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index f6448147392..258f2132466 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -243,6 +243,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `relax` `relaxed-simd` `rtm` +`rva23u64` `sb` `scq` `sha` @@ -304,6 +305,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `ssve-fp8dot2` `ssve-fp8dot4` `ssve-fp8fma` +`supm` `sve` `sve-b16b16` `sve2` diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index 18e038a442e..6490fc63fd7 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -156,7 +156,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_env = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_env` are: ``, `gnu`, `macabi`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `nto80`, `ohos`, `p1`, `p2`, `relibc`, `sgx`, `sim`, `uclibc`, and `v5` + = note: expected values for `target_env` are: ``, `gnu`, `macabi`, `mlibc`, `msvc`, `musl`, `newlib`, `nto70`, `nto71`, `nto71_iosock`, `nto80`, `ohos`, `p1`, `p2`, `relibc`, `sgx`, `sim`, `uclibc`, and `v5` = 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` @@ -201,7 +201,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_os = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` = 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` @@ -274,7 +274,7 @@ LL | #[cfg(target_os = "linuz")] // testing that we suggest `linux` | | | help: there is a expected value with a similar name: `"linux"` | - = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `cygwin`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `lynxos178`, `macos`, `managarm`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `vexos`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: 28 warnings emitted diff --git a/tests/ui/issues/issue-6153.rs b/tests/ui/closures/closure-mut-argument-6153.rs index cd78c85d94b..ac19c2bd15f 100644 --- a/tests/ui/issues/issue-6153.rs +++ b/tests/ui/closures/closure-mut-argument-6153.rs @@ -1,6 +1,6 @@ +// https://github.com/rust-lang/rust/issues/6153 //@ run-pass - fn swap<F>(f: F) -> Vec<isize> where F: FnOnce(Vec<isize>) -> Vec<isize> { let x = vec![1, 2, 3]; f(x) diff --git a/tests/ui/closures/issue-78720.stderr b/tests/ui/closures/issue-78720.stderr index 3e95fab441a..987625d22c9 100644 --- a/tests/ui/closures/issue-78720.stderr +++ b/tests/ui/closures/issue-78720.stderr @@ -9,10 +9,10 @@ error[E0412]: cannot find type `F` in this scope | LL | _func: F, | ^ + | --> $SRC_DIR/core/src/ops/function.rs:LL:COL | = note: similarly named trait `Fn` defined here - | help: a trait with a similar name exists | LL | _func: Fn, diff --git a/tests/ui/closures/issue-90871.stderr b/tests/ui/closures/issue-90871.stderr index ef1cb213f73..12020226680 100644 --- a/tests/ui/closures/issue-90871.stderr +++ b/tests/ui/closures/issue-90871.stderr @@ -3,6 +3,7 @@ error[E0412]: cannot find type `n` in this scope | LL | type_ascribe!(2, n([u8; || 1])) | ^ help: a trait with a similar name exists: `Fn` + | --> $SRC_DIR/core/src/ops/function.rs:LL:COL | = note: similarly named trait `Fn` defined here diff --git a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs index 800dd580af2..ad4fca8252d 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.rs @@ -71,6 +71,6 @@ extern "cmse-nonsecure-entry" fn wrapped_trait_object( } 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 defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention //~| 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 f0190671b5a..7aeb6969feb 100644 --- a/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr +++ b/tests/ui/cmse-nonsecure/cmse-nonsecure-entry/generics.stderr @@ -1,4 +1,4 @@ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/generics.rs:73:53 | LL | extern "cmse-nonsecure-entry" fn c_variadic(_: u32, _: ...) { diff --git a/tests/ui/codegen/empty-static-libs-issue-108825.rs b/tests/ui/codegen/empty-static-libs-issue-108825.rs index 4c644be0954..4f8e4420f72 100644 --- a/tests/ui/codegen/empty-static-libs-issue-108825.rs +++ b/tests/ui/codegen/empty-static-libs-issue-108825.rs @@ -15,4 +15,4 @@ fn panic(_info: &core::panic::PanicInfo) -> ! { } //~? NOTE native-static-libs: -//~? NOTE Link against the following native artifacts when linking against this static library +//~? NOTE link against the following native artifacts when linking against this static library diff --git a/tests/ui/codegen/indirect-nocapture.rs b/tests/ui/codegen/indirect-nocapture.rs new file mode 100644 index 00000000000..78024a94c0d --- /dev/null +++ b/tests/ui/codegen/indirect-nocapture.rs @@ -0,0 +1,15 @@ +// Regression test for issue #137668 where an indirect argument have been marked as nocapture +// despite the fact that callee did in fact capture the address. +// +//@ run-pass +//@ compile-flags: -Copt-level=2 + +#[inline(never)] +pub fn f(a: [u32; 64], b: [u32; 64]) -> bool { + &a as *const _ as usize != &b as *const _ as usize +} + +fn main() { + static S: [u32; 64] = [0; 64]; + assert!(f(S, S)); +} diff --git a/tests/ui/issues/issue-54462-mutable-noalias-correctness.rs b/tests/ui/codegen/matrix-row-swap-54462.rs index 70d0bee7332..6bfc600399a 100644 --- a/tests/ui/issues/issue-54462-mutable-noalias-correctness.rs +++ b/tests/ui/codegen/matrix-row-swap-54462.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/54462 //@ run-pass // //@ compile-flags: -Ccodegen-units=1 -O diff --git a/tests/ui/codegen/mismatched-data-layout.json b/tests/ui/codegen/mismatched-data-layout.json index f8c510c1863..a1b222010ab 100644 --- a/tests/ui/codegen/mismatched-data-layout.json +++ b/tests/ui/codegen/mismatched-data-layout.json @@ -3,7 +3,7 @@ "data-layout": "e-m:e-i64:64-f80:128-n8:16:32:64-S128", "arch": "x86_64", "target-endian": "little", - "target-pointer-width": "64", + "target-pointer-width": 64, "os": "none", "linker-flavor": "ld.lld", "linker": "rust-lld", diff --git a/tests/ui/issues/issue-7012.rs b/tests/ui/codegen/static-array-comparison-7012.rs index 69b881e2a43..c08b1c0059b 100644 --- a/tests/ui/issues/issue-7012.rs +++ b/tests/ui/codegen/static-array-comparison-7012.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7012 //@ run-pass #![allow(non_camel_case_types)] #![allow(non_upper_case_globals)] diff --git a/tests/ui/coercion/mut-trait-coercion-8248.rs b/tests/ui/coercion/coerce-mut-trait-object-8248.rs index a45a4d94315..a45a4d94315 100644 --- a/tests/ui/coercion/mut-trait-coercion-8248.rs +++ b/tests/ui/coercion/coerce-mut-trait-object-8248.rs diff --git a/tests/ui/coercion/mut-trait-coercion-8248.stderr b/tests/ui/coercion/coerce-mut-trait-object-8248.stderr index 0c7d5f9dc45..c3b35a7063c 100644 --- a/tests/ui/coercion/mut-trait-coercion-8248.stderr +++ b/tests/ui/coercion/coerce-mut-trait-object-8248.stderr @@ -1,5 +1,5 @@ warning: method `dummy` is never used - --> $DIR/mut-trait-coercion-8248.rs:5:8 + --> $DIR/coerce-mut-trait-object-8248.rs:5:8 | LL | trait A { | - method in this trait diff --git a/tests/ui/coercion/fake-sized-ptr-cast.rs b/tests/ui/coercion/fake-sized-ptr-cast.rs new file mode 100644 index 00000000000..4b6bf0eb516 --- /dev/null +++ b/tests/ui/coercion/fake-sized-ptr-cast.rs @@ -0,0 +1,16 @@ +// Make sure borrowck doesn't ICE because it thinks a pointer cast is a metadata-preserving +// wide-to-wide ptr cast when it's actually (falsely) a wide-to-thin ptr cast due to an +// impossible dyn sized bound. + +//@ check-pass + +trait Trait<T> {} + +fn func<'a>(x: *const (dyn Trait<()> + 'a)) +where + dyn Trait<u8> + 'a: Sized, +{ + let _x: *const dyn Trait<u8> = x as _; +} + +fn main() {} diff --git a/tests/ui/issues/issue-54477-reduced-2.rs b/tests/ui/collections/vecdeque-append-operation-54477.rs index 5f65e545182..7680fd0bb01 100644 --- a/tests/ui/issues/issue-54477-reduced-2.rs +++ b/tests/ui/collections/vecdeque-append-operation-54477.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/54477 //@ run-pass // rust-lang/rust#54477: runtime bug in the VecDeque library that was // exposed by this test case, derived from test suite of crates.io diff --git a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr index 4c8a5e46751..c05584ef909 100644 --- a/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr +++ b/tests/ui/const-generics/adt_const_params/const_param_ty_bad.stderr @@ -32,8 +32,9 @@ LL | fn check(_: impl std::marker::UnsizedConstParamTy) {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ required by this bound in `check` help: use parentheses to call this closure | -LL | check(|| {}()); - | ++ +LL - check(|| {}); +LL + check((|| {})()); + | error[E0277]: `fn()` can't be used as a const parameter type --> $DIR/const_param_ty_bad.rs:9:11 diff --git a/tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.stderr b/tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.stderr index 12de4f1dc30..cf5b55a0ce2 100644 --- a/tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.stderr +++ b/tests/ui/const-generics/failing_goal_with_repeat_expr_anon_const.stderr @@ -21,10 +21,6 @@ LL | [0u8; std::mem::size_of::<Self::A>()] == Self::P; | ^^ no implementation for `[u8; std::mem::size_of::<Self::A>()] == <Self as T>::A` | = help: the trait `PartialEq<<Self as T>::A>` is not implemented for `[u8; std::mem::size_of::<Self::A>()]` -help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement - | -LL | pub trait T where [u8; std::mem::size_of::<Self::A>()]: PartialEq<<Self as T>::A> { - | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ error: aborting due to 3 previous errors diff --git a/tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.stderr b/tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.stderr index b9db7461699..c9c8115660f 100644 --- a/tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.stderr +++ b/tests/ui/const-generics/generic_const_exprs/expected-type-of-closure-body-to-be-a-closure-or-coroutine-ice-113776.stderr @@ -3,10 +3,10 @@ error[E0412]: cannot find type `F` in this scope | LL | let f: F = async { 1 }; | ^ + | --> $SRC_DIR/core/src/ops/function.rs:LL:COL | = note: similarly named trait `Fn` defined here - | help: a trait with a similar name exists | LL | let f: Fn = async { 1 }; diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr b/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr index 0c57eddbe93..cc6a813b747 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.32bit.stderr @@ -14,7 +14,7 @@ error[E0080]: constructing invalid value: encountered 0x42, but expected a boole LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 42 │ B } @@ -25,7 +25,7 @@ error[E0080]: constructing invalid value: encountered 0x42, but expected a boole LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 42 │ B } diff --git a/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr b/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr index 0c57eddbe93..cc6a813b747 100644 --- a/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr +++ b/tests/ui/const-generics/min_const_generics/invalid-patterns.64bit.stderr @@ -14,7 +14,7 @@ error[E0080]: constructing invalid value: encountered 0x42, but expected a boole LL | get_flag::<{ unsafe { bool_raw.boolean } }, 'z'>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 42 │ B } @@ -25,7 +25,7 @@ error[E0080]: constructing invalid value: encountered 0x42, but expected a boole LL | get_flag::<{ unsafe { bool_raw.boolean } }, { unsafe { char_raw.character } }>(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 42 │ B } diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index 25d6f0461a9..70ae00af23f 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered a null reference LL | pub static S0: &[u32] = unsafe { from_raw_parts(ptr::null(), 0) }; | ^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value: encountered a null reference LL | pub static S1: &[()] = unsafe { from_raw_parts(ptr::null(), 0) }; | ^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -26,7 +26,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (goin LL | pub static S2: &[u32] = unsafe { from_raw_parts(&D0, 2) }; | ^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -37,7 +37,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitializ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; | ^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -50,7 +50,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, size | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - = 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 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 } @@ -61,7 +61,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but e LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; | ^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -72,7 +72,7 @@ error[E0080]: constructing invalid value at .<deref>[1]: encountered uninitializ LL | pub static S7: &[u16] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -83,7 +83,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (goin LL | pub static S8: &[u64] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -94,7 +94,7 @@ error[E0080]: constructing invalid value: encountered a null reference LL | pub static R0: &[u32] = unsafe { from_ptr_range(ptr::null()..ptr::null()) }; | ^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -117,7 +117,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitializ LL | pub static R4: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -130,7 +130,7 @@ LL | pub static R5: &[u8] = unsafe { | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - = 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 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 } @@ -141,7 +141,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but e LL | pub static R6: &[bool] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -152,7 +152,7 @@ error[E0080]: constructing invalid value: encountered an unaligned reference (re LL | pub static R7: &[u16] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ 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 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 } diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr index a8c7ee93971..239bca51fc9 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.32bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<deref>: encountered uninitialized LL | const BAR: &i32 = unsafe { | ^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { ╾ALLOC0<imm>╼ │ ╾──╼ } diff --git a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr index 47e1c22cc2c..3c6d66ac5b6 100644 --- a/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr +++ b/tests/ui/consts/const-eval/heap/alloc_intrinsic_uninit.64bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<deref>: encountered uninitialized LL | const BAR: &i32 = unsafe { | ^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { ╾ALLOC0<imm>╼ │ ╾──────╼ } diff --git a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr index d4039e1952c..152eeababc5 100644 --- a/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr +++ b/tests/ui/consts/const-eval/heap/dealloc_intrinsic_dangling.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (use- LL | const _X: &'static u8 = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ 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 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 } diff --git a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr index 36183e28921..2861f82ec53 100644 --- a/tests/ui/consts/const-eval/raw-bytes.32bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.32bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x00000001, LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 01 00 00 00 │ .... } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x00000000, LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 00 00 00 00 │ .... } @@ -26,7 +26,7 @@ error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabi LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 01 │ . } @@ -37,7 +37,7 @@ error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabi LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 03 │ . } @@ -48,7 +48,7 @@ error[E0080]: constructing invalid value at .<enum-variant(Some)>.0.1: encounter LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { 78 00 00 00 ff ff ff ff │ x....... } @@ -59,7 +59,7 @@ error[E0080]: constructing invalid value: encountered 0, but expected something LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 00 00 00 00 │ .... } @@ -70,7 +70,7 @@ error[E0080]: constructing invalid value at .0: encountered 0, but expected some LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 00 │ . } @@ -81,7 +81,7 @@ error[E0080]: constructing invalid value at .0: encountered 0, but expected some LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 00 00 00 00 │ .... } @@ -92,7 +92,7 @@ error[E0080]: constructing invalid value: encountered 42, but expected something LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 2a 00 00 00 │ *... } @@ -103,7 +103,7 @@ error[E0080]: constructing invalid value: encountered 20, but expected something LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 14 00 00 00 │ .... } @@ -114,7 +114,7 @@ error[E0080]: constructing invalid value: encountered 0, but expected something LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { 00 00 00 00 ╾ALLOC_ID╼ │ ....╾──╼ } @@ -125,7 +125,7 @@ error[E0080]: constructing invalid value: encountered an unaligned reference (re LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } @@ -136,7 +136,7 @@ error[E0080]: constructing invalid value: encountered an unaligned box (required LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } @@ -147,7 +147,7 @@ error[E0080]: constructing invalid value: encountered a null reference LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 00 00 00 00 │ .... } @@ -158,7 +158,7 @@ error[E0080]: constructing invalid value: encountered a null box LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 00 00 00 00 │ .... } @@ -169,7 +169,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (0x53 LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 39 05 00 00 │ 9... } @@ -180,7 +180,7 @@ error[E0080]: constructing invalid value: encountered a dangling box (0x539[noal LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 39 05 00 00 │ 9... } @@ -191,7 +191,7 @@ error[E0080]: constructing invalid value: encountered null pointer, but expected LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 00 00 00 00 │ .... } @@ -202,7 +202,7 @@ error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 0d 00 00 00 │ .... } @@ -213,7 +213,7 @@ error[E0080]: constructing invalid value: encountered ALLOC3<imm>, but expected LL | const DATA_FN_PTR: fn() = 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 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: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } @@ -224,7 +224,7 @@ error[E0080]: constructing invalid value: encountered a reference pointing to un LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 01 00 00 00 │ .... } @@ -235,7 +235,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (goin LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼.... } @@ -246,7 +246,7 @@ error[E0080]: constructing invalid value at .0: encountered invalid reference me LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ ff ff ff ff │ ╾──╼.... } @@ -257,7 +257,7 @@ error[E0080]: constructing invalid value: encountered invalid reference metadata LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ ff ff ff ff │ ╾──╼.... } @@ -268,7 +268,7 @@ error[E0080]: constructing invalid value at .<deref>: encountered uninitialized LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } @@ -279,7 +279,7 @@ error[E0080]: constructing invalid value at .<deref>.0: encountered uninitialize LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } @@ -292,7 +292,7 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _> | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - = 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 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: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } @@ -303,7 +303,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (goin LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼.... } @@ -314,7 +314,7 @@ error[E0080]: constructing invalid value: encountered invalid reference metadata LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ ff ff ff 7f │ ╾──╼.... } @@ -325,7 +325,7 @@ error[E0080]: constructing invalid value: encountered a dangling box (going beyo LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ e7 03 00 00 │ ╾──╼.... } @@ -336,7 +336,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x03, but e LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } @@ -353,7 +353,7 @@ error[E0080]: constructing invalid value at .<deref>.0: encountered 0x03, but ex LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } @@ -370,7 +370,7 @@ error[E0080]: constructing invalid value at .<deref>.1[0]: encountered 0x03, but LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { ╾ALLOC_ID╼ │ ╾──╼ } @@ -387,7 +387,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC17<imm>, but ex LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } @@ -398,7 +398,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC19<imm>, but ex LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } @@ -409,7 +409,7 @@ error[E0080]: constructing invalid value at .0: encountered 0x4[noalloc], but ex LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } @@ -420,7 +420,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC22<imm>, but ex LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } @@ -431,7 +431,7 @@ error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>: encountered LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } @@ -442,7 +442,7 @@ error[E0080]: constructing invalid value: encountered null pointer, but expected LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ 00 00 00 00 │ ╾──╼.... } @@ -453,7 +453,7 @@ error[E0080]: constructing invalid value: encountered ALLOC27<imm>, but expected LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──╼╾──╼ } @@ -464,7 +464,7 @@ error[E0080]: constructing invalid value: encountered a reference pointing to un LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 01 00 00 00 │ .... } @@ -475,7 +475,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^ 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 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: 8, align: 4) { 01 00 00 00 01 00 00 00 │ ........ } @@ -486,7 +486,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; | ^^^^^^^^^^^^^ 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 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: 8, align: 4) { 01 00 00 00 2a 00 00 00 │ ....*... } @@ -497,7 +497,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitializ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; | ^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } @@ -510,7 +510,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem: | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - = 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 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: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } @@ -521,7 +521,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but e LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; | ^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } @@ -532,7 +532,7 @@ error[E0080]: constructing invalid value at .<deref>[1]: encountered uninitializ LL | pub static S7: &[u16] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID+0x2╼ 04 00 00 00 │ ╾──╼.... } @@ -543,7 +543,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitializ LL | pub static R4: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ 01 00 00 00 │ ╾──╼.... } @@ -556,7 +556,7 @@ LL | pub static R5: &[u8] = unsafe { | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - = 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 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: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } @@ -567,7 +567,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but e LL | pub static R6: &[bool] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC_ID╼ 04 00 00 00 │ ╾──╼.... } diff --git a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr index c53326534fd..8e6dc66a40e 100644 --- a/tests/ui/consts/const-eval/raw-bytes.64bit.stderr +++ b/tests/ui/consts/const-eval/raw-bytes.64bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x000000000 LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { 01 00 00 00 00 00 00 00 │ ........ } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x000000000 LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } @@ -26,7 +26,7 @@ error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabi LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 01 │ . } @@ -37,7 +37,7 @@ error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabi LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 03 │ . } @@ -48,7 +48,7 @@ error[E0080]: constructing invalid value at .<enum-variant(Some)>.0.1: encounter LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { 78 00 00 00 ff ff ff ff │ x....... } @@ -59,7 +59,7 @@ error[E0080]: constructing invalid value: encountered 0, but expected something LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } @@ -70,7 +70,7 @@ error[E0080]: constructing invalid value at .0: encountered 0, but expected some LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 00 │ . } @@ -81,7 +81,7 @@ error[E0080]: constructing invalid value at .0: encountered 0, but expected some LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } @@ -92,7 +92,7 @@ error[E0080]: constructing invalid value: encountered 42, but expected something LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 2a 00 00 00 │ *... } @@ -103,7 +103,7 @@ error[E0080]: constructing invalid value: encountered 20, but expected something LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { 14 00 00 00 │ .... } @@ -114,7 +114,7 @@ error[E0080]: constructing invalid value: encountered 0, but expected something LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { 00 00 00 00 00 00 00 00 ╾ALLOC_ID╼ │ ........╾──────╼ } @@ -125,7 +125,7 @@ error[E0080]: constructing invalid value: encountered an unaligned reference (re LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } @@ -136,7 +136,7 @@ error[E0080]: constructing invalid value: encountered an unaligned box (required LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } @@ -147,7 +147,7 @@ error[E0080]: constructing invalid value: encountered a null reference LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } @@ -158,7 +158,7 @@ error[E0080]: constructing invalid value: encountered a null box LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } @@ -169,7 +169,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (0x53 LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { 39 05 00 00 00 00 00 00 │ 9....... } @@ -180,7 +180,7 @@ error[E0080]: constructing invalid value: encountered a dangling box (0x539[noal LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { 39 05 00 00 00 00 00 00 │ 9....... } @@ -191,7 +191,7 @@ error[E0080]: constructing invalid value: encountered null pointer, but expected LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { 00 00 00 00 00 00 00 00 │ ........ } @@ -202,7 +202,7 @@ error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { 0d 00 00 00 00 00 00 00 │ ........ } @@ -213,7 +213,7 @@ error[E0080]: constructing invalid value: encountered ALLOC3<imm>, but expected LL | const DATA_FN_PTR: fn() = 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 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: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } @@ -224,7 +224,7 @@ error[E0080]: constructing invalid value: encountered a reference pointing to un LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { 01 00 00 00 00 00 00 00 │ ........ } @@ -235,7 +235,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (goin LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } @@ -246,7 +246,7 @@ error[E0080]: constructing invalid value at .0: encountered invalid reference me LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } @@ -257,7 +257,7 @@ error[E0080]: constructing invalid value: encountered invalid reference metadata LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } @@ -268,7 +268,7 @@ error[E0080]: constructing invalid value at .<deref>: encountered uninitialized LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -279,7 +279,7 @@ error[E0080]: constructing invalid value at .<deref>.0: encountered uninitialize LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -292,7 +292,7 @@ LL | const MYSTR_NO_INIT_ISSUE83182: &MyStr = unsafe { mem::transmute::<&[_], _> | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - = 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 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: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -303,7 +303,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (goin LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } @@ -314,7 +314,7 @@ error[E0080]: constructing invalid value: encountered invalid reference metadata LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ ff ff ff ff ff ff ff 7f │ ╾──────╼........ } @@ -325,7 +325,7 @@ error[E0080]: constructing invalid value: encountered a dangling box (going beyo LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ e7 03 00 00 00 00 00 00 │ ╾──────╼........ } @@ -336,7 +336,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x03, but e LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } @@ -353,7 +353,7 @@ error[E0080]: constructing invalid value at .<deref>.0: encountered 0x03, but ex LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } @@ -370,7 +370,7 @@ error[E0080]: constructing invalid value at .<deref>.1[0]: encountered 0x03, but LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { ╾ALLOC_ID╼ │ ╾──────╼ } @@ -387,7 +387,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC17<imm>, but ex LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } @@ -398,7 +398,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC19<imm>, but ex LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } @@ -409,7 +409,7 @@ error[E0080]: constructing invalid value at .0: encountered 0x4[noalloc], but ex LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -420,7 +420,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC22<imm>, but ex LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } @@ -431,7 +431,7 @@ error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>: encountered LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } @@ -442,7 +442,7 @@ error[E0080]: constructing invalid value: encountered null pointer, but expected LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ 00 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -453,7 +453,7 @@ error[E0080]: constructing invalid value: encountered ALLOC27<imm>, but expected LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ ╾ALLOC_ID╼ │ ╾──────╼╾──────╼ } @@ -464,7 +464,7 @@ error[E0080]: constructing invalid value: encountered a reference pointing to un LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { 01 00 00 00 00 00 00 00 │ ........ } @@ -475,7 +475,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^ 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 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: 16, align: 8) { 01 00 00 00 00 00 00 00 01 00 00 00 00 00 00 00 │ ................ } @@ -486,7 +486,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; | ^^^^^^^^^^^^^ 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 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: 16, align: 8) { 01 00 00 00 00 00 00 00 2a 00 00 00 00 00 00 00 │ ........*....... } @@ -497,7 +497,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitializ LL | pub static S4: &[u8] = unsafe { from_raw_parts((&D1) as *const _ as _, 1) }; | ^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -510,7 +510,7 @@ LL | pub static S5: &[u8] = unsafe { from_raw_parts((&D3) as *const _ as _, mem: | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - = 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 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: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -521,7 +521,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but e LL | pub static S6: &[bool] = unsafe { from_raw_parts((&D0) as *const _ as _, 4) }; | ^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -532,7 +532,7 @@ error[E0080]: constructing invalid value at .<deref>[1]: encountered uninitializ LL | pub static S7: &[u16] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID+0x2╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -543,7 +543,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered uninitializ LL | pub static R4: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ 01 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -556,7 +556,7 @@ LL | pub static R5: &[u8] = unsafe { | = help: this code performed an operation that depends on the underlying bytes representing a pointer = help: the absolute address of a pointer is not known at compile-time, so such operations are not supported - = 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 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: 16, align: 8) { ╾ALLOC_ID╼ 08 00 00 00 00 00 00 00 │ ╾──────╼........ } @@ -567,7 +567,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x11, but e LL | pub static R6: &[bool] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC_ID╼ 04 00 00 00 00 00 00 00 │ ╾──────╼........ } diff --git a/tests/ui/consts/const-eval/transmute-const.stderr b/tests/ui/consts/const-eval/transmute-const.stderr index ed3b3df70dd..53665c176a7 100644 --- a/tests/ui/consts/const-eval/transmute-const.stderr +++ b/tests/ui/consts/const-eval/transmute-const.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered 0x03, but expected a boole LL | static FOO: bool = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 03 │ . } diff --git a/tests/ui/consts/const-eval/ub-enum.stderr b/tests/ui/consts/const-eval/ub-enum.stderr index 5cbd6176c92..1efd9383229 100644 --- a/tests/ui/consts/const-eval/ub-enum.stderr +++ b/tests/ui/consts/const-eval/ub-enum.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x01, but e LL | const BAD_ENUM: Enum = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -33,7 +33,7 @@ error[E0080]: constructing invalid value at .<enum-tag>: encountered 0x0, but ex LL | const BAD_ENUM2: Enum2 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -81,7 +81,7 @@ error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabi LL | const BAD_UNINHABITED_VARIANT1: UninhDiscriminant = unsafe { mem::transmute(1u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -92,7 +92,7 @@ error[E0080]: constructing invalid value at .<enum-tag>: encountered an uninhabi LL | const BAD_UNINHABITED_VARIANT2: UninhDiscriminant = unsafe { mem::transmute(3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -103,7 +103,7 @@ error[E0080]: constructing invalid value at .<enum-variant(Some)>.0.1: encounter LL | const BAD_OPTION_CHAR: Option<(char, char)> = Some(('x', unsafe { mem::transmute(!0u32) })); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr b/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr index 86d6f8c52bc..1e4d425d78e 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.32bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered ALLOC1<imm>, but expected LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──╼╾──╼ } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value: encountered ALLOC3<imm>, but expected LL | const INVALID_VTABLE_SIZE: &dyn Trait = | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──╼╾──╼ } @@ -26,7 +26,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC5<imm>, but exp LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──╼╾──╼ } @@ -37,7 +37,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC7<imm>, but exp LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC6<imm>╼ ╾ALLOC7<imm>╼ │ ╾──╼╾──╼ } @@ -48,7 +48,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC9<imm>, but exp LL | const INVALID_VTABLE_UB: W<&dyn Trait> = | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC8<imm>╼ ╾ALLOC9<imm>╼ │ ╾──╼╾──╼ } @@ -59,7 +59,7 @@ error[E0080]: constructing invalid value at .1: encountered a dangling reference LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; | ^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC10<imm>╼ ╾ALLOC11╼ │ ╾──╼╾──╼ } diff --git a/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr b/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr index a9518216dbd..a068991f324 100644 --- a/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-incorrect-vtable.64bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered ALLOC1<imm>, but expected LL | const INVALID_VTABLE_ALIGNMENT: &dyn Trait = | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC0<imm>╼ ╾ALLOC1<imm>╼ │ ╾──────╼╾──────╼ } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value: encountered ALLOC3<imm>, but expected LL | const INVALID_VTABLE_SIZE: &dyn Trait = | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC2<imm>╼ ╾ALLOC3<imm>╼ │ ╾──────╼╾──────╼ } @@ -26,7 +26,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC5<imm>, but exp LL | const INVALID_VTABLE_ALIGNMENT_UB: W<&dyn Trait> = | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC4<imm>╼ ╾ALLOC5<imm>╼ │ ╾──────╼╾──────╼ } @@ -37,7 +37,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC7<imm>, but exp LL | const INVALID_VTABLE_SIZE_UB: W<&dyn Trait> = | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC6<imm>╼ ╾ALLOC7<imm>╼ │ ╾──────╼╾──────╼ } @@ -48,7 +48,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC9<imm>, but exp LL | const INVALID_VTABLE_UB: W<&dyn Trait> = | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC8<imm>╼ ╾ALLOC9<imm>╼ │ ╾──────╼╾──────╼ } @@ -59,7 +59,7 @@ error[E0080]: constructing invalid value at .1: encountered a dangling reference LL | const G: Wide = unsafe { Transmute { t: FOO }.u }; | ^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC10<imm>╼ ╾ALLOC11╼ │ ╾──────╼╾──────╼ } diff --git a/tests/ui/consts/const-eval/ub-int-array.stderr b/tests/ui/consts/const-eval/ub-int-array.stderr index 10eb7c46c92..065bfd2c304 100644 --- a/tests/ui/consts/const-eval/ub-int-array.stderr +++ b/tests/ui/consts/const-eval/ub-int-array.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at [0]: encountered uninitialized memor LL | const UNINIT_INT_0: [u32; 3] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 12, align: 4) { __ __ __ __ 11 11 11 11 22 22 22 22 │ ░░░░...."""" } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value at [1]: encountered uninitialized memor LL | const UNINIT_INT_1: [u32; 3] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 12, align: 4) { 00 00 00 00 01 __ 01 01 02 02 __ 02 │ .....░....░. } @@ -26,7 +26,7 @@ error[E0080]: constructing invalid value at [2]: encountered uninitialized memor LL | const UNINIT_INT_2: [u32; 3] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 12, align: 4) { 00 00 00 00 01 01 01 01 02 02 02 __ │ ...........░ } diff --git a/tests/ui/consts/const-eval/ub-nonnull.stderr b/tests/ui/consts/const-eval/ub-nonnull.stderr index 19ae66cf3c6..91c82efbc5e 100644 --- a/tests/ui/consts/const-eval/ub-nonnull.stderr +++ b/tests/ui/consts/const-eval/ub-nonnull.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered 0, but expected something LL | const NULL_PTR: NonNull<u8> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -21,7 +21,7 @@ error[E0080]: constructing invalid value at .0: encountered 0, but expected some LL | const NULL_U8: NonZero<u8> = unsafe { mem::transmute(0u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -32,7 +32,7 @@ error[E0080]: constructing invalid value at .0: encountered 0, but expected some LL | const NULL_USIZE: NonZero<usize> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -53,7 +53,7 @@ error[E0080]: constructing invalid value: encountered 42, but expected something LL | const BAD_RANGE1: RestrictedRange1 = unsafe { RestrictedRange1(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -64,7 +64,7 @@ error[E0080]: constructing invalid value: encountered 20, but expected something LL | const BAD_RANGE2: RestrictedRange2 = unsafe { RestrictedRange2(20) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -75,7 +75,7 @@ error[E0080]: constructing invalid value: encountered 0, but expected something LL | const NULL_FAT_PTR: NonNull<dyn Send> = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } diff --git a/tests/ui/consts/const-eval/ub-ref-ptr.stderr b/tests/ui/consts/const-eval/ub-ref-ptr.stderr index 451ebb6eba1..c45f66c2925 100644 --- a/tests/ui/consts/const-eval/ub-ref-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-ref-ptr.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered an unaligned reference (re LL | const UNALIGNED: &u16 = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value: encountered an unaligned box (required LL | const UNALIGNED_BOX: Box<u16> = unsafe { mem::transmute(&[0u8; 4]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -26,7 +26,7 @@ error[E0080]: constructing invalid value: encountered a null reference LL | const NULL: &u16 = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^ 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 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 } @@ -37,7 +37,7 @@ error[E0080]: constructing invalid value: encountered a null box LL | const NULL_BOX: Box<u16> = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -87,7 +87,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (0x53 LL | const USIZE_AS_REF: &'static u8 = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -98,7 +98,7 @@ error[E0080]: constructing invalid value: encountered a dangling box (0x539[noal LL | const USIZE_AS_BOX: Box<u8> = unsafe { mem::transmute(1337usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -119,7 +119,7 @@ error[E0080]: constructing invalid value: encountered null pointer, but expected LL | const NULL_FN_PTR: fn() = unsafe { mem::transmute(0usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -140,7 +140,7 @@ error[E0080]: constructing invalid value: encountered 0xd[noalloc], but expected LL | const DANGLING_FN_PTR: fn() = unsafe { mem::transmute(13usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -151,7 +151,7 @@ error[E0080]: constructing invalid value: encountered ALLOC2<imm>, but expected LL | const DATA_FN_PTR: fn() = 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 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 } diff --git a/tests/ui/consts/const-eval/ub-uninhabit.stderr b/tests/ui/consts/const-eval/ub-uninhabit.stderr index b0f475fe938..aca0b13bb90 100644 --- a/tests/ui/consts/const-eval/ub-uninhabit.stderr +++ b/tests/ui/consts/const-eval/ub-uninhabit.stderr @@ -10,7 +10,7 @@ error[E0080]: constructing invalid value: encountered a reference pointing to un LL | const BAD_BAD_REF: &Bar = unsafe { mem::transmute(1usize) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } diff --git a/tests/ui/consts/const-eval/ub-upvars.32bit.stderr b/tests/ui/consts/const-eval/ub-upvars.32bit.stderr index ecd1c768c28..b434970b677 100644 --- a/tests/ui/consts/const-eval/ub-upvars.32bit.stderr +++ b/tests/ui/consts/const-eval/ub-upvars.32bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>.<captured-va LL | const BAD_UPVAR: &dyn FnOnce() = &{ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC0<imm>╼ ╾ALLOC1╼ │ ╾──╼╾──╼ } diff --git a/tests/ui/consts/const-eval/ub-upvars.64bit.stderr b/tests/ui/consts/const-eval/ub-upvars.64bit.stderr index 108dfe6b27b..de1e1f8a2be 100644 --- a/tests/ui/consts/const-eval/ub-upvars.64bit.stderr +++ b/tests/ui/consts/const-eval/ub-upvars.64bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>.<captured-va LL | const BAD_UPVAR: &dyn FnOnce() = &{ | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC0<imm>╼ ╾ALLOC1╼ │ ╾──────╼╾──────╼ } diff --git a/tests/ui/consts/const-eval/ub-wide-ptr.stderr b/tests/ui/consts/const-eval/ub-wide-ptr.stderr index ab15ba826a5..c505e5cc8a2 100644 --- a/tests/ui/consts/const-eval/ub-wide-ptr.stderr +++ b/tests/ui/consts/const-eval/ub-wide-ptr.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (goin LL | const STR_TOO_LONG: &str = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value at .0: encountered invalid reference me LL | const NESTED_STR_MUCH_TOO_LONG: (&str,) = (unsafe { mem::transmute((&42, usize::MAX)) },); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -44,7 +44,7 @@ error[E0080]: constructing invalid value: encountered invalid reference metadata LL | const MY_STR_MUCH_TOO_LONG: &MyStr = unsafe { mem::transmute((&42u8, usize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -55,7 +55,7 @@ error[E0080]: constructing invalid value at .<deref>: encountered uninitialized LL | const STR_NO_INIT: &str = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -66,7 +66,7 @@ error[E0080]: constructing invalid value at .<deref>.0: encountered uninitialize LL | const MYSTR_NO_INIT: &MyStr = unsafe { mem::transmute::<&[_], _>(&[MaybeUninit::<u8> { uninit: () }]) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -87,7 +87,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (goin LL | const SLICE_TOO_LONG: &[u8] = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -98,7 +98,7 @@ error[E0080]: constructing invalid value: encountered invalid reference metadata LL | const SLICE_TOO_LONG_OVERFLOW: &[u32] = unsafe { mem::transmute((&42u32, isize::MAX)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -118,7 +118,7 @@ error[E0080]: constructing invalid value: encountered a dangling box (going beyo LL | const SLICE_TOO_LONG_BOX: Box<[u8]> = unsafe { mem::transmute((&42u8, 999usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -138,7 +138,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered 0x03, but e LL | const SLICE_CONTENT_INVALID: &[bool] = &[unsafe { mem::transmute(3u8) }]; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -155,7 +155,7 @@ error[E0080]: constructing invalid value at .<deref>.0: encountered 0x03, but ex LL | const MYSLICE_PREFIX_BAD: &MySliceBool = &MySlice(unsafe { mem::transmute(3u8) }, [false]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -172,7 +172,7 @@ error[E0080]: constructing invalid value at .<deref>.1[0]: encountered 0x03, but LL | const MYSLICE_SUFFIX_BAD: &MySliceBool = &MySlice(true, [unsafe { mem::transmute(3u8) }]); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -199,7 +199,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC12<imm>, but ex LL | const TRAIT_OBJ_SHORT_VTABLE_1: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u8))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -210,7 +210,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC14<imm>, but ex LL | const TRAIT_OBJ_SHORT_VTABLE_2: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &3u64))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -221,7 +221,7 @@ error[E0080]: constructing invalid value at .0: encountered 0x4[noalloc], but ex LL | const TRAIT_OBJ_INT_VTABLE: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, 4usize))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -232,7 +232,7 @@ error[E0080]: constructing invalid value: encountered ALLOC17<imm>, but expected LL | const TRAIT_OBJ_UNALIGNED_VTABLE: &dyn Trait = unsafe { mem::transmute((&92u8, &[0u8; 128])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -243,7 +243,7 @@ error[E0080]: constructing invalid value: encountered ALLOC19<imm>, but expected LL | const TRAIT_OBJ_BAD_DROP_FN_NULL: &dyn Trait = unsafe { mem::transmute((&92u8, &[0usize; 8])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -254,7 +254,7 @@ error[E0080]: constructing invalid value: encountered ALLOC21<imm>, but expected LL | const TRAIT_OBJ_BAD_DROP_FN_INT: &dyn Trait = unsafe { mem::transmute((&92u8, &[1usize; 8])) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -265,7 +265,7 @@ error[E0080]: constructing invalid value at .0: encountered ALLOC23<imm>, but ex LL | const TRAIT_OBJ_BAD_DROP_FN_NOT_FN_PTR: W<&dyn Trait> = unsafe { mem::transmute(W((&92u8, &[&42u8; 8]))) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -276,7 +276,7 @@ error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>: encountered LL | const TRAIT_OBJ_CONTENT_INVALID: &dyn Trait = unsafe { mem::transmute::<_, &bool>(&3u8) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -287,7 +287,7 @@ error[E0080]: constructing invalid value: encountered null pointer, but expected LL | const RAW_TRAIT_OBJ_VTABLE_NULL: *const dyn Trait = unsafe { mem::transmute((&92u8, 0usize)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -298,7 +298,7 @@ error[E0080]: constructing invalid value: encountered ALLOC28<imm>, but expected LL | const RAW_TRAIT_OBJ_VTABLE_INVALID: *const dyn Trait = unsafe { mem::transmute((&92u8, &3u64)) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -309,7 +309,7 @@ error[E0080]: constructing invalid value: encountered null pointer, but expected LL | static mut RAW_TRAIT_OBJ_VTABLE_NULL_THROUGH_REF: *const dyn Trait = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -320,7 +320,7 @@ error[E0080]: constructing invalid value: encountered ALLOC31<imm>, but expected LL | static mut RAW_TRAIT_OBJ_VTABLE_INVALID_THROUGH_REF: *const dyn Trait = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } diff --git a/tests/ui/consts/const-eval/union-ub.32bit.stderr b/tests/ui/consts/const-eval/union-ub.32bit.stderr index 757bcea91c3..fb2311b9921 100644 --- a/tests/ui/consts/const-eval/union-ub.32bit.stderr +++ b/tests/ui/consts/const-eval/union-ub.32bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered 0x2a, but expected a boole LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; | ^^^^^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 2a │ * } diff --git a/tests/ui/consts/const-eval/union-ub.64bit.stderr b/tests/ui/consts/const-eval/union-ub.64bit.stderr index 757bcea91c3..fb2311b9921 100644 --- a/tests/ui/consts/const-eval/union-ub.64bit.stderr +++ b/tests/ui/consts/const-eval/union-ub.64bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered 0x2a, but expected a boole LL | const BAD_BOOL: bool = unsafe { DummyUnion { u8: 42 }.bool }; | ^^^^^^^^^^^^^^^^^^^^ 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 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: 1, align: 1) { 2a │ * } 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 16dee44d800..08656776468 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 @@ -34,7 +34,7 @@ error[E0080]: constructing invalid value: encountered mutable reference or box p LL | const IMMUT_MUT_REF: &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 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 } @@ -45,7 +45,7 @@ error[E0080]: constructing invalid value: encountered mutable reference or box p 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 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 } 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 302e342bce6..96263998ad4 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 @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<enum-variant(Some)>.0: encountered LL | const MUT: Option<&mut i32> = helper(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value at .<enum-variant(Some)>.0: encountered LL | const INT2PTR: Option<&mut i32> = helper_int2ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -26,7 +26,7 @@ error[E0080]: constructing invalid value at .<enum-variant(Some)>.0: encountered LL | static INT2PTR_STATIC: Option<&mut i32> = helper_int2ptr(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -37,7 +37,7 @@ error[E0080]: constructing invalid value at .<enum-variant(Some)>.0: encountered LL | const DANGLING: Option<&mut i32> = helper_dangling(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -48,7 +48,7 @@ error[E0080]: constructing invalid value at .<enum-variant(Some)>.0: encountered LL | static DANGLING_STATIC: Option<&mut i32> = helper_dangling(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } 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 8be8b4bc50f..f9088c318a6 100644 --- a/tests/ui/consts/const_refs_to_static_fail_invalid.stderr +++ b/tests/ui/consts/const_refs_to_static_fail_invalid.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<deref>: encountered 0x0a, but expe LL | const C: &bool = unsafe { std::mem::transmute(&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 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 } diff --git a/tests/ui/consts/dangling-alloc-id-ice.stderr b/tests/ui/consts/dangling-alloc-id-ice.stderr index 65a46b62dae..4b034c81a61 100644 --- a/tests/ui/consts/dangling-alloc-id-ice.stderr +++ b/tests/ui/consts/dangling-alloc-id-ice.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (use- LL | const FOO: &() = { | ^^^^^^^^^^^^^^ 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 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 } diff --git a/tests/ui/consts/dangling-zst-ice-issue-126393.stderr b/tests/ui/consts/dangling-zst-ice-issue-126393.stderr index 2f600e494c4..248db694d52 100644 --- a/tests/ui/consts/dangling-zst-ice-issue-126393.stderr +++ b/tests/ui/consts/dangling-zst-ice-issue-126393.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered a dangling reference (use- LL | pub static MAGIC_FFI_REF: &'static Wrapper = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } diff --git a/tests/ui/consts/interior-mut-const-via-union.32bit.stderr b/tests/ui/consts/interior-mut-const-via-union.32bit.stderr index 47bb2e5e879..17b32383912 100644 --- a/tests/ui/consts/interior-mut-const-via-union.32bit.stderr +++ b/tests/ui/consts/interior-mut-const-via-union.32bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<deref>.y.<enum-variant(B)>.0: enco LL | fn main() { | ^^^^^^^^^ 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 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: 4, align: 4) { ╾ALLOC0╼ │ ╾──╼ } diff --git a/tests/ui/consts/interior-mut-const-via-union.64bit.stderr b/tests/ui/consts/interior-mut-const-via-union.64bit.stderr index b4c9a4bd47e..c4f78e7bf9e 100644 --- a/tests/ui/consts/interior-mut-const-via-union.64bit.stderr +++ b/tests/ui/consts/interior-mut-const-via-union.64bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<deref>.y.<enum-variant(B)>.0: enco LL | fn main() { | ^^^^^^^^^ 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 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: 8, align: 8) { ╾ALLOC0╼ │ ╾──────╼ } diff --git a/tests/ui/consts/issue-17718-const-bad-values.stderr b/tests/ui/consts/issue-17718-const-bad-values.stderr index 68d1a72b71e..2c54200c8a2 100644 --- a/tests/ui/consts/issue-17718-const-bad-values.stderr +++ b/tests/ui/consts/issue-17718-const-bad-values.stderr @@ -14,7 +14,7 @@ error[E0080]: constructing invalid value: encountered mutable reference in `cons LL | const C2: &'static mut i32 = unsafe { &mut 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 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: $PTR, align: $PTR) { HEX_DUMP } diff --git a/tests/ui/consts/issue-63952.32bit.stderr b/tests/ui/consts/issue-63952.32bit.stderr index e5340788167..cf97ed6e487 100644 --- a/tests/ui/consts/issue-63952.32bit.stderr +++ b/tests/ui/consts/issue-63952.32bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered invalid reference metadata LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { ╾ALLOC0<imm>╼ ff ff ff ff │ ╾──╼.... } diff --git a/tests/ui/consts/issue-63952.64bit.stderr b/tests/ui/consts/issue-63952.64bit.stderr index 27e74833fc5..4cea967314c 100644 --- a/tests/ui/consts/issue-63952.64bit.stderr +++ b/tests/ui/consts/issue-63952.64bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered invalid reference metadata LL | const SLICE_WAY_TOO_LONG: &[u8] = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC0<imm>╼ ff ff ff ff ff ff ff ff │ ╾──────╼........ } diff --git a/tests/ui/consts/issue-79690.64bit.stderr b/tests/ui/consts/issue-79690.64bit.stderr index 7488f7b7752..2653ff22f12 100644 --- a/tests/ui/consts/issue-79690.64bit.stderr +++ b/tests/ui/consts/issue-79690.64bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .1: encountered a dangling reference LL | const G: Fat = unsafe { Transmute { t: FOO }.u }; | ^^^^^^^^^^^^ 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 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: 16, align: 8) { ╾ALLOC0<imm>╼ ╾ALLOC1╼ │ ╾──────╼╾──────╼ } diff --git a/tests/ui/consts/issue-89088.stderr b/tests/ui/consts/issue-89088.stderr index 56025e0d9b2..5008a2eada8 100644 --- a/tests/ui/consts/issue-89088.stderr +++ b/tests/ui/consts/issue-89088.stderr @@ -6,6 +6,7 @@ LL | const FOO: &A = &A::Field(Cow::Borrowed("foo")); ... LL | FOO => todo!(), | ^^^ constant of non-structural type + | --> $SRC_DIR/alloc/src/borrow.rs:LL:COL | = note: `Cow<'_, str>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns diff --git a/tests/ui/consts/miri_unleashed/mutable_references.stderr b/tests/ui/consts/miri_unleashed/mutable_references.stderr index 137efde44b3..b35076b669e 100644 --- a/tests/ui/consts/miri_unleashed/mutable_references.stderr +++ b/tests/ui/consts/miri_unleashed/mutable_references.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<deref>: encountered mutable refere LL | static FOO: &&mut u32 = &&mut 42; | ^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value: encountered mutable reference or box p LL | static OH_YES: &mut i32 = &mut 42; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -38,7 +38,7 @@ error[E0080]: constructing invalid value: encountered mutable reference or box p LL | const BLUNT: &mut i32 = &mut 42; | ^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -49,7 +49,7 @@ error[E0080]: constructing invalid value: encountered mutable reference in `cons LL | const SUBTLE: &mut i32 = unsafe { | ^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -60,7 +60,7 @@ error[E0080]: constructing invalid value at .x.<deref>: encountered `UnsafeCell` LL | static MEH: Meh = Meh { x: &UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^ 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 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 } @@ -71,7 +71,7 @@ error[E0080]: constructing invalid value at .x.<deref>: encountered `UnsafeCell` LL | const MUH: Meh = Meh { | ^^^^^^^^^^^^^^ 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 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 } @@ -82,7 +82,7 @@ error[E0080]: constructing invalid value at .<deref>.<dyn-downcast>.x: encounter LL | const SNEAKY: &dyn Sync = &Synced { x: UnsafeCell::new(42) }; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } @@ -93,7 +93,7 @@ error[E0080]: constructing invalid value: encountered mutable reference or box p LL | static mut MUT_TO_READONLY: &mut i32 = unsafe { &mut *(&READONLY as *const _ as *mut _) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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 } diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr b/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr index 1ef20689985..d7c668a9812 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.32bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<deref>.v: encountered `UnsafeCell` LL | static REF: &AtomicI32 = &AtomicI32::new(42); | ^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { ╾ALLOC0╼ │ ╾──╼ } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value: encountered mutable reference or box p LL | static REFMUT: &mut i32 = &mut 0; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { ╾ALLOC1╼ │ ╾──╼ } @@ -26,7 +26,7 @@ error[E0080]: constructing invalid value at .<deref>.v: encountered `UnsafeCell` LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { ╾ALLOC2╼ │ ╾──╼ } @@ -37,7 +37,7 @@ error[E0080]: constructing invalid value: encountered mutable reference or box p LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; | ^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { ╾ALLOC3╼ │ ╾──╼ } diff --git a/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr b/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr index 06f78e679b1..f3bb49900b5 100644 --- a/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr +++ b/tests/ui/consts/miri_unleashed/static-no-inner-mut.64bit.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .<deref>.v: encountered `UnsafeCell` LL | static REF: &AtomicI32 = &AtomicI32::new(42); | ^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { ╾ALLOC0╼ │ ╾──────╼ } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value: encountered mutable reference or box p LL | static REFMUT: &mut i32 = &mut 0; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { ╾ALLOC1╼ │ ╾──────╼ } @@ -26,7 +26,7 @@ error[E0080]: constructing invalid value at .<deref>.v: encountered `UnsafeCell` LL | static REF2: &AtomicI32 = {let x = AtomicI32::new(42); &{x}}; | ^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { ╾ALLOC2╼ │ ╾──────╼ } @@ -37,7 +37,7 @@ error[E0080]: constructing invalid value: encountered mutable reference or box p LL | static REFMUT2: &mut i32 = {let mut x = 0; &mut {x}}; | ^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 8) { ╾ALLOC3╼ │ ╾──────╼ } diff --git a/tests/ui/consts/ptr_comparisons.rs b/tests/ui/consts/ptr_comparisons.rs index e142ab3a754..b8d809475cf 100644 --- a/tests/ui/consts/ptr_comparisons.rs +++ b/tests/ui/consts/ptr_comparisons.rs @@ -1,43 +1,205 @@ //@ compile-flags: --crate-type=lib //@ check-pass +//@ edition: 2024 +#![feature(const_raw_ptr_comparison)] +#![feature(fn_align)] +// Generally: +// For any `Some` return, `None` would also be valid, unless otherwise noted. +// For any `None` return, only `None` is valid, unless otherwise noted. -#![feature( - core_intrinsics, - const_raw_ptr_comparison, -)] +macro_rules! do_test { + ($a:expr, $b:expr, $expected:pat) => { + const _: () = { + let a: *const _ = $a; + let b: *const _ = $b; + assert!(matches!(<*const u8>::guaranteed_eq(a.cast(), b.cast()), $expected)); + }; + }; +} -const FOO: &usize = &42; +#[repr(align(2))] +struct T(#[allow(unused)] u16); -macro_rules! check { - (eq, $a:expr, $b:expr) => { - pub const _: () = - assert!(std::intrinsics::ptr_guaranteed_cmp($a as *const u8, $b as *const u8) == 1); - }; - (ne, $a:expr, $b:expr) => { - pub const _: () = - assert!(std::intrinsics::ptr_guaranteed_cmp($a as *const u8, $b as *const u8) == 0); +#[repr(align(2))] +struct AlignedZst; + +static A: T = T(42); +static B: T = T(42); +static mut MUT_STATIC: T = T(42); +static ZST: () = (); +static ALIGNED_ZST: AlignedZst = AlignedZst; +static LARGE_WORD_ALIGNED: [usize; 2] = [0, 1]; +static mut MUT_LARGE_WORD_ALIGNED: [usize; 2] = [0, 1]; + +const FN_PTR: *const () = { + fn foo() {} + unsafe { std::mem::transmute(foo as fn()) } +}; + +const ALIGNED_FN_PTR: *const () = { + #[rustc_align(2)] + fn aligned_foo() {} + unsafe { std::mem::transmute(aligned_foo as fn()) } +}; + +trait Trait { + #[allow(unused)] + fn method(&self) -> u8; +} +impl Trait for u32 { + fn method(&self) -> u8 { 1 } +} +impl Trait for i32 { + fn method(&self) -> u8 { 2 } +} + +const VTABLE_PTR_1: *const () = { + let [_data, vtable] = unsafe { + std::mem::transmute::<&dyn Trait, [*const (); 2]>(&42_u32 as &dyn Trait) }; - (!, $a:expr, $b:expr) => { - pub const _: () = - assert!(std::intrinsics::ptr_guaranteed_cmp($a as *const u8, $b as *const u8) == 2); + vtable +}; +const VTABLE_PTR_2: *const () = { + let [_data, vtable] = unsafe { + std::mem::transmute::<&dyn Trait, [*const (); 2]>(&42_i32 as &dyn Trait) }; -} + vtable +}; -check!(eq, 0, 0); -check!(ne, 0, 1); -check!(ne, FOO as *const _, 0); -check!(ne, unsafe { (FOO as *const usize).offset(1) }, 0); -check!(ne, unsafe { (FOO as *const usize as *const u8).offset(3) }, 0); +// Cannot be `None`: `is_null` is stable with strong guarantees about integer-valued pointers. +do_test!(0 as *const u8, 0 as *const u8, Some(true)); +do_test!(0 as *const u8, 1 as *const u8, Some(false)); -// We want pointers to be equal to themselves, but aren't checking this yet because -// there are some open questions (e.g. whether function pointers to the same function -// compare equal: they don't necessarily do at runtime). -check!(!, FOO as *const _, FOO as *const _); +// Integer-valued pointers can always be compared. +do_test!(1 as *const u8, 1 as *const u8, Some(true)); +do_test!(1 as *const u8, 2 as *const u8, Some(false)); + +// Cannot be `None`: `static`s' addresses, references, (and within and one-past-the-end of those), +// and `fn` pointers cannot be null, and `is_null` is stable with strong guarantees, and +// `is_null` is implemented using `guaranteed_cmp`. +do_test!(&A, 0 as *const u8, Some(false)); +do_test!((&raw const A).cast::<u8>().wrapping_add(1), 0 as *const u8, Some(false)); +do_test!((&raw const A).wrapping_add(1), 0 as *const u8, Some(false)); +do_test!(&ZST, 0 as *const u8, Some(false)); +do_test!(&(), 0 as *const u8, Some(false)); +do_test!(const { &() }, 0 as *const u8, Some(false)); +do_test!(FN_PTR, 0 as *const u8, Some(false)); + +// This pointer is out-of-bounds, but still cannot be equal to 0 because of alignment. +do_test!((&raw const A).cast::<u8>().wrapping_add(size_of::<T>() + 1), 0 as *const u8, Some(false)); // aside from 0, these pointers might end up pretty much anywhere. -check!(!, FOO as *const _, 1); // this one could be `ne` by taking into account alignment -check!(!, FOO as *const _, 1024); +do_test!(&A, align_of::<T>() as *const u8, None); +do_test!((&raw const A).wrapping_byte_add(1), (align_of::<T>() + 1) as *const u8, None); + +// except that they must still be aligned +do_test!(&A, 1 as *const u8, Some(false)); +do_test!((&raw const A).wrapping_byte_add(1), align_of::<T>() as *const u8, Some(false)); + +// If `ptr.wrapping_sub(int)` cannot be null (because it is in-bounds or one-past-the-end of +// `ptr`'s allocation, or because it is misaligned from `ptr`'s allocation), then we know that +// `ptr != int`, even if `ptr` itself is out-of-bounds or one-past-the-end of its allocation. +do_test!((&raw const A).wrapping_byte_add(1), 1 as *const u8, Some(false)); +do_test!((&raw const A).wrapping_byte_add(2), 2 as *const u8, Some(false)); +do_test!((&raw const A).wrapping_byte_add(3), 1 as *const u8, Some(false)); +do_test!((&raw const ZST).wrapping_byte_add(1), 1 as *const u8, Some(false)); +do_test!(VTABLE_PTR_1.wrapping_byte_add(1), 1 as *const u8, Some(false)); +do_test!(FN_PTR.wrapping_byte_add(1), 1 as *const u8, Some(false)); +do_test!(&A, size_of::<T>().wrapping_neg() as *const u8, Some(false)); +do_test!(&LARGE_WORD_ALIGNED, size_of::<usize>().wrapping_neg() as *const u8, Some(false)); +// (`ptr - int != 0` due to misalignment) +do_test!((&raw const A).wrapping_byte_add(2), 1 as *const u8, Some(false)); +do_test!((&raw const ALIGNED_ZST).wrapping_byte_add(2), 1 as *const u8, Some(false)); // When pointers go out-of-bounds, they *might* become null, so these comparions cannot work. -check!(!, unsafe { (FOO as *const usize).wrapping_add(2) }, 0); -check!(!, unsafe { (FOO as *const usize).wrapping_sub(1) }, 0); +do_test!((&raw const A).wrapping_add(2), 0 as *const u8, None); +do_test!((&raw const A).wrapping_sub(1), 0 as *const u8, None); + +// Statics cannot be duplicated +do_test!(&A, &A, Some(true)); + +// Two non-ZST statics cannot have the same address +do_test!(&A, &B, Some(false)); +do_test!(&A, &raw const MUT_STATIC, Some(false)); + +// One-past-the-end of one static can be equal to the address of another static. +do_test!(&A, (&raw const B).wrapping_add(1), None); + +// Cannot know if ZST static is at the same address with anything non-null (if alignment allows). +do_test!(&A, &ZST, None); +do_test!(&A, &ALIGNED_ZST, None); + +// Unclear if ZST statics can be placed "in the middle of" non-ZST statics. +// For now, we conservatively say they could, and return None here. +do_test!(&ZST, (&raw const A).wrapping_byte_add(1), None); + +// As per https://doc.rust-lang.org/nightly/reference/items/static-items.html#r-items.static.storage-disjointness +// immutable statics are allowed to overlap with const items and promoteds. +do_test!(&A, &T(42), None); +do_test!(&A, const { &T(42) }, None); +do_test!(&A, { const X: T = T(42); &X }, None); + +// These could return Some(false), since only immutable statics can overlap with const items +// and promoteds. +do_test!(&raw const MUT_STATIC, &T(42), None); +do_test!(&raw const MUT_STATIC, const { &T(42) }, None); +do_test!(&raw const MUT_STATIC, { const X: T = T(42); &X }, None); + +// An odd offset from a 2-aligned allocation can never be equal to an even offset from a +// 2-aligned allocation, even if the offsets are out-of-bounds. +do_test!(&A, (&raw const B).wrapping_byte_add(1), Some(false)); +do_test!(&A, (&raw const B).wrapping_byte_add(5), Some(false)); +do_test!(&A, (&raw const ALIGNED_ZST).wrapping_byte_add(1), Some(false)); +do_test!(&ALIGNED_ZST, (&raw const A).wrapping_byte_add(1), Some(false)); +do_test!(&A, (&T(42) as *const T).wrapping_byte_add(1), Some(false)); +do_test!(&A, (const { &T(42) } as *const T).wrapping_byte_add(1), Some(false)); +do_test!(&A, ({ const X: T = T(42); &X } as *const T).wrapping_byte_add(1), Some(false)); + +// We could return `Some(false)` for these, as pointers to different statics can never be equal if +// that would require the statics to overlap, even if the pointers themselves are offset out of +// bounds or one-past-the-end. We currently only check strictly in-bounds pointers when comparing +// pointers to different statics, however. +do_test!((&raw const A).wrapping_add(1), (&raw const B).wrapping_add(1), None); +do_test!( + (&raw const LARGE_WORD_ALIGNED).cast::<usize>().wrapping_add(2), + (&raw const MUT_LARGE_WORD_ALIGNED).cast::<usize>().wrapping_add(1), + None +); + +// Pointers into the same static are equal if and only if their offset is the same, +// even if either is out-of-bounds. +do_test!(&A, &A, Some(true)); +do_test!(&A, &A.0, Some(true)); +do_test!(&A, (&raw const A).wrapping_byte_add(1), Some(false)); +do_test!(&A, (&raw const A).wrapping_byte_add(2), Some(false)); +do_test!(&A, (&raw const A).wrapping_byte_add(51), Some(false)); +do_test!((&raw const A).wrapping_byte_add(51), (&raw const A).wrapping_byte_add(51), Some(true)); + +// Pointers to the same fn may be unequal, since `fn`s can be duplicated. +do_test!(FN_PTR, FN_PTR, None); +do_test!(ALIGNED_FN_PTR, ALIGNED_FN_PTR, None); + +// Pointers to different fns may be equal, since `fn`s can be deduplicated. +do_test!(FN_PTR, ALIGNED_FN_PTR, None); + +// Pointers to the same vtable may be unequal, since vtables can be duplicated. +do_test!(VTABLE_PTR_1, VTABLE_PTR_1, None); + +// Pointers to different vtables may be equal, since vtables can be deduplicated. +do_test!(VTABLE_PTR_1, VTABLE_PTR_2, None); + +// Function pointers to aligned function allocations are not necessarily actually aligned, +// due to platform-specific semantics. +// See https://github.com/rust-lang/rust/issues/144661 +// FIXME: This could return `Some` on platforms where function pointers' addresses actually +// correspond to function addresses including alignment, or on platforms where all functions +// are aligned to some amount (e.g. ARM where a32 function pointers are at least 4-aligned, +// and t32 function pointers are 2-aligned-offset-by-1). +do_test!(ALIGNED_FN_PTR, ALIGNED_FN_PTR.wrapping_byte_offset(1), None); + +// Conservatively say we don't know. +do_test!(FN_PTR, VTABLE_PTR_1, None); +do_test!((&raw const LARGE_WORD_ALIGNED).cast::<usize>().wrapping_add(1), VTABLE_PTR_1, None); +do_test!((&raw const MUT_LARGE_WORD_ALIGNED).cast::<usize>().wrapping_add(1), VTABLE_PTR_1, None); +do_test!((&raw const LARGE_WORD_ALIGNED).cast::<usize>().wrapping_add(1), FN_PTR, None); +do_test!((&raw const MUT_LARGE_WORD_ALIGNED).cast::<usize>().wrapping_add(1), FN_PTR, None); diff --git a/tests/ui/consts/validate_never_arrays.stderr b/tests/ui/consts/validate_never_arrays.stderr index 0f503df4060..3c405e8d3cd 100644 --- a/tests/ui/consts/validate_never_arrays.stderr +++ b/tests/ui/consts/validate_never_arrays.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered a reference pointing to un LL | const _: &[!; 1] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^^^^ 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 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 } @@ -15,7 +15,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 1]) }; | ^^^^^^^^^^^^^ 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 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 } @@ -26,7 +26,7 @@ error[E0080]: constructing invalid value at .<deref>[0]: encountered a value of LL | const _: &[!] = unsafe { &*(1_usize as *const [!; 42]) }; | ^^^^^^^^^^^^^ 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 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 } diff --git a/tests/ui/crate-loading/invalid-rlib.rs b/tests/ui/crate-loading/invalid-rlib.rs index 6b463526244..24293f88b1c 100644 --- a/tests/ui/crate-loading/invalid-rlib.rs +++ b/tests/ui/crate-loading/invalid-rlib.rs @@ -6,6 +6,3 @@ #![no_std] use ::foo; //~ ERROR invalid metadata files for crate `foo` //~| NOTE failed to mmap file -//~^^ ERROR invalid metadata files for crate `foo` -//~| NOTE failed to mmap file -//~| NOTE duplicate diagnostic diff --git a/tests/ui/crate-loading/invalid-rlib.stderr b/tests/ui/crate-loading/invalid-rlib.stderr index 63bb1b95cbb..ad3ab729a5d 100644 --- a/tests/ui/crate-loading/invalid-rlib.stderr +++ b/tests/ui/crate-loading/invalid-rlib.stderr @@ -6,15 +6,6 @@ LL | use ::foo; | = note: failed to mmap file 'auxiliary/libfoo.rlib' -error[E0786]: found invalid metadata files for crate `foo` - --> $DIR/invalid-rlib.rs:7:7 - | -LL | use ::foo; - | ^^^ - | - = note: failed to mmap file 'auxiliary/libfoo.rlib' - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0786`. diff --git a/tests/ui/issues/auxiliary/issue-7178.rs b/tests/ui/cross-crate/auxiliary/aux-7178.rs index 56ae5139af4..56ae5139af4 100644 --- a/tests/ui/issues/auxiliary/issue-7178.rs +++ b/tests/ui/cross-crate/auxiliary/aux-7178.rs diff --git a/tests/ui/cross-crate/static-method-returning-self-with-generics-7178.rs b/tests/ui/cross-crate/static-method-returning-self-with-generics-7178.rs new file mode 100644 index 00000000000..3888d3bdaa9 --- /dev/null +++ b/tests/ui/cross-crate/static-method-returning-self-with-generics-7178.rs @@ -0,0 +1,9 @@ +// https://github.com/rust-lang/rust/issues/7178 +//@ run-pass +//@ aux-build:aux-7178.rs + +extern crate aux_7178 as cross_crate_self; + +pub fn main() { + let _ = cross_crate_self::Foo::new(&1); +} diff --git a/tests/ui/cross-crate/static-regions-in-cross-crate-8259.rs b/tests/ui/cross-crate/static-with-cross-crate-regions-8259.rs index 347cfa2aee1..347cfa2aee1 100644 --- a/tests/ui/cross-crate/static-regions-in-cross-crate-8259.rs +++ b/tests/ui/cross-crate/static-with-cross-crate-regions-8259.rs diff --git a/tests/ui/cross-crate/tuple-struct-cross-crate-7899.rs b/tests/ui/cross-crate/tuple-struct-cross-crate-7899.rs new file mode 100644 index 00000000000..ce3ea7dd579 --- /dev/null +++ b/tests/ui/cross-crate/tuple-struct-cross-crate-7899.rs @@ -0,0 +1,10 @@ +// https://github.com/rust-lang/rust/issues/7899 +//@ run-pass +#![allow(unused_variables)] +//@ aux-build:aux-7899.rs + +extern crate aux_7899 as testcrate; + +fn main() { + let f = testcrate::V2(1.0f32, 2.0f32); +} diff --git a/tests/ui/derives/deriving-meta-unknown-trait.stderr b/tests/ui/derives/deriving-meta-unknown-trait.stderr index 28753b8f9f2..7ee90ae9eb0 100644 --- a/tests/ui/derives/deriving-meta-unknown-trait.stderr +++ b/tests/ui/derives/deriving-meta-unknown-trait.stderr @@ -3,6 +3,7 @@ error: cannot find derive macro `Eqr` in this scope | LL | #[derive(Eqr)] | ^^^ help: a derive macro with a similar name exists: `Eq` + | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named derive macro `Eq` defined here @@ -12,6 +13,7 @@ error: cannot find derive macro `Eqr` in this scope | LL | #[derive(Eqr)] | ^^^ help: a derive macro with a similar name exists: `Eq` + | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named derive macro `Eq` defined here diff --git a/tests/ui/diagnostic-flags/colored-session-opt-error.rs b/tests/ui/diagnostic-flags/colored-session-opt-error.rs index e850345fbf1..1c411048385 100644 --- a/tests/ui/diagnostic-flags/colored-session-opt-error.rs +++ b/tests/ui/diagnostic-flags/colored-session-opt-error.rs @@ -1,4 +1,8 @@ //@ check-pass //@ ignore-windows //@ compile-flags: -Cremark=foo --error-format=human --color=always + +// FIXME(#61117): Respect debuginfo-level-tests, do not force debuginfo-level=0 +//@ compile-flags: -Cdebuginfo=0 + fn main() {} diff --git a/tests/ui/did_you_mean/println-typo.stderr b/tests/ui/did_you_mean/println-typo.stderr index a1e0b1f1ba4..7dd6fbba620 100644 --- a/tests/ui/did_you_mean/println-typo.stderr +++ b/tests/ui/did_you_mean/println-typo.stderr @@ -3,6 +3,7 @@ error: cannot find macro `prinltn` in this scope | LL | prinltn!(); | ^^^^^^^ help: a macro with a similar name exists: `println` + | --> $SRC_DIR/std/src/macros.rs:LL:COL | = note: similarly named macro `println` defined here diff --git a/tests/ui/drop/if-let-super-let.rs b/tests/ui/drop/if-let-super-let.rs new file mode 100644 index 00000000000..c6543e6d3dc --- /dev/null +++ b/tests/ui/drop/if-let-super-let.rs @@ -0,0 +1,112 @@ +//! Test for #145328: ensure the lifetime of a `super let` binding within an `if let` scrutinee is +//! at most the scope of the `if` condition's temporaries. Additionally, test `pin!` since it's +//! implemented in terms of `super let` and exposes this behavior. +//@ run-pass +//@ revisions: e2021 e2024 +//@ [e2021] edition: 2021 +//@ [e2024] edition: 2024 + +#![feature(if_let_guard)] +#![feature(super_let)] +#![expect(irrefutable_let_patterns)] + +use std::cell::RefCell; +use std::pin::pin; + +fn main() { + // The `super let` bindings here should have the same scope as `if let` temporaries. + // In Rust 2021, this means it lives past the end of the `if` expression. + // In Rust 2024, this means it lives to the end of the `if`'s success block. + assert_drop_order(0..=2, |o| { + #[cfg(e2021)] + ( + if let _ = { super let _x = o.log(2); } { o.push(0) }, + o.push(1), + ); + #[cfg(e2024)] + ( + if let _ = { super let _x = o.log(1); } { o.push(0) }, + o.push(2), + ); + }); + assert_drop_order(0..=2, |o| { + #[cfg(e2021)] + ( + if let true = { super let _x = o.log(2); false } {} else { o.push(0) }, + o.push(1), + ); + #[cfg(e2024)] + ( + if let true = { super let _x = o.log(0); false } {} else { o.push(1) }, + o.push(2), + ); + }); + + // `pin!` should behave likewise. + assert_drop_order(0..=2, |o| { + #[cfg(e2021)] (if let _ = pin!(o.log(2)) { o.push(0) }, o.push(1)); + #[cfg(e2024)] (if let _ = pin!(o.log(1)) { o.push(0) }, o.push(2)); + }); + assert_drop_order(0..=2, |o| { + #[cfg(e2021)] + ( + if let None = Some(pin!(o.log(2))) {} else { o.push(0) }, + o.push(1), + ); + #[cfg(e2024)] + ( + if let None = Some(pin!(o.log(0))) {} else { o.push(1) }, + o.push(2), + ); + }); + + // `super let` bindings' scope should also be consistent with `if let` temporaries in guards. + // Here, that means the `super let` binding in the second guard condition operand should be + // dropped before the first operand's temporary. This is consistent across Editions. + assert_drop_order(0..=1, |o| { + match () { + _ if let _ = o.log(1) + && let _ = { super let _x = o.log(0); } => {} + _ => unreachable!(), + } + }); + assert_drop_order(0..=1, |o| { + match () { + _ if let _ = o.log(1) + && let _ = pin!(o.log(0)) => {} + _ => unreachable!(), + } + }); +} + +// # Test scaffolding... + +struct DropOrder(RefCell<Vec<u64>>); +struct LogDrop<'o>(&'o DropOrder, u64); + +impl DropOrder { + fn log(&self, n: u64) -> LogDrop<'_> { + LogDrop(self, n) + } + fn push(&self, n: u64) { + self.0.borrow_mut().push(n); + } +} + +impl<'o> Drop for LogDrop<'o> { + fn drop(&mut self) { + self.0.push(self.1); + } +} + +#[track_caller] +fn assert_drop_order( + ex: impl IntoIterator<Item = u64>, + f: impl Fn(&DropOrder), +) { + let order = DropOrder(RefCell::new(Vec::new())); + f(&order); + let order = order.0.into_inner(); + let expected: Vec<u64> = ex.into_iter().collect(); + assert_eq!(order, expected); +} diff --git a/tests/ui/issues/issue-5900.rs b/tests/ui/enum/enum-referred-by-submodule-5900.rs index 14b7b8f815a..4ed092670a8 100644 --- a/tests/ui/issues/issue-5900.rs +++ b/tests/ui/enum/enum-referred-by-submodule-5900.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5900 //@ check-pass #![allow(dead_code)] diff --git a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997.rs b/tests/ui/enum/enum-with-generic-parameter-5997.rs index 7ed8819f322..fab7ebbbbdc 100644 --- a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997.rs +++ b/tests/ui/enum/enum-with-generic-parameter-5997.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5997 //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/issues/issue-6117.rs b/tests/ui/enum/match-either-enum-variants-6117.rs index 3ccf67b0319..7b395066166 100644 --- a/tests/ui/issues/issue-6117.rs +++ b/tests/ui/enum/match-either-enum-variants-6117.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/6117 //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/error-codes/E0458.rs b/tests/ui/error-codes/E0458.rs index 35e7e84d479..0e35ba43bfb 100644 --- a/tests/ui/error-codes/E0458.rs +++ b/tests/ui/error-codes/E0458.rs @@ -1,4 +1,4 @@ -#[link(kind = "wonderful_unicorn")] extern "C" {} //~ ERROR E0458 +#[link(kind = "wonderful_unicorn")] extern "C" {} //~ ERROR malformed `link` attribute input [E0539] //~| ERROR E0459 fn main() { diff --git a/tests/ui/error-codes/E0458.stderr b/tests/ui/error-codes/E0458.stderr index c13ae4e7862..524765ea12a 100644 --- a/tests/ui/error-codes/E0458.stderr +++ b/tests/ui/error-codes/E0458.stderr @@ -1,8 +1,27 @@ -error[E0458]: unknown link kind `wonderful_unicorn`, expected one of: static, dylib, framework, raw-dylib, link-arg - --> $DIR/E0458.rs:1:15 +error[E0539]: malformed `link` attribute input + --> $DIR/E0458.rs:1:1 | LL | #[link(kind = "wonderful_unicorn")] extern "C" {} - | ^^^^^^^^^^^^^^^^^^^ unknown link kind + | ^^^^^^^^^^^^^^-------------------^^ + | | + | valid arguments are "static", "dylib", "framework", "raw-dylib" or "link-arg" + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(kind = "wonderful_unicorn")] extern "C" {} +LL + #[link(name = "...")] extern "C" {} + | +LL - #[link(kind = "wonderful_unicorn")] extern "C" {} +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] extern "C" {} + | +LL - #[link(kind = "wonderful_unicorn")] extern "C" {} +LL + #[link(name = "...", kind = "dylib|static|...")] extern "C" {} + | +LL - #[link(kind = "wonderful_unicorn")] extern "C" {} +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] extern "C" {} + | + = and 1 other candidate error[E0459]: `#[link]` attribute requires a `name = "string"` argument --> $DIR/E0458.rs:1:1 @@ -12,5 +31,5 @@ LL | #[link(kind = "wonderful_unicorn")] extern "C" {} error: aborting due to 2 previous errors -Some errors have detailed explanations: E0458, E0459. -For more information about an error, try `rustc --explain E0458`. +Some errors have detailed explanations: E0459, E0539. +For more information about an error, try `rustc --explain E0459`. diff --git a/tests/ui/feature-gates/feature-gate-c_variadic.rs b/tests/ui/feature-gates/feature-gate-c_variadic.rs index f189f02a26d..45c68842093 100644 --- a/tests/ui/feature-gates/feature-gate-c_variadic.rs +++ b/tests/ui/feature-gates/feature-gate-c_variadic.rs @@ -2,3 +2,9 @@ pub unsafe extern "C" fn test(_: i32, ap: ...) { } //~^ ERROR C-variadic functions are unstable + +trait Trait { + unsafe extern "C" fn trait_test(_: i32, ap: ...) { } + //~^ ERROR C-variadic functions are unstable + //~| ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention +} diff --git a/tests/ui/feature-gates/feature-gate-c_variadic.stderr b/tests/ui/feature-gates/feature-gate-c_variadic.stderr index 1b6a8c92af5..e30a2f1ede3 100644 --- a/tests/ui/feature-gates/feature-gate-c_variadic.stderr +++ b/tests/ui/feature-gates/feature-gate-c_variadic.stderr @@ -1,3 +1,9 @@ +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention + --> $DIR/feature-gate-c_variadic.rs:7:45 + | +LL | unsafe extern "C" fn trait_test(_: i32, ap: ...) { } + | ^^^^^^^ + error[E0658]: C-variadic functions are unstable --> $DIR/feature-gate-c_variadic.rs:3:1 | @@ -8,6 +14,16 @@ LL | pub unsafe extern "C" fn test(_: i32, ap: ...) { } = help: add `#![feature(c_variadic)]` 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 +error[E0658]: C-variadic functions are unstable + --> $DIR/feature-gate-c_variadic.rs:7:5 + | +LL | unsafe extern "C" fn trait_test(_: i32, ap: ...) { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #44930 <https://github.com/rust-lang/rust/issues/44930> for more information + = help: add `#![feature(c_variadic)]` 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-rustdoc_internals.rs b/tests/ui/feature-gates/feature-gate-rustdoc_internals.rs index 57d6b591287..0ad3b2aead4 100644 --- a/tests/ui/feature-gates/feature-gate-rustdoc_internals.rs +++ b/tests/ui/feature-gates/feature-gate-rustdoc_internals.rs @@ -2,6 +2,10 @@ /// wonderful mod foo {} +#[doc(attribute = "repr")] //~ ERROR: `#[doc(attribute)]` is meant for internal use only +/// wonderful +mod foo2 {} + trait Mine {} #[doc(fake_variadic)] //~ ERROR: `#[doc(fake_variadic)]` is meant for internal use only diff --git a/tests/ui/feature-gates/feature-gate-rustdoc_internals.stderr b/tests/ui/feature-gates/feature-gate-rustdoc_internals.stderr index f3c00a2156b..5a6d4d3b45e 100644 --- a/tests/ui/feature-gates/feature-gate-rustdoc_internals.stderr +++ b/tests/ui/feature-gates/feature-gate-rustdoc_internals.stderr @@ -8,8 +8,18 @@ LL | #[doc(keyword = "match")] = help: add `#![feature(rustdoc_internals)]` 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]: `#[doc(attribute)]` is meant for internal use only + --> $DIR/feature-gate-rustdoc_internals.rs:5:1 + | +LL | #[doc(attribute = "repr")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #90418 <https://github.com/rust-lang/rust/issues/90418> for more information + = help: add `#![feature(rustdoc_internals)]` 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]: `#[doc(fake_variadic)]` is meant for internal use only - --> $DIR/feature-gate-rustdoc_internals.rs:7:1 + --> $DIR/feature-gate-rustdoc_internals.rs:11:1 | LL | #[doc(fake_variadic)] | ^^^^^^^^^^^^^^^^^^^^^ @@ -19,7 +29,7 @@ LL | #[doc(fake_variadic)] = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date error[E0658]: `#[doc(search_unbox)]` is meant for internal use only - --> $DIR/feature-gate-rustdoc_internals.rs:10:1 + --> $DIR/feature-gate-rustdoc_internals.rs:14:1 | LL | #[doc(search_unbox)] | ^^^^^^^^^^^^^^^^^^^^ @@ -28,6 +38,6 @@ LL | #[doc(search_unbox)] = help: add `#![feature(rustdoc_internals)]` 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 +error: aborting due to 4 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-target-feature-inline-always.rs b/tests/ui/feature-gates/feature-gate-target-feature-inline-always.rs new file mode 100644 index 00000000000..181f9a21000 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-target-feature-inline-always.rs @@ -0,0 +1,9 @@ +//@ only-aarch64 +#[inline(always)] +//~^ ERROR cannot use `#[inline(always)]` with `#[target_feature]` +#[target_feature(enable="fp16")] +fn test() { + +} + +fn main() { } diff --git a/tests/ui/feature-gates/feature-gate-target-feature-inline-always.stderr b/tests/ui/feature-gates/feature-gate-target-feature-inline-always.stderr new file mode 100644 index 00000000000..de54844bc29 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-target-feature-inline-always.stderr @@ -0,0 +1,13 @@ +error[E0658]: cannot use `#[inline(always)]` with `#[target_feature]` + --> $DIR/feature-gate-target-feature-inline-always.rs:2:1 + | +LL | #[inline(always)] + | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #145574 <https://github.com/rust-lang/rust/issues/145574> for more information + = help: add `#![feature(target_feature_inline_always)]` 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/feature-gates/issue-43106-gating-of-builtin-attrs.rs b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs index 60666481bec..e5dae4c0069 100644 --- a/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs +++ b/tests/ui/feature-gates/issue-43106-gating-of-builtin-attrs.rs @@ -69,7 +69,7 @@ //~| WARN previously accepted //~| HELP can only be applied to //~| HELP remove the attribute -#![link()] //~ WARN attribute should be applied to an `extern` block +#![link(name = "x")] //~ WARN attribute should be applied to an `extern` block //~^ WARN this was previously accepted #![link_name = "1900"] //~^ WARN attribute cannot be used on @@ -482,21 +482,26 @@ mod no_implicit_prelude { #[reexport_test_harness_main = "2900"] //~^ WARN crate-level attribute should be +//~| HELP add a `!` mod reexport_test_harness_main { mod inner { #![reexport_test_harness_main="2900"] } //~^ WARN crate-level attribute should be #[reexport_test_harness_main = "2900"] fn f() { } //~^ WARN crate-level attribute should be + //~| HELP add a `!` #[reexport_test_harness_main = "2900"] struct S; //~^ WARN crate-level attribute should be + //~| HELP add a `!` #[reexport_test_harness_main = "2900"] type T = S; //~^ WARN crate-level attribute should be + //~| HELP add a `!` #[reexport_test_harness_main = "2900"] impl S { } //~^ WARN crate-level attribute should be + //~| HELP add a `!` } // Cannot feed "2700" to `#[macro_escape]` without signaling an error. @@ -534,21 +539,26 @@ mod macro_escape { #[no_std] //~^ WARN crate-level attribute should be an inner attribute +//~| HELP add a `!` mod no_std { mod inner { #![no_std] } //~^ WARN crate-level attribute should be in the root module #[no_std] fn f() { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[no_std] struct S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[no_std] type T = S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[no_std] impl S { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` } // At time of authorship, #[proc_macro_derive = "2500"] signals error @@ -682,38 +692,38 @@ mod link_section { // Note that this is a `check-pass` test, so it will never invoke the linker. -#[link()] +#[link(name = "x")] //~^ WARN attribute should be applied to an `extern` block //~| WARN this was previously accepted mod link { //~^ NOTE not an `extern` block - mod inner { #![link()] } + mod inner { #![link(name = "x")] } //~^ WARN attribute should be applied to an `extern` block //~| WARN this was previously accepted //~| NOTE not an `extern` block - #[link()] fn f() { } + #[link(name = "x")] fn f() { } //~^ WARN attribute should be applied to an `extern` block //~| WARN this was previously accepted //~| NOTE not an `extern` block - #[link()] struct S; + #[link(name = "x")] struct S; //~^ WARN attribute should be applied to an `extern` block //~| WARN this was previously accepted //~| NOTE not an `extern` block - #[link()] type T = S; + #[link(name = "x")] type T = S; //~^ WARN attribute should be applied to an `extern` block //~| WARN this was previously accepted //~| NOTE not an `extern` block - #[link()] impl S { } + #[link(name = "x")] impl S { } //~^ WARN attribute should be applied to an `extern` block //~| WARN this was previously accepted //~| NOTE not an `extern` block - #[link()] extern "Rust" {} + #[link(name = "x")] extern "Rust" {} //~^ WARN attribute should be applied to an `extern` block //~| WARN this was previously accepted } @@ -760,21 +770,26 @@ mod must_use { #[windows_subsystem = "windows"] //~^ WARN crate-level attribute should be an inner attribute +//~| HELP add a `!` mod windows_subsystem { mod inner { #![windows_subsystem="windows"] } //~^ WARN crate-level attribute should be in the root module #[windows_subsystem = "windows"] fn f() { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[windows_subsystem = "windows"] struct S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[windows_subsystem = "windows"] type T = S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[windows_subsystem = "windows"] impl S { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` } // BROKEN USES OF CRATE-LEVEL BUILT-IN ATTRIBUTES @@ -782,135 +797,170 @@ mod windows_subsystem { #[crate_name = "0900"] //~^ WARN crate-level attribute should be an inner attribute mod crate_name { +//~^ NOTE This attribute does not have an `!`, which means it is applied to this module mod inner { #![crate_name="0900"] } -//~^ WARN crate-level attribute should be in the root module +//~^ WARN the `#![crate_name]` attribute can only be used at the crate root #[crate_name = "0900"] fn f() { } //~^ WARN crate-level attribute should be an inner attribute + //~| NOTE This attribute does not have an `!`, which means it is applied to this function #[crate_name = "0900"] struct S; //~^ WARN crate-level attribute should be an inner attribute + //~| NOTE This attribute does not have an `!`, which means it is applied to this struct #[crate_name = "0900"] type T = S; //~^ WARN crate-level attribute should be an inner attribute + //~| NOTE This attribute does not have an `!`, which means it is applied to this type alias #[crate_name = "0900"] impl S { } //~^ WARN crate-level attribute should be an inner attribute + //~| NOTE This attribute does not have an `!`, which means it is applied to this implementation block } #[crate_type = "0800"] //~^ WARN crate-level attribute should be an inner attribute +//~| HELP add a `!` mod crate_type { mod inner { #![crate_type="0800"] } //~^ WARN crate-level attribute should be in the root module #[crate_type = "0800"] fn f() { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[crate_type = "0800"] struct S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[crate_type = "0800"] type T = S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[crate_type = "0800"] impl S { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` } #[feature(x0600)] //~^ WARN crate-level attribute should be an inner attribute +//~| HELP add a `!` mod feature { mod inner { #![feature(x0600)] } //~^ WARN crate-level attribute should be in the root module #[feature(x0600)] fn f() { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[feature(x0600)] struct S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[feature(x0600)] type T = S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[feature(x0600)] impl S { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` } #[no_main] //~^ WARN crate-level attribute should be an inner attribute +//~| HELP add a `!` mod no_main_1 { mod inner { #![no_main] } //~^ WARN crate-level attribute should be in the root module #[no_main] fn f() { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[no_main] struct S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[no_main] type T = S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[no_main] impl S { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` } #[no_builtins] //~^ WARN crate-level attribute should be an inner attribute +//~| HELP add a `!` mod no_builtins { mod inner { #![no_builtins] } //~^ WARN crate-level attribute should be in the root module #[no_builtins] fn f() { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[no_builtins] struct S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[no_builtins] type T = S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[no_builtins] impl S { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` } #[recursion_limit="0200"] //~^ WARN crate-level attribute should be an inner attribute +//~| HELP add a `!` mod recursion_limit { mod inner { #![recursion_limit="0200"] } //~^ WARN crate-level attribute should be in the root module #[recursion_limit="0200"] fn f() { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[recursion_limit="0200"] struct S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[recursion_limit="0200"] type T = S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[recursion_limit="0200"] impl S { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` } #[type_length_limit="0100"] //~^ WARN crate-level attribute should be an inner attribute +//~| HELP add a `!` mod type_length_limit { mod inner { #![type_length_limit="0100"] } //~^ WARN crate-level attribute should be in the root module #[type_length_limit="0100"] fn f() { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[type_length_limit="0100"] struct S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[type_length_limit="0100"] type T = S; //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` #[type_length_limit="0100"] impl S { } //~^ WARN crate-level attribute should be an inner attribute + //~| HELP add a `!` } fn main() {} 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 7488c68b59f..ef74a00e5a1 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 @@ -1,5 +1,5 @@ warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:506:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:511:17 | LL | mod inner { #![macro_escape] } | ^^^^^^^^^^^^^^^^ @@ -7,7 +7,7 @@ LL | mod inner { #![macro_escape] } = help: try an outer attribute: `#[macro_use]` warning: `#[macro_escape]` is a deprecated synonym for `#[macro_use]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:503:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:508:1 | LL | #[macro_escape] | ^^^^^^^^^^^^^^^ @@ -198,87 +198,126 @@ note: the lint level is defined here LL | #![warn(unused_attributes, unknown_lints)] | ^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` +warning: crate-level attribute should be an inner attribute --> $DIR/issue-43106-gating-of-builtin-attrs.rs:483:1 | LL | #[reexport_test_harness_main = "2900"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![reexport_test_harness_main = "2900"] + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:535:1 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:540:1 | LL | #[no_std] | ^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_std] + | + warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:685:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:695:1 | -LL | #[link()] - | ^^^^^^^^^ +LL | #[link(name = "x")] + | ^^^^^^^^^^^^^^^^^^^ ... LL | / mod link { LL | | LL | | -LL | | mod inner { #![link()] } +LL | | mod inner { #![link(name = "x")] } ... | LL | | } | |_- not an `extern` block | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:761:1 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:771:1 | LL | #[windows_subsystem = "windows"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:782:1 | -LL | #[crate_name = "0900"] - | ^^^^^^^^^^^^^^^^^^^^^^ +help: add a `!` + | +LL | #![windows_subsystem = "windows"] + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:801:1 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:821:1 | LL | #[crate_type = "0800"] | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![crate_type = "0800"] + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:820:1 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:845:1 | LL | #[feature(x0600)] | ^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![feature(x0600)] + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:840:1 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:870:1 | LL | #[no_main] | ^^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_main] + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:859:1 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:894:1 | LL | #[no_builtins] | ^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_builtins] + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:878:1 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:918:1 | LL | #[recursion_limit="0200"] | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![recursion_limit="0200"] + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:897:1 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:942:1 | LL | #[type_length_limit="0100"] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![type_length_limit="0100"] + | + warning: attribute should be applied to an `extern` block with non-Rust ABI --> $DIR/issue-43106-gating-of-builtin-attrs.rs:72:1 | -LL | #![link()] - | ^^^^^^^^^^ not an `extern` block +LL | #![link(name = "x")] + | ^^^^^^^^^^^^^^^^^^^^ not an `extern` block | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! @@ -321,352 +360,502 @@ LL | #[macro_export] impl S { } | ^^^^^^^^^^^^^^^ warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:486:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:487:17 | LL | mod inner { #![reexport_test_harness_main="2900"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:489:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:490:5 | LL | #[reexport_test_harness_main = "2900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![reexport_test_harness_main = "2900"] fn f() { } + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:492:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:494:5 | LL | #[reexport_test_harness_main = "2900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![reexport_test_harness_main = "2900"] struct S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:495:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:498:5 | LL | #[reexport_test_harness_main = "2900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![reexport_test_harness_main = "2900"] type T = S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:498:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:502:5 | LL | #[reexport_test_harness_main = "2900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![reexport_test_harness_main = "2900"] impl S { } + | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:538:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:544:17 | LL | mod inner { #![no_std] } | ^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:541:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:547:5 | LL | #[no_std] fn f() { } | ^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_std] fn f() { } + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:544:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:551:5 | LL | #[no_std] struct S; | ^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_std] struct S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:547:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:555:5 | LL | #[no_std] type T = S; | ^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_std] type T = S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:550:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:559:5 | LL | #[no_std] impl S { } | ^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_std] impl S { } + | + warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:691:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:701:17 | -LL | mod inner { #![link()] } - | ------------^^^^^^^^^^-- not an `extern` block +LL | mod inner { #![link(name = "x")] } + | ------------^^^^^^^^^^^^^^^^^^^^-- not an `extern` block | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:696:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:706:5 | -LL | #[link()] fn f() { } - | ^^^^^^^^^ ---------- not an `extern` block +LL | #[link(name = "x")] fn f() { } + | ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:701:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:711:5 | -LL | #[link()] struct S; - | ^^^^^^^^^ --------- not an `extern` block +LL | #[link(name = "x")] struct S; + | ^^^^^^^^^^^^^^^^^^^ --------- not an `extern` block | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:706:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:5 | -LL | #[link()] type T = S; - | ^^^^^^^^^ ----------- not an `extern` block +LL | #[link(name = "x")] type T = S; + | ^^^^^^^^^^^^^^^^^^^ ----------- not an `extern` block | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:711:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:721:5 | -LL | #[link()] impl S { } - | ^^^^^^^^^ ---------- not an `extern` block +LL | #[link(name = "x")] impl S { } + | ^^^^^^^^^^^^^^^^^^^ ---------- not an `extern` block | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: attribute should be applied to an `extern` block with non-Rust ABI - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:716:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:726:5 | -LL | #[link()] extern "Rust" {} - | ^^^^^^^^^ +LL | #[link(name = "x")] extern "Rust" {} + | ^^^^^^^^^^^^^^^^^^^ | = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:764:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:775:17 | LL | mod inner { #![windows_subsystem="windows"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:767:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:778:5 | LL | #[windows_subsystem = "windows"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![windows_subsystem = "windows"] fn f() { } + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:770:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:782:5 | LL | #[windows_subsystem = "windows"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:773:5 | -LL | #[windows_subsystem = "windows"] type T = S; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: add a `!` + | +LL | #![windows_subsystem = "windows"] struct S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:776:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:786:5 | -LL | #[windows_subsystem = "windows"] impl S { } +LL | #[windows_subsystem = "windows"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:785:17 | -LL | mod inner { #![crate_name="0900"] } - | ^^^^^^^^^^^^^^^^^^^^^ - -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:788:5 +help: add a `!` | -LL | #[crate_name = "0900"] fn f() { } - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | #![windows_subsystem = "windows"] type T = S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:791:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:790:5 | -LL | #[crate_name = "0900"] struct S; - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:794:5 +LL | #[windows_subsystem = "windows"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | -LL | #[crate_name = "0900"] type T = S; - | ^^^^^^^^^^^^^^^^^^^^^^ - -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:797:5 +help: add a `!` | -LL | #[crate_name = "0900"] impl S { } - | ^^^^^^^^^^^^^^^^^^^^^^ +LL | #![windows_subsystem = "windows"] impl S { } + | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:804:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:825:17 | LL | mod inner { #![crate_type="0800"] } | ^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:807:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:828:5 | LL | #[crate_type = "0800"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![crate_type = "0800"] fn f() { } + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:810:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:832:5 | LL | #[crate_type = "0800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![crate_type = "0800"] struct S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:813:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:836:5 | LL | #[crate_type = "0800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![crate_type = "0800"] type T = S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:816:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:840:5 | LL | #[crate_type = "0800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![crate_type = "0800"] impl S { } + | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:823:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:849:17 | LL | mod inner { #![feature(x0600)] } | ^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:826:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:5 | LL | #[feature(x0600)] fn f() { } | ^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![feature(x0600)] fn f() { } + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:829:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:856:5 | LL | #[feature(x0600)] struct S; | ^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![feature(x0600)] struct S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:832:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:860:5 | LL | #[feature(x0600)] type T = S; | ^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![feature(x0600)] type T = S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:835:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:864:5 | LL | #[feature(x0600)] impl S { } | ^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![feature(x0600)] impl S { } + | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:843:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:874:17 | LL | mod inner { #![no_main] } | ^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:846:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:877:5 | LL | #[no_main] fn f() { } | ^^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_main] fn f() { } + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:849:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:881:5 | LL | #[no_main] struct S; | ^^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_main] struct S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:852:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:885:5 | LL | #[no_main] type T = S; | ^^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_main] type T = S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:855:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:889:5 | LL | #[no_main] impl S { } | ^^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_main] impl S { } + | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:862:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:898:17 | LL | mod inner { #![no_builtins] } | ^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:865:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:901:5 | LL | #[no_builtins] fn f() { } | ^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_builtins] fn f() { } + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:868:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:905:5 | LL | #[no_builtins] struct S; | ^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_builtins] struct S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:871:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:909:5 | LL | #[no_builtins] type T = S; | ^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_builtins] type T = S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:874:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:913:5 | LL | #[no_builtins] impl S { } | ^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![no_builtins] impl S { } + | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:881:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:922:17 | LL | mod inner { #![recursion_limit="0200"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:884:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:925:5 | LL | #[recursion_limit="0200"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![recursion_limit="0200"] fn f() { } + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:887:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:929:5 | LL | #[recursion_limit="0200"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![recursion_limit="0200"] struct S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:890:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:933:5 | LL | #[recursion_limit="0200"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![recursion_limit="0200"] type T = S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:893:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:937:5 | LL | #[recursion_limit="0200"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![recursion_limit="0200"] impl S { } + | + warning: crate-level attribute should be in the root module - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:900:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:946:17 | LL | mod inner { #![type_length_limit="0100"] } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:903:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:949:5 | LL | #[type_length_limit="0100"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![type_length_limit="0100"] fn f() { } + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:906:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:953:5 | LL | #[type_length_limit="0100"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![type_length_limit="0100"] struct S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:909:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:957:5 | LL | #[type_length_limit="0100"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![type_length_limit="0100"] type T = S; + | + -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:912:5 +warning: crate-level attribute should be an inner attribute + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:961:5 | LL | #[type_length_limit="0100"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![type_length_limit="0100"] impl S { } + | + warning: `#[macro_use]` attribute cannot be used on functions --> $DIR/issue-43106-gating-of-builtin-attrs.rs:191:5 @@ -993,7 +1182,7 @@ LL | #[no_implicit_prelude] impl S { } = help: `#[no_implicit_prelude]` can be applied to modules and crates warning: `#[macro_escape]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:510:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:515:5 | LL | #[macro_escape] fn f() { } | ^^^^^^^^^^^^^^^ @@ -1002,7 +1191,7 @@ LL | #[macro_escape] fn f() { } = help: `#[macro_escape]` can be applied to modules, extern crates, and crates warning: `#[macro_escape]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:516:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:521:5 | LL | #[macro_escape] struct S; | ^^^^^^^^^^^^^^^ @@ -1011,7 +1200,7 @@ LL | #[macro_escape] struct S; = help: `#[macro_escape]` can be applied to modules, extern crates, and crates warning: `#[macro_escape]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:522:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:527:5 | LL | #[macro_escape] type T = S; | ^^^^^^^^^^^^^^^ @@ -1020,7 +1209,7 @@ LL | #[macro_escape] type T = S; = help: `#[macro_escape]` can be applied to modules, extern crates, and crates warning: `#[macro_escape]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:528:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:533:5 | LL | #[macro_escape] impl S { } | ^^^^^^^^^^^^^^^ @@ -1029,7 +1218,7 @@ LL | #[macro_escape] impl S { } = help: `#[macro_escape]` can be applied to modules, extern crates, and crates warning: `#[cold]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:571:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:581:1 | LL | #[cold] | ^^^^^^^ @@ -1038,7 +1227,7 @@ LL | #[cold] = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:578:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:588:17 | LL | mod inner { #![cold] } | ^^^^^^^^ @@ -1047,7 +1236,7 @@ LL | mod inner { #![cold] } = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:586:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:596:5 | LL | #[cold] struct S; | ^^^^^^^ @@ -1056,7 +1245,7 @@ LL | #[cold] struct S; = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:592:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:602:5 | LL | #[cold] type T = S; | ^^^^^^^ @@ -1065,7 +1254,7 @@ LL | #[cold] type T = S; = help: `#[cold]` can only be applied to functions warning: `#[cold]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:598:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:608:5 | LL | #[cold] impl S { } | ^^^^^^^ @@ -1074,7 +1263,7 @@ LL | #[cold] impl S { } = help: `#[cold]` can only be applied to functions warning: `#[link_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:605:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:615:1 | LL | #[link_name = "1900"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1083,7 +1272,7 @@ LL | #[link_name = "1900"] = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on foreign modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:611:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:621:5 | LL | #[link_name = "1900"] | ^^^^^^^^^^^^^^^^^^^^^ @@ -1092,7 +1281,7 @@ LL | #[link_name = "1900"] = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:618:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:628:17 | LL | mod inner { #![link_name="1900"] } | ^^^^^^^^^^^^^^^^^^^^ @@ -1101,7 +1290,7 @@ LL | mod inner { #![link_name="1900"] } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on functions - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:624:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:634:5 | LL | #[link_name = "1900"] fn f() { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1110,7 +1299,7 @@ LL | #[link_name = "1900"] fn f() { } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:630:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:640:5 | LL | #[link_name = "1900"] struct S; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1119,7 +1308,7 @@ LL | #[link_name = "1900"] struct S; = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:636:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:646:5 | LL | #[link_name = "1900"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^ @@ -1128,7 +1317,7 @@ LL | #[link_name = "1900"] type T = S; = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_name]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:642:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:652:5 | LL | #[link_name = "1900"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^ @@ -1137,7 +1326,7 @@ LL | #[link_name = "1900"] impl S { } = help: `#[link_name]` can be applied to foreign functions and foreign statics warning: `#[link_section]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:649:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:659:1 | LL | #[link_section = "1800"] | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1146,7 +1335,7 @@ LL | #[link_section = "1800"] = help: `#[link_section]` can be applied to statics and functions warning: `#[link_section]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:655:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:665:17 | LL | mod inner { #![link_section="1800"] } | ^^^^^^^^^^^^^^^^^^^^^^^ @@ -1155,7 +1344,7 @@ LL | mod inner { #![link_section="1800"] } = help: `#[link_section]` can be applied to statics and functions warning: `#[link_section]` attribute cannot be used on structs - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:663:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:673:5 | LL | #[link_section = "1800"] struct S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1164,7 +1353,7 @@ LL | #[link_section = "1800"] struct S; = help: `#[link_section]` can be applied to statics and functions warning: `#[link_section]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:669:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:679:5 | LL | #[link_section = "1800"] type T = S; | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1173,7 +1362,7 @@ LL | #[link_section = "1800"] type T = S; = help: `#[link_section]` can be applied to statics and functions warning: `#[link_section]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:675:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:685:5 | LL | #[link_section = "1800"] impl S { } | ^^^^^^^^^^^^^^^^^^^^^^^^ @@ -1182,7 +1371,7 @@ LL | #[link_section = "1800"] impl S { } = help: `#[link_section]` can be applied to statics and functions warning: `#[must_use]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:736:1 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:746:1 | LL | #[must_use] | ^^^^^^^^^^^ @@ -1191,7 +1380,7 @@ LL | #[must_use] = help: `#[must_use]` can be applied to functions, data types, unions, and traits warning: `#[must_use]` attribute cannot be used on modules - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:741:17 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:751:17 | LL | mod inner { #![must_use] } | ^^^^^^^^^^^^ @@ -1200,7 +1389,7 @@ LL | mod inner { #![must_use] } = help: `#[must_use]` can be applied to functions, data types, unions, and traits warning: `#[must_use]` attribute cannot be used on type aliases - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:750:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:760:5 | LL | #[must_use] type T = S; | ^^^^^^^^^^^ @@ -1209,7 +1398,7 @@ LL | #[must_use] type T = S; = help: `#[must_use]` can be applied to functions, data types, unions, and traits warning: `#[must_use]` attribute cannot be used on inherent impl blocks - --> $DIR/issue-43106-gating-of-builtin-attrs.rs:755:5 + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:765:5 | LL | #[must_use] impl S { } | ^^^^^^^^^^^ @@ -1217,6 +1406,76 @@ LL | #[must_use] impl S { } = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! = help: `#[must_use]` can be applied to functions, data types, unions, and traits +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:797:1 + | +LL | #[crate_name = "0900"] + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: This attribute does not have an `!`, which means it is applied to this module + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:799:1 + | +LL | / mod crate_name { +LL | | +LL | | mod inner { #![crate_name="0900"] } +... | +LL | | } + | |_^ + +warning: the `#![crate_name]` attribute can only be used at the crate root + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:801:17 + | +LL | mod inner { #![crate_name="0900"] } + | ^^^^^^^^^^^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:804:5 + | +LL | #[crate_name = "0900"] fn f() { } + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: This attribute does not have an `!`, which means it is applied to this function + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:804:28 + | +LL | #[crate_name = "0900"] fn f() { } + | ^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:808:5 + | +LL | #[crate_name = "0900"] struct S; + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: This attribute does not have an `!`, which means it is applied to this struct + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:808:28 + | +LL | #[crate_name = "0900"] struct S; + | ^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:812:5 + | +LL | #[crate_name = "0900"] type T = S; + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: This attribute does not have an `!`, which means it is applied to this type alias + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:812:28 + | +LL | #[crate_name = "0900"] type T = S; + | ^^^^^^^^^^^ + +warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:816:5 + | +LL | #[crate_name = "0900"] impl S { } + | ^^^^^^^^^^^^^^^^^^^^^^ + | +note: This attribute does not have an `!`, which means it is applied to this implementation block + --> $DIR/issue-43106-gating-of-builtin-attrs.rs:816:28 + | +LL | #[crate_name = "0900"] impl S { } + | ^^^^^^^^^^ + warning: `#[should_panic]` attribute cannot be used on crates --> $DIR/issue-43106-gating-of-builtin-attrs.rs:50:1 | diff --git a/tests/ui/fmt/format-string-wrong-order.rs b/tests/ui/fmt/format-string-wrong-order.rs index 891279b97e4..4d4e04ecd04 100644 --- a/tests/ui/fmt/format-string-wrong-order.rs +++ b/tests/ui/fmt/format-string-wrong-order.rs @@ -13,9 +13,11 @@ fn main() { format!("{?:#?}", bar); //~^ ERROR invalid format string: expected format parameter to occur after `:` format!("Hello {<5:}!", "x"); - //~^ ERROR invalid format string: expected format parameter to occur after `:` + //~^ ERROR invalid format string: expected alignment specifier after `:` in format string; example: `{:>?}` format!("Hello {^5:}!", "x"); - //~^ ERROR invalid format string: expected format parameter to occur after `:` + //~^ ERROR invalid format string: expected alignment specifier after `:` in format string; example: `{:>?}` format!("Hello {>5:}!", "x"); - //~^ ERROR invalid format string: expected format parameter to occur after `:` + //~^ ERROR invalid format string: expected alignment specifier after `:` in format string; example: `{:>?}` + println!("{0:#X>18}", 12345); + //~^ ERROR invalid format string: expected alignment specifier after `:` in format string; example: `{:>?}` } diff --git a/tests/ui/fmt/format-string-wrong-order.stderr b/tests/ui/fmt/format-string-wrong-order.stderr index 7f017511761..441ae6d2e50 100644 --- a/tests/ui/fmt/format-string-wrong-order.stderr +++ b/tests/ui/fmt/format-string-wrong-order.stderr @@ -50,23 +50,29 @@ LL | format!("{?:#?}", bar); | = note: `?` comes after `:`, try `:?` instead -error: invalid format string: expected format parameter to occur after `:` +error: invalid format string: expected alignment specifier after `:` in format string; example: `{:>?}` --> $DIR/format-string-wrong-order.rs:15:21 | LL | format!("Hello {<5:}!", "x"); | ^ expected `<` to occur after `:` in format string -error: invalid format string: expected format parameter to occur after `:` +error: invalid format string: expected alignment specifier after `:` in format string; example: `{:>?}` --> $DIR/format-string-wrong-order.rs:17:21 | LL | format!("Hello {^5:}!", "x"); | ^ expected `^` to occur after `:` in format string -error: invalid format string: expected format parameter to occur after `:` +error: invalid format string: expected alignment specifier after `:` in format string; example: `{:>?}` --> $DIR/format-string-wrong-order.rs:19:21 | LL | format!("Hello {>5:}!", "x"); | ^ expected `>` to occur after `:` in format string -error: aborting due to 9 previous errors +error: invalid format string: expected alignment specifier after `:` in format string; example: `{:>?}` + --> $DIR/format-string-wrong-order.rs:21:20 + | +LL | println!("{0:#X>18}", 12345); + | ^ expected `>` to occur after `:` in format string + +error: aborting due to 10 previous errors diff --git a/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.fixed b/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.fixed index b58c3a6720d..14d5de0261d 100644 --- a/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.fixed +++ b/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.fixed @@ -1,5 +1,5 @@ //@ run-rustfix -#![deny(unused_assignments, unused_variables)] +#![deny(unused_assignments)] #![allow(unused_mut)] struct Object; @@ -8,15 +8,15 @@ fn change_object(object: &mut Object) { //~ HELP you might have meant to mutate *object = object2; //~ ERROR mismatched types } -fn change_object2(object: &mut Object) { //~ ERROR variable `object` is assigned to, but never used - //~^ HELP you might have meant to mutate +fn change_object2(object: &mut Object) { + //~^ HELP you might have meant to mutate let object2 = Object; *object = object2; //~^ ERROR `object2` does not live long enough //~| ERROR value assigned to `object` is never read } -fn change_object3(object: &mut Object) { //~ ERROR variable `object` is assigned to, but never used +fn change_object3(object: &mut Object) { //~^ HELP you might have meant to mutate let mut object2 = Object; //~ HELP consider changing this to be mutable *object = object2; diff --git a/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs b/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs index 1fd222e0db1..5805afb3369 100644 --- a/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs +++ b/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs @@ -1,5 +1,5 @@ //@ run-rustfix -#![deny(unused_assignments, unused_variables)] +#![deny(unused_assignments)] #![allow(unused_mut)] struct Object; @@ -8,15 +8,15 @@ fn change_object(mut object: &Object) { //~ HELP you might have meant to mutate object = object2; //~ ERROR mismatched types } -fn change_object2(mut object: &Object) { //~ ERROR variable `object` is assigned to, but never used - //~^ HELP you might have meant to mutate +fn change_object2(mut object: &Object) { + //~^ HELP you might have meant to mutate let object2 = Object; object = &object2; //~^ ERROR `object2` does not live long enough //~| ERROR value assigned to `object` is never read } -fn change_object3(mut object: &mut Object) { //~ ERROR variable `object` is assigned to, but never used +fn change_object3(mut object: &mut Object) { //~^ HELP you might have meant to mutate let object2 = Object; //~ HELP consider changing this to be mutable object = &mut object2; diff --git a/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.stderr b/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.stderr index 0330853d922..c2c7378f07a 100644 --- a/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.stderr +++ b/tests/ui/fn/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.stderr @@ -23,7 +23,7 @@ LL | object = &object2; note: the lint level is defined here --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:2:9 | -LL | #![deny(unused_assignments, unused_variables)] +LL | #![deny(unused_assignments)] | ^^^^^^^^^^^^^^^^^^ help: you might have meant to mutate the pointed at value being passed in, instead of changing the reference in the local binding | @@ -33,19 +33,6 @@ LL | let object2 = Object; LL ~ *object = object2; | -error: variable `object` is assigned to, but never used - --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:11:23 - | -LL | fn change_object2(mut object: &Object) { - | ^^^^^^ - | - = note: consider using `_object` instead -note: the lint level is defined here - --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:2:29 - | -LL | #![deny(unused_assignments, unused_variables)] - | ^^^^^^^^^^^^^^^^ - error[E0597]: `object2` does not live long enough --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:14:13 | @@ -77,14 +64,6 @@ LL | let object2 = Object; LL ~ *object = object2; | -error: variable `object` is assigned to, but never used - --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:19:23 - | -LL | fn change_object3(mut object: &mut Object) { - | ^^^^^^ - | - = note: consider using `_object` instead - error[E0596]: cannot borrow `object2` as mutable, as it is not declared as mutable --> $DIR/mut-arg-of-borrowed-type-meant-to-be-arg-of-mut-borrow.rs:22:14 | @@ -96,7 +75,7 @@ help: consider changing this to be mutable LL | let mut object2 = Object; | +++ -error: aborting due to 7 previous errors +error: aborting due to 5 previous errors Some errors have detailed explanations: E0308, E0596, E0597. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/frontmatter/frontmatter-contains-whitespace.rs b/tests/ui/frontmatter/frontmatter-contains-whitespace.rs new file mode 100644 index 00000000000..11df822f793 --- /dev/null +++ b/tests/ui/frontmatter/frontmatter-contains-whitespace.rs @@ -0,0 +1,22 @@ +#!/usr/bin/env -S cargo -Zscript +---cargo +# Beware editing: it has numerous whitespace characters which are important. +# It contains one ranges from the 'PATTERN_WHITE_SPACE' property outlined in +# https://unicode.org/Public/UNIDATA/PropList.txt +# +# The characters in the first expression of the assertion can be generated +# from: "4\u{0C}+\n\t\r7\t*\u{20}2\u{85}/\u{200E}3\u{200F}*\u{2028}2\u{2029}" +package.description = """ +4+ + +7 * 2 /3* 2 +""" +--- + +//@ check-pass + +// Ensure the frontmatter can contain any whitespace + +#![feature(frontmatter)] + +fn main() {} diff --git a/tests/ui/frontmatter/frontmatter-crlf.rs b/tests/ui/frontmatter/frontmatter-crlf.rs new file mode 100644 index 00000000000..b46cc9ddbb0 --- /dev/null +++ b/tests/ui/frontmatter/frontmatter-crlf.rs @@ -0,0 +1,14 @@ +#!/usr/bin/env -S cargo -Zscript +--- +[dependencies] +clap = "4" +--- + +//@ check-pass +// ignore-tidy-cr + +// crlf line endings should be accepted + +#![feature(frontmatter)] + +fn main() {} diff --git a/tests/ui/frontmatter/frontmatter-whitespace-1.rs b/tests/ui/frontmatter/frontmatter-whitespace-1.rs index 8b6e2d1af84..3b7f762d26e 100644 --- a/tests/ui/frontmatter/frontmatter-whitespace-1.rs +++ b/tests/ui/frontmatter/frontmatter-whitespace-1.rs @@ -1,7 +1,7 @@ --- //~^ ERROR: invalid preceding whitespace for frontmatter opening +//~^^ ERROR: unclosed frontmatter --- -//~^ ERROR: invalid preceding whitespace for frontmatter close #![feature(frontmatter)] diff --git a/tests/ui/frontmatter/frontmatter-whitespace-1.stderr b/tests/ui/frontmatter/frontmatter-whitespace-1.stderr index 37ece27acb2..f16788fa399 100644 --- a/tests/ui/frontmatter/frontmatter-whitespace-1.stderr +++ b/tests/ui/frontmatter/frontmatter-whitespace-1.stderr @@ -10,17 +10,21 @@ note: frontmatter opening should not be preceded by whitespace LL | --- | ^^ -error: invalid preceding whitespace for frontmatter close - --> $DIR/frontmatter-whitespace-1.rs:3:1 +error: unclosed frontmatter + --> $DIR/frontmatter-whitespace-1.rs:1:3 | -LL | --- - | ^^^^^ +LL | / --- +LL | | +LL | | +LL | | --- +LL | | + | |_^ | -note: frontmatter close should not be preceded by whitespace - --> $DIR/frontmatter-whitespace-1.rs:3:1 +note: frontmatter opening here was not closed + --> $DIR/frontmatter-whitespace-1.rs:1:3 | LL | --- - | ^^ + | ^^^ error: aborting due to 2 previous errors diff --git a/tests/ui/frontmatter/frontmatter-whitespace-2.rs b/tests/ui/frontmatter/frontmatter-whitespace-2.rs index e8c100849b4..7a28e5c1b85 100644 --- a/tests/ui/frontmatter/frontmatter-whitespace-2.rs +++ b/tests/ui/frontmatter/frontmatter-whitespace-2.rs @@ -1,4 +1,5 @@ ---cargo +//~^ ERROR: unclosed frontmatter //@ compile-flags: --crate-type lib @@ -6,10 +7,8 @@ fn foo(x: i32) -> i32 { ---x - //~^ ERROR: invalid preceding whitespace for frontmatter close - //~| ERROR: extra characters after frontmatter close are not allowed + //~^ WARNING: use of a double negation [double_negations] } -//~^ ERROR: unexpected closing delimiter: `}` // this test is for the weird case that valid Rust code can have three dashes // within them and get treated as a frontmatter close. diff --git a/tests/ui/frontmatter/frontmatter-whitespace-2.stderr b/tests/ui/frontmatter/frontmatter-whitespace-2.stderr index ada6af0ec04..2ae63cdc6fe 100644 --- a/tests/ui/frontmatter/frontmatter-whitespace-2.stderr +++ b/tests/ui/frontmatter/frontmatter-whitespace-2.stderr @@ -1,26 +1,30 @@ -error: invalid preceding whitespace for frontmatter close - --> $DIR/frontmatter-whitespace-2.rs:8:1 +error: unclosed frontmatter + --> $DIR/frontmatter-whitespace-2.rs:1:1 | -LL | ---x - | ^^^^^^^^ +LL | / ---cargo +... | +LL | | + | |_^ | -note: frontmatter close should not be preceded by whitespace - --> $DIR/frontmatter-whitespace-2.rs:8:1 +note: frontmatter opening here was not closed + --> $DIR/frontmatter-whitespace-2.rs:1:1 | -LL | ---x - | ^^^^ +LL | ---cargo + | ^^^ -error: extra characters after frontmatter close are not allowed - --> $DIR/frontmatter-whitespace-2.rs:8:1 +warning: use of a double negation + --> $DIR/frontmatter-whitespace-2.rs:9:6 | LL | ---x - | ^^^^^^^^ - -error: unexpected closing delimiter: `}` - --> $DIR/frontmatter-whitespace-2.rs:11:1 + | ^^^ + | + = note: the prefix `--` could be misinterpreted as a decrement operator which exists in other languages + = note: use `-= 1` if you meant to decrement the value + = note: `#[warn(double_negations)]` on by default +help: add parentheses for clarity | -LL | } - | ^ unexpected closing delimiter +LL | --(-x) + | + + -error: aborting due to 3 previous errors +error: aborting due to 1 previous error; 1 warning emitted diff --git a/tests/ui/frontmatter/frontmatter-whitespace-3.rs b/tests/ui/frontmatter/frontmatter-whitespace-3.rs index 95e0981e2ae..6580514fba2 100644 --- a/tests/ui/frontmatter/frontmatter-whitespace-3.rs +++ b/tests/ui/frontmatter/frontmatter-whitespace-3.rs @@ -1,7 +1,7 @@ ----cargo ---- +---cargo +--- // please note the whitespace characters after the first four lines. // This ensures that we accept whitespaces before the frontmatter, after @@ -10,6 +10,7 @@ //@ check-pass // ignore-tidy-end-whitespace // ignore-tidy-leading-newlines +// ignore-tidy-tab #![feature(frontmatter)] diff --git a/tests/ui/frontmatter/frontmatter-whitespace-4.rs b/tests/ui/frontmatter/frontmatter-whitespace-4.rs index 3bda3227838..1e7c5556647 100644 --- a/tests/ui/frontmatter/frontmatter-whitespace-4.rs +++ b/tests/ui/frontmatter/frontmatter-whitespace-4.rs @@ -1,7 +1,8 @@ ---- cargo +--- cargo --- //@ check-pass +// ignore-tidy-tab // A frontmatter infostring can have leading whitespace. #![feature(frontmatter)] diff --git a/tests/ui/frontmatter/multifrontmatter-2.rs b/tests/ui/frontmatter/multifrontmatter-2.rs index 33cc30cb465..8e5b45a0bf7 100644 --- a/tests/ui/frontmatter/multifrontmatter-2.rs +++ b/tests/ui/frontmatter/multifrontmatter-2.rs @@ -1,12 +1,12 @@ --- --- -//~^ ERROR: invalid preceding whitespace for frontmatter close --- -//~^ ERROR: expected item, found `-` -// FIXME(frontmatter): make this diagnostic better --- +// hyphens only need to be escaped when at the start of a line +//@ check-pass + #![feature(frontmatter)] fn main() {} diff --git a/tests/ui/frontmatter/multifrontmatter-2.stderr b/tests/ui/frontmatter/multifrontmatter-2.stderr deleted file mode 100644 index ed9ac4029e2..00000000000 --- a/tests/ui/frontmatter/multifrontmatter-2.stderr +++ /dev/null @@ -1,22 +0,0 @@ -error: invalid preceding whitespace for frontmatter close - --> $DIR/multifrontmatter-2.rs:2:1 - | -LL | --- - | ^^^^ - | -note: frontmatter close should not be preceded by whitespace - --> $DIR/multifrontmatter-2.rs:2:1 - | -LL | --- - | ^ - -error: expected item, found `-` - --> $DIR/multifrontmatter-2.rs:5:2 - | -LL | --- - | ^ expected item - | - = note: for a full list of items that can appear in modules, see <https://doc.rust-lang.org/reference/items.html> - -error: aborting due to 2 previous errors - diff --git a/tests/ui/issues/issue-54696.rs b/tests/ui/function-pointer/function-pointer-comparison-54696.rs index 63ffbe42bcc..2e28dfeaaf8 100644 --- a/tests/ui/issues/issue-54696.rs +++ b/tests/ui/function-pointer/function-pointer-comparison-54696.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/54696 //@ run-pass #![allow(unpredictable_function_pointer_comparisons)] diff --git a/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.next.stderr b/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.next.stderr index d624fb1e42b..d6294efbd28 100644 --- a/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.next.stderr +++ b/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.next.stderr @@ -1,30 +1,14 @@ -error[E0283]: type annotations needed - --> $DIR/ambig-hr-projection-issue-93340.rs:17:5 +error[E0282]: type annotations needed + --> $DIR/ambig-hr-projection-issue-93340.rs:16:5 | LL | cmp_eq | ^^^^^^ cannot infer type of the type parameter `A` declared on the function `cmp_eq` | - = note: cannot satisfy `_: Scalar` -note: required by a bound in `cmp_eq` - --> $DIR/ambig-hr-projection-issue-93340.rs:10:22 - | -LL | fn cmp_eq<'a, 'b, A: Scalar, B: Scalar, O: Scalar>(a: A::RefType<'a>, b: B::RefType<'b>) -> O { - | ^^^^^^ required by this bound in `cmp_eq` help: consider specifying the generic arguments | LL | cmp_eq::<A, B, O> | +++++++++++ -error[E0277]: expected a `Fn(<A as Scalar>::RefType<'_>, <B as Scalar>::RefType<'_>)` closure, found `for<'a, 'b> fn(<O as Scalar>::RefType<'a>, <_ as Scalar>::RefType<'b>) -> O {cmp_eq::<O, _, O>}` - --> $DIR/ambig-hr-projection-issue-93340.rs:14:1 - | -LL | / fn build_expression<A: Scalar, B: Scalar, O: Scalar>( -LL | | ) -> impl Fn(A::RefType<'_>, B::RefType<'_>) -> O { - | |_________________________________________________^ expected an `Fn(<A as Scalar>::RefType<'_>, <B as Scalar>::RefType<'_>)` closure, found `for<'a, 'b> fn(<O as Scalar>::RefType<'a>, <_ as Scalar>::RefType<'b>) -> O {cmp_eq::<O, _, O>}` - | - = help: the trait `for<'a, 'b> Fn(<A as Scalar>::RefType<'a>, <B as Scalar>::RefType<'b>)` is not implemented for fn item `for<'a, 'b> fn(<O as Scalar>::RefType<'a>, <_ as Scalar>::RefType<'b>) -> O {cmp_eq::<O, _, O>}` - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0277, E0283. -For more information about an error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.old.stderr b/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.old.stderr index 4a293d44e0e..d913b2e91ca 100644 --- a/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.old.stderr +++ b/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.old.stderr @@ -1,5 +1,5 @@ error[E0283]: type annotations needed - --> $DIR/ambig-hr-projection-issue-93340.rs:17:5 + --> $DIR/ambig-hr-projection-issue-93340.rs:16:5 | LL | cmp_eq | ^^^^^^ cannot infer type of the type parameter `A` declared on the function `cmp_eq` diff --git a/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.rs b/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.rs index 6ba3c4c65d0..acfebad38db 100644 --- a/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.rs +++ b/tests/ui/generic-associated-types/ambig-hr-projection-issue-93340.rs @@ -13,7 +13,6 @@ fn cmp_eq<'a, 'b, A: Scalar, B: Scalar, O: Scalar>(a: A::RefType<'a>, b: B::RefT fn build_expression<A: Scalar, B: Scalar, O: Scalar>( ) -> impl Fn(A::RefType<'_>, B::RefType<'_>) -> O { - //[next]~^^ ERROR expected a `Fn(<A as Scalar>::RefType<'_>, <B as Scalar>::RefType<'_>)` closure cmp_eq //~^ ERROR type annotations needed } diff --git a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-enum.rs b/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.rs index 0b1857ae3df..00bf66dd4e0 100644 --- a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-enum.rs +++ b/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5997 fn f<Z>() -> bool { enum E { V(Z) } //~^ ERROR can't use generic parameters from outer item diff --git a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-enum.stderr b/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.stderr index c0b3cd6de66..aea0f049b07 100644 --- a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-enum.stderr +++ b/tests/ui/generics/enum-definition-with-outer-generic-parameter-5997.stderr @@ -1,5 +1,5 @@ error[E0401]: can't use generic parameters from outer item - --> $DIR/issue-5997-enum.rs:2:16 + --> $DIR/enum-definition-with-outer-generic-parameter-5997.rs:3:16 | LL | fn f<Z>() -> bool { | - type parameter from outer item diff --git a/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr b/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr index d7add865aa0..2e3fd612334 100644 --- a/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr +++ b/tests/ui/higher-ranked/higher-ranked-lifetime-error.stderr @@ -2,7 +2,7 @@ error: implementation of `FnMut` is not general enough --> $DIR/higher-ranked-lifetime-error.rs:12:5 | LL | assert_all::<_, &String>(id); - | ^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnMut` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnMut` is not general enough | = note: `for<'a> fn(&'a String) -> &'a String {id}` must implement `FnMut<(&String,)>` = note: ...but it actually implements `FnMut<(&'0 String,)>`, for some specific lifetime `'0` diff --git a/tests/ui/higher-ranked/trait-bounds/due-to-where-clause.stderr b/tests/ui/higher-ranked/trait-bounds/due-to-where-clause.stderr index 916854e07af..6c17b1f4874 100644 --- a/tests/ui/higher-ranked/trait-bounds/due-to-where-clause.stderr +++ b/tests/ui/higher-ranked/trait-bounds/due-to-where-clause.stderr @@ -2,7 +2,7 @@ error: implementation of `Foo` is not general enough --> $DIR/due-to-where-clause.rs:2:5 | LL | test::<FooS>(&mut 42); - | ^^^^^^^^^^^^ implementation of `Foo` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^ implementation of `Foo` is not general enough | = note: `FooS<'_>` must implement `Foo<'0>`, for any lifetime `'0`... = note: ...but `FooS<'_>` actually implements `Foo<'1>`, for some specific lifetime `'1` diff --git a/tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr b/tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr index 5caf0eb2fd4..7170efc8638 100644 --- a/tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr +++ b/tests/ui/impl-trait/auto-trait-selection-freeze.next.stderr @@ -1,17 +1,9 @@ -error[E0283]: type annotations needed +error[E0282]: type annotations needed --> $DIR/auto-trait-selection-freeze.rs:19:16 | LL | if false { is_trait(foo()) } else { Default::default() } - | ^^^^^^^^ ----- type must be known at this point - | | - | cannot infer type of the type parameter `T` declared on the function `is_trait` + | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `is_trait` | - = note: cannot satisfy `_: Trait<_>` -note: required by a bound in `is_trait` - --> $DIR/auto-trait-selection-freeze.rs:11:16 - | -LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U { - | ^^^^^^^^ required by this bound in `is_trait` help: consider specifying the generic arguments | LL | if false { is_trait::<T, U>(foo()) } else { Default::default() } @@ -19,4 +11,4 @@ LL | if false { is_trait::<T, U>(foo()) } else { Default::default() } error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/impl-trait/auto-trait-selection.next.stderr b/tests/ui/impl-trait/auto-trait-selection.next.stderr index d34fdcc4496..0f33aca3019 100644 --- a/tests/ui/impl-trait/auto-trait-selection.next.stderr +++ b/tests/ui/impl-trait/auto-trait-selection.next.stderr @@ -1,17 +1,9 @@ -error[E0283]: type annotations needed +error[E0282]: type annotations needed --> $DIR/auto-trait-selection.rs:15:16 | LL | if false { is_trait(foo()) } else { Default::default() } - | ^^^^^^^^ ----- type must be known at this point - | | - | cannot infer type of the type parameter `T` declared on the function `is_trait` + | ^^^^^^^^ cannot infer type of the type parameter `T` declared on the function `is_trait` | - = note: cannot satisfy `_: Trait<_>` -note: required by a bound in `is_trait` - --> $DIR/auto-trait-selection.rs:7:16 - | -LL | fn is_trait<T: Trait<U>, U: Default>(_: T) -> U { - | ^^^^^^^^ required by this bound in `is_trait` help: consider specifying the generic arguments | LL | if false { is_trait::<T, U>(foo()) } else { Default::default() } @@ -19,4 +11,4 @@ LL | if false { is_trait::<T, U>(foo()) } else { Default::default() } error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/impl-trait/call_method_without_import.no_import.stderr b/tests/ui/impl-trait/call_method_without_import.no_import.stderr index dbac74b2247..2ca79aa7c10 100644 --- a/tests/ui/impl-trait/call_method_without_import.no_import.stderr +++ b/tests/ui/impl-trait/call_method_without_import.no_import.stderr @@ -3,6 +3,7 @@ error[E0599]: no method named `fmt` found for opaque type `impl Debug` in the cu | LL | x.fmt(f); | ^^^ method not found in `impl Debug` + | --> $SRC_DIR/core/src/fmt/mod.rs:LL:COL | = note: the method is available for `impl Debug` here diff --git a/tests/ui/impl-trait/impl-generic-mismatch.stderr b/tests/ui/impl-trait/impl-generic-mismatch.stderr index 18347bd0f97..d7fff4c445d 100644 --- a/tests/ui/impl-trait/impl-generic-mismatch.stderr +++ b/tests/ui/impl-trait/impl-generic-mismatch.stderr @@ -48,6 +48,7 @@ error[E0643]: method `hash` has incompatible signature for trait | LL | fn hash(&self, hasher: &mut impl Hasher) {} | ^^^^^^^^^^^ expected generic parameter, found `impl Trait` + | --> $SRC_DIR/core/src/hash/mod.rs:LL:COL | = note: declaration in trait here diff --git a/tests/ui/impl-trait/non-defining-uses/as-projection-term.next.stderr b/tests/ui/impl-trait/non-defining-uses/as-projection-term.next.stderr deleted file mode 100644 index 96e242d5d48..00000000000 --- a/tests/ui/impl-trait/non-defining-uses/as-projection-term.next.stderr +++ /dev/null @@ -1,8 +0,0 @@ -error: non-defining use of `impl Sized + '_` in the defining scope - --> $DIR/as-projection-term.rs:14:19 - | -LL | prove_proj(|| recur()); - | ^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/impl-trait/non-defining-uses/as-projection-term.rs b/tests/ui/impl-trait/non-defining-uses/as-projection-term.rs index f0cf333b6a1..19f983bab70 100644 --- a/tests/ui/impl-trait/non-defining-uses/as-projection-term.rs +++ b/tests/ui/impl-trait/non-defining-uses/as-projection-term.rs @@ -1,7 +1,7 @@ //@ revisions: current next //@[next] compile-flags: -Znext-solver //@ ignore-compare-mode-next-solver (explicit revisions) -//@[current] check-pass +//@ check-pass fn prove_proj<R>(_: impl FnOnce() -> R) {} fn recur<'a>() -> impl Sized + 'a { @@ -12,6 +12,6 @@ fn recur<'a>() -> impl Sized + 'a { // inference variable at this point, we unify it with `opaque<'1>` and // end up ignoring that defining use as the hidden type is equal to its key. prove_proj(|| recur()); - //[next]~^ ERROR non-defining use of `impl Sized + '_` in the defining scope } + fn main() {} diff --git a/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.current.stderr b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.current.stderr new file mode 100644 index 00000000000..30424ec58f9 --- /dev/null +++ b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.current.stderr @@ -0,0 +1,17 @@ +error[E0792]: expected generic type parameter, found `impl Foo` + --> $DIR/double-wrap-with-defining-use.rs:12:26 + | +LL | fn a<T: Foo>(x: T) -> impl Foo { + | - this generic parameter must be used with a generic type parameter +LL | if true { x } else { a(a(x)) } + | ^^^^^^^ + +error: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias + --> $DIR/double-wrap-with-defining-use.rs:12:26 + | +LL | if true { x } else { a(a(x)) } + | ^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.rs b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.rs index 339277fec37..734b1920772 100644 --- a/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.rs +++ b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.rs @@ -1,12 +1,17 @@ // Regression test for ICE from issue #140545 // The error message is confusing and wrong, but that's a different problem (#139350) + //@ edition:2018 +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] check-pass trait Foo {} -fn a(x: impl Foo) -> impl Foo { +fn a<T: Foo>(x: T) -> impl Foo { if true { x } else { a(a(x)) } - //~^ ERROR: expected generic type parameter, found `impl Foo` [E0792] - //~| ERROR: type parameter `impl Foo` is part of concrete type but not used in parameter list for the `impl Trait` type alias + //[current]~^ ERROR: expected generic type parameter, found `impl Foo` [E0792] + //[current]~| ERROR: type parameter `T` is part of concrete type but not used in parameter list for the `impl Trait` type alias } fn main(){} diff --git a/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.stderr b/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.stderr deleted file mode 100644 index 1b02811e31b..00000000000 --- a/tests/ui/impl-trait/non-defining-uses/double-wrap-with-defining-use.stderr +++ /dev/null @@ -1,17 +0,0 @@ -error[E0792]: expected generic type parameter, found `impl Foo` - --> $DIR/double-wrap-with-defining-use.rs:7:26 - | -LL | fn a(x: impl Foo) -> impl Foo { - | -------- this generic parameter must be used with a generic type parameter -LL | if true { x } else { a(a(x)) } - | ^^^^^^^ - -error: type parameter `impl Foo` is part of concrete type but not used in parameter list for the `impl Trait` type alias - --> $DIR/double-wrap-with-defining-use.rs:7:26 - | -LL | if true { x } else { a(a(x)) } - | ^^^^^^^ - -error: aborting due to 2 previous errors - -For more information about this error, try `rustc --explain E0792`. diff --git a/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.current.stderr b/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.current.stderr new file mode 100644 index 00000000000..ccbe2d3593c --- /dev/null +++ b/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.current.stderr @@ -0,0 +1,29 @@ +error[E0277]: the trait bound `(): ReturnsSend` is not satisfied + --> $DIR/ice-issue-146191.rs:6:52 + | +LL | fn create_complex_future() -> impl Future<Output = impl ReturnsSend> { + | ^^^^^^^^^^^^^^^^ the trait `ReturnsSend` is not implemented for `()` + | +help: this trait has no implementations, consider adding one + --> $DIR/ice-issue-146191.rs:14:1 + | +LL | trait ReturnsSend {} + | ^^^^^^^^^^^^^^^^^ +note: required by a bound in an opaque type + --> $DIR/ice-issue-146191.rs:6:57 + | +LL | fn create_complex_future() -> impl Future<Output = impl ReturnsSend> { + | ^^^^^^^^^^^ + +error[E0733]: recursion in an async block requires boxing + --> $DIR/ice-issue-146191.rs:8:5 + | +LL | async { create_complex_future().await } + | ^^^^^ ----------------------------- recursive call here + | + = note: a recursive `async fn` call must introduce indirection such as `Box::pin` to avoid an infinitely sized future + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0277, E0733. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.next.stderr b/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.next.stderr new file mode 100644 index 00000000000..e8b551c65fc --- /dev/null +++ b/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.next.stderr @@ -0,0 +1,17 @@ +error[E0282]: type annotations needed + --> $DIR/ice-issue-146191.rs:8:5 + | +LL | async { create_complex_future().await } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type + +error[E0282]: type annotations needed + --> $DIR/ice-issue-146191.rs:8:5 + | +LL | async { create_complex_future().await } + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type + | + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.rs b/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.rs new file mode 100644 index 00000000000..356f7d01eb9 --- /dev/null +++ b/tests/ui/impl-trait/non-defining-uses/ice-issue-146191.rs @@ -0,0 +1,15 @@ +//@ edition: 2024 +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) + +fn create_complex_future() -> impl Future<Output = impl ReturnsSend> { + //[current]~^ ERROR the trait bound `(): ReturnsSend` is not satisfied + async { create_complex_future().await } + //[current]~^ ERROR recursion in an async block requires + //[next]~^^ ERROR type annotations needed + //[next]~| ERROR type annotations needed +} + +trait ReturnsSend {} +fn main() {} diff --git a/tests/ui/impl-trait/non-defining-uses/recursive-call.rs b/tests/ui/impl-trait/non-defining-uses/recursive-call.rs new file mode 100644 index 00000000000..ecddf2cec47 --- /dev/null +++ b/tests/ui/impl-trait/non-defining-uses/recursive-call.rs @@ -0,0 +1,30 @@ +//@ revisions: current next +//@[next] compile-flags: -Znext-solver +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ check-pass + +// Regression test for the non-defining use error in `gll`. + +struct Foo; +impl Foo { + fn recur(&self, b: bool) -> impl Sized + '_ { + if b { + let temp = Foo; + temp.recur(false); + // desugars to `Foo::recur(&temp);` + } + + self + } + + fn in_closure(&self) -> impl Sized + '_ { + let _ = || { + let temp = Foo; + temp.in_closure(); + // desugars to `Foo::in_closure(&temp);` + }; + + self + } +} +fn main() {} diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr b/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr index 080c3284641..11a88b0918c 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.current.stderr @@ -11,7 +11,7 @@ LL | fn build2<T>(x: T) -> impl Sized { | ^^^^^^^^^^ error[E0720]: cannot resolve opaque type - --> $DIR/recursive-in-exhaustiveness.rs:39:23 + --> $DIR/recursive-in-exhaustiveness.rs:37:23 | LL | fn build3<T>(x: T) -> impl Sized { | ^^^^^^^^^^ diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr b/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr index db57be73acc..45df8cc9c0c 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.next.stderr @@ -1,80 +1,21 @@ -error[E0284]: type annotations needed: cannot normalize `build<_>::{opaque#0}` - --> $DIR/recursive-in-exhaustiveness.rs:20:5 +error[E0282]: type annotations needed + --> $DIR/recursive-in-exhaustiveness.rs:19:17 | -LL | build(x) - | ^^^^^^^^ cannot normalize `build<_>::{opaque#0}` +LL | let (x,) = (build(x),); + | ^^^^^^^^ cannot infer type -error[E0271]: type mismatch resolving `build2<(_,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:30:6 +error[E0282]: type annotations needed + --> $DIR/recursive-in-exhaustiveness.rs:29:17 | -LL | (build2(x),) - | ^^^^^^^^^ types differ +LL | let (x,) = (build2(x),); + | ^^^^^^^^^ cannot infer type -error[E0271]: type mismatch resolving `build2<(_,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:30:5 +error[E0282]: type annotations needed + --> $DIR/recursive-in-exhaustiveness.rs:40:5 | -LL | (build2(x),) - | ^^^^^^^^^^^^ types differ +LL | build3(x) + | ^^^^^^^^^ cannot infer type -error[E0277]: the size for values of type `(impl Sized,)` cannot be known at compilation time - --> $DIR/recursive-in-exhaustiveness.rs:30:5 - | -LL | (build2(x),) - | ^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `(impl Sized,)` - = note: tuples must have a statically known size to be initialized - -error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:41:17 - | -LL | let (x,) = (build3((x,)),); - | ^^^^^^^^^^^^ types differ - -error[E0277]: the size for values of type `(impl Sized,)` cannot be known at compilation time - --> $DIR/recursive-in-exhaustiveness.rs:41:16 - | -LL | let (x,) = (build3((x,)),); - | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `(impl Sized,)` - = note: tuples must have a statically known size to be initialized - -error[E0308]: mismatched types - --> $DIR/recursive-in-exhaustiveness.rs:41:16 - | -LL | fn build3<T>(x: T) -> impl Sized { - | ---------- the found opaque type -LL | -LL | let (x,) = (build3((x,)),); - | ^^^^^^^^^^^^^^^ types differ - | - = note: expected type `_` - found tuple `(impl Sized,)` - -error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:41:17 - | -LL | let (x,) = (build3((x,)),); - | ^^^^^^^^^^^^ types differ - | - = note: the return type of a function must have a statically known size - -error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:41:16 - | -LL | let (x,) = (build3((x,)),); - | ^^^^^^^^^^^^^^^ types differ - -error[E0271]: type mismatch resolving `build3<(T,)>::{opaque#0} normalizes-to _` - --> $DIR/recursive-in-exhaustiveness.rs:41:17 - | -LL | let (x,) = (build3((x,)),); - | ^^^^^^^^^^^^ types differ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` - -error: aborting due to 10 previous errors +error: aborting due to 3 previous errors -Some errors have detailed explanations: E0271, E0277, E0284, E0308. -For more information about an error, try `rustc --explain E0271`. +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/impl-trait/recursive-in-exhaustiveness.rs b/tests/ui/impl-trait/recursive-in-exhaustiveness.rs index dabef22af86..7aee8a630a5 100644 --- a/tests/ui/impl-trait/recursive-in-exhaustiveness.rs +++ b/tests/ui/impl-trait/recursive-in-exhaustiveness.rs @@ -17,8 +17,8 @@ fn build<T>(x: T) -> impl Sized { //[current]~^ ERROR cannot resolve opaque type let (x,) = (build(x),); + //[next]~^ ERROR type annotations needed build(x) - //[next]~^ ERROR type annotations needed: cannot normalize `build<_>::{opaque#0}` } // Opaque<T> = (Opaque<T>,) @@ -27,10 +27,8 @@ fn build<T>(x: T) -> impl Sized { fn build2<T>(x: T) -> impl Sized { //[current]~^ ERROR cannot resolve opaque type let (x,) = (build2(x),); + //[next]~^ ERROR type annotations needed (build2(x),) - //[next]~^ ERROR type mismatch resolving - //[next]~| ERROR type mismatch resolving - //[next]~| ERROR the size for values of type } // Opaque<T> = Opaque<(T,)> @@ -39,13 +37,8 @@ fn build2<T>(x: T) -> impl Sized { fn build3<T>(x: T) -> impl Sized { //[current]~^ ERROR cannot resolve opaque type let (x,) = (build3((x,)),); - //[next]~^ ERROR type mismatch resolving - //[next]~| ERROR type mismatch resolving - //[next]~| ERROR type mismatch resolving - //[next]~| ERROR type mismatch resolving - //[next]~| ERROR the size for values of type - //[next]~| ERROR mismatched types build3(x) + //[next]~^ ERROR type annotations needed } fn main() {} diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr b/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr index fac4776905d..785e5fdeb64 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.next.stderr @@ -1,9 +1,15 @@ error[E0282]: type annotations needed - --> $DIR/two_tait_defining_each_other2.rs:12:11 + --> $DIR/two_tait_defining_each_other2.rs:12:8 | LL | fn muh(x: A) -> B { - | ^ cannot infer type + | ^ cannot infer type -error: aborting due to 1 previous error +error[E0282]: type annotations needed + --> $DIR/two_tait_defining_each_other2.rs:14:5 + | +LL | x // B's hidden type is A (opaquely) + | ^ cannot infer type + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/impl-trait/two_tait_defining_each_other2.rs b/tests/ui/impl-trait/two_tait_defining_each_other2.rs index ec2963249f9..99262f4bc4b 100644 --- a/tests/ui/impl-trait/two_tait_defining_each_other2.rs +++ b/tests/ui/impl-trait/two_tait_defining_each_other2.rs @@ -12,7 +12,8 @@ trait Foo {} fn muh(x: A) -> B { //[next]~^ ERROR: type annotations needed x // B's hidden type is A (opaquely) - //[current]~^ ERROR opaque type's hidden type cannot be another opaque type + //[next]~^ ERROR: type annotations needed + //[current]~^^ ERROR opaque type's hidden type cannot be another opaque type } struct Bar; diff --git a/tests/ui/imports/overwritten-extern-flag-ambig.rs b/tests/ui/imports/overwritten-extern-flag-ambig.rs new file mode 100644 index 00000000000..80f394d34de --- /dev/null +++ b/tests/ui/imports/overwritten-extern-flag-ambig.rs @@ -0,0 +1,13 @@ +// Test for issue #145575. + +//@ check-pass +//@ edition: 2018 + +extern crate core as std; + +mod inner { + use crate::*; + use std::str; // OK for now +} + +fn main() {} diff --git a/tests/ui/imports/suggest-remove-issue-121315.stderr b/tests/ui/imports/suggest-remove-issue-121315.stderr index 5d0bf9bea6a..c91ea8a8793 100644 --- a/tests/ui/imports/suggest-remove-issue-121315.stderr +++ b/tests/ui/imports/suggest-remove-issue-121315.stderr @@ -3,10 +3,10 @@ error: the item `TryFrom` is imported redundantly | LL | use std::convert::TryFrom; | ^^^^^^^^^^^^^^^^^^^^^ + | --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | = note: the item `TryFrom` is already defined here - | note: the lint level is defined here --> $DIR/suggest-remove-issue-121315.rs:2:25 | @@ -18,6 +18,7 @@ error: the item `TryFrom` is imported redundantly | LL | use std::convert::{TryFrom, TryInto}; | ^^^^^^^ + | --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | = note: the item `TryFrom` is already defined here @@ -27,6 +28,7 @@ error: the item `TryInto` is imported redundantly | LL | use std::convert::{TryFrom, TryInto}; | ^^^^^^^ + | --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | = note: the item `TryInto` is already defined here @@ -48,6 +50,7 @@ error: the item `Into` is imported redundantly | LL | use std::convert::{AsMut, Into}; | ^^^^ + | --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | = note: the item `Into` is already defined here diff --git a/tests/ui/issues/issue-17546.stderr b/tests/ui/issues/issue-17546.stderr index 25a94dd9723..5bae738d3ec 100644 --- a/tests/ui/issues/issue-17546.stderr +++ b/tests/ui/issues/issue-17546.stderr @@ -3,10 +3,10 @@ error[E0573]: expected type, found variant `NoResult` | LL | fn new() -> NoResult<MyEnum, String> { | ^^^^^^^^^^^^^^^^^^^^^^^^ + | --> $SRC_DIR/core/src/result.rs:LL:COL | = note: similarly named enum `Result` defined here - | help: try using the variant's enum | LL - fn new() -> NoResult<MyEnum, String> { @@ -57,10 +57,10 @@ error[E0573]: expected type, found variant `NoResult` | LL | fn newer() -> NoResult<foo::MyEnum, String> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | --> $SRC_DIR/core/src/result.rs:LL:COL | = note: similarly named enum `Result` defined here - | help: try using the variant's enum | LL - fn newer() -> NoResult<foo::MyEnum, String> { diff --git a/tests/ui/issues/issue-27033.stderr b/tests/ui/issues/issue-27033.stderr index 7a0ca888d74..129870f8c40 100644 --- a/tests/ui/issues/issue-27033.stderr +++ b/tests/ui/issues/issue-27033.stderr @@ -3,6 +3,7 @@ error[E0530]: match bindings cannot shadow unit variants | LL | None @ _ => {} | ^^^^ cannot be named the same as a unit variant + | --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | = note: the unit variant `None` is defined here diff --git a/tests/ui/issues/issue-29466.rs b/tests/ui/issues/issue-29466.rs index dbc37506a17..3962940e848 100644 --- a/tests/ui/issues/issue-29466.rs +++ b/tests/ui/issues/issue-29466.rs @@ -2,6 +2,9 @@ // //@ run-pass +// FIXME(#61117): Respect debuginfo-level-tests, do not force debuginfo-level=0 +//@ compile-flags: -Cdebuginfo=0 + #![allow(unused_variables)] macro_rules! m( diff --git a/tests/ui/issues/issue-54410.rs b/tests/ui/issues/issue-54410.rs deleted file mode 100644 index e3e8ca985b9..00000000000 --- a/tests/ui/issues/issue-54410.rs +++ /dev/null @@ -1,8 +0,0 @@ -extern "C" { - pub static mut symbol: [i8]; - //~^ ERROR the size for values of type `[i8]` cannot be known at compilation time -} - -fn main() { - println!("{:p}", unsafe { &symbol }); -} diff --git a/tests/ui/issues/issue-54410.stderr b/tests/ui/issues/issue-54410.stderr deleted file mode 100644 index cb68ada7e13..00000000000 --- a/tests/ui/issues/issue-54410.stderr +++ /dev/null @@ -1,12 +0,0 @@ -error[E0277]: the size for values of type `[i8]` cannot be known at compilation time - --> $DIR/issue-54410.rs:2:5 - | -LL | pub static mut symbol: [i8]; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/issue-5518.rs b/tests/ui/issues/issue-5518.rs deleted file mode 100644 index 333185c482f..00000000000 --- a/tests/ui/issues/issue-5518.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@ run-pass -//@ aux-build:issue-5518.rs - - -extern crate issue_5518 as other; - -fn main() {} diff --git a/tests/ui/issues/issue-5844.rs b/tests/ui/issues/issue-5844.rs deleted file mode 100644 index 23021207ae1..00000000000 --- a/tests/ui/issues/issue-5844.rs +++ /dev/null @@ -1,7 +0,0 @@ -//@aux-build:issue-5844-aux.rs - -extern crate issue_5844_aux; - -fn main() { - issue_5844_aux::rand(); //~ ERROR: requires unsafe -} diff --git a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.rs b/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.rs deleted file mode 100644 index 19d994b0dfb..00000000000 --- a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.rs +++ /dev/null @@ -1,10 +0,0 @@ -fn f<T>() -> bool { - struct S(T); //~ ERROR can't use generic parameters from outer item - - true -} - -fn main() { - let b = f::<isize>(); - assert!(b); -} diff --git a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.stderr b/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.stderr deleted file mode 100644 index 670a54894b5..00000000000 --- a/tests/ui/issues/issue-5997-outer-generic-parameter/issue-5997-struct.stderr +++ /dev/null @@ -1,13 +0,0 @@ -error[E0401]: can't use generic parameters from outer item - --> $DIR/issue-5997-struct.rs:2:14 - | -LL | fn f<T>() -> bool { - | - type parameter from outer item -LL | struct S(T); - | -^ use of generic parameter from outer item - | | - | help: try introducing a local generic parameter here: `<T>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0401`. diff --git a/tests/ui/issues/issue-6344-match.rs b/tests/ui/issues/issue-6344-match.rs deleted file mode 100644 index 9251e274383..00000000000 --- a/tests/ui/issues/issue-6344-match.rs +++ /dev/null @@ -1,18 +0,0 @@ -//@ run-pass -#![allow(non_shorthand_field_patterns)] - -struct A { x: usize } - -impl Drop for A { - fn drop(&mut self) {} -} - -pub fn main() { - let a = A { x: 0 }; - - match a { - A { x : ref x } => { - println!("{}", x) - } - } -} diff --git a/tests/ui/issues/issue-7178.rs b/tests/ui/issues/issue-7178.rs deleted file mode 100644 index 408ce0b03eb..00000000000 --- a/tests/ui/issues/issue-7178.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ run-pass -//@ aux-build:issue-7178.rs - - -extern crate issue_7178 as cross_crate_self; - -pub fn main() { - let _ = cross_crate_self::Foo::new(&1); -} diff --git a/tests/ui/issues/issue-53419.rs b/tests/ui/lifetimes/dyn-trait-function-pointer-53419.rs index 55d41f2005d..b1017b104ac 100644 --- a/tests/ui/issues/issue-53419.rs +++ b/tests/ui/lifetimes/dyn-trait-function-pointer-53419.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/53419 //@ check-pass struct Foo { diff --git a/tests/ui/issues/issue-7268.rs b/tests/ui/lifetimes/static-bound-fulfillment-with-pointer-7268.rs index a3bc1bc3446..8ec58e6cd80 100644 --- a/tests/ui/issues/issue-7268.rs +++ b/tests/ui/lifetimes/static-bound-fulfillment-with-pointer-7268.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7268 //@ check-pass #![allow(dead_code)] diff --git a/tests/ui/limits/huge-enum.stderr b/tests/ui/limits/huge-enum.full-debuginfo.stderr index 18168b3fa5c..4b179d59e5f 100644 --- a/tests/ui/limits/huge-enum.stderr +++ b/tests/ui/limits/huge-enum.full-debuginfo.stderr @@ -1,5 +1,5 @@ error: values of the type `Option<TYPE>` are too big for the target architecture - --> $DIR/huge-enum.rs:12:9 + --> $DIR/huge-enum.rs:17:9 | LL | let big: BIG = None; | ^^^ diff --git a/tests/ui/limits/huge-enum.no-debuginfo.stderr b/tests/ui/limits/huge-enum.no-debuginfo.stderr new file mode 100644 index 00000000000..4b179d59e5f --- /dev/null +++ b/tests/ui/limits/huge-enum.no-debuginfo.stderr @@ -0,0 +1,8 @@ +error: values of the type `Option<TYPE>` are too big for the target architecture + --> $DIR/huge-enum.rs:17:9 + | +LL | let big: BIG = None; + | ^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/limits/huge-enum.rs b/tests/ui/limits/huge-enum.rs index 66c5be20693..9395bee9765 100644 --- a/tests/ui/limits/huge-enum.rs +++ b/tests/ui/limits/huge-enum.rs @@ -1,6 +1,11 @@ +// FIXME(#61117): Remove revisions once x86_64-gnu-debug CI job sets rust.debuginfo-level-tests=2 +// NOTE: The .stderr for both revisions shall be identical. +//@ revisions: no-debuginfo full-debuginfo //@ build-fail //@ normalize-stderr: "std::option::Option<\[u32; \d+\]>" -> "TYPE" //@ normalize-stderr: "\[u32; \d+\]" -> "TYPE" +//@[no-debuginfo] compile-flags: -Cdebuginfo=0 +//@[full-debuginfo] compile-flags: -Cdebuginfo=2 #[cfg(target_pointer_width = "32")] type BIG = Option<[u32; (1<<29)-1]>; diff --git a/tests/ui/link-native-libs/issue-43925.rs b/tests/ui/link-native-libs/issue-43925.rs index 1a210887154..e3ce71352c0 100644 --- a/tests/ui/link-native-libs/issue-43925.rs +++ b/tests/ui/link-native-libs/issue-43925.rs @@ -1,4 +1,6 @@ -#[link(name = "foo", cfg("rlib"))] //~ ERROR link cfg must have a single predicate argument +#[link(name = "foo", cfg("rlib"))] +//~^ ERROR link cfg is unstable +//~| ERROR `cfg` predicate key must be an identifier extern "C" {} fn main() {} diff --git a/tests/ui/link-native-libs/issue-43925.stderr b/tests/ui/link-native-libs/issue-43925.stderr index 7cc347c6163..82d204222df 100644 --- a/tests/ui/link-native-libs/issue-43925.stderr +++ b/tests/ui/link-native-libs/issue-43925.stderr @@ -1,8 +1,18 @@ -error: link cfg must have a single predicate argument +error[E0658]: link cfg is unstable --> $DIR/issue-43925.rs:1:22 | LL | #[link(name = "foo", cfg("rlib"))] | ^^^^^^^^^^^ + | + = help: add `#![feature(link_cfg)]` 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: `cfg` predicate key must be an identifier + --> $DIR/issue-43925.rs:1:26 + | +LL | #[link(name = "foo", cfg("rlib"))] + | ^^^^^^ -error: aborting due to 1 previous error +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/link-native-libs/issue-43926.rs b/tests/ui/link-native-libs/issue-43926.rs index 6d3003552dc..293ad3f4ec1 100644 --- a/tests/ui/link-native-libs/issue-43926.rs +++ b/tests/ui/link-native-libs/issue-43926.rs @@ -1,4 +1,4 @@ -#[link(name = "foo", cfg())] //~ ERROR link cfg must have a single predicate argument +#[link(name = "foo", cfg())] //~ ERROR malformed `link` attribute input extern "C" {} fn main() {} diff --git a/tests/ui/link-native-libs/issue-43926.stderr b/tests/ui/link-native-libs/issue-43926.stderr index 7c5c50a38a9..9e3ec21cc94 100644 --- a/tests/ui/link-native-libs/issue-43926.stderr +++ b/tests/ui/link-native-libs/issue-43926.stderr @@ -1,8 +1,28 @@ -error: link cfg must have a single predicate argument - --> $DIR/issue-43926.rs:1:22 +error[E0805]: malformed `link` attribute input + --> $DIR/issue-43926.rs:1:1 | LL | #[link(name = "foo", cfg())] - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^-----^^ + | | + | expected a single argument here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "foo", cfg())] +LL + #[link(name = "...")] + | +LL - #[link(name = "foo", cfg())] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "foo", cfg())] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "foo", cfg())] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0805`. diff --git a/tests/ui/link-native-libs/link-attr-validation-early.rs b/tests/ui/link-native-libs/link-attr-validation-early.rs index a7dd80f8920..89a34ac6ca1 100644 --- a/tests/ui/link-native-libs/link-attr-validation-early.rs +++ b/tests/ui/link-native-libs/link-attr-validation-early.rs @@ -1,8 +1,6 @@ // Top-level ill-formed -#[link] //~ ERROR valid forms for the attribute are - //~| WARN this was previously accepted -#[link = "foo"] //~ ERROR valid forms for the attribute are - //~| WARN this was previously accepted +#[link] //~ ERROR malformed +#[link = "foo"] //~ ERROR malformed extern "C" {} fn main() {} diff --git a/tests/ui/link-native-libs/link-attr-validation-early.stderr b/tests/ui/link-native-libs/link-attr-validation-early.stderr index d4fc2e272f8..e4799b1a161 100644 --- a/tests/ui/link-native-libs/link-attr-validation-early.stderr +++ b/tests/ui/link-native-libs/link-attr-validation-early.stderr @@ -1,47 +1,45 @@ -error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` +error[E0539]: malformed `link` attribute input --> $DIR/link-attr-validation-early.rs:2:1 | LL | #[link] - | ^^^^^^^ + | ^^^^^^^ expected this to be a list | - = 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: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> - = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default +help: try changing it to one of the following valid forms of the attribute + | +LL | #[link(name = "...")] + | ++++++++++++++ +LL | #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +LL | #[link(name = "...", kind = "dylib|static|...")] + | +++++++++++++++++++++++++++++++++++++++++ +LL | #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + = and 1 other candidate -error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` - --> $DIR/link-attr-validation-early.rs:4:1 +error[E0539]: malformed `link` attribute input + --> $DIR/link-attr-validation-early.rs:3:1 | LL | #[link = "foo"] - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^ expected this to be a list | - = 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: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> - -error: aborting due to 2 previous errors - -Future incompatibility report: Future breakage diagnostic: -error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` - --> $DIR/link-attr-validation-early.rs:2:1 +help: try changing it to one of the following valid forms of the attribute | -LL | #[link] - | ^^^^^^^ +LL - #[link = "foo"] +LL + #[link(name = "...")] | - = 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: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> - = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default - -Future breakage diagnostic: -error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` - --> $DIR/link-attr-validation-early.rs:4:1 +LL - #[link = "foo"] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] | -LL | #[link = "foo"] - | ^^^^^^^^^^^^^^^ +LL - #[link = "foo"] +LL + #[link(name = "...", kind = "dylib|static|...")] | - = 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: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> - = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default +LL - #[link = "foo"] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate + +error: aborting due to 2 previous errors +For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/link-native-libs/link-attr-validation-late.rs b/tests/ui/link-native-libs/link-attr-validation-late.rs index 4eeb8ba4884..d2947b5f61a 100644 --- a/tests/ui/link-native-libs/link-attr-validation-late.rs +++ b/tests/ui/link-native-libs/link-attr-validation-late.rs @@ -1,38 +1,36 @@ #![feature(link_cfg)] // Top-level ill-formed -#[link(name = "...", "literal")] //~ ERROR unexpected `#[link]` argument -#[link(name = "...", unknown)] //~ ERROR unexpected `#[link]` argument +#[link(name = "...", "literal")] //~ ERROR malformed `link` attribute input +#[link(name = "...", unknown)] //~ ERROR malformed `link` attribute input extern "C" {} // Duplicate arguments -#[link(name = "foo", name = "bar")] //~ ERROR multiple `name` arguments -#[link(name = "...", kind = "dylib", kind = "bar")] //~ ERROR multiple `kind` arguments -#[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] //~ ERROR multiple `modifiers` arguments -#[link(name = "...", cfg(false), cfg(false))] //~ ERROR multiple `cfg` arguments -#[link(wasm_import_module = "foo", wasm_import_module = "bar")] //~ ERROR multiple `wasm_import_module` arguments +#[link(name = "foo", name = "bar")] //~ ERROR malformed `link` attribute input +#[link(name = "...", kind = "dylib", kind = "bar")] //~ ERROR malformed `link` attribute input +#[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] //~ ERROR malformed `link` attribute input +#[link(name = "...", cfg(false), cfg(false))] //~ ERROR malformed `link` attribute input +#[link(wasm_import_module = "foo", wasm_import_module = "bar")] //~ ERROR malformed `link` attribute input extern "C" {} // Ill-formed arguments -#[link(name)] //~ ERROR link name must be of the form `name = "string"` - //~| ERROR `#[link]` attribute requires a `name = "string"` argument -#[link(name())] //~ ERROR link name must be of the form `name = "string"` - //~| ERROR `#[link]` attribute requires a `name = "string"` argument -#[link(name = "...", kind)] //~ ERROR link kind must be of the form `kind = "string"` -#[link(name = "...", kind())] //~ ERROR link kind must be of the form `kind = "string"` -#[link(name = "...", modifiers)] //~ ERROR link modifiers must be of the form `modifiers = "string"` -#[link(name = "...", modifiers())] //~ ERROR link modifiers must be of the form `modifiers = "string"` -#[link(name = "...", cfg)] //~ ERROR link cfg must be of the form `cfg(/* predicate */)` -#[link(name = "...", cfg = "literal")] //~ ERROR link cfg must be of the form `cfg(/* predicate */)` -#[link(name = "...", cfg("literal"))] //~ ERROR link cfg must have a single predicate argument -#[link(name = "...", wasm_import_module)] //~ ERROR wasm import module must be of the form `wasm_import_module = "string"` -#[link(name = "...", wasm_import_module())] //~ ERROR wasm import module must be of the form `wasm_import_module = "string"` +#[link(name)] //~ ERROR malformed `link` attribute input +#[link(name())] //~ ERROR malformed `link` attribute input +#[link(name = "...", kind)] //~ ERROR malformed `link` attribute input +#[link(name = "...", kind())] //~ ERROR malformed `link` attribute input +#[link(name = "...", modifiers)] //~ ERROR malformed `link` attribute input +#[link(name = "...", modifiers())] //~ ERROR malformed `link` attribute input +#[link(name = "...", cfg)] //~ ERROR malformed `link` attribute input +#[link(name = "...", cfg = "literal")] //~ ERROR malformed `link` attribute input +#[link(name = "...", cfg("literal"))] //~ ERROR `cfg` predicate key must be an identifier +#[link(name = "...", wasm_import_module)] //~ ERROR malformed `link` attribute input +#[link(name = "...", wasm_import_module())] //~ ERROR malformed `link` attribute input extern "C" {} // Basic modifier validation #[link(name = "...", modifiers = "")] //~ ERROR invalid linking modifier syntax, expected '+' or '-' prefix #[link(name = "...", modifiers = "no-plus-minus")] //~ ERROR invalid linking modifier syntax, expected '+' or '-' prefix -#[link(name = "...", modifiers = "+unknown")] //~ ERROR unknown linking modifier `unknown` +#[link(name = "...", modifiers = "+unknown")] //~ ERROR malformed `link` attribute input #[link(name = "...", modifiers = "+verbatim,+verbatim")] //~ ERROR multiple `verbatim` modifiers extern "C" {} diff --git a/tests/ui/link-native-libs/link-attr-validation-late.stderr b/tests/ui/link-native-libs/link-attr-validation-late.stderr index f3989c09360..834dca0bc0b 100644 --- a/tests/ui/link-native-libs/link-attr-validation-late.stderr +++ b/tests/ui/link-native-libs/link-attr-validation-late.stderr @@ -1,147 +1,472 @@ -error: unexpected `#[link]` argument, expected one of: name, kind, modifiers, cfg, wasm_import_module, import_name_type - --> $DIR/link-attr-validation-late.rs:4:22 +error[E0565]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:4:1 | LL | #[link(name = "...", "literal")] - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^---------^^ + | | + | didn't expect a literal here + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", "literal")] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", "literal")] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", "literal")] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", "literal")] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: unexpected `#[link]` argument, expected one of: name, kind, modifiers, cfg, wasm_import_module, import_name_type - --> $DIR/link-attr-validation-late.rs:5:22 +error[E0539]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:5:1 | LL | #[link(name = "...", unknown)] - | ^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^-------^^ + | | + | valid arguments are "name", "kind", "modifiers", "cfg", "wasm_import_module" or "import_name_type" + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", unknown)] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", unknown)] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", unknown)] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", unknown)] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: multiple `name` arguments in a single `#[link]` attribute - --> $DIR/link-attr-validation-late.rs:9:22 +error[E0538]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:9:1 | LL | #[link(name = "foo", name = "bar")] - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^------------^^ + | | + | found `name` used as a key more than once + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "foo", name = "bar")] +LL + #[link(name = "...")] + | +LL - #[link(name = "foo", name = "bar")] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "foo", name = "bar")] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "foo", name = "bar")] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: multiple `kind` arguments in a single `#[link]` attribute - --> $DIR/link-attr-validation-late.rs:10:38 +error[E0538]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:10:1 | LL | #[link(name = "...", kind = "dylib", kind = "bar")] - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------^^ + | | + | found `kind` used as a key more than once + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", kind = "dylib", kind = "bar")] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", kind = "dylib", kind = "bar")] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", kind = "dylib", kind = "bar")] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", kind = "dylib", kind = "bar")] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: multiple `modifiers` arguments in a single `#[link]` attribute - --> $DIR/link-attr-validation-late.rs:11:47 +error[E0538]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:11:1 | LL | #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] - | ^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-----------------^^ + | | + | found `modifiers` used as a key more than once + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", modifiers = "+verbatim", modifiers = "bar")] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: multiple `cfg` arguments in a single `#[link]` attribute - --> $DIR/link-attr-validation-late.rs:12:34 +error[E0538]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:12:1 | LL | #[link(name = "...", cfg(false), cfg(false))] - | ^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------^^ + | | + | found `cfg` used as a key more than once + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", cfg(false), cfg(false))] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", cfg(false), cfg(false))] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", cfg(false), cfg(false))] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", cfg(false), cfg(false))] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: multiple `wasm_import_module` arguments in a single `#[link]` attribute - --> $DIR/link-attr-validation-late.rs:13:36 +error[E0538]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:13:1 | LL | #[link(wasm_import_module = "foo", wasm_import_module = "bar")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: link name must be of the form `name = "string"` - --> $DIR/link-attr-validation-late.rs:17:8 + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------------^^ + | | + | found `wasm_import_module` used as a key more than once | -LL | #[link(name)] - | ^^^^ + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(wasm_import_module = "foo", wasm_import_module = "bar")] +LL + #[link(name = "...")] + | +LL - #[link(wasm_import_module = "foo", wasm_import_module = "bar")] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(wasm_import_module = "foo", wasm_import_module = "bar")] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(wasm_import_module = "foo", wasm_import_module = "bar")] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error[E0459]: `#[link]` attribute requires a `name = "string"` argument +error[E0539]: malformed `link` attribute input --> $DIR/link-attr-validation-late.rs:17:1 | LL | #[link(name)] - | ^^^^^^^^^^^^^ missing `name` argument - -error: link name must be of the form `name = "string"` - --> $DIR/link-attr-validation-late.rs:19:8 + | ^^^^^^^----^^ + | | + | expected this to be of the form `name = "..."` | -LL | #[link(name())] - | ^^^^^^ + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL | #[link(name = "...")] + | +++++++ +LL | #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +LL | #[link(name = "...", kind = "dylib|static|...")] + | ++++++++++++++++++++++++++++++++++ +LL | #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + = and 1 other candidate -error[E0459]: `#[link]` attribute requires a `name = "string"` argument - --> $DIR/link-attr-validation-late.rs:19:1 +error[E0539]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:18:1 | LL | #[link(name())] - | ^^^^^^^^^^^^^^^ missing `name` argument + | ^^^^^^^------^^ + | | + | expected this to be of the form `name = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name())] +LL + #[link(name = "...")] + | +LL - #[link(name())] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name())] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name())] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: link kind must be of the form `kind = "string"` - --> $DIR/link-attr-validation-late.rs:21:22 +error[E0539]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:19:1 | LL | #[link(name = "...", kind)] - | ^^^^ + | ^^^^^^^^^^^^^^^^^^^^^----^^ + | | + | expected this to be of the form `kind = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", kind)] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", kind)] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL | #[link(name = "...", kind = "dylib|static|...")] + | ++++++++++++++++++++ +LL | #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + = and 1 other candidate -error: link kind must be of the form `kind = "string"` - --> $DIR/link-attr-validation-late.rs:22:22 +error[E0539]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:20:1 | LL | #[link(name = "...", kind())] - | ^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^------^^ + | | + | expected this to be of the form `kind = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", kind())] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", kind())] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", kind())] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", kind())] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: link modifiers must be of the form `modifiers = "string"` - --> $DIR/link-attr-validation-late.rs:23:22 +error[E0539]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:21:1 | LL | #[link(name = "...", modifiers)] - | ^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^---------^^ + | | + | expected this to be of the form `modifiers = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", modifiers)] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", modifiers)] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", modifiers)] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", modifiers)] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: link modifiers must be of the form `modifiers = "string"` - --> $DIR/link-attr-validation-late.rs:24:22 +error[E0539]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:22:1 | LL | #[link(name = "...", modifiers())] - | ^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^-----------^^ + | | + | expected this to be of the form `modifiers = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", modifiers())] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", modifiers())] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", modifiers())] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", modifiers())] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: link cfg must be of the form `cfg(/* predicate */)` - --> $DIR/link-attr-validation-late.rs:25:22 +error[E0539]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:23:1 | LL | #[link(name = "...", cfg)] - | ^^^ + | ^^^^^^^^^^^^^^^^^^^^^---^^ + | | + | expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", cfg)] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", cfg)] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", cfg)] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", cfg)] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: link cfg must be of the form `cfg(/* predicate */)` - --> $DIR/link-attr-validation-late.rs:26:22 +error[E0539]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:24:1 | LL | #[link(name = "...", cfg = "literal")] - | ^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^---------------^^ + | | + | expected this to be a list + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", cfg = "literal")] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", cfg = "literal")] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", cfg = "literal")] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", cfg = "literal")] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: link cfg must have a single predicate argument - --> $DIR/link-attr-validation-late.rs:27:22 +error: `cfg` predicate key must be an identifier + --> $DIR/link-attr-validation-late.rs:25:26 | LL | #[link(name = "...", cfg("literal"))] - | ^^^^^^^^^^^^^^ + | ^^^^^^^^^ -error: wasm import module must be of the form `wasm_import_module = "string"` - --> $DIR/link-attr-validation-late.rs:28:22 +error[E0539]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:26:1 | LL | #[link(name = "...", wasm_import_module)] - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^------------------^^ + | | + | expected this to be of the form `wasm_import_module = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", wasm_import_module)] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", wasm_import_module)] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", wasm_import_module)] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", wasm_import_module)] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: wasm import module must be of the form `wasm_import_module = "string"` - --> $DIR/link-attr-validation-late.rs:29:22 +error[E0539]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:27:1 | LL | #[link(name = "...", wasm_import_module())] - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^--------------------^^ + | | + | expected this to be of the form `wasm_import_module = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", wasm_import_module())] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", wasm_import_module())] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", wasm_import_module())] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", wasm_import_module())] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed - --> $DIR/link-attr-validation-late.rs:33:34 + --> $DIR/link-attr-validation-late.rs:31:34 | LL | #[link(name = "...", modifiers = "")] | ^^ error: invalid linking modifier syntax, expected '+' or '-' prefix before one of: bundle, verbatim, whole-archive, as-needed - --> $DIR/link-attr-validation-late.rs:34:34 + --> $DIR/link-attr-validation-late.rs:32:34 | LL | #[link(name = "...", modifiers = "no-plus-minus")] | ^^^^^^^^^^^^^^^ -error: unknown linking modifier `unknown`, expected one of: bundle, verbatim, whole-archive, as-needed - --> $DIR/link-attr-validation-late.rs:35:34 +error[E0539]: malformed `link` attribute input + --> $DIR/link-attr-validation-late.rs:33:1 | LL | #[link(name = "...", modifiers = "+unknown")] - | ^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------^^ + | | + | valid arguments are "bundle", "verbatim", "whole-archive" or "as-needed" + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", modifiers = "+unknown")] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", modifiers = "+unknown")] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", modifiers = "+unknown")] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", modifiers = "+unknown")] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate error: multiple `verbatim` modifiers in a single `modifiers` argument - --> $DIR/link-attr-validation-late.rs:36:34 + --> $DIR/link-attr-validation-late.rs:34:34 | LL | #[link(name = "...", modifiers = "+verbatim,+verbatim")] | ^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 24 previous errors +error: aborting due to 22 previous errors -For more information about this error, try `rustc --explain E0459`. +Some errors have detailed explanations: E0538, E0539, E0565. +For more information about an error, try `rustc --explain E0538`. diff --git a/tests/ui/link-native-libs/modifiers-override-4.rs b/tests/ui/link-native-libs/modifiers-override-4.rs new file mode 100644 index 00000000000..cc5b07e20cc --- /dev/null +++ b/tests/ui/link-native-libs/modifiers-override-4.rs @@ -0,0 +1,12 @@ +#[link(name = "foo")] +#[link( +//~^ ERROR malformed `link` attribute input + name = "bar", + kind = "static", + modifiers = "+whole-archive,-whole-archive", + //~^ ERROR multiple `whole-archive` modifiers in a single `modifiers` argument + modifiers = "+bundle" +)] +extern "C" {} + +fn main() {} diff --git a/tests/ui/link-native-libs/modifiers-override-4.stderr b/tests/ui/link-native-libs/modifiers-override-4.stderr new file mode 100644 index 00000000000..317e89cb39c --- /dev/null +++ b/tests/ui/link-native-libs/modifiers-override-4.stderr @@ -0,0 +1,67 @@ +error[E0538]: malformed `link` attribute input + --> $DIR/modifiers-override-4.rs:2:1 + | +LL | / #[link( +LL | | +LL | | name = "bar", +LL | | kind = "static", +... | +LL | | modifiers = "+bundle" + | | --------------------- found `modifiers` used as a key more than once +LL | | )] + | |__^ + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link( +LL - +LL - name = "bar", +LL - kind = "static", +LL - modifiers = "+whole-archive,-whole-archive", +LL - +LL - modifiers = "+bundle" +LL - )] +LL + #[link(name = "...")] + | +LL - #[link( +LL - +LL - name = "bar", +LL - kind = "static", +LL - modifiers = "+whole-archive,-whole-archive", +LL - +LL - modifiers = "+bundle" +LL - )] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link( +LL - +LL - name = "bar", +LL - kind = "static", +LL - modifiers = "+whole-archive,-whole-archive", +LL - +LL - modifiers = "+bundle" +LL - )] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link( +LL - +LL - name = "bar", +LL - kind = "static", +LL - modifiers = "+whole-archive,-whole-archive", +LL - +LL - modifiers = "+bundle" +LL - )] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate + +error: multiple `whole-archive` modifiers in a single `modifiers` argument + --> $DIR/modifiers-override-4.rs:6:17 + | +LL | modifiers = "+whole-archive,-whole-archive", + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0538`. diff --git a/tests/ui/link-native-libs/modifiers-override.rs b/tests/ui/link-native-libs/modifiers-override.rs index cd2d003664a..a44b7d37ed8 100644 --- a/tests/ui/link-native-libs/modifiers-override.rs +++ b/tests/ui/link-native-libs/modifiers-override.rs @@ -4,13 +4,8 @@ #[link( name = "bar", kind = "static", - modifiers = "+whole-archive,-whole-archive", - //~^ ERROR multiple `whole-archive` modifiers in a single `modifiers` argument - modifiers = "+bundle" - //~^ ERROR multiple `modifiers` arguments in a single `#[link]` attribute )] extern "C" {} //~^ ERROR overriding linking modifiers from command line is not supported -//~| ERROR overriding linking modifiers from command line is not supported fn main() {} diff --git a/tests/ui/link-native-libs/modifiers-override.stderr b/tests/ui/link-native-libs/modifiers-override.stderr index 64427651e9f..3cc99c96c7c 100644 --- a/tests/ui/link-native-libs/modifiers-override.stderr +++ b/tests/ui/link-native-libs/modifiers-override.stderr @@ -1,28 +1,8 @@ -error: multiple `modifiers` arguments in a single `#[link]` attribute - --> $DIR/modifiers-override.rs:9:5 - | -LL | modifiers = "+bundle" - | ^^^^^^^^^^^^^^^^^^^^^ - -error: multiple `whole-archive` modifiers in a single `modifiers` argument - --> $DIR/modifiers-override.rs:7:17 - | -LL | modifiers = "+whole-archive,-whole-archive", - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: overriding linking modifiers from command line is not supported - --> $DIR/modifiers-override.rs:12:1 - | -LL | extern "C" {} - | ^^^^^^^^^^^^^ - error: overriding linking modifiers from command line is not supported - --> $DIR/modifiers-override.rs:12:1 + --> $DIR/modifiers-override.rs:8:1 | LL | extern "C" {} | ^^^^^^^^^^^^^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` -error: aborting due to 4 previous errors +error: aborting due to 1 previous error diff --git a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-invalid-format.rs b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-invalid-format.rs index 50ad8a173ad..542f34b3eb1 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-invalid-format.rs +++ b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-invalid-format.rs @@ -1,7 +1,10 @@ -//@ only-windows -//@ only-x86 +//@ add-core-stubs +//@ compile-flags: --target i686-pc-windows-msvc +//@ needs-llvm-components: x86 +#![feature(no_core, rustc_attrs, lang_items)] +#![no_core] +#![crate_type = "lib"] + #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] -//~^ ERROR import name type must be of the form `import_name_type = "string"` +//~^ ERROR malformed extern "C" { } - -fn main() {} diff --git a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-invalid-format.stderr b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-invalid-format.stderr index d2cf7a0ba1f..6121762fb03 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-invalid-format.stderr +++ b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-invalid-format.stderr @@ -1,8 +1,28 @@ -error: import name type must be of the form `import_name_type = "string"` - --> $DIR/import-name-type-invalid-format.rs:3:42 +error[E0539]: malformed `link` attribute input + --> $DIR/import-name-type-invalid-format.rs:8:1 | LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^--------------------^^ + | | + | expected this to be of the form `import_name_type = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] +LL + #[link(name = "...")] + | +LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = 6)] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-multiple.rs b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-multiple.rs index cf456b9b261..e2418642aea 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-multiple.rs +++ b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-multiple.rs @@ -1,8 +1,11 @@ // ignore-tidy-linelength -//@ only-windows -//@ only-x86 +//@ add-core-stubs +//@ compile-flags: --target i686-pc-windows-msvc +//@ needs-llvm-components: x86 +#![feature(no_core, rustc_attrs, lang_items)] +#![no_core] +#![crate_type = "lib"] + #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] -//~^ ERROR multiple `import_name_type` arguments in a single `#[link]` attribute +//~^ ERROR malformed extern "C" { } - -fn main() {} diff --git a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-multiple.stderr b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-multiple.stderr index 8e65baf65df..adfe915b464 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-multiple.stderr +++ b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-multiple.stderr @@ -1,8 +1,28 @@ -error: multiple `import_name_type` arguments in a single `#[link]` attribute - --> $DIR/import-name-type-multiple.rs:4:74 +error[E0538]: malformed `link` attribute input + --> $DIR/import-name-type-multiple.rs:9:1 | LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------^^ + | | + | found `import_name_type` used as a key more than once + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] +LL + #[link(name = "...")] + | +LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated", import_name_type = "decorated")] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0538`. diff --git a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unknown-value.rs b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unknown-value.rs index b3859ba1ce6..174e8682f29 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unknown-value.rs +++ b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unknown-value.rs @@ -1,7 +1,10 @@ -//@ only-windows -//@ only-x86 +//@ add-core-stubs +//@ compile-flags: --target i686-pc-windows-msvc +//@ needs-llvm-components: x86 +#![feature(no_core, rustc_attrs, lang_items)] +#![no_core] +#![crate_type = "lib"] + #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] -//~^ ERROR unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated +//~^ ERROR malformed extern "C" { } - -fn main() {} diff --git a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unknown-value.stderr b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unknown-value.stderr index 4b8b90eb6e2..fc24a6bed17 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unknown-value.stderr +++ b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unknown-value.stderr @@ -1,8 +1,28 @@ -error: unknown import name type `unknown`, expected one of: decorated, noprefix, undecorated - --> $DIR/import-name-type-unknown-value.rs:3:42 +error[E0539]: malformed `link` attribute input + --> $DIR/import-name-type-unknown-value.rs:8:1 | LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^----------------------------^^ + | | + | valid arguments are "decorated", "noprefix" or "undecorated" + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] +LL + #[link(name = "...")] + | +LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "foo", kind = "raw-dylib", import_name_type = "unknown")] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate error: aborting due to 1 previous error +For more information about this error, try `rustc --explain E0539`. diff --git a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unsupported-link-kind.rs b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unsupported-link-kind.rs index 3ead5cb1fd7..ca6aef79c95 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unsupported-link-kind.rs +++ b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unsupported-link-kind.rs @@ -1,5 +1,10 @@ -//@ only-windows -//@ only-x86 +//@ add-core-stubs +//@ compile-flags: --target i686-pc-windows-msvc +//@ needs-llvm-components: x86 +#![feature(no_core, rustc_attrs, lang_items)] +#![no_core] +#![crate_type = "lib"] + #[link(name = "foo", import_name_type = "decorated")] //~^ ERROR import name type can only be used with link kind `raw-dylib` extern "C" { } @@ -11,5 +16,3 @@ extern "C" { } // Specifying `import_name_type` before `kind` shouldn't raise an error. #[link(name = "bar", import_name_type = "decorated", kind = "raw-dylib")] extern "C" { } - -fn main() {} diff --git a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unsupported-link-kind.stderr b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unsupported-link-kind.stderr index 75cadc471c4..075e4ffffb8 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unsupported-link-kind.stderr +++ b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-unsupported-link-kind.stderr @@ -1,11 +1,11 @@ error: import name type can only be used with link kind `raw-dylib` - --> $DIR/import-name-type-unsupported-link-kind.rs:3:22 + --> $DIR/import-name-type-unsupported-link-kind.rs:8:22 | LL | #[link(name = "foo", import_name_type = "decorated")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: import name type can only be used with link kind `raw-dylib` - --> $DIR/import-name-type-unsupported-link-kind.rs:7:39 + --> $DIR/import-name-type-unsupported-link-kind.rs:12:39 | LL | #[link(name = "bar", kind = "static", import_name_type = "decorated")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-x86-only.rs b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-x86-only.rs index ab0dcda64e6..5f1410f7d2a 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-x86-only.rs +++ b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-x86-only.rs @@ -1,7 +1,10 @@ -//@ only-windows -//@ ignore-x86 +//@ add-core-stubs +//@ compile-flags: --target aarch64-pc-windows-msvc +//@ needs-llvm-components: aarch64 +#![feature(no_core, rustc_attrs, lang_items)] +#![no_core] +#![crate_type = "lib"] + #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] //~^ ERROR import name type is only supported on x86 extern "C" { } - -fn main() {} diff --git a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-x86-only.stderr b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-x86-only.stderr index 757f1f7994e..ad3b9f79c84 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-x86-only.stderr +++ b/tests/ui/linkage-attr/raw-dylib/windows/import-name-type-x86-only.stderr @@ -1,5 +1,5 @@ error: import name type is only supported on x86 - --> $DIR/import-name-type-x86-only.rs:3:42 + --> $DIR/import-name-type-x86-only.rs:8:42 | LL | #[link(name = "foo", kind = "raw-dylib", import_name_type = "decorated")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/linkage-attr/raw-dylib/windows/invalid-dlltool.rs b/tests/ui/linkage-attr/raw-dylib/windows/invalid-dlltool.rs index 0c78d799bad..f5f92db3b50 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/invalid-dlltool.rs +++ b/tests/ui/linkage-attr/raw-dylib/windows/invalid-dlltool.rs @@ -11,4 +11,4 @@ pub fn lib_main() { unsafe { f(42); } } -//~? ERROR Error calling dlltool 'does_not_exist.exe': program not found +//~? ERROR error calling dlltool 'does_not_exist.exe': program not found diff --git a/tests/ui/linkage-attr/raw-dylib/windows/invalid-dlltool.stderr b/tests/ui/linkage-attr/raw-dylib/windows/invalid-dlltool.stderr index 4bbad9b30a7..311d8c61589 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/invalid-dlltool.stderr +++ b/tests/ui/linkage-attr/raw-dylib/windows/invalid-dlltool.stderr @@ -1,4 +1,4 @@ -error: Error calling dlltool 'does_not_exist.exe': program not found +error: error calling dlltool 'does_not_exist.exe': program not found error: aborting due to 1 previous error diff --git a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs index 301e690be38..8651a4e7175 100644 --- a/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs +++ b/tests/ui/linkage-attr/raw-dylib/windows/link-ordinal-not-foreign-fn.rs @@ -10,7 +10,7 @@ fn test() {} //~^ ERROR attribute cannot be used on static mut imported_val: i32 = 123; -#[link(name = "exporter", kind = "raw-dylib")] +#[link(name = "exporter")] extern "C" { #[link_ordinal(13)] fn imported_function(); diff --git a/tests/ui/linking/mixed-allocator-shim.rs b/tests/ui/linking/mixed-allocator-shim.rs new file mode 100644 index 00000000000..e4f20a11ebb --- /dev/null +++ b/tests/ui/linking/mixed-allocator-shim.rs @@ -0,0 +1,16 @@ +//@ build-pass +//@ compile-flags: --crate-type staticlib,dylib -Zstaticlib-prefer-dynamic +//@ no-prefer-dynamic +//@ needs-crate-type: dylib + +// Test that compiling for multiple crate types in a single compilation with +// mismatching allocator shim requirements doesn't result in the allocator shim +// missing entirely. +// In this particular test the dylib crate type will statically link libstd and +// thus need an allocator shim, while the staticlib crate type will dynamically +// link libstd and thus not need an allocator shim. +// The -Zstaticlib-prefer-dynamic flag could be avoided by doing it the other +// way around, but testing that the staticlib correctly has the allocator shim +// in that case would require a run-make test instead. + +pub fn foo() {} diff --git a/tests/ui/lint/improper_ctypes/allow-phantomdata-in-ffi.rs b/tests/ui/lint/improper-ctypes/allow-phantomdata-in-ffi.rs index a90159d2b58..a90159d2b58 100644 --- a/tests/ui/lint/improper_ctypes/allow-phantomdata-in-ffi.rs +++ b/tests/ui/lint/improper-ctypes/allow-phantomdata-in-ffi.rs diff --git a/tests/ui/lint/lint-ctypes-113436-1.rs b/tests/ui/lint/improper-ctypes/lint-113436-1.rs index 1ca59c6868d..1ca59c6868d 100644 --- a/tests/ui/lint/lint-ctypes-113436-1.rs +++ b/tests/ui/lint/improper-ctypes/lint-113436-1.rs diff --git a/tests/ui/lint/lint-ctypes-113436-1.stderr b/tests/ui/lint/improper-ctypes/lint-113436-1.stderr index 7b63043f057..f01dc3b6e0d 100644 --- a/tests/ui/lint/lint-ctypes-113436-1.stderr +++ b/tests/ui/lint/improper-ctypes/lint-113436-1.stderr @@ -1,5 +1,5 @@ error: `extern` fn uses type `NotSafe`, which is not FFI-safe - --> $DIR/lint-ctypes-113436-1.rs:22:22 + --> $DIR/lint-113436-1.rs:22:22 | LL | extern "C" fn bar(x: Bar) -> Bar { | ^^^ not FFI-safe @@ -7,18 +7,18 @@ LL | extern "C" fn bar(x: Bar) -> Bar { = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout note: the type is defined here - --> $DIR/lint-ctypes-113436-1.rs:13:1 + --> $DIR/lint-113436-1.rs:13:1 | LL | struct NotSafe(u32); | ^^^^^^^^^^^^^^ note: the lint level is defined here - --> $DIR/lint-ctypes-113436-1.rs:1:9 + --> $DIR/lint-113436-1.rs:1:9 | LL | #![deny(improper_ctypes_definitions)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `NotSafe`, which is not FFI-safe - --> $DIR/lint-ctypes-113436-1.rs:22:30 + --> $DIR/lint-113436-1.rs:22:30 | LL | extern "C" fn bar(x: Bar) -> Bar { | ^^^ not FFI-safe @@ -26,7 +26,7 @@ LL | extern "C" fn bar(x: Bar) -> Bar { = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout note: the type is defined here - --> $DIR/lint-ctypes-113436-1.rs:13:1 + --> $DIR/lint-113436-1.rs:13:1 | LL | struct NotSafe(u32); | ^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/lint-ctypes-73249-2.rs b/tests/ui/lint/improper-ctypes/lint-73249-2.rs index 31af0e3d381..31af0e3d381 100644 --- a/tests/ui/lint/lint-ctypes-73249-2.rs +++ b/tests/ui/lint/improper-ctypes/lint-73249-2.rs diff --git a/tests/ui/lint/lint-ctypes-73249-2.stderr b/tests/ui/lint/improper-ctypes/lint-73249-2.stderr index 2d0dfe94f09..d6c1cec2bd6 100644 --- a/tests/ui/lint/lint-ctypes-73249-2.stderr +++ b/tests/ui/lint/improper-ctypes/lint-73249-2.stderr @@ -1,12 +1,12 @@ error: `extern` block uses type `Qux`, which is not FFI-safe - --> $DIR/lint-ctypes-73249-2.rs:27:21 + --> $DIR/lint-73249-2.rs:27:21 | LL | fn lint_me() -> A<()>; | ^^^^^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here - --> $DIR/lint-ctypes-73249-2.rs:2:9 + --> $DIR/lint-73249-2.rs:2:9 | LL | #![deny(improper_ctypes)] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/lint-ctypes-73249-3.rs b/tests/ui/lint/improper-ctypes/lint-73249-3.rs index 8bdf536bf77..8bdf536bf77 100644 --- a/tests/ui/lint/lint-ctypes-73249-3.rs +++ b/tests/ui/lint/improper-ctypes/lint-73249-3.rs diff --git a/tests/ui/lint/lint-ctypes-73249-3.stderr b/tests/ui/lint/improper-ctypes/lint-73249-3.stderr index e1a313a2906..ebc9eb5eb82 100644 --- a/tests/ui/lint/lint-ctypes-73249-3.stderr +++ b/tests/ui/lint/improper-ctypes/lint-73249-3.stderr @@ -1,12 +1,12 @@ error: `extern` block uses type `Qux`, which is not FFI-safe - --> $DIR/lint-ctypes-73249-3.rs:21:25 + --> $DIR/lint-73249-3.rs:21:25 | LL | pub fn lint_me() -> A; | ^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here - --> $DIR/lint-ctypes-73249-3.rs:2:9 + --> $DIR/lint-73249-3.rs:2:9 | LL | #![deny(improper_ctypes)] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/lint-ctypes-73249-5.rs b/tests/ui/lint/improper-ctypes/lint-73249-5.rs index cc6da59950d..cc6da59950d 100644 --- a/tests/ui/lint/lint-ctypes-73249-5.rs +++ b/tests/ui/lint/improper-ctypes/lint-73249-5.rs diff --git a/tests/ui/lint/lint-ctypes-73249-5.stderr b/tests/ui/lint/improper-ctypes/lint-73249-5.stderr index c4fa955de05..484927f57fe 100644 --- a/tests/ui/lint/lint-ctypes-73249-5.stderr +++ b/tests/ui/lint/improper-ctypes/lint-73249-5.stderr @@ -1,12 +1,12 @@ error: `extern` block uses type `Qux`, which is not FFI-safe - --> $DIR/lint-ctypes-73249-5.rs:21:25 + --> $DIR/lint-73249-5.rs:21:25 | LL | pub fn lint_me() -> A; | ^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here - --> $DIR/lint-ctypes-73249-5.rs:2:9 + --> $DIR/lint-73249-5.rs:2:9 | LL | #![deny(improper_ctypes)] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/lint-ctypes-73251-1.rs b/tests/ui/lint/improper-ctypes/lint-73251-1.rs index 07ae05be69f..07ae05be69f 100644 --- a/tests/ui/lint/lint-ctypes-73251-1.rs +++ b/tests/ui/lint/improper-ctypes/lint-73251-1.rs diff --git a/tests/ui/lint/lint-ctypes-73251-1.stderr b/tests/ui/lint/improper-ctypes/lint-73251-1.stderr index 675a9de51cd..749722f0e22 100644 --- a/tests/ui/lint/lint-ctypes-73251-1.stderr +++ b/tests/ui/lint/improper-ctypes/lint-73251-1.stderr @@ -1,12 +1,12 @@ error: `extern` block uses type `Qux`, which is not FFI-safe - --> $DIR/lint-ctypes-73251-1.rs:24:21 + --> $DIR/lint-73251-1.rs:24:21 | LL | fn lint_me() -> <u32 as Foo>::Assoc; | ^^^^^^^^^^^^^^^^^^^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here - --> $DIR/lint-ctypes-73251-1.rs:2:9 + --> $DIR/lint-73251-1.rs:2:9 | LL | #![deny(improper_ctypes)] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/lint-ctypes-73251-2.rs b/tests/ui/lint/improper-ctypes/lint-73251-2.rs index c47118672e0..c47118672e0 100644 --- a/tests/ui/lint/lint-ctypes-73251-2.rs +++ b/tests/ui/lint/improper-ctypes/lint-73251-2.rs diff --git a/tests/ui/lint/lint-ctypes-73251-2.stderr b/tests/ui/lint/improper-ctypes/lint-73251-2.stderr index 634950b29ed..3770b7d789f 100644 --- a/tests/ui/lint/lint-ctypes-73251-2.stderr +++ b/tests/ui/lint/improper-ctypes/lint-73251-2.stderr @@ -1,12 +1,12 @@ error: `extern` block uses type `AliasA`, which is not FFI-safe - --> $DIR/lint-ctypes-73251-2.rs:38:21 + --> $DIR/lint-73251-2.rs:38:21 | LL | fn lint_me() -> <AliasB as TraitB>::Assoc; | ^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = note: opaque types have no C equivalent note: the lint level is defined here - --> $DIR/lint-ctypes-73251-2.rs:2:9 + --> $DIR/lint-73251-2.rs:2:9 | LL | #![deny(improper_ctypes)] | ^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/lint-ctypes-94223.rs b/tests/ui/lint/improper-ctypes/lint-94223.rs index ac24f61b0ac..ac24f61b0ac 100644 --- a/tests/ui/lint/lint-ctypes-94223.rs +++ b/tests/ui/lint/improper-ctypes/lint-94223.rs diff --git a/tests/ui/lint/lint-ctypes-94223.stderr b/tests/ui/lint/improper-ctypes/lint-94223.stderr index bd127cf6004..008debf8f01 100644 --- a/tests/ui/lint/lint-ctypes-94223.stderr +++ b/tests/ui/lint/improper-ctypes/lint-94223.stderr @@ -1,5 +1,5 @@ error: `extern` fn uses type `[u8]`, which is not FFI-safe - --> $DIR/lint-ctypes-94223.rs:4:15 + --> $DIR/lint-94223.rs:4:15 | LL | pub fn bad(f: extern "C" fn([u8])) {} | ^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -7,13 +7,13 @@ LL | pub fn bad(f: extern "C" fn([u8])) {} = help: consider using a raw pointer instead = note: slices have no C equivalent note: the lint level is defined here - --> $DIR/lint-ctypes-94223.rs:2:9 + --> $DIR/lint-94223.rs:2:9 | LL | #![deny(improper_ctypes_definitions)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `[u8]`, which is not FFI-safe - --> $DIR/lint-ctypes-94223.rs:7:28 + --> $DIR/lint-94223.rs:7:28 | LL | pub fn bad_twice(f: Result<extern "C" fn([u8]), extern "C" fn([u8])>) {} | ^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -22,7 +22,7 @@ LL | pub fn bad_twice(f: Result<extern "C" fn([u8]), extern "C" fn([u8])>) {} = note: slices have no C equivalent error: `extern` fn uses type `[u8]`, which is not FFI-safe - --> $DIR/lint-ctypes-94223.rs:7:49 + --> $DIR/lint-94223.rs:7:49 | LL | pub fn bad_twice(f: Result<extern "C" fn([u8]), extern "C" fn([u8])>) {} | ^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -31,7 +31,7 @@ LL | pub fn bad_twice(f: Result<extern "C" fn([u8]), extern "C" fn([u8])>) {} = note: slices have no C equivalent error: `extern` fn uses type `[u8]`, which is not FFI-safe - --> $DIR/lint-ctypes-94223.rs:11:18 + --> $DIR/lint-94223.rs:11:18 | LL | struct BadStruct(extern "C" fn([u8])); | ^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -40,7 +40,7 @@ LL | struct BadStruct(extern "C" fn([u8])); = note: slices have no C equivalent error: `extern` fn uses type `[u8]`, which is not FFI-safe - --> $DIR/lint-ctypes-94223.rs:15:7 + --> $DIR/lint-94223.rs:15:7 | LL | A(extern "C" fn([u8])), | ^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -49,7 +49,7 @@ LL | A(extern "C" fn([u8])), = note: slices have no C equivalent error: `extern` fn uses type `[u8]`, which is not FFI-safe - --> $DIR/lint-ctypes-94223.rs:20:7 + --> $DIR/lint-94223.rs:20:7 | LL | A(extern "C" fn([u8])), | ^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -58,7 +58,7 @@ LL | A(extern "C" fn([u8])), = note: slices have no C equivalent error: `extern` fn uses type `[u8]`, which is not FFI-safe - --> $DIR/lint-ctypes-94223.rs:24:12 + --> $DIR/lint-94223.rs:24:12 | LL | type Foo = extern "C" fn([u8]); | ^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -67,7 +67,7 @@ LL | type Foo = extern "C" fn([u8]); = note: slices have no C equivalent error: `extern` fn uses type `Option<&<T as FooTrait>::FooType>`, which is not FFI-safe - --> $DIR/lint-ctypes-94223.rs:31:20 + --> $DIR/lint-94223.rs:31:20 | LL | pub type Foo2<T> = extern "C" fn(Option<&<T as FooTrait>::FooType>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -76,7 +76,7 @@ LL | pub type Foo2<T> = extern "C" fn(Option<&<T as FooTrait>::FooType>); = note: enum has no representation hint error: `extern` fn uses type `FfiUnsafe`, which is not FFI-safe - --> $DIR/lint-ctypes-94223.rs:41:17 + --> $DIR/lint-94223.rs:41:17 | LL | pub static BAD: extern "C" fn(FfiUnsafe) = f; | ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -84,13 +84,13 @@ LL | pub static BAD: extern "C" fn(FfiUnsafe) = f; = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout note: the type is defined here - --> $DIR/lint-ctypes-94223.rs:34:1 + --> $DIR/lint-94223.rs:34:1 | LL | pub struct FfiUnsafe; | ^^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `FfiUnsafe`, which is not FFI-safe - --> $DIR/lint-ctypes-94223.rs:44:30 + --> $DIR/lint-94223.rs:44:30 | LL | pub static BAD_TWICE: Result<extern "C" fn(FfiUnsafe), extern "C" fn(FfiUnsafe)> = Ok(f); | ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -98,13 +98,13 @@ LL | pub static BAD_TWICE: Result<extern "C" fn(FfiUnsafe), extern "C" fn(FfiUns = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout note: the type is defined here - --> $DIR/lint-ctypes-94223.rs:34:1 + --> $DIR/lint-94223.rs:34:1 | LL | pub struct FfiUnsafe; | ^^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `FfiUnsafe`, which is not FFI-safe - --> $DIR/lint-ctypes-94223.rs:44:56 + --> $DIR/lint-94223.rs:44:56 | LL | pub static BAD_TWICE: Result<extern "C" fn(FfiUnsafe), extern "C" fn(FfiUnsafe)> = Ok(f); | ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -112,13 +112,13 @@ LL | pub static BAD_TWICE: Result<extern "C" fn(FfiUnsafe), extern "C" fn(FfiUns = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout note: the type is defined here - --> $DIR/lint-ctypes-94223.rs:34:1 + --> $DIR/lint-94223.rs:34:1 | LL | pub struct FfiUnsafe; | ^^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `FfiUnsafe`, which is not FFI-safe - --> $DIR/lint-ctypes-94223.rs:48:22 + --> $DIR/lint-94223.rs:48:22 | LL | pub const BAD_CONST: extern "C" fn(FfiUnsafe) = f; | ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -126,7 +126,7 @@ LL | pub const BAD_CONST: extern "C" fn(FfiUnsafe) = f; = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout note: the type is defined here - --> $DIR/lint-ctypes-94223.rs:34:1 + --> $DIR/lint-94223.rs:34:1 | LL | pub struct FfiUnsafe; | ^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/lint-ctypes-cstr.rs b/tests/ui/lint/improper-ctypes/lint-cstr.rs index b04decd0bca..b04decd0bca 100644 --- a/tests/ui/lint/lint-ctypes-cstr.rs +++ b/tests/ui/lint/improper-ctypes/lint-cstr.rs diff --git a/tests/ui/lint/lint-ctypes-cstr.stderr b/tests/ui/lint/improper-ctypes/lint-cstr.stderr index 8957758d577..da263065843 100644 --- a/tests/ui/lint/lint-ctypes-cstr.stderr +++ b/tests/ui/lint/improper-ctypes/lint-cstr.stderr @@ -1,5 +1,5 @@ error: `extern` block uses type `CStr`, which is not FFI-safe - --> $DIR/lint-ctypes-cstr.rs:7:21 + --> $DIR/lint-cstr.rs:7:21 | LL | fn take_cstr(s: CStr); | ^^^^ not FFI-safe @@ -7,13 +7,13 @@ LL | fn take_cstr(s: CStr); = help: consider passing a `*const std::ffi::c_char` instead, and use `CStr::as_ptr()` = note: `CStr`/`CString` do not have a guaranteed layout note: the lint level is defined here - --> $DIR/lint-ctypes-cstr.rs:2:9 + --> $DIR/lint-cstr.rs:2:9 | LL | #![deny(improper_ctypes, improper_ctypes_definitions)] | ^^^^^^^^^^^^^^^ error: `extern` block uses type `CStr`, which is not FFI-safe - --> $DIR/lint-ctypes-cstr.rs:10:25 + --> $DIR/lint-cstr.rs:10:25 | LL | fn take_cstr_ref(s: &CStr); | ^^^^^ not FFI-safe @@ -22,7 +22,7 @@ LL | fn take_cstr_ref(s: &CStr); = note: `CStr`/`CString` do not have a guaranteed layout error: `extern` block uses type `CString`, which is not FFI-safe - --> $DIR/lint-ctypes-cstr.rs:13:24 + --> $DIR/lint-cstr.rs:13:24 | LL | fn take_cstring(s: CString); | ^^^^^^^ not FFI-safe @@ -31,7 +31,7 @@ LL | fn take_cstring(s: CString); = note: `CStr`/`CString` do not have a guaranteed layout error: `extern` block uses type `CString`, which is not FFI-safe - --> $DIR/lint-ctypes-cstr.rs:16:28 + --> $DIR/lint-cstr.rs:16:28 | LL | fn take_cstring_ref(s: &CString); | ^^^^^^^^ not FFI-safe @@ -40,7 +40,7 @@ LL | fn take_cstring_ref(s: &CString); = note: `CStr`/`CString` do not have a guaranteed layout error: `extern` block uses type `CString`, which is not FFI-safe - --> $DIR/lint-ctypes-cstr.rs:20:43 + --> $DIR/lint-cstr.rs:20:43 | LL | fn no_special_help_for_mut_cstring(s: *mut CString); | ^^^^^^^^^^^^ not FFI-safe @@ -49,7 +49,7 @@ LL | fn no_special_help_for_mut_cstring(s: *mut CString); = note: this struct has unspecified layout error: `extern` block uses type `CString`, which is not FFI-safe - --> $DIR/lint-ctypes-cstr.rs:24:47 + --> $DIR/lint-cstr.rs:24:47 | LL | fn no_special_help_for_mut_cstring_ref(s: &mut CString); | ^^^^^^^^^^^^ not FFI-safe @@ -58,7 +58,7 @@ LL | fn no_special_help_for_mut_cstring_ref(s: &mut CString); = note: this struct has unspecified layout error: `extern` fn uses type `CStr`, which is not FFI-safe - --> $DIR/lint-ctypes-cstr.rs:29:37 + --> $DIR/lint-cstr.rs:29:37 | LL | extern "C" fn rust_take_cstr_ref(s: &CStr) {} | ^^^^^ not FFI-safe @@ -66,13 +66,13 @@ LL | extern "C" fn rust_take_cstr_ref(s: &CStr) {} = help: consider passing a `*const std::ffi::c_char` instead, and use `CStr::as_ptr()` = note: `CStr`/`CString` do not have a guaranteed layout note: the lint level is defined here - --> $DIR/lint-ctypes-cstr.rs:2:26 + --> $DIR/lint-cstr.rs:2:26 | LL | #![deny(improper_ctypes, improper_ctypes_definitions)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `CString`, which is not FFI-safe - --> $DIR/lint-ctypes-cstr.rs:32:36 + --> $DIR/lint-cstr.rs:32:36 | LL | extern "C" fn rust_take_cstring(s: CString) {} | ^^^^^^^ not FFI-safe diff --git a/tests/ui/lint/lint-ctypes.rs b/tests/ui/lint/improper-ctypes/lint-ctypes.rs index 47586c826ab..7dc06079fa3 100644 --- a/tests/ui/lint/lint-ctypes.rs +++ b/tests/ui/lint/improper-ctypes/lint-ctypes.rs @@ -52,7 +52,6 @@ extern "C" { pub fn str_type(p: &str); //~ ERROR: uses type `str` pub fn box_type(p: Box<u32>); //~ ERROR uses type `Box<u32>` pub fn opt_box_type(p: Option<Box<u32>>); - //~^ ERROR uses type `Option<Box<u32>>` pub fn char_type(p: char); //~ ERROR uses type `char` pub fn trait_type(p: &dyn Bar); //~ ERROR uses type `dyn Bar` pub fn tuple_type(p: (i32, i32)); //~ ERROR uses type `(i32, i32)` diff --git a/tests/ui/lint/lint-ctypes.stderr b/tests/ui/lint/improper-ctypes/lint-ctypes.stderr index 3fb36647d4f..6f8b951c53d 100644 --- a/tests/ui/lint/lint-ctypes.stderr +++ b/tests/ui/lint/improper-ctypes/lint-ctypes.stderr @@ -67,17 +67,8 @@ LL | pub fn box_type(p: Box<u32>); = help: consider adding a `#[repr(C)]` or `#[repr(transparent)]` attribute to this struct = note: this struct has unspecified layout -error: `extern` block uses type `Option<Box<u32>>`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:54:28 - | -LL | pub fn opt_box_type(p: Option<Box<u32>>); - | ^^^^^^^^^^^^^^^^ not FFI-safe - | - = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum - = note: enum has no representation hint - error: `extern` block uses type `char`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:56:25 + --> $DIR/lint-ctypes.rs:55:25 | LL | pub fn char_type(p: char); | ^^^^ not FFI-safe @@ -86,7 +77,7 @@ LL | pub fn char_type(p: char); = note: the `char` type has no C equivalent error: `extern` block uses type `dyn Bar`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:57:26 + --> $DIR/lint-ctypes.rs:56:26 | LL | pub fn trait_type(p: &dyn Bar); | ^^^^^^^^ not FFI-safe @@ -94,7 +85,7 @@ LL | pub fn trait_type(p: &dyn Bar); = note: trait objects have no C equivalent error: `extern` block uses type `(i32, i32)`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:58:26 + --> $DIR/lint-ctypes.rs:57:26 | LL | pub fn tuple_type(p: (i32, i32)); | ^^^^^^^^^^ not FFI-safe @@ -103,7 +94,7 @@ LL | pub fn tuple_type(p: (i32, i32)); = note: tuples have unspecified layout error: `extern` block uses type `(i32, i32)`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:59:27 + --> $DIR/lint-ctypes.rs:58:27 | LL | pub fn tuple_type2(p: I32Pair); | ^^^^^^^ not FFI-safe @@ -112,7 +103,7 @@ LL | pub fn tuple_type2(p: I32Pair); = note: tuples have unspecified layout error: `extern` block uses type `ZeroSize`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:60:25 + --> $DIR/lint-ctypes.rs:59:25 | LL | pub fn zero_size(p: ZeroSize); | ^^^^^^^^ not FFI-safe @@ -126,7 +117,7 @@ LL | pub struct ZeroSize; | ^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `ZeroSizeWithPhantomData`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:61:33 + --> $DIR/lint-ctypes.rs:60:33 | LL | pub fn zero_size_phantom(p: ZeroSizeWithPhantomData); | ^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -139,7 +130,7 @@ LL | pub struct ZeroSizeWithPhantomData(::std::marker::PhantomData<i32>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` block uses type `PhantomData<bool>`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:64:12 + --> $DIR/lint-ctypes.rs:63:12 | LL | -> ::std::marker::PhantomData<bool>; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -147,7 +138,7 @@ LL | -> ::std::marker::PhantomData<bool>; = note: composed only of `PhantomData` error: `extern` block uses type `fn()`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:65:23 + --> $DIR/lint-ctypes.rs:64:23 | LL | pub fn fn_type(p: RustFn); | ^^^^^^ not FFI-safe @@ -156,7 +147,7 @@ LL | pub fn fn_type(p: RustFn); = note: this function pointer has Rust-specific calling convention error: `extern` block uses type `fn()`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:66:24 + --> $DIR/lint-ctypes.rs:65:24 | LL | pub fn fn_type2(p: fn()); | ^^^^ not FFI-safe @@ -165,7 +156,7 @@ LL | pub fn fn_type2(p: fn()); = note: this function pointer has Rust-specific calling convention error: `extern` block uses type `Box<u32>`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:67:28 + --> $DIR/lint-ctypes.rs:66:28 | LL | pub fn fn_contained(p: RustBadRet); | ^^^^^^^^^^ not FFI-safe @@ -174,7 +165,7 @@ LL | pub fn fn_contained(p: RustBadRet); = note: this struct has unspecified layout error: `extern` block uses type `str`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:68:31 + --> $DIR/lint-ctypes.rs:67:31 | LL | pub fn transparent_str(p: TransparentStr); | ^^^^^^^^^^^^^^ not FFI-safe @@ -183,7 +174,7 @@ LL | pub fn transparent_str(p: TransparentStr); = note: string slices have no C equivalent error: `extern` block uses type `Box<u32>`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:69:30 + --> $DIR/lint-ctypes.rs:68:30 | LL | pub fn transparent_fn(p: TransparentBadFn); | ^^^^^^^^^^^^^^^^ not FFI-safe @@ -192,7 +183,7 @@ LL | pub fn transparent_fn(p: TransparentBadFn); = note: this struct has unspecified layout error: `extern` block uses type `[u8; 8]`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:70:27 + --> $DIR/lint-ctypes.rs:69:27 | LL | pub fn raw_array(arr: [u8; 8]); | ^^^^^^^ not FFI-safe @@ -201,7 +192,7 @@ LL | pub fn raw_array(arr: [u8; 8]); = note: passing raw arrays by value is not FFI-safe error: `extern` block uses type `Option<UnsafeCell<extern "C" fn()>>`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:72:26 + --> $DIR/lint-ctypes.rs:71:26 | LL | pub fn no_niche_a(a: Option<UnsafeCell<extern "C" fn()>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -210,7 +201,7 @@ LL | pub fn no_niche_a(a: Option<UnsafeCell<extern "C" fn()>>); = note: enum has no representation hint error: `extern` block uses type `Option<UnsafeCell<&i32>>`, which is not FFI-safe - --> $DIR/lint-ctypes.rs:74:26 + --> $DIR/lint-ctypes.rs:73:26 | LL | pub fn no_niche_b(b: Option<UnsafeCell<&i32>>); | ^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -218,5 +209,5 @@ LL | pub fn no_niche_b(b: Option<UnsafeCell<&i32>>); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint -error: aborting due to 22 previous errors +error: aborting due to 21 previous errors diff --git a/tests/ui/lint/lint-ctypes-enum.rs b/tests/ui/lint/improper-ctypes/lint-enum.rs index f900f998d06..f900f998d06 100644 --- a/tests/ui/lint/lint-ctypes-enum.rs +++ b/tests/ui/lint/improper-ctypes/lint-enum.rs diff --git a/tests/ui/lint/lint-ctypes-enum.stderr b/tests/ui/lint/improper-ctypes/lint-enum.stderr index 40d22723309..35d1dcb87fd 100644 --- a/tests/ui/lint/lint-ctypes-enum.stderr +++ b/tests/ui/lint/improper-ctypes/lint-enum.stderr @@ -1,5 +1,5 @@ error: `extern` block uses type `U`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:82:14 + --> $DIR/lint-enum.rs:82:14 | LL | fn uf(x: U); | ^ not FFI-safe @@ -7,18 +7,18 @@ LL | fn uf(x: U); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint note: the type is defined here - --> $DIR/lint-ctypes-enum.rs:9:1 + --> $DIR/lint-enum.rs:9:1 | LL | enum U { | ^^^^^^ note: the lint level is defined here - --> $DIR/lint-ctypes-enum.rs:2:9 + --> $DIR/lint-enum.rs:2:9 | LL | #![deny(improper_ctypes)] | ^^^^^^^^^^^^^^^ error: `extern` block uses type `B`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:83:14 + --> $DIR/lint-enum.rs:83:14 | LL | fn bf(x: B); | ^ not FFI-safe @@ -26,13 +26,13 @@ LL | fn bf(x: B); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint note: the type is defined here - --> $DIR/lint-ctypes-enum.rs:12:1 + --> $DIR/lint-enum.rs:12:1 | LL | enum B { | ^^^^^^ error: `extern` block uses type `T`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:84:14 + --> $DIR/lint-enum.rs:84:14 | LL | fn tf(x: T); | ^ not FFI-safe @@ -40,13 +40,13 @@ LL | fn tf(x: T); = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint note: the type is defined here - --> $DIR/lint-ctypes-enum.rs:16:1 + --> $DIR/lint-enum.rs:16:1 | LL | enum T { | ^^^^^^ error: `extern` block uses type `Option<TransparentUnion<NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:108:36 + --> $DIR/lint-enum.rs:108:36 | LL | fn option_transparent_union(x: Option<TransparentUnion<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -55,7 +55,7 @@ LL | fn option_transparent_union(x: Option<TransparentUnion<num::NonZero<u8> = note: enum has no representation hint error: `extern` block uses type `Option<Rust<NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:110:28 + --> $DIR/lint-enum.rs:110:28 | LL | fn option_repr_rust(x: Option<Rust<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -64,7 +64,7 @@ LL | fn option_repr_rust(x: Option<Rust<num::NonZero<u8>>>); = note: enum has no representation hint error: `extern` block uses type `Option<u8>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:111:21 + --> $DIR/lint-enum.rs:111:21 | LL | fn option_u8(x: Option<u8>); | ^^^^^^^^^^ not FFI-safe @@ -73,7 +73,7 @@ LL | fn option_u8(x: Option<u8>); = note: enum has no representation hint error: `extern` block uses type `Result<TransparentUnion<NonZero<u8>>, ()>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:131:38 + --> $DIR/lint-enum.rs:131:38 | LL | fn result_transparent_union_t(x: Result<TransparentUnion<num::NonZero<u8>>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -82,7 +82,7 @@ LL | fn result_transparent_union_t(x: Result<TransparentUnion<num::NonZero<u = note: enum has no representation hint error: `extern` block uses type `Result<Rust<NonZero<u8>>, ()>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:133:30 + --> $DIR/lint-enum.rs:133:30 | LL | fn result_repr_rust_t(x: Result<Rust<num::NonZero<u8>>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -91,7 +91,7 @@ LL | fn result_repr_rust_t(x: Result<Rust<num::NonZero<u8>>, ()>); = note: enum has no representation hint error: `extern` block uses type `Result<NonZero<u8>, U>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:137:51 + --> $DIR/lint-enum.rs:137:51 | LL | fn result_1zst_exhaustive_single_variant_t(x: Result<num::NonZero<u8>, U>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -100,7 +100,7 @@ LL | fn result_1zst_exhaustive_single_variant_t(x: Result<num::NonZero<u8>, = note: enum has no representation hint error: `extern` block uses type `Result<NonZero<u8>, B>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:139:53 + --> $DIR/lint-enum.rs:139:53 | LL | fn result_1zst_exhaustive_multiple_variant_t(x: Result<num::NonZero<u8>, B>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -109,7 +109,7 @@ LL | fn result_1zst_exhaustive_multiple_variant_t(x: Result<num::NonZero<u8> = note: enum has no representation hint error: `extern` block uses type `Result<NonZero<u8>, NonExhaustive>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:141:51 + --> $DIR/lint-enum.rs:141:51 | LL | fn result_1zst_non_exhaustive_no_variant_t(x: Result<num::NonZero<u8>, NonExhaustive>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -118,7 +118,7 @@ LL | fn result_1zst_non_exhaustive_no_variant_t(x: Result<num::NonZero<u8>, = note: enum has no representation hint error: `extern` block uses type `Result<NonZero<u8>, Field>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:144:49 + --> $DIR/lint-enum.rs:144:49 | LL | fn result_1zst_exhaustive_single_field_t(x: Result<num::NonZero<u8>, Field>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -127,7 +127,7 @@ LL | fn result_1zst_exhaustive_single_field_t(x: Result<num::NonZero<u8>, Fi = note: enum has no representation hint error: `extern` block uses type `Result<Result<(), NonZero<u8>>, ()>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:146:30 + --> $DIR/lint-enum.rs:146:30 | LL | fn result_cascading_t(x: Result<Result<(), num::NonZero<u8>>, ()>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -136,7 +136,7 @@ LL | fn result_cascading_t(x: Result<Result<(), num::NonZero<u8>>, ()>); = note: enum has no representation hint error: `extern` block uses type `Result<(), TransparentUnion<NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:167:38 + --> $DIR/lint-enum.rs:167:38 | LL | fn result_transparent_union_e(x: Result<(), TransparentUnion<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -145,7 +145,7 @@ LL | fn result_transparent_union_e(x: Result<(), TransparentUnion<num::NonZe = note: enum has no representation hint error: `extern` block uses type `Result<(), Rust<NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:169:30 + --> $DIR/lint-enum.rs:169:30 | LL | fn result_repr_rust_e(x: Result<(), Rust<num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -154,7 +154,7 @@ LL | fn result_repr_rust_e(x: Result<(), Rust<num::NonZero<u8>>>); = note: enum has no representation hint error: `extern` block uses type `Result<U, NonZero<u8>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:173:51 + --> $DIR/lint-enum.rs:173:51 | LL | fn result_1zst_exhaustive_single_variant_e(x: Result<U, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -163,7 +163,7 @@ LL | fn result_1zst_exhaustive_single_variant_e(x: Result<U, num::NonZero<u8 = note: enum has no representation hint error: `extern` block uses type `Result<B, NonZero<u8>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:175:53 + --> $DIR/lint-enum.rs:175:53 | LL | fn result_1zst_exhaustive_multiple_variant_e(x: Result<B, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -172,7 +172,7 @@ LL | fn result_1zst_exhaustive_multiple_variant_e(x: Result<B, num::NonZero< = note: enum has no representation hint error: `extern` block uses type `Result<NonExhaustive, NonZero<u8>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:177:51 + --> $DIR/lint-enum.rs:177:51 | LL | fn result_1zst_non_exhaustive_no_variant_e(x: Result<NonExhaustive, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -181,7 +181,7 @@ LL | fn result_1zst_non_exhaustive_no_variant_e(x: Result<NonExhaustive, num = note: enum has no representation hint error: `extern` block uses type `Result<Field, NonZero<u8>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:180:49 + --> $DIR/lint-enum.rs:180:49 | LL | fn result_1zst_exhaustive_single_field_e(x: Result<Field, num::NonZero<u8>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -190,7 +190,7 @@ LL | fn result_1zst_exhaustive_single_field_e(x: Result<Field, num::NonZero< = note: enum has no representation hint error: `extern` block uses type `Result<(), Result<(), NonZero<u8>>>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:182:30 + --> $DIR/lint-enum.rs:182:30 | LL | fn result_cascading_e(x: Result<(), Result<(), num::NonZero<u8>>>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -199,7 +199,7 @@ LL | fn result_cascading_e(x: Result<(), Result<(), num::NonZero<u8>>>); = note: enum has no representation hint error: `extern` block uses type `Result<(), ()>`, which is not FFI-safe - --> $DIR/lint-ctypes-enum.rs:184:27 + --> $DIR/lint-enum.rs:184:27 | LL | fn result_unit_t_e(x: Result<(), ()>); | ^^^^^^^^^^^^^^ not FFI-safe diff --git a/tests/ui/lint/lint-ctypes-fn.rs b/tests/ui/lint/improper-ctypes/lint-fn.rs index 0b84098e390..0b84098e390 100644 --- a/tests/ui/lint/lint-ctypes-fn.rs +++ b/tests/ui/lint/improper-ctypes/lint-fn.rs diff --git a/tests/ui/lint/lint-ctypes-fn.stderr b/tests/ui/lint/improper-ctypes/lint-fn.stderr index a19c04a63b5..34e3bd021b9 100644 --- a/tests/ui/lint/lint-ctypes-fn.stderr +++ b/tests/ui/lint/improper-ctypes/lint-fn.stderr @@ -1,5 +1,5 @@ error: `extern` fn uses type `[u32]`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:70:33 + --> $DIR/lint-fn.rs:70:33 | LL | pub extern "C" fn slice_type(p: &[u32]) { } | ^^^^^^ not FFI-safe @@ -7,13 +7,13 @@ LL | pub extern "C" fn slice_type(p: &[u32]) { } = help: consider using a raw pointer instead = note: slices have no C equivalent note: the lint level is defined here - --> $DIR/lint-ctypes-fn.rs:2:9 + --> $DIR/lint-fn.rs:2:9 | LL | #![deny(improper_ctypes_definitions)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `str`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:73:31 + --> $DIR/lint-fn.rs:73:31 | LL | pub extern "C" fn str_type(p: &str) { } | ^^^^ not FFI-safe @@ -22,7 +22,7 @@ LL | pub extern "C" fn str_type(p: &str) { } = note: string slices have no C equivalent error: `extern` fn uses type `Box<[u8]>`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:80:34 + --> $DIR/lint-fn.rs:80:34 | LL | pub extern "C" fn boxed_slice(p: Box<[u8]>) { } | ^^^^^^^^^ not FFI-safe @@ -30,7 +30,7 @@ LL | pub extern "C" fn boxed_slice(p: Box<[u8]>) { } = note: box cannot be represented as a single pointer error: `extern` fn uses type `Box<str>`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:83:35 + --> $DIR/lint-fn.rs:83:35 | LL | pub extern "C" fn boxed_string(p: Box<str>) { } | ^^^^^^^^ not FFI-safe @@ -38,7 +38,7 @@ LL | pub extern "C" fn boxed_string(p: Box<str>) { } = note: box cannot be represented as a single pointer error: `extern` fn uses type `Box<dyn Trait>`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:86:34 + --> $DIR/lint-fn.rs:86:34 | LL | pub extern "C" fn boxed_trait(p: Box<dyn Trait>) { } | ^^^^^^^^^^^^^^ not FFI-safe @@ -46,7 +46,7 @@ LL | pub extern "C" fn boxed_trait(p: Box<dyn Trait>) { } = note: box cannot be represented as a single pointer error: `extern` fn uses type `char`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:89:32 + --> $DIR/lint-fn.rs:89:32 | LL | pub extern "C" fn char_type(p: char) { } | ^^^^ not FFI-safe @@ -55,7 +55,7 @@ LL | pub extern "C" fn char_type(p: char) { } = note: the `char` type has no C equivalent error: `extern` fn uses type `(i32, i32)`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:92:33 + --> $DIR/lint-fn.rs:92:33 | LL | pub extern "C" fn tuple_type(p: (i32, i32)) { } | ^^^^^^^^^^ not FFI-safe @@ -64,7 +64,7 @@ LL | pub extern "C" fn tuple_type(p: (i32, i32)) { } = note: tuples have unspecified layout error: `extern` fn uses type `(i32, i32)`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:95:34 + --> $DIR/lint-fn.rs:95:34 | LL | pub extern "C" fn tuple_type2(p: I32Pair) { } | ^^^^^^^ not FFI-safe @@ -73,7 +73,7 @@ LL | pub extern "C" fn tuple_type2(p: I32Pair) { } = note: tuples have unspecified layout error: `extern` fn uses type `ZeroSize`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:98:32 + --> $DIR/lint-fn.rs:98:32 | LL | pub extern "C" fn zero_size(p: ZeroSize) { } | ^^^^^^^^ not FFI-safe @@ -81,26 +81,26 @@ LL | pub extern "C" fn zero_size(p: ZeroSize) { } = help: consider adding a member to this struct = note: this struct has no fields note: the type is defined here - --> $DIR/lint-ctypes-fn.rs:25:1 + --> $DIR/lint-fn.rs:25:1 | LL | pub struct ZeroSize; | ^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `ZeroSizeWithPhantomData`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:101:40 + --> $DIR/lint-fn.rs:101:40 | LL | pub extern "C" fn zero_size_phantom(p: ZeroSizeWithPhantomData) { } | ^^^^^^^^^^^^^^^^^^^^^^^ not FFI-safe | = note: composed only of `PhantomData` note: the type is defined here - --> $DIR/lint-ctypes-fn.rs:60:1 + --> $DIR/lint-fn.rs:60:1 | LL | pub struct ZeroSizeWithPhantomData(PhantomData<i32>); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: `extern` fn uses type `PhantomData<bool>`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:104:51 + --> $DIR/lint-fn.rs:104:51 | LL | pub extern "C" fn zero_size_phantom_toplevel() -> PhantomData<bool> { | ^^^^^^^^^^^^^^^^^ not FFI-safe @@ -108,7 +108,7 @@ LL | pub extern "C" fn zero_size_phantom_toplevel() -> PhantomData<bool> { = note: composed only of `PhantomData` error: `extern` fn uses type `fn()`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:109:30 + --> $DIR/lint-fn.rs:109:30 | LL | pub extern "C" fn fn_type(p: RustFn) { } | ^^^^^^ not FFI-safe @@ -117,7 +117,7 @@ LL | pub extern "C" fn fn_type(p: RustFn) { } = note: this function pointer has Rust-specific calling convention error: `extern` fn uses type `fn()`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:112:31 + --> $DIR/lint-fn.rs:112:31 | LL | pub extern "C" fn fn_type2(p: fn()) { } | ^^^^ not FFI-safe @@ -126,7 +126,7 @@ LL | pub extern "C" fn fn_type2(p: fn()) { } = note: this function pointer has Rust-specific calling convention error: `extern` fn uses type `str`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:117:38 + --> $DIR/lint-fn.rs:117:38 | LL | pub extern "C" fn transparent_str(p: TransparentStr) { } | ^^^^^^^^^^^^^^ not FFI-safe @@ -135,7 +135,7 @@ LL | pub extern "C" fn transparent_str(p: TransparentStr) { } = note: string slices have no C equivalent error: `extern` fn uses type `PhantomData<bool>`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:169:43 + --> $DIR/lint-fn.rs:169:43 | LL | pub extern "C" fn unused_generic2<T>() -> PhantomData<bool> { | ^^^^^^^^^^^^^^^^^ not FFI-safe @@ -143,7 +143,7 @@ LL | pub extern "C" fn unused_generic2<T>() -> PhantomData<bool> { = note: composed only of `PhantomData` error: `extern` fn uses type `Vec<T>`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:182:39 + --> $DIR/lint-fn.rs:182:39 | LL | pub extern "C" fn used_generic4<T>(x: Vec<T>) { } | ^^^^^^ not FFI-safe @@ -152,7 +152,7 @@ LL | pub extern "C" fn used_generic4<T>(x: Vec<T>) { } = note: this struct has unspecified layout error: `extern` fn uses type `Vec<T>`, which is not FFI-safe - --> $DIR/lint-ctypes-fn.rs:185:41 + --> $DIR/lint-fn.rs:185:41 | LL | pub extern "C" fn used_generic5<T>() -> Vec<T> { | ^^^^^^ not FFI-safe diff --git a/tests/ui/lint/lint-ctypes-non-recursion-limit.rs b/tests/ui/lint/improper-ctypes/lint-non-recursion-limit.rs index 61e95dc5a46..61e95dc5a46 100644 --- a/tests/ui/lint/lint-ctypes-non-recursion-limit.rs +++ b/tests/ui/lint/improper-ctypes/lint-non-recursion-limit.rs diff --git a/tests/ui/lint/lint-ctypes-option-nonnull-unsized.rs b/tests/ui/lint/improper-ctypes/lint-option-nonnull-unsized.rs index ca08eb23a57..ca08eb23a57 100644 --- a/tests/ui/lint/lint-ctypes-option-nonnull-unsized.rs +++ b/tests/ui/lint/improper-ctypes/lint-option-nonnull-unsized.rs diff --git a/tests/ui/lint/lint-ctypes-option-nonnull-unsized.stderr b/tests/ui/lint/improper-ctypes/lint-option-nonnull-unsized.stderr index 74630469416..b17fb6bd614 100644 --- a/tests/ui/lint/lint-ctypes-option-nonnull-unsized.stderr +++ b/tests/ui/lint/improper-ctypes/lint-option-nonnull-unsized.stderr @@ -1,5 +1,5 @@ error: `extern` fn uses type `Option<&T>`, which is not FFI-safe - --> $DIR/lint-ctypes-option-nonnull-unsized.rs:3:45 + --> $DIR/lint-option-nonnull-unsized.rs:3:45 | LL | extern "C" fn foo<T: ?Sized + 'static>() -> Option<&'static T> { | ^^^^^^^^^^^^^^^^^^ not FFI-safe @@ -7,7 +7,7 @@ LL | extern "C" fn foo<T: ?Sized + 'static>() -> Option<&'static T> { = help: consider adding a `#[repr(C)]`, `#[repr(transparent)]`, or integer `#[repr(...)]` attribute to this enum = note: enum has no representation hint note: the lint level is defined here - --> $DIR/lint-ctypes-option-nonnull-unsized.rs:1:9 + --> $DIR/lint-option-nonnull-unsized.rs:1:9 | LL | #![deny(improper_ctypes_definitions)] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/lint/lint-ctypes-113436.rs b/tests/ui/lint/improper-ctypes/mustpass-113436.rs index d5acdc45f92..d5acdc45f92 100644 --- a/tests/ui/lint/lint-ctypes-113436.rs +++ b/tests/ui/lint/improper-ctypes/mustpass-113436.rs diff --git a/tests/ui/lint/lint-ctypes-113900.rs b/tests/ui/lint/improper-ctypes/mustpass-113900.rs index 3dd196a4094..3dd196a4094 100644 --- a/tests/ui/lint/lint-ctypes-113900.rs +++ b/tests/ui/lint/improper-ctypes/mustpass-113900.rs diff --git a/tests/ui/lint/improper_ctypes_definitions_ice_134060.rs b/tests/ui/lint/improper-ctypes/mustpass-134060.rs index b30be996736..b30be996736 100644 --- a/tests/ui/lint/improper_ctypes_definitions_ice_134060.rs +++ b/tests/ui/lint/improper-ctypes/mustpass-134060.rs diff --git a/tests/ui/lint/improper_ctypes_definitions_ice_134060.stderr b/tests/ui/lint/improper-ctypes/mustpass-134060.stderr index f6ac9a92cd5..791b2f73709 100644 --- a/tests/ui/lint/improper_ctypes_definitions_ice_134060.stderr +++ b/tests/ui/lint/improper-ctypes/mustpass-134060.stderr @@ -1,5 +1,5 @@ warning: `extern` fn uses type `()`, which is not FFI-safe - --> $DIR/improper_ctypes_definitions_ice_134060.rs:11:34 + --> $DIR/mustpass-134060.rs:11:34 | LL | extern "C" fn foo_(&self, _: ()) -> i64 { | ^^ not FFI-safe diff --git a/tests/ui/lint/lint-ctypes-66202.rs b/tests/ui/lint/improper-ctypes/mustpass-66202.rs index e4cfa54c8d8..e4cfa54c8d8 100644 --- a/tests/ui/lint/lint-ctypes-66202.rs +++ b/tests/ui/lint/improper-ctypes/mustpass-66202.rs diff --git a/tests/ui/lint/lint-ctypes-73249-1.rs b/tests/ui/lint/improper-ctypes/mustpass-73249-1.rs index 0ca91ef294f..0ca91ef294f 100644 --- a/tests/ui/lint/lint-ctypes-73249-1.rs +++ b/tests/ui/lint/improper-ctypes/mustpass-73249-1.rs diff --git a/tests/ui/lint/lint-ctypes-73249-4.rs b/tests/ui/lint/improper-ctypes/mustpass-73249-4.rs index 37099c1313a..37099c1313a 100644 --- a/tests/ui/lint/lint-ctypes-73249-4.rs +++ b/tests/ui/lint/improper-ctypes/mustpass-73249-4.rs diff --git a/tests/ui/lint/lint-ctypes-73249.rs b/tests/ui/lint/improper-ctypes/mustpass-73249.rs index c5f2318ef0a..c5f2318ef0a 100644 --- a/tests/ui/lint/lint-ctypes-73249.rs +++ b/tests/ui/lint/improper-ctypes/mustpass-73249.rs diff --git a/tests/ui/lint/lint-ctypes-73251.rs b/tests/ui/lint/improper-ctypes/mustpass-73251.rs index 15c1dfcaabf..15c1dfcaabf 100644 --- a/tests/ui/lint/lint-ctypes-73251.rs +++ b/tests/ui/lint/improper-ctypes/mustpass-73251.rs diff --git a/tests/ui/lint/lint-ctypes-73747.rs b/tests/ui/lint/improper-ctypes/mustpass-73747.rs index a2562e3b421..a2562e3b421 100644 --- a/tests/ui/lint/lint-ctypes-73747.rs +++ b/tests/ui/lint/improper-ctypes/mustpass-73747.rs diff --git a/tests/ui/lint/improper_ctypes/repr-rust-is-undefined.rs b/tests/ui/lint/improper-ctypes/repr-rust-is-undefined.rs index 379c4132404..379c4132404 100644 --- a/tests/ui/lint/improper_ctypes/repr-rust-is-undefined.rs +++ b/tests/ui/lint/improper-ctypes/repr-rust-is-undefined.rs diff --git a/tests/ui/lint/improper_ctypes/repr-rust-is-undefined.stderr b/tests/ui/lint/improper-ctypes/repr-rust-is-undefined.stderr index 5f0465bcf00..5f0465bcf00 100644 --- a/tests/ui/lint/improper_ctypes/repr-rust-is-undefined.stderr +++ b/tests/ui/lint/improper-ctypes/repr-rust-is-undefined.stderr diff --git a/tests/ui/lint/inert-attr-macro.rs b/tests/ui/lint/inert-attr-macro.rs index d345cbc0f07..c2ccba7f9ba 100644 --- a/tests/ui/lint/inert-attr-macro.rs +++ b/tests/ui/lint/inert-attr-macro.rs @@ -1,6 +1,5 @@ //@ check-pass -#![feature(rustc_attrs)] #![warn(unused)] macro_rules! foo { @@ -8,16 +7,18 @@ macro_rules! foo { } fn main() { - #[rustc_dummy] foo!(); //~ WARN unused attribute `rustc_dummy` + #[inline] foo!(); //~ WARN `#[inline]` attribute cannot be used on macro calls + //~^ WARN previously accepted // This does nothing, since `#[allow(warnings)]` is itself // an inert attribute on a macro call - #[allow(warnings)] #[rustc_dummy] foo!(); //~ WARN unused attribute `allow` - //~^ WARN unused attribute `rustc_dummy` + #[allow(warnings)] #[inline] foo!(); //~ WARN unused attribute `allow` + //~^ WARN `#[inline]` attribute cannot be used on macro calls + //~| WARN previously accepted // This does work, since the attribute is on a parent // of the macro invocation. - #[allow(warnings)] { #[rustc_dummy] foo!(); } + #[allow(warnings)] { #[inline] foo!(); } // Ok, `cfg` and `cfg_attr` are expanded eagerly and do not warn. #[cfg(true)] foo!(); diff --git a/tests/ui/lint/inert-attr-macro.stderr b/tests/ui/lint/inert-attr-macro.stderr index fc02ee34ae6..9ab6e3ddc74 100644 --- a/tests/ui/lint/inert-attr-macro.stderr +++ b/tests/ui/lint/inert-attr-macro.stderr @@ -1,16 +1,13 @@ -warning: unused attribute `rustc_dummy` - --> $DIR/inert-attr-macro.rs:11:5 +warning: `#[inline]` attribute cannot be used on macro calls + --> $DIR/inert-attr-macro.rs:10:5 | -LL | #[rustc_dummy] foo!(); - | ^^^^^^^^^^^^^^ +LL | #[inline] foo!(); + | ^^^^^^^^^ | -note: the built-in attribute `rustc_dummy` will be ignored, since it's applied to the macro invocation `foo` - --> $DIR/inert-attr-macro.rs:11:20 - | -LL | #[rustc_dummy] foo!(); - | ^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[inline]` can only be applied to functions note: the lint level is defined here - --> $DIR/inert-attr-macro.rs:4:9 + --> $DIR/inert-attr-macro.rs:3:9 | LL | #![warn(unused)] | ^^^^^^ @@ -19,26 +16,23 @@ LL | #![warn(unused)] warning: unused attribute `allow` --> $DIR/inert-attr-macro.rs:15:5 | -LL | #[allow(warnings)] #[rustc_dummy] foo!(); +LL | #[allow(warnings)] #[inline] foo!(); | ^^^^^^^^^^^^^^^^^^ | note: the built-in attribute `allow` will be ignored, since it's applied to the macro invocation `foo` - --> $DIR/inert-attr-macro.rs:15:39 + --> $DIR/inert-attr-macro.rs:15:34 | -LL | #[allow(warnings)] #[rustc_dummy] foo!(); - | ^^^ +LL | #[allow(warnings)] #[inline] foo!(); + | ^^^ -warning: unused attribute `rustc_dummy` +warning: `#[inline]` attribute cannot be used on macro calls --> $DIR/inert-attr-macro.rs:15:24 | -LL | #[allow(warnings)] #[rustc_dummy] foo!(); - | ^^^^^^^^^^^^^^ - | -note: the built-in attribute `rustc_dummy` will be ignored, since it's applied to the macro invocation `foo` - --> $DIR/inert-attr-macro.rs:15:39 +LL | #[allow(warnings)] #[inline] foo!(); + | ^^^^^^^^^ | -LL | #[allow(warnings)] #[rustc_dummy] foo!(); - | ^^^ + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in a future release! + = help: `#[inline]` can only be applied to functions warning: 3 warnings emitted diff --git a/tests/ui/lint/int_to_ptr-unsized.rs b/tests/ui/lint/int_to_ptr-unsized.rs new file mode 100644 index 00000000000..bbdc2474561 --- /dev/null +++ b/tests/ui/lint/int_to_ptr-unsized.rs @@ -0,0 +1,23 @@ +// Checks for the `integer_to_pointer_transmutes` lint with unsized types +// +// Related to https://github.com/rust-lang/rust/issues/145935 + +//@ check-pass + +#![allow(non_camel_case_types)] +#![allow(unused_unsafe)] + +#[cfg(target_pointer_width = "64")] +type usizemetadata = i128; + +#[cfg(target_pointer_width = "32")] +type usizemetadata = i64; + +unsafe fn unsized_type(a: usize) { + let _ref = unsafe { std::mem::transmute::<usizemetadata, &'static str>(0xff) }; + //~^ WARN transmuting an integer to a pointer + let _ptr = unsafe { std::mem::transmute::<usizemetadata, *const [u8]>(0xff) }; + //~^ WARN transmuting an integer to a pointer +} + +fn main() {} diff --git a/tests/ui/lint/int_to_ptr-unsized.stderr b/tests/ui/lint/int_to_ptr-unsized.stderr new file mode 100644 index 00000000000..9799af8b12c --- /dev/null +++ b/tests/ui/lint/int_to_ptr-unsized.stderr @@ -0,0 +1,27 @@ +warning: transmuting an integer to a pointer creates a pointer without provenance + --> $DIR/int_to_ptr-unsized.rs:17:25 + | +LL | let _ref = unsafe { std::mem::transmute::<usizemetadata, &'static str>(0xff) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` + = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers> + = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance> + = note: `#[warn(integer_to_ptr_transmutes)]` on by default + +warning: transmuting an integer to a pointer creates a pointer without provenance + --> $DIR/int_to_ptr-unsized.rs:19:25 + | +LL | let _ptr = unsafe { std::mem::transmute::<usizemetadata, *const [u8]>(0xff) }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this is dangerous because dereferencing the resulting pointer is undefined behavior + = note: exposed provenance semantics can be used to create a pointer based on some previously exposed provenance + = help: if you truly mean to create a pointer without provenance, use `std::ptr::without_provenance_mut` + = help: for more information about transmute, see <https://doc.rust-lang.org/std/mem/fn.transmute.html#transmutation-between-pointers-and-integers> + = help: for more information about exposed provenance, see <https://doc.rust-lang.org/std/ptr/index.html#exposed-provenance> + +warning: 2 warnings emitted + diff --git a/tests/ui/lint/linker-warning.stderr b/tests/ui/lint/linker-warning.stderr index c678562ab54..ae5f6b3adec 100644 --- a/tests/ui/lint/linker-warning.stderr +++ b/tests/ui/lint/linker-warning.stderr @@ -1,4 +1,4 @@ -warning: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` +warning: crate-level attribute should be an inner attribute --> $DIR/linker-warning.rs:7:1 | LL | #[allow(linker_messages)] @@ -9,6 +9,10 @@ note: the lint level is defined here | LL | #![warn(unused_attributes)] | ^^^^^^^^^^^^^^^^^ +help: add a `!` + | +LL | #![allow(linker_messages)] + | + warning: unused attribute --> $DIR/linker-warning.rs:4:1 diff --git a/tests/ui/lint/lint-misplaced-attr.stderr b/tests/ui/lint/lint-misplaced-attr.stderr index abaf4620e6f..bcfda170080 100644 --- a/tests/ui/lint/lint-misplaced-attr.stderr +++ b/tests/ui/lint/lint-misplaced-attr.stderr @@ -10,11 +10,16 @@ note: the lint level is defined here LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ -error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` +error: crate-level attribute should be an inner attribute --> $DIR/lint-misplaced-attr.rs:10:1 | LL | #[crate_type = "bin"] fn main() {} | ^^^^^^^^^^^^^^^^^^^^^ + | +help: add a `!` + | +LL | #![crate_type = "bin"] fn main() {} + | + error: aborting due to 2 previous errors diff --git a/tests/ui/lint/non-snake-case/lint-uppercase-variables.stderr b/tests/ui/lint/non-snake-case/lint-uppercase-variables.stderr index b0c56003957..e5f2e65fd91 100644 --- a/tests/ui/lint/non-snake-case/lint-uppercase-variables.stderr +++ b/tests/ui/lint/non-snake-case/lint-uppercase-variables.stderr @@ -16,7 +16,7 @@ warning: unused variable: `Foo` --> $DIR/lint-uppercase-variables.rs:22:9 | LL | Foo => {} - | ^^^ help: if this is intentional, prefix it with an underscore: `_Foo` + | ^^^ | note: the lint level is defined here --> $DIR/lint-uppercase-variables.rs:1:9 @@ -24,12 +24,29 @@ note: the lint level is defined here LL | #![warn(unused)] | ^^^^^^ = note: `#[warn(unused_variables)]` implied by `#[warn(unused)]` +help: if this is intentional, prefix it with an underscore + | +LL | _Foo => {} + | + +help: you might have meant to pattern match on the similarly named variant `Foo` + | +LL | foo::Foo::Foo => {} + | ++++++++++ warning: unused variable: `Foo` --> $DIR/lint-uppercase-variables.rs:28:9 | LL | let Foo = foo::Foo::Foo; - | ^^^ help: if this is intentional, prefix it with an underscore: `_Foo` + | ^^^ + | +help: if this is intentional, prefix it with an underscore + | +LL | let _Foo = foo::Foo::Foo; + | + +help: you might have meant to pattern match on the similarly named variant `Foo` + | +LL | let foo::Foo::Foo = foo::Foo::Foo; + | ++++++++++ error[E0170]: pattern binding `Foo` is named the same as one of the variants of the type `foo::Foo` --> $DIR/lint-uppercase-variables.rs:33:17 @@ -41,7 +58,16 @@ warning: unused variable: `Foo` --> $DIR/lint-uppercase-variables.rs:33:17 | LL | fn in_param(Foo: foo::Foo) {} - | ^^^ help: if this is intentional, prefix it with an underscore: `_Foo` + | ^^^ + | +help: if this is intentional, prefix it with an underscore + | +LL | fn in_param(_Foo: foo::Foo) {} + | + +help: you might have meant to pattern match on the similarly named variant `Foo` + | +LL | fn in_param(foo::Foo::Foo: foo::Foo) {} + | ++++++++++ error: structure field `X` should have a snake case name --> $DIR/lint-uppercase-variables.rs:10:5 diff --git a/tests/ui/lint/unused/concat-in-crate-name-issue-137687.rs b/tests/ui/lint/unused/concat-in-crate-name-issue-137687.rs index 37fbf93ffa1..c507b6590c2 100644 --- a/tests/ui/lint/unused/concat-in-crate-name-issue-137687.rs +++ b/tests/ui/lint/unused/concat-in-crate-name-issue-137687.rs @@ -1,7 +1,7 @@ #![deny(unused)] #[crate_name = concat !()] -//~^ ERROR crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo] +//~^ ERROR crate-level attribute should be an inner attribute macro_rules! a { //~^ ERROR unused macro definition () => {}; diff --git a/tests/ui/lint/unused/concat-in-crate-name-issue-137687.stderr b/tests/ui/lint/unused/concat-in-crate-name-issue-137687.stderr index 4ffb55d493a..b06e65af7bc 100644 --- a/tests/ui/lint/unused/concat-in-crate-name-issue-137687.stderr +++ b/tests/ui/lint/unused/concat-in-crate-name-issue-137687.stderr @@ -11,12 +11,20 @@ LL | #![deny(unused)] | ^^^^^^ = note: `#[deny(unused_macros)]` implied by `#[deny(unused)]` -error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` +error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![crate_name]` --> $DIR/concat-in-crate-name-issue-137687.rs:3:1 | LL | #[crate_name = concat !()] | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | +note: This attribute does not have an `!`, which means it is applied to this macro def + --> $DIR/concat-in-crate-name-issue-137687.rs:5:1 + | +LL | / macro_rules! a { +LL | | +LL | | () => {}; +LL | | } + | |_^ = note: `#[deny(unused_attributes)]` implied by `#[deny(unused)]` error: aborting due to 2 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 9d61120463c..af64be8f6e9 100644 --- a/tests/ui/lint/unused/unused-attr-macro-rules.stderr +++ b/tests/ui/lint/unused/unused-attr-macro-rules.stderr @@ -1,4 +1,4 @@ -error: crate-level attribute should be an inner attribute: add an exclamation mark: `#![foo]` +error: crate-level attribute should be an inner attribute --> $DIR/unused-attr-macro-rules.rs:11:1 | LL | #[recursion_limit="1"] @@ -9,6 +9,10 @@ note: the lint level is defined here | LL | #![deny(unused_attributes)] | ^^^^^^^^^^^^^^^^^ +help: add a `!` + | +LL | #![recursion_limit="1"] + | + error: `#[macro_use]` attribute cannot be used on macro defs --> $DIR/unused-attr-macro-rules.rs:7:1 diff --git a/tests/ui/lint/unused/unused_attributes-must_use.fixed b/tests/ui/lint/unused/unused_attributes-must_use.fixed index 6bc63c8ee5b..fa596da95cc 100644 --- a/tests/ui/lint/unused/unused_attributes-must_use.fixed +++ b/tests/ui/lint/unused/unused_attributes-must_use.fixed @@ -65,7 +65,6 @@ extern "Rust" { fn foreign_foo() -> i64; } - //~ ERROR unused attribute //~^ ERROR `#[must_use]` attribute cannot be used on macro calls //~| WARN this was previously accepted by the compiler but is being phased out global_asm!(""); diff --git a/tests/ui/lint/unused/unused_attributes-must_use.rs b/tests/ui/lint/unused/unused_attributes-must_use.rs index 3c0d76e619f..3e72dd1e438 100644 --- a/tests/ui/lint/unused/unused_attributes-must_use.rs +++ b/tests/ui/lint/unused/unused_attributes-must_use.rs @@ -65,7 +65,7 @@ extern "Rust" { fn foreign_foo() -> i64; } -#[must_use] //~ ERROR unused attribute +#[must_use] //~^ ERROR `#[must_use]` attribute cannot be used on macro calls //~| WARN this was previously accepted by the compiler but is being phased out global_asm!(""); diff --git a/tests/ui/lint/unused/unused_attributes-must_use.stderr b/tests/ui/lint/unused/unused_attributes-must_use.stderr index 231d799057c..001ec52ddd9 100644 --- a/tests/ui/lint/unused/unused_attributes-must_use.stderr +++ b/tests/ui/lint/unused/unused_attributes-must_use.stderr @@ -12,18 +12,6 @@ note: the lint level is defined here LL | #![deny(unused_attributes, unused_must_use)] | ^^^^^^^^^^^^^^^^^ -error: unused attribute `must_use` - --> $DIR/unused_attributes-must_use.rs:68:1 - | -LL | #[must_use] - | ^^^^^^^^^^^ - | -note: the built-in attribute `must_use` will be ignored, since it's applied to the macro invocation `global_asm` - --> $DIR/unused_attributes-must_use.rs:71:1 - | -LL | global_asm!(""); - | ^^^^^^^^^^ - error: `#[must_use]` attribute cannot be used on extern crates --> $DIR/unused_attributes-must_use.rs:7:1 | @@ -295,5 +283,5 @@ help: use `let _ = ...` to ignore the resulting value LL | let _ = ().get_four(); | +++++++ -error: aborting due to 30 previous errors +error: aborting due to 29 previous errors diff --git a/tests/ui/lint/use-redundant/use-redundant-issue-71450.stderr b/tests/ui/lint/use-redundant/use-redundant-issue-71450.stderr index c14ab9e11e0..8a5c243ddf8 100644 --- a/tests/ui/lint/use-redundant/use-redundant-issue-71450.stderr +++ b/tests/ui/lint/use-redundant/use-redundant-issue-71450.stderr @@ -3,10 +3,10 @@ warning: the item `String` is imported redundantly | LL | use std::string::String; | ^^^^^^^^^^^^^^^^^^^ + | --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | = note: the item `String` is already defined here - | note: the lint level is defined here --> $DIR/use-redundant-issue-71450.rs:3:9 | diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr index 48d5c275055..71bc7d3b371 100644 --- a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2015.stderr @@ -3,10 +3,10 @@ warning: the item `Some` is imported redundantly | LL | use std::option::Option::Some; | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | = note: the item `Some` is already defined here - | note: the lint level is defined here --> $DIR/use-redundant-prelude-rust-2015.rs:3:9 | @@ -18,6 +18,7 @@ warning: the item `None` is imported redundantly | LL | use std::option::Option::None; | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | = note: the item `None` is already defined here @@ -27,6 +28,7 @@ warning: the item `Ok` is imported redundantly | LL | use std::result::Result::Ok; | ^^^^^^^^^^^^^^^^^^^^^^^ + | --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | = note: the item `Ok` is already defined here @@ -36,6 +38,7 @@ warning: the item `Err` is imported redundantly | LL | use std::result::Result::Err; | ^^^^^^^^^^^^^^^^^^^^^^^^ + | --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | = note: the item `Err` is already defined here diff --git a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr index 526771c597a..f9b7af2105c 100644 --- a/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr +++ b/tests/ui/lint/use-redundant/use-redundant-prelude-rust-2021.stderr @@ -3,10 +3,10 @@ warning: the item `TryFrom` is imported redundantly | LL | use std::convert::TryFrom; | ^^^^^^^^^^^^^^^^^^^^^ + | --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | = note: the item `TryFrom` is already defined here - | note: the lint level is defined here --> $DIR/use-redundant-prelude-rust-2021.rs:3:9 | @@ -18,6 +18,7 @@ warning: the item `TryInto` is imported redundantly | LL | use std::convert::TryInto; | ^^^^^^^^^^^^^^^^^^^^^ + | --> $SRC_DIR/std/src/prelude/mod.rs:LL:COL | = note: the item `TryInto` is already defined here diff --git a/tests/ui/loop-match/diverges.rs b/tests/ui/loop-match/diverges.rs new file mode 100644 index 00000000000..f1b3ffb2076 --- /dev/null +++ b/tests/ui/loop-match/diverges.rs @@ -0,0 +1,44 @@ +//@ build-pass +//@ compile-flags: -Zvalidate-mir +#![allow(incomplete_features)] +#![feature(loop_match)] +#![crate_type = "lib"] + +// Test that a #[loop_match] without an explicit break from the loop generates valid MIR. + +fn break_to_block_unit() -> u8 { + let mut state = 0; + #[loop_match] + loop { + state = 'blk: { + match state { + _ => 'b: { + break 'b 2; + } + } + } + } +} + +fn break_to_block_value() -> u8 { + let mut state = 0u8; + #[loop_match] + 'a: loop { + state = 'blk: { + match state { + _ => break 'blk state, + } + } + } +} + +fn infinite_a(mut state: u8) { + #[loop_match] + loop { + state = 'blk: { + match state { + a => a, + } + } + } +} diff --git a/tests/ui/issues/issue-5741.rs b/tests/ui/loops/unreachable-while-loop-5741.rs index af4702ec22c..bc69df0f675 100644 --- a/tests/ui/issues/issue-5741.rs +++ b/tests/ui/loops/unreachable-while-loop-5741.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5741 //@ run-pass #![allow(while_true)] #![allow(unreachable_code)] diff --git a/tests/ui/lto/issue-100772.rs b/tests/ui/lto/issue-100772.rs index 29ec5b9bf96..9468e20894a 100644 --- a/tests/ui/lto/issue-100772.rs +++ b/tests/ui/lto/issue-100772.rs @@ -1,6 +1,6 @@ //@ build-pass //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu diff --git a/tests/ui/lto/lto-global-allocator.rs b/tests/ui/lto/lto-global-allocator.rs new file mode 100644 index 00000000000..03f11709c90 --- /dev/null +++ b/tests/ui/lto/lto-global-allocator.rs @@ -0,0 +1,19 @@ +//@ compile-flags: --crate-type cdylib -C lto +//@ build-pass +//@ no-prefer-dynamic +//@ needs-crate-type: cdylib + +use std::alloc::{GlobalAlloc, Layout}; + +struct MyAllocator; + +unsafe impl GlobalAlloc for MyAllocator { + unsafe fn alloc(&self, _layout: Layout) -> *mut u8 { + todo!() + } + + unsafe fn dealloc(&self, _ptr: *mut u8, _layout: Layout) {} +} + +#[global_allocator] +static GLOBAL: MyAllocator = MyAllocator; diff --git a/tests/ui/macros/format-foreign-dollar-without-spec.rs b/tests/ui/macros/format-foreign-dollar-without-spec.rs new file mode 100644 index 00000000000..c57c1382c8d --- /dev/null +++ b/tests/ui/macros/format-foreign-dollar-without-spec.rs @@ -0,0 +1,5 @@ +// https://github.com/rust-lang/rust/issues/137580 +fn main() { + println!("%65536$", 1); + //~^ ERROR never used +} diff --git a/tests/ui/macros/format-foreign-dollar-without-spec.stderr b/tests/ui/macros/format-foreign-dollar-without-spec.stderr new file mode 100644 index 00000000000..d5a07c50f00 --- /dev/null +++ b/tests/ui/macros/format-foreign-dollar-without-spec.stderr @@ -0,0 +1,16 @@ +error: argument never used + --> $DIR/format-foreign-dollar-without-spec.rs:3:25 + | +LL | println!("%65536$", 1); + | ^ argument never used + | +note: format specifiers use curly braces, and the conversion specifier ` + ` is unknown or unsupported + --> $DIR/format-foreign-dollar-without-spec.rs:3:15 + | +LL | println!("%65536$", 1); + | ^^^^^^^^ + = note: printf formatting is not supported; see the documentation for `std::fmt` + +error: aborting due to 1 previous error + diff --git a/tests/ui/macros/macro-metavar-expr-concat/in-repetition.rs b/tests/ui/macros/macro-metavar-expr-concat/in-repetition.rs new file mode 100644 index 00000000000..d2bd31b06d6 --- /dev/null +++ b/tests/ui/macros/macro-metavar-expr-concat/in-repetition.rs @@ -0,0 +1,21 @@ +// issue: <https://github.com/rust-lang/rust/issues/140479> +// Ensure a proper compiler error, instead of an ICE occurs. +// FIXME(macro_metavar_expr_concat): this error message could be improved +#![feature(macro_metavar_expr_concat)] + +macro_rules! InRepetition { + ( + $( + $($arg:ident),+ + )+ + ) => { + $( + $( + ${concat(_, $arg)} //~ ERROR nested repetitions with `${concat(...)}` metavariable expressions are not yet supported + )* + )* + }; +} +InRepetition!(other); + +fn main() {} diff --git a/tests/ui/macros/macro-metavar-expr-concat/in-repetition.stderr b/tests/ui/macros/macro-metavar-expr-concat/in-repetition.stderr new file mode 100644 index 00000000000..ec39ca799e1 --- /dev/null +++ b/tests/ui/macros/macro-metavar-expr-concat/in-repetition.stderr @@ -0,0 +1,8 @@ +error: nested repetitions with `${concat(...)}` metavariable expressions are not yet supported + --> $DIR/in-repetition.rs:14:30 + | +LL | ${concat(_, $arg)} + | ^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/macros/macro-name-typo.stderr b/tests/ui/macros/macro-name-typo.stderr index 9059b10faaa..1cc7ea6ec1b 100644 --- a/tests/ui/macros/macro-name-typo.stderr +++ b/tests/ui/macros/macro-name-typo.stderr @@ -3,6 +3,7 @@ error: cannot find macro `printlx` in this scope | LL | printlx!("oh noes!"); | ^^^^^^^ help: a macro with a similar name exists: `println` + | --> $SRC_DIR/std/src/macros.rs:LL:COL | = note: similarly named macro `println` defined here diff --git a/tests/ui/macros/macro-path-prelude-fail-3.stderr b/tests/ui/macros/macro-path-prelude-fail-3.stderr index 485d7b7869a..3d0a074deeb 100644 --- a/tests/ui/macros/macro-path-prelude-fail-3.stderr +++ b/tests/ui/macros/macro-path-prelude-fail-3.stderr @@ -3,6 +3,7 @@ error: cannot find macro `inline` in this scope | LL | inline!(); | ^^^^^^ help: a macro with a similar name exists: `line` + | --> $SRC_DIR/core/src/macros/mod.rs:LL:COL | = note: similarly named macro `line` defined here diff --git a/tests/ui/issues/issue-5554.rs b/tests/ui/macros/macro-variable-declaration-with-bounds-5554.rs index 7d219a0df70..8ccf8e80131 100644 --- a/tests/ui/issues/issue-5554.rs +++ b/tests/ui/macros/macro-variable-declaration-with-bounds-5554.rs @@ -1,7 +1,7 @@ +// https://github.com/rust-lang/rust/issues/5554 //@ run-pass #![allow(dead_code)] - pub struct X<T> { a: T, } diff --git a/tests/ui/issues/issue-5718.rs b/tests/ui/macros/macro-variable-unused-reporting-5718.rs index 234fb2e2222..55da925461d 100644 --- a/tests/ui/issues/issue-5718.rs +++ b/tests/ui/macros/macro-variable-unused-reporting-5718.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5718 //@ run-pass struct Element; diff --git a/tests/ui/macros/missing-writer-issue-139830.stderr b/tests/ui/macros/missing-writer-issue-139830.stderr index 34dd61328e0..0a1c6f6f3ea 100644 --- a/tests/ui/macros/missing-writer-issue-139830.stderr +++ b/tests/ui/macros/missing-writer-issue-139830.stderr @@ -3,10 +3,10 @@ error[E0599]: cannot write into `String` | 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 | diff --git a/tests/ui/malformed/malformed-regressions.rs b/tests/ui/malformed/malformed-regressions.rs index 99f0fc904a9..407920c4e4e 100644 --- a/tests/ui/malformed/malformed-regressions.rs +++ b/tests/ui/malformed/malformed-regressions.rs @@ -4,9 +4,7 @@ //~^ WARN this was previously accepted #[inline = ""] //~ ERROR valid forms for the attribute are //~^ WARN this was previously accepted -#[link] //~ ERROR valid forms for the attribute are -//~^ WARN this was previously accepted -#[link = ""] //~ ERROR valid forms for the attribute are -//~^ WARN this was previously accepted +#[link] //~ ERROR malformed +#[link = ""] //~ ERROR malformed fn main() {} diff --git a/tests/ui/malformed/malformed-regressions.stderr b/tests/ui/malformed/malformed-regressions.stderr index cab347a8062..850bcb6cbc2 100644 --- a/tests/ui/malformed/malformed-regressions.stderr +++ b/tests/ui/malformed/malformed-regressions.stderr @@ -9,25 +9,47 @@ LL | #[doc] = note: for more information, visit <https://doc.rust-lang.org/rustdoc/write-documentation/the-doc-attribute.html> = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default -error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` +error[E0539]: malformed `link` attribute input --> $DIR/malformed-regressions.rs:7:1 | LL | #[link] - | ^^^^^^^ + | ^^^^^^^ expected this to be a list | - = 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: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL | #[link(name = "...")] + | ++++++++++++++ +LL | #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ +LL | #[link(name = "...", kind = "dylib|static|...")] + | +++++++++++++++++++++++++++++++++++++++++ +LL | #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | ++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++++ + = and 1 other candidate -error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` - --> $DIR/malformed-regressions.rs:9:1 +error[E0539]: malformed `link` attribute input + --> $DIR/malformed-regressions.rs:8:1 | LL | #[link = ""] - | ^^^^^^^^^^^^ + | ^^^^^^^^^^^^ expected this to be a list | - = 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: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link = ""] +LL + #[link(name = "...")] + | +LL - #[link = ""] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link = ""] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link = ""] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` --> $DIR/malformed-regressions.rs:3:1 @@ -49,6 +71,7 @@ LL | #[inline = ""] error: aborting due to 5 previous errors +For more information about this error, try `rustc --explain E0539`. Future incompatibility report: Future breakage diagnostic: error: valid forms for the attribute are `#[doc(hidden)]`, `#[doc(inline)]`, and `#[doc = "string"]` --> $DIR/malformed-regressions.rs:1:1 @@ -62,30 +85,6 @@ LL | #[doc] = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default Future breakage diagnostic: -error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` - --> $DIR/malformed-regressions.rs:7: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> - = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> - = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default - -Future breakage diagnostic: -error: valid forms for the attribute are `#[link(name = "...")]`, `#[link(name = "...", kind = "dylib|static|...")]`, `#[link(name = "...", wasm_import_module = "...")]`, `#[link(name = "...", import_name_type = "decorated|noprefix|undecorated")]`, and `#[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")]` - --> $DIR/malformed-regressions.rs:9: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> - = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> - = note: `#[deny(ill_formed_attribute_input)]` (part of `#[deny(future_incompatible)]`) on by default - -Future breakage diagnostic: error: valid forms for the attribute are `#[ignore = "reason"]` and `#[ignore]` --> $DIR/malformed-regressions.rs:3:1 | diff --git a/tests/ui/issues/issue-5358-1.rs b/tests/ui/match/mismatched-types-in-match-5358.rs index 281f219c039..d096bf3a493 100644 --- a/tests/ui/issues/issue-5358-1.rs +++ b/tests/ui/match/mismatched-types-in-match-5358.rs @@ -1,8 +1,13 @@ -enum Either<T, U> { Left(T), Right(U) } +// https://github.com/rust-lang/rust/issues/5358 +enum Either<T, U> { + Left(T), + Right(U), +} struct S(Either<usize, usize>); fn main() { - match S(Either::Left(5)) { //~ NOTE this expression has type `S` + match S(Either::Left(5)) { + //~^ NOTE this expression has type `S` Either::Right(_) => {} //~^ ERROR mismatched types //~| NOTE expected `S`, found `Either<_, _>` diff --git a/tests/ui/issues/issue-5358-1.stderr b/tests/ui/match/mismatched-types-in-match-5358.stderr index e68db865dc4..6a6cf3ee269 100644 --- a/tests/ui/issues/issue-5358-1.stderr +++ b/tests/ui/match/mismatched-types-in-match-5358.stderr @@ -1,8 +1,9 @@ error[E0308]: mismatched types - --> $DIR/issue-5358-1.rs:6:9 + --> $DIR/mismatched-types-in-match-5358.rs:11:9 | LL | match S(Either::Left(5)) { | ------------------ this expression has type `S` +LL | LL | Either::Right(_) => {} | ^^^^^^^^^^^^^^^^ expected `S`, found `Either<_, _>` | diff --git a/tests/ui/match/mismatched-types-in-match-pattern-7867.rs b/tests/ui/match/mismatched-types-in-match-7867.rs index 9ff8755c819..9ff8755c819 100644 --- a/tests/ui/match/mismatched-types-in-match-pattern-7867.rs +++ b/tests/ui/match/mismatched-types-in-match-7867.rs diff --git a/tests/ui/match/mismatched-types-in-match-pattern-7867.stderr b/tests/ui/match/mismatched-types-in-match-7867.stderr index 8997f36114a..e41a61e42f4 100644 --- a/tests/ui/match/mismatched-types-in-match-pattern-7867.stderr +++ b/tests/ui/match/mismatched-types-in-match-7867.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/mismatched-types-in-match-pattern-7867.rs:10:9 + --> $DIR/mismatched-types-in-match-7867.rs:10:9 | LL | enum A { B, C } | - unit variant defined here diff --git a/tests/ui/methods/method-call-lifetime-args-unresolved.stderr b/tests/ui/methods/method-call-lifetime-args-unresolved.stderr index a87c47a9f12..cc8bd18449a 100644 --- a/tests/ui/methods/method-call-lifetime-args-unresolved.stderr +++ b/tests/ui/methods/method-call-lifetime-args-unresolved.stderr @@ -14,6 +14,7 @@ warning: cannot specify lifetime arguments explicitly if late bound lifetime par | LL | 0.clone::<'a>(); | ^^ + | --> $SRC_DIR/core/src/clone.rs:LL:COL | = note: the late bound lifetime parameter is introduced here diff --git a/tests/ui/methods/trait-method-self-param-error-7575.rs b/tests/ui/methods/trait-method-resolution-7575.rs index 9793d43cc24..9793d43cc24 100644 --- a/tests/ui/methods/trait-method-self-param-error-7575.rs +++ b/tests/ui/methods/trait-method-resolution-7575.rs diff --git a/tests/ui/methods/trait-method-self-param-error-7575.stderr b/tests/ui/methods/trait-method-resolution-7575.stderr index 656db30352d..8bbc360de57 100644 --- a/tests/ui/methods/trait-method-self-param-error-7575.stderr +++ b/tests/ui/methods/trait-method-resolution-7575.stderr @@ -1,5 +1,5 @@ warning: trait `Foo` is never used - --> $DIR/trait-method-self-param-error-7575.rs:4:7 + --> $DIR/trait-method-resolution-7575.rs:4:7 | LL | trait Foo { | ^^^ diff --git a/tests/ui/mir/issue-83499-input-output-iteration-ice.rs b/tests/ui/mir/issue-83499-input-output-iteration-ice.rs index 78e5c961802..9277994d9b3 100644 --- a/tests/ui/mir/issue-83499-input-output-iteration-ice.rs +++ b/tests/ui/mir/issue-83499-input-output-iteration-ice.rs @@ -5,6 +5,6 @@ fn main() {} fn foo(_: Bar, ...) -> impl {} -//~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +//~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention //~| ERROR cannot find type `Bar` in this scope //~| ERROR at least one trait must be specified diff --git a/tests/ui/mir/issue-83499-input-output-iteration-ice.stderr b/tests/ui/mir/issue-83499-input-output-iteration-ice.stderr index 80a8a94aea4..4a1aa49eb6e 100644 --- a/tests/ui/mir/issue-83499-input-output-iteration-ice.stderr +++ b/tests/ui/mir/issue-83499-input-output-iteration-ice.stderr @@ -1,4 +1,4 @@ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/issue-83499-input-output-iteration-ice.rs:7:16 | LL | fn foo(_: Bar, ...) -> impl {} diff --git a/tests/ui/mismatched_types/hr-projection-mismatch.current.stderr b/tests/ui/mismatched_types/hr-projection-mismatch.current.stderr index a2cec972e4a..6bda7840f7b 100644 --- a/tests/ui/mismatched_types/hr-projection-mismatch.current.stderr +++ b/tests/ui/mismatched_types/hr-projection-mismatch.current.stderr @@ -2,7 +2,7 @@ error[E0308]: mismatched types --> $DIR/hr-projection-mismatch.rs:20:5 | LL | wrap::<_, Thing>(); - | ^^^^^^^^^^^^^^^^ one type is more general than the other + | ^^^^^^^^^^^^^^^^^^ one type is more general than the other | = note: expected reference `&'a _` found reference `&_` diff --git a/tests/ui/issues/issue-5950.rs b/tests/ui/modules/pub-use-module-alias-5950.rs index 6015560fcf8..91d3f9b16ff 100644 --- a/tests/ui/issues/issue-5950.rs +++ b/tests/ui/modules/pub-use-module-alias-5950.rs @@ -1,6 +1,6 @@ +// https://github.com/rust-lang/rust/issues/5950 //@ check-pass - pub use local as local_alias; pub mod local { } diff --git a/tests/ui/resolve/module-import-resolution-7663.rs b/tests/ui/modules/use-statement-duplicate-check-7663.rs index 872806594fc..872806594fc 100644 --- a/tests/ui/resolve/module-import-resolution-7663.rs +++ b/tests/ui/modules/use-statement-duplicate-check-7663.rs diff --git a/tests/ui/nll/ice-106874.stderr b/tests/ui/nll/ice-106874.stderr index ead4d490a62..0edbd7b44ef 100644 --- a/tests/ui/nll/ice-106874.stderr +++ b/tests/ui/nll/ice-106874.stderr @@ -17,6 +17,15 @@ LL | A(B(C::new(D::new(move |st| f(st))))) = note: ...but it actually implements `FnOnce<(&'1 mut V,)>`, for some specific lifetime `'1` = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` +error: implementation of `FnOnce` is not general enough + --> $DIR/ice-106874.rs:8:7 + | +LL | A(B(C::new(D::new(move |st| f(st))))) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough + | + = note: closure with signature `fn(&'2 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any lifetime `'1`... + = note: ...but it actually implements `FnOnce<(&'2 mut V,)>`, for some specific lifetime `'2` + error: implementation of `Fn` is not general enough --> $DIR/ice-106874.rs:8:7 | @@ -34,6 +43,7 @@ LL | A(B(C::new(D::new(move |st| f(st))))) | = note: closure with signature `fn(&'2 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 mut V,)>`, for some specific lifetime `'2` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `Fn` is not general enough --> $DIR/ice-106874.rs:8:7 @@ -46,45 +56,36 @@ LL | A(B(C::new(D::new(move |st| f(st))))) = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `FnOnce` is not general enough - --> $DIR/ice-106874.rs:8:9 + --> $DIR/ice-106874.rs:8:7 | LL | A(B(C::new(D::new(move |st| f(st))))) - | ^^^^^^ implementation of `FnOnce` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough | = note: closure with signature `fn(&'2 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any lifetime `'1`... = note: ...but it actually implements `FnOnce<(&'2 mut V,)>`, for some specific lifetime `'2` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: implementation of `Fn` is not general enough - --> $DIR/ice-106874.rs:8:9 + --> $DIR/ice-106874.rs:8:7 | LL | A(B(C::new(D::new(move |st| f(st))))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Fn` is not general enough + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `Fn` is not general enough | = note: closure with signature `fn(&'2 mut V)` must implement `Fn<(&'1 mut V,)>`, for any lifetime `'1`... = note: ...but it actually implements `Fn<(&'2 mut V,)>`, for some specific lifetime `'2` - -error: implementation of `FnOnce` is not general enough - --> $DIR/ice-106874.rs:8:9 - | -LL | A(B(C::new(D::new(move |st| f(st))))) - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ implementation of `FnOnce` is not general enough - | - = note: closure with signature `fn(&'2 mut V)` must implement `FnOnce<(&'1 mut V,)>`, for any lifetime `'1`... - = note: ...but it actually implements `FnOnce<(&'2 mut V,)>`, for some specific lifetime `'2` + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: higher-ranked subtype error - --> $DIR/ice-106874.rs:8:41 + --> $DIR/ice-106874.rs:8:7 | LL | A(B(C::new(D::new(move |st| f(st))))) - | ^ + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error: higher-ranked subtype error --> $DIR/ice-106874.rs:8:41 | LL | A(B(C::new(D::new(move |st| f(st))))) | ^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 10 previous errors diff --git a/tests/ui/nll/missing-universe-cause-issue-114907.stderr b/tests/ui/nll/missing-universe-cause-issue-114907.stderr index 26ad1efec05..c2e91edd138 100644 --- a/tests/ui/nll/missing-universe-cause-issue-114907.stderr +++ b/tests/ui/nll/missing-universe-cause-issue-114907.stderr @@ -38,18 +38,16 @@ LL | accept(callback); = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: higher-ranked subtype error - --> $DIR/missing-universe-cause-issue-114907.rs:33:21 + --> $DIR/missing-universe-cause-issue-114907.rs:33:5 | LL | accept(callback); - | ^ + | ^^^^^^^^^^^^^^^^ error: higher-ranked subtype error --> $DIR/missing-universe-cause-issue-114907.rs:33:21 | LL | accept(callback); | ^ - | - = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` error: aborting due to 6 previous errors diff --git a/tests/ui/issues/issue-6130.rs b/tests/ui/numeric/type-limit-comparisons-6130.rs index c675a8a41dd..54b3f631e67 100644 --- a/tests/ui/issues/issue-6130.rs +++ b/tests/ui/numeric/type-limit-comparisons-6130.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/6130 //@ run-pass pub fn main() { diff --git a/tests/ui/or-patterns/binding-typo-2.rs b/tests/ui/or-patterns/binding-typo-2.rs new file mode 100644 index 00000000000..275b68a22e2 --- /dev/null +++ b/tests/ui/or-patterns/binding-typo-2.rs @@ -0,0 +1,122 @@ +// Issue #51976 +#![deny(unused_variables)] //~ NOTE: the lint level is defined here +enum Lol { + Foo, + Bar, +} +const Bat: () = (); +const Battery: () = (); +struct Bay; + +fn foo(x: (Lol, Lol)) { + use Lol::*; + match &x { + (Foo, Bar) | (Ban, Foo) => {} + //~^ ERROR: variable `Ban` is not bound in all patterns + //~| HELP: you might have meant to use the similarly named previously used binding `Bar` + //~| NOTE: pattern doesn't bind `Ban` + //~| NOTE: variable not in all patterns + //~| ERROR: variable `Ban` is assigned to, but never used + //~| NOTE: consider using `_Ban` instead + //~| HELP: you might have meant to pattern match on the similarly named + _ => {} + } + match &x { + (Foo, _) | (Ban, Foo) => {} + //~^ ERROR: variable `Ban` is not bound in all patterns + //~| HELP: you might have meant to use the similarly named unit variant `Bar` + //~| NOTE: pattern doesn't bind `Ban` + //~| NOTE: variable not in all patterns + //~| ERROR: variable `Ban` is assigned to, but never used + //~| NOTE: consider using `_Ban` instead + //~| HELP: you might have meant to pattern match on the similarly named + _ => {} + } + match Some(42) { + Some(_) => {} + Non => {} + //~^ ERROR: unused variable: `Non` + //~| HELP: if this is intentional, prefix it with an underscore + //~| HELP: you might have meant to pattern match on the similarly named + } + match Some(42) { + Some(_) => {} + Non | None => {} + //~^ ERROR: unused variable: `Non` + //~| HELP: if this is intentional, prefix it with an underscore + //~| ERROR: variable `Non` is not bound in all patterns [E0408] + //~| NOTE: pattern doesn't bind `Non` + //~| NOTE: variable not in all patterns + //~| HELP: you might have meant to use the similarly named unit variant `None` + //~| HELP: you might have meant to pattern match on the similarly named + } + match Some(42) { + Non | Some(_) => {} + //~^ ERROR: unused variable: `Non` + //~| HELP: if this is intentional, prefix it with an underscore + //~| ERROR: variable `Non` is not bound in all patterns [E0408] + //~| NOTE: pattern doesn't bind `Non` + //~| NOTE: variable not in all patterns + //~| HELP: you might have meant to use the similarly named unit variant `None` + //~| HELP: you might have meant to pattern match on the similarly named + } +} +fn bar(x: (Lol, Lol)) { + use Lol::*; + use ::Bat; + use ::Bay; + match &x { + (Foo, _) | (Ban, Foo) => {} + //~^ ERROR: variable `Ban` is not bound in all patterns + //~| HELP: you might have meant to use the similarly named unit variant `Bar` + //~| HELP: you might have meant to use the similarly named unit struct `Bay` + //~| HELP: you might have meant to use the similarly named constant `Bat` + //~| NOTE: pattern doesn't bind `Ban` + //~| NOTE: variable not in all patterns + //~| ERROR: variable `Ban` is assigned to, but never used + //~| NOTE: consider using `_Ban` instead + //~| HELP: you might have meant to pattern match on the similarly named + _ => {} + } +} +fn baz(x: (Lol, Lol)) { + use Lol::*; + use Bat; + match &x { + (Foo, _) | (Ban, Foo) => {} + //~^ ERROR: variable `Ban` is not bound in all patterns + //~| HELP: you might have meant to use the similarly named unit variant `Bar` + //~| HELP: you might have meant to use the similarly named constant `Bat` + //~| NOTE: pattern doesn't bind `Ban` + //~| NOTE: variable not in all patterns + //~| ERROR: variable `Ban` is assigned to, but never used + //~| NOTE: consider using `_Ban` instead + //~| HELP: you might have meant to pattern match on the similarly named + _ => {} + } + match &x { + (Ban, _) => {} + //~^ ERROR: unused variable: `Ban` + //~| HELP: if this is intentional, prefix it with an underscore + //~| HELP: you might have meant to pattern match on the similarly named + } + match Bay { + Ban => {} + //~^ ERROR: unused variable: `Ban` + //~| HELP: if this is intentional, prefix it with an underscore + //~| HELP: you might have meant to pattern match on the similarly named + } + match () { + Batery => {} + //~^ ERROR: unused variable: `Batery` + //~| HELP: if this is intentional, prefix it with an underscore + //~| HELP: you might have meant to pattern match on the similarly named constant + } +} + +fn main() { + use Lol::*; + foo((Foo, Bar)); + bar((Foo, Bar)); + baz((Foo, Bar)); +} diff --git a/tests/ui/or-patterns/binding-typo-2.stderr b/tests/ui/or-patterns/binding-typo-2.stderr new file mode 100644 index 00000000000..81ea6e6b1bc --- /dev/null +++ b/tests/ui/or-patterns/binding-typo-2.stderr @@ -0,0 +1,254 @@ +error[E0408]: variable `Ban` is not bound in all patterns + --> $DIR/binding-typo-2.rs:14:9 + | +LL | (Foo, Bar) | (Ban, Foo) => {} + | ^^^^^^^^^^ --- variable not in all patterns + | | + | pattern doesn't bind `Ban` + | +help: you might have meant to use the similarly named previously used binding `Bar` + | +LL - (Foo, Bar) | (Ban, Foo) => {} +LL + (Foo, Bar) | (Bar, Foo) => {} + | + +error[E0408]: variable `Ban` is not bound in all patterns + --> $DIR/binding-typo-2.rs:25:9 + | +LL | (Foo, _) | (Ban, Foo) => {} + | ^^^^^^^^ --- variable not in all patterns + | | + | pattern doesn't bind `Ban` + | +help: you might have meant to use the similarly named unit variant `Bar` + | +LL - (Foo, _) | (Ban, Foo) => {} +LL + (Foo, _) | (Bar, Foo) => {} + | + +error[E0408]: variable `Non` is not bound in all patterns + --> $DIR/binding-typo-2.rs:44:15 + | +LL | Non | None => {} + | --- ^^^^ pattern doesn't bind `Non` + | | + | variable not in all patterns + | +help: you might have meant to use the similarly named unit variant `None` + | +LL - Non | None => {} +LL + core::option::Option::None | None => {} + | + +error[E0408]: variable `Non` is not bound in all patterns + --> $DIR/binding-typo-2.rs:54:15 + | +LL | Non | Some(_) => {} + | --- ^^^^^^^ pattern doesn't bind `Non` + | | + | variable not in all patterns + | +help: you might have meant to use the similarly named unit variant `None` + | +LL - Non | Some(_) => {} +LL + core::option::Option::None | Some(_) => {} + | + +error[E0408]: variable `Ban` is not bound in all patterns + --> $DIR/binding-typo-2.rs:69:9 + | +LL | (Foo, _) | (Ban, Foo) => {} + | ^^^^^^^^ --- variable not in all patterns + | | + | pattern doesn't bind `Ban` + | +help: you might have meant to use the similarly named unit variant `Bar` + | +LL - (Foo, _) | (Ban, Foo) => {} +LL + (Foo, _) | (Bar, Foo) => {} + | +help: you might have meant to use the similarly named unit struct `Bay` + | +LL - (Foo, _) | (Ban, Foo) => {} +LL + (Foo, _) | (Bay, Foo) => {} + | +help: you might have meant to use the similarly named constant `Bat` + | +LL - (Foo, _) | (Ban, Foo) => {} +LL + (Foo, _) | (Bat, Foo) => {} + | + +error[E0408]: variable `Ban` is not bound in all patterns + --> $DIR/binding-typo-2.rs:86:9 + | +LL | (Foo, _) | (Ban, Foo) => {} + | ^^^^^^^^ --- variable not in all patterns + | | + | pattern doesn't bind `Ban` + | +help: you might have meant to use the similarly named unit variant `Bar` + | +LL - (Foo, _) | (Ban, Foo) => {} +LL + (Foo, _) | (Bar, Foo) => {} + | +help: you might have meant to use the similarly named constant `Bat` + | +LL - (Foo, _) | (Ban, Foo) => {} +LL + (Foo, _) | (Bat, Foo) => {} + | + +error: variable `Ban` is assigned to, but never used + --> $DIR/binding-typo-2.rs:14:23 + | +LL | (Foo, Bar) | (Ban, Foo) => {} + | ^^^ + | + = note: consider using `_Ban` instead +note: the lint level is defined here + --> $DIR/binding-typo-2.rs:2:9 + | +LL | #![deny(unused_variables)] + | ^^^^^^^^^^^^^^^^ +help: you might have meant to pattern match on the similarly named variant `Bar` + | +LL - (Foo, Bar) | (Ban, Foo) => {} +LL + (Foo, Bar) | (Lol::Bar, Foo) => {} + | + +error: variable `Ban` is assigned to, but never used + --> $DIR/binding-typo-2.rs:25:21 + | +LL | (Foo, _) | (Ban, Foo) => {} + | ^^^ + | + = note: consider using `_Ban` instead +help: you might have meant to pattern match on the similarly named variant `Bar` + | +LL - (Foo, _) | (Ban, Foo) => {} +LL + (Foo, _) | (Lol::Bar, Foo) => {} + | + +error: unused variable: `Non` + --> $DIR/binding-typo-2.rs:37:9 + | +LL | Non => {} + | ^^^ + | +help: if this is intentional, prefix it with an underscore + | +LL | _Non => {} + | + +help: you might have meant to pattern match on the similarly named variant `None` + | +LL - Non => {} +LL + std::prelude::v1::None => {} + | + +error: unused variable: `Non` + --> $DIR/binding-typo-2.rs:44:9 + | +LL | Non | None => {} + | ^^^ + | +help: if this is intentional, prefix it with an underscore + | +LL | _Non | None => {} + | + +help: you might have meant to pattern match on the similarly named variant `None` + | +LL - Non | None => {} +LL + std::prelude::v1::None | None => {} + | + +error: unused variable: `Non` + --> $DIR/binding-typo-2.rs:54:9 + | +LL | Non | Some(_) => {} + | ^^^ + | +help: if this is intentional, prefix it with an underscore + | +LL | _Non | Some(_) => {} + | + +help: you might have meant to pattern match on the similarly named variant `None` + | +LL - Non | Some(_) => {} +LL + std::prelude::v1::None | Some(_) => {} + | + +error: variable `Ban` is assigned to, but never used + --> $DIR/binding-typo-2.rs:69:21 + | +LL | (Foo, _) | (Ban, Foo) => {} + | ^^^ + | + = note: consider using `_Ban` instead +help: you might have meant to pattern match on the similarly named variant `Bar` + | +LL - (Foo, _) | (Ban, Foo) => {} +LL + (Foo, _) | (Lol::Bar, Foo) => {} + | + +error: variable `Ban` is assigned to, but never used + --> $DIR/binding-typo-2.rs:86:21 + | +LL | (Foo, _) | (Ban, Foo) => {} + | ^^^ + | + = note: consider using `_Ban` instead +help: you might have meant to pattern match on the similarly named variant `Bar` + | +LL - (Foo, _) | (Ban, Foo) => {} +LL + (Foo, _) | (Lol::Bar, Foo) => {} + | + +error: unused variable: `Ban` + --> $DIR/binding-typo-2.rs:98:10 + | +LL | (Ban, _) => {} + | ^^^ + | +help: if this is intentional, prefix it with an underscore + | +LL | (_Ban, _) => {} + | + +help: you might have meant to pattern match on the similarly named variant `Bar` + | +LL - (Ban, _) => {} +LL + (Lol::Bar, _) => {} + | + +error: unused variable: `Ban` + --> $DIR/binding-typo-2.rs:104:9 + | +LL | Ban => {} + | ^^^ + | +help: if this is intentional, prefix it with an underscore + | +LL | _Ban => {} + | + +help: you might have meant to pattern match on the similarly named struct `Bay` + | +LL - Ban => {} +LL + Bay => {} + | + +error: unused variable: `Batery` + --> $DIR/binding-typo-2.rs:110:9 + | +LL | Batery => {} + | ^^^^^^ + | +help: if this is intentional, prefix it with an underscore + | +LL | _Batery => {} + | + +help: you might have meant to pattern match on the similarly named constant `Battery` + | +LL | Battery => {} + | + + +error: aborting due to 16 previous errors + +For more information about this error, try `rustc --explain E0408`. diff --git a/tests/ui/or-patterns/binding-typo.fixed b/tests/ui/or-patterns/binding-typo.fixed new file mode 100644 index 00000000000..f209ad644db --- /dev/null +++ b/tests/ui/or-patterns/binding-typo.fixed @@ -0,0 +1,32 @@ +// Issue #51976 +//@ run-rustfix +#![allow(unused_variables)] // allowed so we don't get overlapping suggestions +enum Lol { + Foo, + Bar, +} + +fn foo(x: (Lol, Lol)) { + use Lol::*; + match &x { + (Foo, Bar) | (Bar, Foo) => {} + //~^ ERROR: variable `Ban` is not bound in all patterns + //~| HELP: you might have meant to use the similarly named previously used binding `Bar` + //~| NOTE: pattern doesn't bind `Ban` + //~| NOTE: variable not in all patterns + _ => {} + } + match &x { + (Foo, _) | (Bar, Foo) => {} + //~^ ERROR: variable `Ban` is not bound in all patterns + //~| HELP: you might have meant to use the similarly named unit variant `Bar` + //~| NOTE: pattern doesn't bind `Ban` + //~| NOTE: variable not in all patterns + _ => {} + } +} + +fn main() { + use Lol::*; + foo((Foo, Bar)); +} diff --git a/tests/ui/or-patterns/binding-typo.rs b/tests/ui/or-patterns/binding-typo.rs new file mode 100644 index 00000000000..6be9b801a0d --- /dev/null +++ b/tests/ui/or-patterns/binding-typo.rs @@ -0,0 +1,32 @@ +// Issue #51976 +//@ run-rustfix +#![allow(unused_variables)] // allowed so we don't get overlapping suggestions +enum Lol { + Foo, + Bar, +} + +fn foo(x: (Lol, Lol)) { + use Lol::*; + match &x { + (Foo, Bar) | (Ban, Foo) => {} + //~^ ERROR: variable `Ban` is not bound in all patterns + //~| HELP: you might have meant to use the similarly named previously used binding `Bar` + //~| NOTE: pattern doesn't bind `Ban` + //~| NOTE: variable not in all patterns + _ => {} + } + match &x { + (Foo, _) | (Ban, Foo) => {} + //~^ ERROR: variable `Ban` is not bound in all patterns + //~| HELP: you might have meant to use the similarly named unit variant `Bar` + //~| NOTE: pattern doesn't bind `Ban` + //~| NOTE: variable not in all patterns + _ => {} + } +} + +fn main() { + use Lol::*; + foo((Foo, Bar)); +} diff --git a/tests/ui/or-patterns/binding-typo.stderr b/tests/ui/or-patterns/binding-typo.stderr new file mode 100644 index 00000000000..fb6d5f71209 --- /dev/null +++ b/tests/ui/or-patterns/binding-typo.stderr @@ -0,0 +1,31 @@ +error[E0408]: variable `Ban` is not bound in all patterns + --> $DIR/binding-typo.rs:12:9 + | +LL | (Foo, Bar) | (Ban, Foo) => {} + | ^^^^^^^^^^ --- variable not in all patterns + | | + | pattern doesn't bind `Ban` + | +help: you might have meant to use the similarly named previously used binding `Bar` + | +LL - (Foo, Bar) | (Ban, Foo) => {} +LL + (Foo, Bar) | (Bar, Foo) => {} + | + +error[E0408]: variable `Ban` is not bound in all patterns + --> $DIR/binding-typo.rs:20:9 + | +LL | (Foo, _) | (Ban, Foo) => {} + | ^^^^^^^^ --- variable not in all patterns + | | + | pattern doesn't bind `Ban` + | +help: you might have meant to use the similarly named unit variant `Bar` + | +LL - (Foo, _) | (Ban, Foo) => {} +LL + (Foo, _) | (Bar, Foo) => {} + | + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0408`. diff --git a/tests/ui/or-patterns/missing-bindings.stderr b/tests/ui/or-patterns/missing-bindings.stderr index 6288cc58913..636f7016647 100644 --- a/tests/ui/or-patterns/missing-bindings.stderr +++ b/tests/ui/or-patterns/missing-bindings.stderr @@ -86,6 +86,12 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | ^^^^^^^ - variable not in all patterns | | | pattern doesn't bind `c` + | +help: you might have meant to use the similarly named previously used binding `a` + | +LL - let (A(A(a, b) | B(c), d) | B(e)) = Y; +LL + let (A(A(a, b) | B(a), d) | B(e)) = Y; + | error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:47:22 @@ -94,6 +100,12 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | - ^^^^ pattern doesn't bind `a` | | | variable not in all patterns + | +help: you might have meant to use the similarly named previously used binding `c` + | +LL - let (A(A(a, b) | B(c), d) | B(e)) = Y; +LL + let (A(A(c, b) | B(c), d) | B(e)) = Y; + | error[E0408]: variable `b` is not bound in all patterns --> $DIR/missing-bindings.rs:47:22 @@ -102,6 +114,12 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | - ^^^^ pattern doesn't bind `b` | | | variable not in all patterns + | +help: you might have meant to use the similarly named previously used binding `c` + | +LL - let (A(A(a, b) | B(c), d) | B(e)) = Y; +LL + let (A(A(a, c) | B(c), d) | B(e)) = Y; + | error[E0408]: variable `e` is not bound in all patterns --> $DIR/missing-bindings.rs:47:10 @@ -110,6 +128,12 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | ^^^^^^^^^^^^^^^^^^^^ - variable not in all patterns | | | pattern doesn't bind `e` + | +help: you might have meant to use the similarly named previously used binding `c` + | +LL - let (A(A(a, b) | B(c), d) | B(e)) = Y; +LL + let (A(A(a, b) | B(c), d) | B(c)) = Y; + | error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:47:33 @@ -118,6 +142,12 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | - ^^^^ pattern doesn't bind `a` | | | variable not in all patterns + | +help: you might have meant to use the similarly named previously used binding `e` + | +LL - let (A(A(a, b) | B(c), d) | B(e)) = Y; +LL + let (A(A(e, b) | B(c), d) | B(e)) = Y; + | error[E0408]: variable `b` is not bound in all patterns --> $DIR/missing-bindings.rs:47:33 @@ -126,6 +156,12 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | - ^^^^ pattern doesn't bind `b` | | | variable not in all patterns + | +help: you might have meant to use the similarly named previously used binding `e` + | +LL - let (A(A(a, b) | B(c), d) | B(e)) = Y; +LL + let (A(A(a, e) | B(c), d) | B(e)) = Y; + | error[E0408]: variable `c` is not bound in all patterns --> $DIR/missing-bindings.rs:47:33 @@ -134,6 +170,12 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | - ^^^^ pattern doesn't bind `c` | | | variable not in all patterns + | +help: you might have meant to use the similarly named previously used binding `e` + | +LL - let (A(A(a, b) | B(c), d) | B(e)) = Y; +LL + let (A(A(a, b) | B(e), d) | B(e)) = Y; + | error[E0408]: variable `d` is not bound in all patterns --> $DIR/missing-bindings.rs:47:33 @@ -142,6 +184,12 @@ LL | let (A(A(a, b) | B(c), d) | B(e)) = Y; | - ^^^^ pattern doesn't bind `d` | | | variable not in all patterns + | +help: you might have meant to use the similarly named previously used binding `e` + | +LL - let (A(A(a, b) | B(c), d) | B(e)) = Y; +LL + let (A(A(a, b) | B(c), e) | B(e)) = Y; + | error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:63:29 @@ -158,6 +206,12 @@ LL | A(_, a) | | ^^^^^^^ pattern doesn't bind `b` LL | B(b), | - variable not in all patterns + | +help: you might have meant to use the similarly named previously used binding `a` + | +LL - B(b), +LL + B(a), + | error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:71:21 @@ -166,6 +220,12 @@ LL | A(_, a) | | - variable not in all patterns LL | B(b), | ^^^^ pattern doesn't bind `a` + | +help: you might have meant to use the similarly named previously used binding `b` + | +LL - A(_, a) | +LL + A(_, b) | + | error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:74:17 @@ -202,6 +262,12 @@ LL | B(b), ... LL | V3(c), | ^^^^^ pattern doesn't bind `b` + | +help: you might have meant to use the similarly named previously used binding `c` + | +LL - B(b), +LL + B(c), + | error[E0408]: variable `c` is not bound in all patterns --> $DIR/missing-bindings.rs:59:13 @@ -223,6 +289,12 @@ LL | | ) | | |_____________^ pattern doesn't bind `c` LL | V3(c), | - variable not in all patterns + | +help: you might have meant to use the similarly named previously used binding `a` + | +LL - V3(c), +LL + V3(a), + | error[E0408]: variable `a` is not bound in all patterns --> $DIR/missing-bindings.rs:78:13 @@ -235,6 +307,15 @@ LL | A(_, a) | ... LL | V3(c), | ^^^^^ pattern doesn't bind `a` + | +help: you might have meant to use the similarly named previously used binding `c` + | +LL ~ B(Ok(a) | Err(c)) +LL | ) | +LL | V2( +LL | A( +LL ~ A(_, c) | + | error[E0170]: pattern binding `beta` is named the same as one of the variants of the type `check_handling_of_paths::bar::foo` --> $DIR/missing-bindings.rs:19:18 diff --git a/tests/ui/panics/issue-47429-short-backtraces.rs b/tests/ui/panics/issue-47429-short-backtraces.rs index 378ade67bfd..21428d876e2 100644 --- a/tests/ui/panics/issue-47429-short-backtraces.rs +++ b/tests/ui/panics/issue-47429-short-backtraces.rs @@ -6,6 +6,9 @@ //@ check-run-results //@ exec-env:RUST_BACKTRACE=1 +// FIXME(#61117): Respect debuginfo-level-tests, do not force debuginfo-level=0 +//@ compile-flags: -Cdebuginfo=0 + // This is needed to avoid test output differences across std being built with v0 symbols vs legacy // symbols. //@ normalize-stderr: "begin_panic::<&str>" -> "begin_panic" diff --git a/tests/ui/panics/issue-47429-short-backtraces.run.stderr b/tests/ui/panics/issue-47429-short-backtraces.run.stderr index 13b59a7c7af..32aa6a3502e 100644 --- a/tests/ui/panics/issue-47429-short-backtraces.run.stderr +++ b/tests/ui/panics/issue-47429-short-backtraces.run.stderr @@ -1,5 +1,5 @@ -thread 'main' ($TID) panicked at $DIR/issue-47429-short-backtraces.rs:24:5: +thread 'main' ($TID) panicked at $DIR/issue-47429-short-backtraces.rs:27:5: explicit panic stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/panics/runtime-switch.rs b/tests/ui/panics/runtime-switch.rs index 7d5b4169340..61c07a97c70 100644 --- a/tests/ui/panics/runtime-switch.rs +++ b/tests/ui/panics/runtime-switch.rs @@ -6,6 +6,9 @@ //@ check-run-results //@ exec-env:RUST_BACKTRACE=0 +// FIXME(#61117): Respect debuginfo-level-tests, do not force debuginfo-level=0 +//@ compile-flags: -Cdebuginfo=0 + // This is needed to avoid test output differences across std being built with v0 symbols vs legacy // symbols. //@ normalize-stderr: "begin_panic::<&str>" -> "begin_panic" diff --git a/tests/ui/panics/runtime-switch.run.stderr b/tests/ui/panics/runtime-switch.run.stderr index f3f60445952..48a12b59b69 100644 --- a/tests/ui/panics/runtime-switch.run.stderr +++ b/tests/ui/panics/runtime-switch.run.stderr @@ -1,5 +1,5 @@ -thread 'main' ($TID) panicked at $DIR/runtime-switch.rs:28:5: +thread 'main' ($TID) panicked at $DIR/runtime-switch.rs:31:5: explicit panic stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/parser/bad-lit-suffixes.rs b/tests/ui/parser/bad-lit-suffixes.rs index 0a01bb84f01..0a1ee120730 100644 --- a/tests/ui/parser/bad-lit-suffixes.rs +++ b/tests/ui/parser/bad-lit-suffixes.rs @@ -42,5 +42,10 @@ 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; + +impl S { + #[rustc_confusables("blah"suffix)] + //~^ ERROR suffixes on string literals are invalid + fn woof() { } +} diff --git a/tests/ui/parser/bad-lit-suffixes.stderr b/tests/ui/parser/bad-lit-suffixes.stderr index e1a8a6834f4..6c3dbbcec64 100644 --- a/tests/ui/parser/bad-lit-suffixes.stderr +++ b/tests/ui/parser/bad-lit-suffixes.stderr @@ -10,12 +10,6 @@ error: suffixes on string literals are invalid LL | "C"suffix | ^^^^^^^^^ invalid suffix `suffix` -error: suffixes on string literals are invalid - --> $DIR/bad-lit-suffixes.rs:39:15 - | -LL | #[link(name = "string"suffix)] - | ^^^^^^^^^^^^^^ invalid suffix `suffix` - warning: `extern` declarations without an explicit ABI are deprecated --> $DIR/bad-lit-suffixes.rs:3:1 | @@ -160,6 +154,12 @@ LL - #[must_use = "string"suffix] LL + #[must_use] | +error: suffixes on string literals are invalid + --> $DIR/bad-lit-suffixes.rs:39:15 + | +LL | #[link(name = "string"suffix)] + | ^^^^^^^^^^^^^^ invalid suffix `suffix` + error: invalid suffix `suffix` for number literal --> $DIR/bad-lit-suffixes.rs:43:41 | @@ -168,14 +168,11 @@ LL | #[rustc_layout_scalar_valid_range_start(0suffix)] | = help: the suffix must be one of the numeric types (`u32`, `isize`, `f32`, etc.) -error[E0539]: malformed `rustc_layout_scalar_valid_range_start` attribute input - --> $DIR/bad-lit-suffixes.rs:43:1 +error: suffixes on string literals are invalid + --> $DIR/bad-lit-suffixes.rs:48:25 | -LL | #[rustc_layout_scalar_valid_range_start(0suffix)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^-------^^ - | | | - | | expected an integer literal here - | help: must be of the form: `#[rustc_layout_scalar_valid_range_start(start)]` +LL | #[rustc_confusables("blah"suffix)] + | ^^^^^^^^^^^^ invalid suffix `suffix` error: aborting due to 22 previous errors; 2 warnings emitted diff --git a/tests/ui/parser/expr-as-stmt-2.rs b/tests/ui/parser/expr-as-stmt-2.rs index 3a18bdc3b73..4b1f62d8056 100644 --- a/tests/ui/parser/expr-as-stmt-2.rs +++ b/tests/ui/parser/expr-as-stmt-2.rs @@ -7,4 +7,25 @@ fn foo(a: Option<u32>, b: Option<u32>) -> bool { if let Some(y) = a { true } else { false } } -fn main() {} +fn bar() -> bool { + false +} + +fn main() { + if true { true } else { false } && true; + //~^ ERROR mismatched types + //~| ERROR mismatched types + if true { true } else { false } && if true { true } else { false }; + //~^ ERROR mismatched types + //~| ERROR mismatched types + if true { true } else { false } if true { true } else { false }; + //~^ ERROR mismatched types + //~| ERROR mismatched types + if true { bar() } else { bar() } && if true { bar() } else { bar() }; + //~^ ERROR mismatched types + //~| ERROR mismatched types + if true { bar() } else { bar() } if true { bar() } else { bar() }; + //~^ ERROR mismatched types + //~| ERROR mismatched types + let _ = if true { true } else { false } && true; // ok +} diff --git a/tests/ui/parser/expr-as-stmt-2.stderr b/tests/ui/parser/expr-as-stmt-2.stderr index 2b6314c38ce..f9838ee0299 100644 --- a/tests/ui/parser/expr-as-stmt-2.stderr +++ b/tests/ui/parser/expr-as-stmt-2.stderr @@ -7,6 +7,10 @@ LL | if let Some(x) = a { true } else { false } | | expected `()`, found `bool` | expected this to be `()` | +help: parentheses are required to parse this as an expression + | +LL | (if let Some(x) = a { true } else { false }) + | + + help: you might have meant to return this value | LL | if let Some(x) = a { return true; } else { false } @@ -21,6 +25,10 @@ LL | if let Some(x) = a { true } else { false } | | expected `()`, found `bool` | expected this to be `()` | +help: parentheses are required to parse this as an expression + | +LL | (if let Some(x) = a { true } else { false }) + | + + help: you might have meant to return this value | LL | if let Some(x) = a { true } else { return false; } @@ -41,6 +49,152 @@ help: parentheses are required to parse this as an expression LL | (if let Some(x) = a { true } else { false }) | + + -error: aborting due to 3 previous errors +error[E0308]: mismatched types + --> $DIR/expr-as-stmt-2.rs:15:15 + | +LL | if true { true } else { false } && true; + | ----------^^^^----------------- + | | | + | | expected `()`, found `bool` + | expected this to be `()` + | +help: parentheses are required to parse this as an expression + | +LL | (if true { true } else { false }) && true; + | + + + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt-2.rs:15:29 + | +LL | if true { true } else { false } && true; + | ------------------------^^^^^-- + | | | + | | expected `()`, found `bool` + | expected this to be `()` + | +help: parentheses are required to parse this as an expression + | +LL | (if true { true } else { false }) && true; + | + + + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt-2.rs:18:15 + | +LL | if true { true } else { false } && if true { true } else { false }; + | ----------^^^^----------------- + | | | + | | expected `()`, found `bool` + | expected this to be `()` + | +help: parentheses are required to parse this as an expression + | +LL | (if true { true } else { false }) && if true { true } else { false }; + | + + + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt-2.rs:18:29 + | +LL | if true { true } else { false } && if true { true } else { false }; + | ------------------------^^^^^-- + | | | + | | expected `()`, found `bool` + | expected this to be `()` + | +help: parentheses are required to parse this as an expression + | +LL | (if true { true } else { false }) && if true { true } else { false }; + | + + + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt-2.rs:21:15 + | +LL | if true { true } else { false } if true { true } else { false }; + | ----------^^^^----------------- + | | | + | | expected `()`, found `bool` + | expected this to be `()` + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt-2.rs:21:29 + | +LL | if true { true } else { false } if true { true } else { false }; + | ------------------------^^^^^-- + | | | + | | expected `()`, found `bool` + | expected this to be `()` + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt-2.rs:24:15 + | +LL | if true { bar() } else { bar() } && if true { bar() } else { bar() }; + | ----------^^^^^----------------- + | | | + | | expected `()`, found `bool` + | expected this to be `()` + | +help: parentheses are required to parse this as an expression + | +LL | (if true { bar() } else { bar() }) && if true { bar() } else { bar() }; + | + + +help: consider using a semicolon here + | +LL | if true { bar() } else { bar() }; && if true { bar() } else { bar() }; + | + + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt-2.rs:24:30 + | +LL | if true { bar() } else { bar() } && if true { bar() } else { bar() }; + | -------------------------^^^^^-- + | | | + | | expected `()`, found `bool` + | expected this to be `()` + | +help: parentheses are required to parse this as an expression + | +LL | (if true { bar() } else { bar() }) && if true { bar() } else { bar() }; + | + + +help: consider using a semicolon here + | +LL | if true { bar() } else { bar() }; && if true { bar() } else { bar() }; + | + + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt-2.rs:27:15 + | +LL | if true { bar() } else { bar() } if true { bar() } else { bar() }; + | ----------^^^^^----------------- + | | | + | | expected `()`, found `bool` + | expected this to be `()` + | +help: consider using a semicolon here + | +LL | if true { bar(); } else { bar() } if true { bar() } else { bar() }; + | + +help: consider using a semicolon here + | +LL | if true { bar() } else { bar() }; if true { bar() } else { bar() }; + | + + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt-2.rs:27:30 + | +LL | if true { bar() } else { bar() } if true { bar() } else { bar() }; + | -------------------------^^^^^-- + | | | + | | expected `()`, found `bool` + | expected this to be `()` + | +help: consider using a semicolon here + | +LL | if true { bar() } else { bar(); } if true { bar() } else { bar() }; + | + +help: consider using a semicolon here + | +LL | if true { bar() } else { bar() }; if true { bar() } else { bar() }; + | + + +error: aborting due to 13 previous errors For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/expr-as-stmt.fixed b/tests/ui/parser/expr-as-stmt.fixed index 0a4d62a4a0c..bfae55047ed 100644 --- a/tests/ui/parser/expr-as-stmt.fixed +++ b/tests/ui/parser/expr-as-stmt.fixed @@ -66,7 +66,7 @@ fn asteroids() -> impl FnOnce() -> bool { // https://github.com/rust-lang/rust/issues/105179 fn r#match() -> i32 { - (match () { () => 1 }) + match () { () => 1 } //~ ERROR expected expression, found `+` + ((match () { () => 1 })) + match () { () => 1 } //~ ERROR expected expression, found `+` //~^ ERROR mismatched types } @@ -76,4 +76,13 @@ fn r#unsafe() -> i32 { //~^ ERROR mismatched types } +// https://github.com/rust-lang/rust/issues/88727 +fn matches() -> bool { + (match () { _ => true }) && match () { _ => true }; //~ ERROR mismatched types + (match () { _ => true }) && match () { _ => true }; //~ ERROR mismatched types + //~^ ERROR expected `;`, found keyword `match` + (match () { _ => true }) && true; //~ ERROR mismatched types + ((match () { _ => true })) && true //~ ERROR mismatched types + //~^ ERROR mismatched types +} fn main() {} diff --git a/tests/ui/parser/expr-as-stmt.rs b/tests/ui/parser/expr-as-stmt.rs index 99c85e65baa..94917432cb0 100644 --- a/tests/ui/parser/expr-as-stmt.rs +++ b/tests/ui/parser/expr-as-stmt.rs @@ -76,4 +76,13 @@ fn r#unsafe() -> i32 { //~^ ERROR mismatched types } +// https://github.com/rust-lang/rust/issues/88727 +fn matches() -> bool { + match () { _ => true } && match () { _ => true }; //~ ERROR mismatched types + match () { _ => true } && match () { _ => true } //~ ERROR mismatched types + //~^ ERROR expected `;`, found keyword `match` + match () { _ => true } && true; //~ ERROR mismatched types + match () { _ => true } && true //~ ERROR mismatched types + //~^ ERROR mismatched types +} fn main() {} diff --git a/tests/ui/parser/expr-as-stmt.stderr b/tests/ui/parser/expr-as-stmt.stderr index 577c3455a71..4681129baba 100644 --- a/tests/ui/parser/expr-as-stmt.stderr +++ b/tests/ui/parser/expr-as-stmt.stderr @@ -77,6 +77,15 @@ help: parentheses are required to parse this as an expression LL | (unsafe { 1 }) + unsafe { 1 } | + + +error: expected `;`, found keyword `match` + --> $DIR/expr-as-stmt.rs:82:53 + | +LL | match () { _ => true } && match () { _ => true } + | ^ help: add `;` here +LL | +LL | match () { _ => true } && true; + | ----- unexpected token + error[E0308]: mismatched types --> $DIR/expr-as-stmt.rs:64:7 | @@ -227,9 +236,12 @@ error[E0308]: mismatched types --> $DIR/expr-as-stmt.rs:69:5 | LL | match () { () => 1 } + match () { () => 1 } - | ^^^^^^^^^^^^^^^^^^^^- help: consider using a semicolon here - | | - | expected `()`, found integer + | ^^^^^^^^^^^^^^^^^^^^ expected `()`, found integer + | +help: parentheses are required to parse this as an expression + | +LL | (match () { () => 1 }) + match () { () => 1 } + | + + error[E0308]: mismatched types --> $DIR/expr-as-stmt.rs:75:14 @@ -242,7 +254,65 @@ help: you might have meant to return this value LL | unsafe { return 1; } + unsafe { 1 } | ++++++ + -error: aborting due to 22 previous errors +error[E0308]: mismatched types + --> $DIR/expr-as-stmt.rs:81:5 + | +LL | match () { _ => true } && match () { _ => true }; + | ^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `bool` + | +help: parentheses are required to parse this as an expression + | +LL | (match () { _ => true }) && match () { _ => true }; + | + + + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt.rs:82:5 + | +LL | match () { _ => true } && match () { _ => true } + | ^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `bool` + | +help: parentheses are required to parse this as an expression + | +LL | (match () { _ => true }) && match () { _ => true } + | + + + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt.rs:84:5 + | +LL | match () { _ => true } && true; + | ^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `bool` + | +help: parentheses are required to parse this as an expression + | +LL | (match () { _ => true }) && true; + | + + + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt.rs:85:5 + | +LL | match () { _ => true } && true + | ^^^^^^^^^^^^^^^^^^^^^^ expected `()`, found `bool` + | +help: parentheses are required to parse this as an expression + | +LL | (match () { _ => true }) && true + | + + + +error[E0308]: mismatched types + --> $DIR/expr-as-stmt.rs:85:28 + | +LL | fn matches() -> bool { + | ---- expected `bool` because of return type +... +LL | match () { _ => true } && true + | ^^^^^^^ expected `bool`, found `&&bool` + | +help: parentheses are required to parse this as an expression + | +LL | (match () { _ => true }) && true + | + + + +error: aborting due to 28 previous errors Some errors have detailed explanations: E0308, E0600, E0614. For more information about an error, try `rustc --explain E0308`. diff --git a/tests/ui/parser/misspelled-keywords/ref.stderr b/tests/ui/parser/misspelled-keywords/ref.stderr index 21b99d6e663..dd33fdb21ba 100644 --- a/tests/ui/parser/misspelled-keywords/ref.stderr +++ b/tests/ui/parser/misspelled-keywords/ref.stderr @@ -15,6 +15,7 @@ error[E0023]: this pattern has 2 fields, but the corresponding tuple variant has | LL | Some(refe list) => println!("{list:?}"), | ^^^^ ^^^^ expected 1 field, found 2 + | --> $SRC_DIR/core/src/option.rs:LL:COL | = note: tuple variant has 1 field diff --git a/tests/ui/issues/issue-5572.rs b/tests/ui/parser/partial-eq-trait-bound-5572.rs index f27744ef0ac..7ee0cdc43ee 100644 --- a/tests/ui/issues/issue-5572.rs +++ b/tests/ui/parser/partial-eq-trait-bound-5572.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5572 //@ check-pass #![allow(dead_code)] diff --git a/tests/ui/parser/recover/recover-pat-exprs.stderr b/tests/ui/parser/recover/recover-pat-exprs.stderr index 33000022b8f..a99f7e16fca 100644 --- a/tests/ui/parser/recover/recover-pat-exprs.stderr +++ b/tests/ui/parser/recover/recover-pat-exprs.stderr @@ -690,6 +690,7 @@ error: expected one of `)`, `,`, `@`, `if`, or `|`, found `*` | LL | let b = matches!(x, (x * x | x.f()) | x[0]); | ^ expected one of `)`, `,`, `@`, `if`, or `|` + | --> $SRC_DIR/core/src/macros/mod.rs:LL:COL | = note: while parsing argument for this `pat` macro fragment diff --git a/tests/ui/parser/variadic-ffi-semantic-restrictions.rs b/tests/ui/parser/variadic-ffi-semantic-restrictions.rs index 1cd6d13d56b..e7a0248cffa 100644 --- a/tests/ui/parser/variadic-ffi-semantic-restrictions.rs +++ b/tests/ui/parser/variadic-ffi-semantic-restrictions.rs @@ -4,29 +4,29 @@ fn main() {} fn f1_1(x: isize, ...) {} -//~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +//~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention fn f1_2(...) {} -//~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +//~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention extern "C" fn f2_1(x: isize, ...) {} -//~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +//~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention extern "C" fn f2_2(...) {} -//~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +//~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention extern "C" fn f2_3(..., x: isize) {} -//~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +//~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention //~| ERROR `...` must be the last argument of a C-variadic function extern "C" fn f3_1(x: isize, ...) {} -//~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +//~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention extern "C" fn f3_2(...) {} -//~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +//~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention extern "C" fn f3_3(..., x: isize) {} -//~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +//~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention //~| ERROR `...` must be the last argument of a C-variadic function const unsafe extern "C" fn f4_1(x: isize, ...) {} @@ -35,12 +35,12 @@ const unsafe extern "C" fn f4_1(x: isize, ...) {} const extern "C" fn f4_2(x: isize, ...) {} //~^ ERROR functions cannot be both `const` and C-variadic -//~| ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +//~| ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention //~| ERROR destructor of `VaListImpl<'_>` cannot be evaluated at compile-time const extern "C" fn f4_3(..., x: isize, ...) {} //~^ ERROR functions cannot be both `const` and C-variadic -//~| ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +//~| ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention //~| ERROR `...` must be the last argument of a C-variadic function extern "C" { @@ -52,34 +52,34 @@ struct X; impl X { fn i_f1(x: isize, ...) {} - //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + //~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention fn i_f2(...) {} - //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + //~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention fn i_f3(..., x: isize, ...) {} - //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + //~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention //~| ERROR `...` must be the last argument of a C-variadic function fn i_f4(..., x: isize, ...) {} - //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + //~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention //~| ERROR `...` must be the last argument of a C-variadic function const fn i_f5(x: isize, ...) {} - //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + //~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention //~| ERROR functions cannot be both `const` and C-variadic //~| ERROR destructor of `VaListImpl<'_>` cannot be evaluated at compile-time } trait T { fn t_f1(x: isize, ...) {} - //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + //~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention fn t_f2(x: isize, ...); - //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + //~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention fn t_f3(...) {} - //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + //~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention fn t_f4(...); - //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + //~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention fn t_f5(..., x: isize) {} - //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + //~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention //~| ERROR `...` must be the last argument of a C-variadic function fn t_f6(..., x: isize); - //~^ ERROR only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg + //~^ ERROR defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention //~| ERROR `...` must be the last argument of a C-variadic function } diff --git a/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr b/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr index b740cef0200..5379045967a 100644 --- a/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr +++ b/tests/ui/parser/variadic-ffi-semantic-restrictions.stderr @@ -1,22 +1,22 @@ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:6:19 | LL | fn f1_1(x: isize, ...) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:9:9 | LL | fn f1_2(...) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:12:30 | LL | extern "C" fn f2_1(x: isize, ...) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:15:20 | LL | extern "C" fn f2_2(...) {} @@ -28,19 +28,19 @@ error: `...` must be the last argument of a C-variadic function LL | extern "C" fn f2_3(..., x: isize) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:18:20 | LL | extern "C" fn f2_3(..., x: isize) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:22:30 | LL | extern "C" fn f3_1(x: isize, ...) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:25:20 | LL | extern "C" fn f3_2(...) {} @@ -52,7 +52,7 @@ error: `...` must be the last argument of a C-variadic function LL | extern "C" fn f3_3(..., x: isize) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:28:20 | LL | extern "C" fn f3_3(..., x: isize) {} @@ -70,7 +70,7 @@ error: functions cannot be both `const` and C-variadic LL | const extern "C" fn f4_2(x: isize, ...) {} | ^^^^^ `const` because of this ^^^ C-variadic because of this -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:36:36 | LL | const extern "C" fn f4_2(x: isize, ...) {} @@ -91,7 +91,7 @@ LL | const extern "C" fn f4_3(..., x: isize, ...) {} | | C-variadic because of this | `const` because of this -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:41:26 | LL | const extern "C" fn f4_3(..., x: isize, ...) {} @@ -103,13 +103,13 @@ error: `...` must be the last argument of a C-variadic function LL | fn e_f2(..., x: isize); | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:54:23 | LL | fn i_f1(x: isize, ...) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:56:13 | LL | fn i_f2(...) {} @@ -121,7 +121,7 @@ error: `...` must be the last argument of a C-variadic function LL | fn i_f3(..., x: isize, ...) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:58:13 | LL | fn i_f3(..., x: isize, ...) {} @@ -133,7 +133,7 @@ error: `...` must be the last argument of a C-variadic function LL | fn i_f4(..., x: isize, ...) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:61:13 | LL | fn i_f4(..., x: isize, ...) {} @@ -147,31 +147,31 @@ LL | const fn i_f5(x: isize, ...) {} | | | `const` because of this -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:64:29 | LL | const fn i_f5(x: isize, ...) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:71:23 | LL | fn t_f1(x: isize, ...) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:73:23 | LL | fn t_f2(x: isize, ...); | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:75:13 | LL | fn t_f3(...) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:77:13 | LL | fn t_f4(...); @@ -183,7 +183,7 @@ error: `...` must be the last argument of a C-variadic function LL | fn t_f5(..., x: isize) {} | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:79:13 | LL | fn t_f5(..., x: isize) {} @@ -195,7 +195,7 @@ error: `...` must be the last argument of a C-variadic function LL | fn t_f6(..., x: isize); | ^^^ -error: only foreign, `unsafe extern "C"`, or `unsafe extern "C-unwind"` functions may have a C-variadic arg +error: defining functions with C-variadic arguments is only allowed for free functions with the "C" or "C-unwind" calling convention --> $DIR/variadic-ffi-semantic-restrictions.rs:82:13 | LL | fn t_f6(..., x: isize); diff --git a/tests/ui/pattern/at-in-struct-patterns.rs b/tests/ui/pattern/at-in-struct-patterns.rs index e8fad61f317..b0557220d05 100644 --- a/tests/ui/pattern/at-in-struct-patterns.rs +++ b/tests/ui/pattern/at-in-struct-patterns.rs @@ -5,7 +5,7 @@ struct Foo { fn main() { let foo = Foo { field1: 1, field2: 2 }; - let Foo { var @ field1, .. } = foo; //~ ERROR Unexpected `@` in struct pattern + let Foo { var @ field1, .. } = foo; //~ ERROR unexpected `@` in struct pattern dbg!(var); //~ ERROR cannot find value `var` in this scope let Foo { field1: _, bar @ .. } = foo; //~ ERROR `@ ..` is not supported in struct patterns let Foo { bar @ .. } = foo; //~ ERROR `@ ..` is not supported in struct patterns diff --git a/tests/ui/pattern/at-in-struct-patterns.stderr b/tests/ui/pattern/at-in-struct-patterns.stderr index ff75edfe681..20832897ca5 100644 --- a/tests/ui/pattern/at-in-struct-patterns.stderr +++ b/tests/ui/pattern/at-in-struct-patterns.stderr @@ -1,4 +1,4 @@ -error: Unexpected `@` in struct pattern +error: unexpected `@` in struct pattern --> $DIR/at-in-struct-patterns.rs:8:15 | LL | let Foo { var @ field1, .. } = foo; diff --git a/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr b/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr index 21d09ec44c4..6d430184628 100644 --- a/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr +++ b/tests/ui/pattern/deref-patterns/implicit-const-deref.stderr @@ -6,6 +6,7 @@ LL | const EMPTY: Vec<()> = Vec::new(); ... LL | EMPTY => {} | ^^^^^ constant of non-structural type + | --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | = note: `Vec<()>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns diff --git a/tests/ui/pattern/issue-115599.stderr b/tests/ui/pattern/issue-115599.stderr index 69d10728ccd..ed465ea0bba 100644 --- a/tests/ui/pattern/issue-115599.stderr +++ b/tests/ui/pattern/issue-115599.stderr @@ -6,6 +6,7 @@ LL | const CONST_STRING: String = String::new(); ... LL | if let CONST_STRING = empty_str {} | ^^^^^^^^^^^^ constant of non-structural type + | --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL | = note: `Vec<u8>` must be annotated with `#[derive(PartialEq)]` to be usable in patterns diff --git a/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.stderr b/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.stderr index d76e60478a1..a5d9fd2b1a6 100644 --- a/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.stderr +++ b/tests/ui/pattern/rfc-3637-guard-patterns/name-resolution.stderr @@ -5,6 +5,12 @@ LL | ((Ok(x) if y) | (Err(y) if x),) => x && y, | ^^^^^^^^^^^^ - variable not in all patterns | | | pattern doesn't bind `y` + | +help: you might have meant to use the similarly named previously used binding `x` + | +LL - ((Ok(x) if y) | (Err(y) if x),) => x && y, +LL + ((Ok(x) if y) | (Err(x) if x),) => x && y, + | error[E0408]: variable `x` is not bound in all patterns --> $DIR/name-resolution.rs:37:25 @@ -13,6 +19,12 @@ LL | ((Ok(x) if y) | (Err(y) if x),) => x && y, | - ^^^^^^^^^^^^^ pattern doesn't bind `x` | | | variable not in all patterns + | +help: you might have meant to use the similarly named previously used binding `y` + | +LL - ((Ok(x) if y) | (Err(y) if x),) => x && y, +LL + ((Ok(y) if y) | (Err(y) if x),) => x && y, + | error[E0408]: variable `x` is not bound in all patterns --> $DIR/name-resolution.rs:63:28 diff --git a/tests/ui/print_type_sizes/async.rs b/tests/ui/print_type_sizes/async.rs index 805bccbcf63..951e7cd1012 100644 --- a/tests/ui/print_type_sizes/async.rs +++ b/tests/ui/print_type_sizes/async.rs @@ -1,7 +1,9 @@ -//@ compile-flags: -Z print-type-sizes --crate-type lib +//@ compile-flags: -C panic=abort -Z print-type-sizes --crate-type lib +//@ needs-deterministic-layouts //@ edition:2021 //@ build-pass //@ ignore-pass +//@ only-x86_64 #![allow(dropping_copy_types)] diff --git a/tests/ui/print_type_sizes/async.stdout b/tests/ui/print_type_sizes/async.stdout index 83a6962e4cd..d3d6b6471c6 100644 --- a/tests/ui/print_type_sizes/async.stdout +++ b/tests/ui/print_type_sizes/async.stdout @@ -16,6 +16,35 @@ print-type-size type: `std::mem::MaybeUninit<[u8; 8192]>`: 8192 bytes, alignment print-type-size variant `MaybeUninit`: 8192 bytes print-type-size field `.uninit`: 0 bytes print-type-size field `.value`: 8192 bytes +print-type-size type: `std::task::Context<'_>`: 32 bytes, alignment: 8 bytes +print-type-size field `.waker`: 8 bytes +print-type-size field `.local_waker`: 8 bytes +print-type-size field `.ext`: 16 bytes +print-type-size field `._marker`: 0 bytes +print-type-size field `._marker2`: 0 bytes +print-type-size type: `std::panic::Location<'_>`: 24 bytes, alignment: 8 bytes +print-type-size field `.filename`: 16 bytes +print-type-size field `.line`: 4 bytes +print-type-size field `.col`: 4 bytes +print-type-size field `._filename`: 0 bytes +print-type-size type: `core::task::wake::ExtData<'_>`: 16 bytes, alignment: 8 bytes +print-type-size variant `Some`: 16 bytes +print-type-size field `.0`: 16 bytes +print-type-size variant `None`: 0 bytes +print-type-size field `.0`: 0 bytes +print-type-size type: `std::panic::AssertUnwindSafe<core::task::wake::ExtData<'_>>`: 16 bytes, alignment: 8 bytes +print-type-size field `.0`: 16 bytes +print-type-size type: `std::ptr::NonNull<str>`: 16 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 16 bytes +print-type-size type: `std::pin::Pin<&mut {async fn body of test()}>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::pin::Pin<&mut {async fn body of wait()}>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes +print-type-size type: `std::ptr::DynMetadata<dyn std::any::Any>`: 8 bytes, alignment: 8 bytes +print-type-size field `._vtable_ptr`: 8 bytes +print-type-size field `._phantom`: 0 bytes +print-type-size type: `std::ptr::NonNull<std::ptr::metadata::VTable>`: 8 bytes, alignment: 8 bytes +print-type-size field `.pointer`: 8 bytes print-type-size type: `std::mem::ManuallyDrop<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes print-type-size field `.value`: 1 bytes print-type-size type: `std::mem::MaybeUninit<{async fn body of wait()}>`: 1 bytes, alignment: 1 bytes @@ -32,3 +61,7 @@ print-type-size discriminant: 1 bytes print-type-size variant `Unresumed`: 0 bytes print-type-size variant `Returned`: 0 bytes print-type-size variant `Panicked`: 0 bytes +print-type-size type: `std::marker::PhantomData<&str>`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData<*mut ()>`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData<dyn std::any::Any>`: 0 bytes, alignment: 1 bytes +print-type-size type: `std::marker::PhantomData<fn(&()) -> &()>`: 0 bytes, alignment: 1 bytes diff --git a/tests/ui/issues/auxiliary/iss.rs b/tests/ui/privacy/auxiliary/iss-6919.rs index cf32f6c2d5d..cf32f6c2d5d 100644 --- a/tests/ui/issues/auxiliary/iss.rs +++ b/tests/ui/privacy/auxiliary/iss-6919.rs diff --git a/tests/ui/issues/issue-6919.rs b/tests/ui/privacy/deref-separate-compile-unit-6919.rs index 7fb8a2f33bc..5d8934987e5 100644 --- a/tests/ui/issues/issue-6919.rs +++ b/tests/ui/privacy/deref-separate-compile-unit-6919.rs @@ -1,7 +1,7 @@ +// https://github.com/rust-lang/rust/issues/6919 //@ run-pass #![allow(unused_attributes)] -//@ aux-build:iss.rs - +//@ aux-build:iss-6919.rs extern crate issue6919_3; diff --git a/tests/ui/privacy/private-field-ty-err.stderr b/tests/ui/privacy/private-field-ty-err.stderr index 17d50f24a94..0eecad14cfc 100644 --- a/tests/ui/privacy/private-field-ty-err.stderr +++ b/tests/ui/privacy/private-field-ty-err.stderr @@ -3,6 +3,11 @@ error[E0616]: field `len` of struct `Foo` is private | LL | if x.len { | ^^^ private field + | +help: a method `len` also exists, call it with parentheses + | +LL | if x.len() { + | ++ error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-55376.rs b/tests/ui/privacy/pub-restricted-path-usage-55376.rs index 5a6862b6530..ca4e27c30a8 100644 --- a/tests/ui/issues/issue-55376.rs +++ b/tests/ui/privacy/pub-restricted-path-usage-55376.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/55376 //@ run-pass // Tests that paths in `pub(...)` don't fail HIR verification. diff --git a/tests/ui/privacy/suggest-box-new.rs b/tests/ui/privacy/suggest-box-new.rs index 7125285fc77..ff585387020 100644 --- a/tests/ui/privacy/suggest-box-new.rs +++ b/tests/ui/privacy/suggest-box-new.rs @@ -16,4 +16,7 @@ fn main() { let _ = std::collections::HashMap {}; //~^ ERROR cannot construct `HashMap<_, _, _>` with struct literal syntax due to private fields let _ = Box {}; //~ ERROR cannot construct `Box<_, _>` with struct literal syntax due to private fields + + // test that we properly instantiate the parameter of `Box::<T>::new` with an inference variable + let _ = Box::<i32> {}; //~ ERROR cannot construct `Box<i32>` with struct literal syntax due to private fields } diff --git a/tests/ui/privacy/suggest-box-new.stderr b/tests/ui/privacy/suggest-box-new.stderr index 6c47b52c9de..37b2989dcc1 100644 --- a/tests/ui/privacy/suggest-box-new.stderr +++ b/tests/ui/privacy/suggest-box-new.stderr @@ -3,10 +3,10 @@ error[E0423]: expected function, tuple struct or tuple variant, found struct `st | LL | let _ = std::collections::HashMap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL | = note: `std::collections::HashMap` defined here - | help: you might have meant to use an associated function to build this type | LL | let _ = std::collections::HashMap::new(); @@ -118,13 +118,41 @@ LL + let _ = Box::new_zeroed(); LL - let _ = Box {}; LL + let _ = Box::new_in(_, _); | - = and 12 other candidates + = and 13 other candidates help: consider using the `Default` trait | LL - let _ = Box {}; LL + let _ = <Box as std::default::Default>::default(); | -error: aborting due to 4 previous errors +error: cannot construct `Box<i32>` with struct literal syntax due to private fields + --> $DIR/suggest-box-new.rs:21:13 + | +LL | let _ = Box::<i32> {}; + | ^^^^^^^^^^ + | + = note: private fields `0` and `1` that were not provided +help: you might have meant to use an associated function to build this type + | +LL - let _ = Box::<i32> {}; +LL + let _ = Box::<i32>::new(_); + | +LL - let _ = Box::<i32> {}; +LL + let _ = Box::<i32>::new_in(_, _); + | +LL - let _ = Box::<i32> {}; +LL + let _ = Box::<i32>::into_inner(_); + | +LL - let _ = Box::<i32> {}; +LL + let _ = Box::<i32>::write(_, _); + | + = and 4 other candidates +help: consider using the `Default` trait + | +LL - let _ = Box::<i32> {}; +LL + let _ = <Box::<i32> as std::default::Default>::default(); + | + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0423`. diff --git a/tests/ui/privacy/suggest-new-projection-ice.rs b/tests/ui/privacy/suggest-new-projection-ice.rs new file mode 100644 index 00000000000..41ac27508e8 --- /dev/null +++ b/tests/ui/privacy/suggest-new-projection-ice.rs @@ -0,0 +1,19 @@ +//! Regression test for <https://github.com/rust-lang/rust/issues/146174>. +//! Ensure that we don't ICE when an associated function returns an associated type. + +mod m { + pub trait Project { + type Assoc; + } + pub struct Foo { + _priv: (), + } + impl Foo { + fn new<T: Project>() -> T::Assoc { + todo!() + } + } +} +fn main() { + let _ = m::Foo {}; //~ ERROR: cannot construct `Foo` +} diff --git a/tests/ui/privacy/suggest-new-projection-ice.stderr b/tests/ui/privacy/suggest-new-projection-ice.stderr new file mode 100644 index 00000000000..4700772096b --- /dev/null +++ b/tests/ui/privacy/suggest-new-projection-ice.stderr @@ -0,0 +1,10 @@ +error: cannot construct `Foo` with struct literal syntax due to private fields + --> $DIR/suggest-new-projection-ice.rs:18:13 + | +LL | let _ = m::Foo {}; + | ^^^^^^ + | + = note: private field `_priv` that was not provided + +error: aborting due to 1 previous error + diff --git a/tests/ui/proc-macro/parent-source-spans.stderr b/tests/ui/proc-macro/parent-source-spans.stderr index a3b27fd7bcc..db1eed5e458 100644 --- a/tests/ui/proc-macro/parent-source-spans.stderr +++ b/tests/ui/proc-macro/parent-source-spans.stderr @@ -144,6 +144,7 @@ LL | parent_source_spans!($($tokens)*); ... LL | one!("hello", "world"); | ---------------------- in this macro invocation + | --> $SRC_DIR/core/src/result.rs:LL:COL | = note: similarly named tuple variant `Ok` defined here @@ -158,6 +159,7 @@ LL | parent_source_spans!($($tokens)*); ... LL | two!("yay", "rust"); | ------------------- in this macro invocation + | --> $SRC_DIR/core/src/result.rs:LL:COL | = note: similarly named tuple variant `Ok` defined here @@ -172,6 +174,7 @@ LL | parent_source_spans!($($tokens)*); ... LL | three!("hip", "hop"); | -------------------- in this macro invocation + | --> $SRC_DIR/core/src/result.rs:LL:COL | = note: similarly named tuple variant `Ok` defined here diff --git a/tests/ui/proc-macro/resolve-error.stderr b/tests/ui/proc-macro/resolve-error.stderr index 963298311ef..45b71a3e7b3 100644 --- a/tests/ui/proc-macro/resolve-error.stderr +++ b/tests/ui/proc-macro/resolve-error.stderr @@ -76,6 +76,7 @@ error: cannot find derive macro `Dlone` in this scope | LL | #[derive(Dlone)] | ^^^^^ help: a derive macro with a similar name exists: `Clone` + | --> $SRC_DIR/core/src/clone.rs:LL:COL | = note: similarly named derive macro `Clone` defined here @@ -85,6 +86,7 @@ error: cannot find derive macro `Dlone` in this scope | LL | #[derive(Dlone)] | ^^^^^ help: a derive macro with a similar name exists: `Clone` + | --> $SRC_DIR/core/src/clone.rs:LL:COL | = note: similarly named derive macro `Clone` defined here diff --git a/tests/ui/issues/issue-53728.rs b/tests/ui/repr/packed-struct-with-enum-53728.rs index 364965228c6..6ce65ed634f 100644 --- a/tests/ui/issues/issue-53728.rs +++ b/tests/ui/repr/packed-struct-with-enum-53728.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/53728 //@ run-pass #![allow(dead_code)] diff --git a/tests/ui/issues/issue-6936.rs b/tests/ui/resolve/duplicate-name-in-module-6936.rs index e9aa80b4eb3..ae9282c0c24 100644 --- a/tests/ui/issues/issue-6936.rs +++ b/tests/ui/resolve/duplicate-name-in-module-6936.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/6936 struct T; mod t1 { @@ -30,5 +31,4 @@ mod t6 { impl Foo {} // ok } - fn main() {} diff --git a/tests/ui/issues/issue-6936.stderr b/tests/ui/resolve/duplicate-name-in-module-6936.stderr index 03cc50636b4..76bb8f57386 100644 --- a/tests/ui/issues/issue-6936.stderr +++ b/tests/ui/resolve/duplicate-name-in-module-6936.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `Foo` is defined multiple times - --> $DIR/issue-6936.rs:5:5 + --> $DIR/duplicate-name-in-module-6936.rs:6:5 | LL | type Foo = crate::T; | -------------------- previous definition of the type `Foo` here @@ -9,7 +9,7 @@ LL | mod Foo {} = note: `Foo` must be defined only once in the type namespace of this module error[E0428]: the name `Foo` is defined multiple times - --> $DIR/issue-6936.rs:10:5 + --> $DIR/duplicate-name-in-module-6936.rs:11:5 | LL | type Foo = crate::T; | -------------------- previous definition of the type `Foo` here @@ -19,7 +19,7 @@ LL | struct Foo; = note: `Foo` must be defined only once in the type namespace of this module error[E0428]: the name `Foo` is defined multiple times - --> $DIR/issue-6936.rs:15:5 + --> $DIR/duplicate-name-in-module-6936.rs:16:5 | LL | type Foo = crate::T; | -------------------- previous definition of the type `Foo` here @@ -29,7 +29,7 @@ LL | enum Foo {} = note: `Foo` must be defined only once in the type namespace of this module error[E0428]: the name `Bar` is defined multiple times - --> $DIR/issue-6936.rs:25:5 + --> $DIR/duplicate-name-in-module-6936.rs:26:5 | LL | type Bar<T> = T; | ---------------- previous definition of the type `Bar` here diff --git a/tests/ui/resolve/issue-102946.rs b/tests/ui/resolve/issue-102946.rs index c6feca6f32f..8d90e61bb5d 100644 --- a/tests/ui/resolve/issue-102946.rs +++ b/tests/ui/resolve/issue-102946.rs @@ -1,7 +1,6 @@ impl Error for str::Utf8Error { //~^ ERROR cannot find trait `Error` in this scope //~| ERROR ambiguous associated type - fn description(&self) {} } fn main() {} diff --git a/tests/ui/resolve/levenshtein.stderr b/tests/ui/resolve/levenshtein.stderr index cf478210132..7fc5710c35e 100644 --- a/tests/ui/resolve/levenshtein.stderr +++ b/tests/ui/resolve/levenshtein.stderr @@ -18,6 +18,7 @@ error[E0412]: cannot find type `Opiton` in this scope | LL | type B = Opiton<u8>; // Misspelled type name from the prelude. | ^^^^^^ help: an enum with a similar name exists: `Option` + | --> $SRC_DIR/core/src/option.rs:LL:COL | = note: similarly named enum `Option` defined here diff --git a/tests/ui/resolve/resolve-inconsistent-names.rs b/tests/ui/resolve/resolve-inconsistent-names.rs index 9a40b20346c..96504720e83 100644 --- a/tests/ui/resolve/resolve-inconsistent-names.rs +++ b/tests/ui/resolve/resolve-inconsistent-names.rs @@ -10,8 +10,8 @@ pub mod m { fn main() { let y = 1; match y { - a | b => {} //~ ERROR variable `a` is not bound in all patterns - //~| ERROR variable `b` is not bound in all patterns + a | b => {} //~ ERROR variable `a` is not bound in all patterns + //~| ERROR variable `b` is not bound in all patterns } let x = (E::A, E::B); diff --git a/tests/ui/resolve/resolve-inconsistent-names.stderr b/tests/ui/resolve/resolve-inconsistent-names.stderr index 5fac622eef2..d2333150961 100644 --- a/tests/ui/resolve/resolve-inconsistent-names.stderr +++ b/tests/ui/resolve/resolve-inconsistent-names.stderr @@ -1,18 +1,18 @@ error[E0408]: variable `b` is not bound in all patterns - --> $DIR/resolve-inconsistent-names.rs:13:8 + --> $DIR/resolve-inconsistent-names.rs:13:9 | -LL | a | b => {} - | ^ - variable not in all patterns - | | - | pattern doesn't bind `b` +LL | a | b => {} + | ^ - variable not in all patterns + | | + | pattern doesn't bind `b` error[E0408]: variable `a` is not bound in all patterns - --> $DIR/resolve-inconsistent-names.rs:13:12 + --> $DIR/resolve-inconsistent-names.rs:13:13 | -LL | a | b => {} - | - ^ pattern doesn't bind `a` - | | - | variable not in all patterns +LL | a | b => {} + | - ^ pattern doesn't bind `a` + | | + | variable not in all patterns error[E0408]: variable `c` is not bound in all patterns --> $DIR/resolve-inconsistent-names.rs:19:9 diff --git a/tests/ui/issues/issue-7044.rs b/tests/ui/resolve/unit-like-struct-masks-constant-7044.rs index a6e22bc5237..f48dd695f01 100644 --- a/tests/ui/issues/issue-7044.rs +++ b/tests/ui/resolve/unit-like-struct-masks-constant-7044.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7044 static X: isize = 0; struct X; //~ ERROR the name `X` is defined multiple times diff --git a/tests/ui/issues/issue-7044.stderr b/tests/ui/resolve/unit-like-struct-masks-constant-7044.stderr index 9d1fb3a10dd..48aa6fce455 100644 --- a/tests/ui/issues/issue-7044.stderr +++ b/tests/ui/resolve/unit-like-struct-masks-constant-7044.stderr @@ -1,5 +1,5 @@ error[E0428]: the name `X` is defined multiple times - --> $DIR/issue-7044.rs:2:1 + --> $DIR/unit-like-struct-masks-constant-7044.rs:3:1 | LL | static X: isize = 0; | -------------------- previous definition of the value `X` here diff --git a/tests/ui/rfcs/rfc-2091-track-caller/file-is-nul-terminated.rs b/tests/ui/rfcs/rfc-2091-track-caller/file-is-nul-terminated.rs index 65e61a21f1a..7902f40b09b 100644 --- a/tests/ui/rfcs/rfc-2091-track-caller/file-is-nul-terminated.rs +++ b/tests/ui/rfcs/rfc-2091-track-caller/file-is-nul-terminated.rs @@ -5,12 +5,12 @@ const fn assert_file_has_trailing_zero() { let caller = core::panic::Location::caller(); let file_str = caller.file(); - let file_with_nul = caller.file_with_nul(); - if file_str.len() != file_with_nul.count_bytes() { + let file_cstr = caller.file_as_c_str(); + if file_str.len() != file_cstr.count_bytes() { panic!("mismatched lengths"); } let trailing_byte: core::ffi::c_char = unsafe { - *file_with_nul.as_ptr().offset(file_with_nul.count_bytes() as _) + *file_cstr.as_ptr().offset(file_cstr.count_bytes() as _) }; if trailing_byte != 0 { panic!("trailing byte was nonzero") diff --git a/tests/ui/sanitizer/address.rs b/tests/ui/sanitizer/address.rs index 704d84764c1..1688f46c2d5 100644 --- a/tests/ui/sanitizer/address.rs +++ b/tests/ui/sanitizer/address.rs @@ -2,7 +2,7 @@ //@ needs-sanitizer-address //@ ignore-cross-compile // -//@ compile-flags: -Z sanitizer=address -O -g +//@ compile-flags: -Z sanitizer=address -O -g -C unsafe-allow-abi-mismatch=sanitizer // //@ run-fail-or-crash //@ error-pattern: AddressSanitizer: stack-buffer-overflow diff --git a/tests/ui/sanitizer/asan_odr_windows.rs b/tests/ui/sanitizer/asan_odr_windows.rs index 28c24716761..b638d6eb969 100644 --- a/tests/ui/sanitizer/asan_odr_windows.rs +++ b/tests/ui/sanitizer/asan_odr_windows.rs @@ -2,7 +2,7 @@ //! See <https://github.com/rust-lang/rust/issues/124390>. //@ run-pass -//@ compile-flags:-Zsanitizer=address +//@ compile-flags:-Zsanitizer=address -C unsafe-allow-abi-mismatch=sanitizer //@ aux-build: asan_odr_win-2.rs //@ only-windows-msvc //@ needs-sanitizer-support diff --git a/tests/ui/sanitizer/badfree.rs b/tests/ui/sanitizer/badfree.rs index 6b3aea7239c..b1b02649dcc 100644 --- a/tests/ui/sanitizer/badfree.rs +++ b/tests/ui/sanitizer/badfree.rs @@ -2,7 +2,7 @@ //@ needs-sanitizer-address //@ ignore-cross-compile // -//@ compile-flags: -Z sanitizer=address -O +//@ compile-flags: -Z sanitizer=address -O -C unsafe-allow-abi-mismatch=sanitizer // //@ run-fail-or-crash //@ regex-error-pattern: AddressSanitizer: (SEGV|attempting free on address which was not malloc) diff --git a/tests/ui/sanitizer/cfi/assoc-ty-lifetime-issue-123053.rs b/tests/ui/sanitizer/cfi/assoc-ty-lifetime-issue-123053.rs index fad57198dfb..5de5e99f6d0 100644 --- a/tests/ui/sanitizer/cfi/assoc-ty-lifetime-issue-123053.rs +++ b/tests/ui/sanitizer/cfi/assoc-ty-lifetime-issue-123053.rs @@ -2,7 +2,7 @@ // trait object type to fail, causing an ICE. // //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer //@ edition: 2021 //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu diff --git a/tests/ui/sanitizer/cfi/async-closures.rs b/tests/ui/sanitizer/cfi/async-closures.rs index 9b099263000..621a0882c91 100644 --- a/tests/ui/sanitizer/cfi/async-closures.rs +++ b/tests/ui/sanitizer/cfi/async-closures.rs @@ -7,7 +7,7 @@ //@ ignore-backends: gcc //@ [cfi] needs-sanitizer-cfi //@ [kcfi] needs-sanitizer-kcfi -//@ compile-flags: -C target-feature=-crt-static +//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 //@ [cfi] compile-flags: -Z sanitizer=cfi //@ [kcfi] compile-flags: -Z sanitizer=kcfi diff --git a/tests/ui/sanitizer/cfi/can-reveal-opaques.rs b/tests/ui/sanitizer/cfi/can-reveal-opaques.rs index a881c6b92b2..310ce04c552 100644 --- a/tests/ui/sanitizer/cfi/can-reveal-opaques.rs +++ b/tests/ui/sanitizer/cfi/can-reveal-opaques.rs @@ -1,5 +1,5 @@ //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu //@ ignore-backends: gcc diff --git a/tests/ui/sanitizer/cfi/closures.rs b/tests/ui/sanitizer/cfi/closures.rs index fc9718faa28..7493dba4928 100644 --- a/tests/ui/sanitizer/cfi/closures.rs +++ b/tests/ui/sanitizer/cfi/closures.rs @@ -6,7 +6,7 @@ //@ ignore-backends: gcc //@ [cfi] needs-sanitizer-cfi //@ [kcfi] needs-sanitizer-kcfi -//@ compile-flags: -C target-feature=-crt-static +//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 //@ [cfi] compile-flags: -Z sanitizer=cfi //@ [kcfi] compile-flags: -Z sanitizer=kcfi diff --git a/tests/ui/sanitizer/cfi/complex-receiver.rs b/tests/ui/sanitizer/cfi/complex-receiver.rs index aac44c33227..adacc0d6c5d 100644 --- a/tests/ui/sanitizer/cfi/complex-receiver.rs +++ b/tests/ui/sanitizer/cfi/complex-receiver.rs @@ -8,7 +8,7 @@ //@ ignore-backends: gcc //@ [cfi] needs-sanitizer-cfi //@ [kcfi] needs-sanitizer-kcfi -//@ compile-flags: -C target-feature=-crt-static +//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 //@ [cfi] compile-flags: -Z sanitizer=cfi //@ [kcfi] compile-flags: -Z sanitizer=kcfi diff --git a/tests/ui/sanitizer/cfi/coroutine.rs b/tests/ui/sanitizer/cfi/coroutine.rs index 084a521f597..d85615b597d 100644 --- a/tests/ui/sanitizer/cfi/coroutine.rs +++ b/tests/ui/sanitizer/cfi/coroutine.rs @@ -8,6 +8,7 @@ //@ [cfi] needs-sanitizer-cfi //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 //@ [cfi] compile-flags: -Z sanitizer=cfi //@ [kcfi] compile-flags: -Z sanitizer=kcfi diff --git a/tests/ui/sanitizer/cfi/drop-in-place.rs b/tests/ui/sanitizer/cfi/drop-in-place.rs index 160338a5b54..fe59d546312 100644 --- a/tests/ui/sanitizer/cfi/drop-in-place.rs +++ b/tests/ui/sanitizer/cfi/drop-in-place.rs @@ -5,6 +5,7 @@ //@ ignore-backends: gcc //@ needs-sanitizer-cfi //@ compile-flags: -Clto -Copt-level=0 -Cprefer-dynamic=off -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer //@ run-pass struct EmptyDrop; diff --git a/tests/ui/sanitizer/cfi/drop-no-principal.rs b/tests/ui/sanitizer/cfi/drop-no-principal.rs index e3a46fe9d75..4fb905eb51d 100644 --- a/tests/ui/sanitizer/cfi/drop-no-principal.rs +++ b/tests/ui/sanitizer/cfi/drop-no-principal.rs @@ -4,7 +4,7 @@ // FIXME(#122848) Remove only-linux once OSX CFI binaries works //@ only-linux //@ ignore-backends: gcc -//@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zsanitizer=cfi +//@ compile-flags: --crate-type=bin -Cprefer-dynamic=off -Clto -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer //@ compile-flags: -C target-feature=-crt-static -C codegen-units=1 -C opt-level=0 // FIXME(#118761) Should be run-pass once the labels on drop are compatible. // This test is being landed ahead of that to test that the compiler doesn't ICE while labeling the diff --git a/tests/ui/sanitizer/cfi/fn-ptr.rs b/tests/ui/sanitizer/cfi/fn-ptr.rs index d3209c62ddf..bdb8c7ceb32 100644 --- a/tests/ui/sanitizer/cfi/fn-ptr.rs +++ b/tests/ui/sanitizer/cfi/fn-ptr.rs @@ -7,6 +7,7 @@ //@ [cfi] needs-sanitizer-cfi //@ [kcfi] needs-sanitizer-kcfi //@ compile-flags: -C target-feature=-crt-static +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer //@ [cfi] compile-flags: -C opt-level=0 -C codegen-units=1 -C lto //@ [cfi] compile-flags: -C prefer-dynamic=off //@ [cfi] compile-flags: -Z sanitizer=cfi diff --git a/tests/ui/sanitizer/cfi/generalize-pointers-attr-cfg.rs b/tests/ui/sanitizer/cfi/generalize-pointers-attr-cfg.rs index d46002c69fd..44cdcb250e7 100644 --- a/tests/ui/sanitizer/cfi/generalize-pointers-attr-cfg.rs +++ b/tests/ui/sanitizer/cfi/generalize-pointers-attr-cfg.rs @@ -4,6 +4,7 @@ //@ needs-sanitizer-cfi //@ check-pass //@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-generalize-pointers +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer #![feature(cfg_sanitizer_cfi)] diff --git a/tests/ui/sanitizer/cfi/normalize-integers-attr-cfg.rs b/tests/ui/sanitizer/cfi/normalize-integers-attr-cfg.rs index 24c2c2c13da..ce4e31eb69b 100644 --- a/tests/ui/sanitizer/cfi/normalize-integers-attr-cfg.rs +++ b/tests/ui/sanitizer/cfi/normalize-integers-attr-cfg.rs @@ -3,7 +3,7 @@ // //@ needs-sanitizer-cfi //@ check-pass -//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers +//@ compile-flags: -Clto -Cno-prepopulate-passes -Ctarget-feature=-crt-static -Zsanitizer=cfi -Zsanitizer-cfi-normalize-integers -C unsafe-allow-abi-mismatch=sanitizer,sanitizer-cfi-normalize-integers #![feature(cfg_sanitizer_cfi)] diff --git a/tests/ui/sanitizer/cfi/self-ref.rs b/tests/ui/sanitizer/cfi/self-ref.rs index b93d49296b6..827610a2610 100644 --- a/tests/ui/sanitizer/cfi/self-ref.rs +++ b/tests/ui/sanitizer/cfi/self-ref.rs @@ -6,7 +6,7 @@ //@ ignore-backends: gcc //@ [cfi] needs-sanitizer-cfi //@ [kcfi] needs-sanitizer-kcfi -//@ compile-flags: -C target-feature=-crt-static +//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 //@ [cfi] compile-flags: -Z sanitizer=cfi //@ [kcfi] compile-flags: -Z sanitizer=kcfi diff --git a/tests/ui/sanitizer/cfi/sized-associated-ty.rs b/tests/ui/sanitizer/cfi/sized-associated-ty.rs index eefc3e2e9db..da8c385c6fc 100644 --- a/tests/ui/sanitizer/cfi/sized-associated-ty.rs +++ b/tests/ui/sanitizer/cfi/sized-associated-ty.rs @@ -7,7 +7,7 @@ //@ ignore-backends: gcc //@ [cfi] needs-sanitizer-cfi //@ [kcfi] needs-sanitizer-kcfi -//@ compile-flags: -C target-feature=-crt-static +//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 //@ [cfi] compile-flags: -Z sanitizer=cfi //@ [kcfi] compile-flags: -Z sanitizer=kcfi diff --git a/tests/ui/sanitizer/cfi/supertraits.rs b/tests/ui/sanitizer/cfi/supertraits.rs index f5a984b9583..b2782dff5d5 100644 --- a/tests/ui/sanitizer/cfi/supertraits.rs +++ b/tests/ui/sanitizer/cfi/supertraits.rs @@ -6,7 +6,7 @@ //@ ignore-backends: gcc //@ [cfi] needs-sanitizer-cfi //@ [kcfi] needs-sanitizer-kcfi -//@ compile-flags: -C target-feature=-crt-static +//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 //@ [cfi] compile-flags: -Z sanitizer=cfi //@ [kcfi] compile-flags: -Z sanitizer=kcfi diff --git a/tests/ui/sanitizer/cfi/transparent-has-regions.rs b/tests/ui/sanitizer/cfi/transparent-has-regions.rs index b70e1ea1791..b82850133c1 100644 --- a/tests/ui/sanitizer/cfi/transparent-has-regions.rs +++ b/tests/ui/sanitizer/cfi/transparent-has-regions.rs @@ -1,5 +1,5 @@ //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu //@ build-pass diff --git a/tests/ui/sanitizer/cfi/virtual-auto.rs b/tests/ui/sanitizer/cfi/virtual-auto.rs index e6f2ebd4b2c..d3a715c079a 100644 --- a/tests/ui/sanitizer/cfi/virtual-auto.rs +++ b/tests/ui/sanitizer/cfi/virtual-auto.rs @@ -6,7 +6,7 @@ //@ ignore-backends: gcc //@ [cfi] needs-sanitizer-cfi //@ [kcfi] needs-sanitizer-kcfi -//@ compile-flags: -C target-feature=-crt-static +//@ compile-flags: -C target-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer //@ [cfi] compile-flags: -C codegen-units=1 -C lto -C prefer-dynamic=off -C opt-level=0 //@ [cfi] compile-flags: -Z sanitizer=cfi //@ [kcfi] compile-flags: -Z sanitizer=kcfi diff --git a/tests/ui/sanitizer/dataflow.rs b/tests/ui/sanitizer/dataflow.rs index 658a9e48086..d99a1a6ac24 100644 --- a/tests/ui/sanitizer/dataflow.rs +++ b/tests/ui/sanitizer/dataflow.rs @@ -4,7 +4,7 @@ //@ needs-sanitizer-support //@ needs-sanitizer-dataflow //@ run-pass -//@ compile-flags: -Zsanitizer=dataflow -Zsanitizer-dataflow-abilist={{src-base}}/sanitizer/dataflow-abilist.txt +//@ compile-flags: -Zsanitizer=dataflow -Zsanitizer-dataflow-abilist={{src-base}}/sanitizer/dataflow-abilist.txt -C unsafe-allow-abi-mismatch=sanitizer use std::mem::size_of; use std::os::raw::{c_int, c_long, c_void}; diff --git a/tests/ui/sanitizer/hwaddress.rs b/tests/ui/sanitizer/hwaddress.rs index e5939eb734b..05fcab17506 100644 --- a/tests/ui/sanitizer/hwaddress.rs +++ b/tests/ui/sanitizer/hwaddress.rs @@ -5,7 +5,7 @@ //@ ignore-aarch64-unknown-linux-gnu // // FIXME(#83989): codegen-units=1 triggers linker errors on aarch64-gnu -//@ compile-flags: -Z sanitizer=hwaddress -O -g -C codegen-units=16 +//@ compile-flags: -Z sanitizer=hwaddress -O -g -C codegen-units=16 -C unsafe-allow-abi-mismatch=sanitizer // //@ run-fail //@ error-pattern: HWAddressSanitizer: tag-mismatch diff --git a/tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs b/tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs index 7d0c73c2841..be81c7bd0ca 100644 --- a/tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs +++ b/tests/ui/sanitizer/issue-111184-cfi-coroutine-witness.rs @@ -2,7 +2,7 @@ // encode_ty and caused the compiler to ICE. // //@ needs-sanitizer-cfi -//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi +//@ compile-flags: -Ccodegen-units=1 -Clto -Ctarget-feature=-crt-static -Zsanitizer=cfi -C unsafe-allow-abi-mismatch=sanitizer //@ edition: 2021 //@ no-prefer-dynamic //@ only-x86_64-unknown-linux-gnu diff --git a/tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs b/tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs index b1b7487fa2a..f7af2842ad6 100644 --- a/tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs +++ b/tests/ui/sanitizer/issue-114275-cfi-const-expr-in-arry-len.rs @@ -2,7 +2,7 @@ // was expecting array type lengths to be evaluated, this was causing an ICE. // //@ build-pass -//@ compile-flags: -Ccodegen-units=1 -Clto -Zsanitizer=cfi -Ctarget-feature=-crt-static +//@ compile-flags: -Ccodegen-units=1 -Clto -Zsanitizer=cfi -Ctarget-feature=-crt-static -C unsafe-allow-abi-mismatch=sanitizer //@ needs-sanitizer-cfi #![crate_type = "lib"] diff --git a/tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs b/tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs index aa0c19db9a1..edeb1b0bf94 100644 --- a/tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs +++ b/tests/ui/sanitizer/issue-72154-address-lifetime-markers.rs @@ -7,7 +7,7 @@ //@ needs-sanitizer-address //@ ignore-cross-compile // -//@ compile-flags: -Copt-level=0 -Zsanitizer=address +//@ compile-flags: -Copt-level=0 -Zsanitizer=address -C unsafe-allow-abi-mismatch=sanitizer //@ run-pass pub struct Wrap { diff --git a/tests/ui/sanitizer/kcfi-mangling.rs b/tests/ui/sanitizer/kcfi-mangling.rs index ba36dc184ec..371f34ba72a 100644 --- a/tests/ui/sanitizer/kcfi-mangling.rs +++ b/tests/ui/sanitizer/kcfi-mangling.rs @@ -2,7 +2,7 @@ //@ needs-sanitizer-kcfi //@ no-prefer-dynamic -//@ compile-flags: -C panic=abort -Zsanitizer=kcfi -C symbol-mangling-version=v0 +//@ compile-flags: -C panic=abort -Zsanitizer=kcfi -C symbol-mangling-version=v0 -C unsafe-allow-abi-mismatch=sanitizer //@ build-pass //@ ignore-backends: gcc diff --git a/tests/ui/sanitizer/leak.rs b/tests/ui/sanitizer/leak.rs index 65915ec24b7..4ce3f7ab1b9 100644 --- a/tests/ui/sanitizer/leak.rs +++ b/tests/ui/sanitizer/leak.rs @@ -1,7 +1,7 @@ //@ needs-sanitizer-support //@ needs-sanitizer-leak // -//@ compile-flags: -Z sanitizer=leak -O +//@ compile-flags: -Z sanitizer=leak -O -C unsafe-allow-abi-mismatch=sanitizer // //@ run-fail //@ error-pattern: LeakSanitizer: detected memory leaks diff --git a/tests/ui/sanitizer/memory-eager.rs b/tests/ui/sanitizer/memory-eager.rs index 709299f87d4..9498336abb7 100644 --- a/tests/ui/sanitizer/memory-eager.rs +++ b/tests/ui/sanitizer/memory-eager.rs @@ -1,6 +1,8 @@ //@ needs-sanitizer-support //@ needs-sanitizer-memory // +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer +// //@ revisions: unoptimized optimized // //@ [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O diff --git a/tests/ui/sanitizer/memory-passing.rs b/tests/ui/sanitizer/memory-passing.rs index 96a4cd909c7..6ac41b178fe 100644 --- a/tests/ui/sanitizer/memory-passing.rs +++ b/tests/ui/sanitizer/memory-passing.rs @@ -1,6 +1,8 @@ //@ needs-sanitizer-support //@ needs-sanitizer-memory // +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer +// //@ revisions: unoptimized optimized // //@ [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O diff --git a/tests/ui/sanitizer/memory.rs b/tests/ui/sanitizer/memory.rs index a91fefe4d16..1566637acd2 100644 --- a/tests/ui/sanitizer/memory.rs +++ b/tests/ui/sanitizer/memory.rs @@ -1,6 +1,8 @@ //@ needs-sanitizer-support //@ needs-sanitizer-memory // +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer +// //@ revisions: unoptimized optimized // //@ [optimized]compile-flags: -Z sanitizer=memory -Zsanitizer-memory-track-origins -O diff --git a/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs b/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs index c1a2c2f26ac..b6656847427 100644 --- a/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs +++ b/tests/ui/sanitizer/new-llvm-pass-manager-thin-lto.rs @@ -6,6 +6,8 @@ //@ needs-sanitizer-address //@ ignore-cross-compile // +//@ compile-flags: -C unsafe-allow-abi-mismatch=sanitizer +// //@ no-prefer-dynamic //@ revisions: opt0 opt1 //@ compile-flags: -Zsanitizer=address -Clto=thin diff --git a/tests/ui/sanitizer/thread.rs b/tests/ui/sanitizer/thread.rs index 9073124d1bd..8f72b1b41a8 100644 --- a/tests/ui/sanitizer/thread.rs +++ b/tests/ui/sanitizer/thread.rs @@ -13,7 +13,7 @@ //@ needs-sanitizer-support //@ needs-sanitizer-thread // -//@ compile-flags: -Z sanitizer=thread -O +//@ compile-flags: -Z sanitizer=thread -O -C unsafe-allow-abi-mismatch=sanitizer // //@ run-fail-or-crash //@ error-pattern: WARNING: ThreadSanitizer: data race diff --git a/tests/ui/sanitizer/use-after-scope.rs b/tests/ui/sanitizer/use-after-scope.rs index 106dc6466d6..1c477d0be14 100644 --- a/tests/ui/sanitizer/use-after-scope.rs +++ b/tests/ui/sanitizer/use-after-scope.rs @@ -2,7 +2,7 @@ //@ needs-sanitizer-address //@ ignore-cross-compile // -//@ compile-flags: -Zsanitizer=address +//@ compile-flags: -Zsanitizer=address -C unsafe-allow-abi-mismatch=sanitizer //@ run-fail-or-crash //@ error-pattern: ERROR: AddressSanitizer: stack-use-after-scope diff --git a/tests/ui/span/issue-39698.stderr b/tests/ui/span/issue-39698.stderr index 73fcc5c8477..eb18969c3c0 100644 --- a/tests/ui/span/issue-39698.stderr +++ b/tests/ui/span/issue-39698.stderr @@ -7,6 +7,12 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?} | | | pattern doesn't bind `b` | | variable not in all patterns | pattern doesn't bind `b` + | +help: you might have meant to use the similarly named previously used binding `c` + | +LL - T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } +LL + T::T1(a, d) | T::T2(d, c) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } + | error[E0408]: variable `c` is not bound in all patterns --> $DIR/issue-39698.rs:10:9 @@ -17,6 +23,12 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?} | | | variable not in all patterns | | pattern doesn't bind `c` | pattern doesn't bind `c` + | +help: you might have meant to use the similarly named previously used binding `d` + | +LL - T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } +LL + T::T1(a, d) | T::T2(d, b) | T::T3(d) | T::T4(a) => { println!("{:?}", a); } + | error[E0408]: variable `a` is not bound in all patterns --> $DIR/issue-39698.rs:10:23 @@ -27,6 +39,12 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?} | | | pattern doesn't bind `a` | | pattern doesn't bind `a` | variable not in all patterns + | +help: you might have meant to use the similarly named previously used binding `c` + | +LL - T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } +LL + T::T1(c, d) | T::T2(d, b) | T::T3(c) | T::T4(c) => { println!("{:?}", a); } + | error[E0408]: variable `d` is not bound in all patterns --> $DIR/issue-39698.rs:10:37 @@ -37,6 +55,12 @@ LL | T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?} | | | pattern doesn't bind `d` | | variable not in all patterns | variable not in all patterns + | +help: you might have meant to use the similarly named previously used binding `c` + | +LL - T::T1(a, d) | T::T2(d, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } +LL + T::T1(a, c) | T::T2(c, b) | T::T3(c) | T::T4(a) => { println!("{:?}", a); } + | error[E0381]: used binding `a` is possibly-uninitialized --> $DIR/issue-39698.rs:10:79 diff --git a/tests/ui/issues/issue-55380.rs b/tests/ui/specialization/trait-specialization-default-methods-55380.rs index 54894cdede0..b3d79fb5ffb 100644 --- a/tests/ui/issues/issue-55380.rs +++ b/tests/ui/specialization/trait-specialization-default-methods-55380.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/55380 //@ run-pass #![feature(specialization)] //~^ WARN the feature `specialization` is incomplete diff --git a/tests/ui/issues/issue-55380.stderr b/tests/ui/specialization/trait-specialization-default-methods-55380.stderr index 403844c726f..f7c1903da62 100644 --- a/tests/ui/issues/issue-55380.stderr +++ b/tests/ui/specialization/trait-specialization-default-methods-55380.stderr @@ -1,5 +1,5 @@ warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/issue-55380.rs:2:12 + --> $DIR/trait-specialization-default-methods-55380.rs:3:12 | LL | #![feature(specialization)] | ^^^^^^^^^^^^^^ diff --git a/tests/ui/issues/issue-7364.rs b/tests/ui/static/global-variable-promotion-error-7364.rs index 4ce9beb68cd..dba4a484d61 100644 --- a/tests/ui/issues/issue-7364.rs +++ b/tests/ui/static/global-variable-promotion-error-7364.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7364 use std::cell::RefCell; // Regression test for issue 7364 diff --git a/tests/ui/issues/issue-7364.stderr b/tests/ui/static/global-variable-promotion-error-7364.stderr index a47a90c90ce..b9d75676bef 100644 --- a/tests/ui/issues/issue-7364.stderr +++ b/tests/ui/static/global-variable-promotion-error-7364.stderr @@ -1,5 +1,5 @@ error[E0277]: `RefCell<isize>` cannot be shared between threads safely - --> $DIR/issue-7364.rs:4:15 + --> $DIR/global-variable-promotion-error-7364.rs:5:15 | LL | static boxed: Box<RefCell<isize>> = Box::new(RefCell::new(0)); | ^^^^^^^^^^^^^^^^^^^ `RefCell<isize>` cannot be shared between threads safely @@ -12,7 +12,7 @@ note: required because it appears within the type `Box<RefCell<isize>>` = note: shared static variables must have a type that implements `Sync` error[E0015]: cannot call non-const associated function `Box::<RefCell<isize>>::new` in statics - --> $DIR/issue-7364.rs:4:37 + --> $DIR/global-variable-promotion-error-7364.rs:5:37 | LL | static boxed: Box<RefCell<isize>> = Box::new(RefCell::new(0)); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/issues/issue-5917.rs b/tests/ui/static/static-list-initialization-5917.rs index 8e91b1052a2..c6c32f7582e 100644 --- a/tests/ui/issues/issue-5917.rs +++ b/tests/ui/static/static-list-initialization-5917.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5917 //@ run-pass #![allow(non_upper_case_globals)] diff --git a/tests/ui/issues/issue-5688.rs b/tests/ui/static/static-struct-initialization-5688.rs index a7db1dfb15f..6a4c2f45b6b 100644 --- a/tests/ui/issues/issue-5688.rs +++ b/tests/ui/static/static-struct-initialization-5688.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5688 //@ run-pass /* # Corrupted initialization in the static struct diff --git a/tests/ui/statics/mutable_memory_validation.stderr b/tests/ui/statics/mutable_memory_validation.stderr index df36287cc69..1d6ba195fa2 100644 --- a/tests/ui/statics/mutable_memory_validation.stderr +++ b/tests/ui/statics/mutable_memory_validation.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value at .x.<deref>: encountered `UnsafeCell` LL | const MUH: Meh = Meh { x: unsafe { &mut *(&READONLY as *const _ as *mut _) } }; | ^^^^^^^^^^^^^^ 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 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 } diff --git a/tests/ui/stats/input-stats.stderr b/tests/ui/stats/input-stats.stderr index 72a9820bb64..4a73a4747ad 100644 --- a/tests/ui/stats/input-stats.stderr +++ b/tests/ui/stats/input-stats.stderr @@ -23,10 +23,10 @@ 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 Pat 560 (NN.N%) 7 80 +ast-stats - Struct 80 (NN.N%) 1 +ast-stats - Wild 80 (NN.N%) 1 +ast-stats - Ident 400 (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 @@ -57,7 +57,7 @@ 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_472 129 +ast-stats Total 7_528 129 ast-stats ================================================================ hir-stats ================================================================ hir-stats HIR STATS: input_stats @@ -85,11 +85,11 @@ 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 Pat 400 (NN.N%) 5 80 +hir-stats - Struct 80 (NN.N%) 1 +hir-stats - Wild 80 (NN.N%) 1 +hir-stats - Binding 240 (NN.N%) 3 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 @@ -119,5 +119,5 @@ hir-stats TraitItemId 8 (NN.N%) 2 4 hir-stats ImplItemId 8 (NN.N%) 2 4 hir-stats ForeignItemId 4 (NN.N%) 1 4 hir-stats ---------------------------------------------------------------- -hir-stats Total 8_584 173 +hir-stats Total 8_624 173 hir-stats ================================================================ diff --git a/tests/ui/structs-enums/auxiliary/aux-8044.rs b/tests/ui/structs/auxiliary/aux-8044.rs index 2ec25f51cde..2ec25f51cde 100644 --- a/tests/ui/structs-enums/auxiliary/aux-8044.rs +++ b/tests/ui/structs/auxiliary/aux-8044.rs diff --git a/tests/ui/structs-enums/struct-and-enum-usage-8044.rs b/tests/ui/structs/btree-struct-usage-8044.rs index 9b544f33f1c..9b544f33f1c 100644 --- a/tests/ui/structs-enums/struct-and-enum-usage-8044.rs +++ b/tests/ui/structs/btree-struct-usage-8044.rs diff --git a/tests/ui/issues/issue-6344-let.rs b/tests/ui/structs/destructuring-struct-with-dtor-6344.rs index 1e1bdfa17be..b107a99e89f 100644 --- a/tests/ui/issues/issue-6344-let.rs +++ b/tests/ui/structs/destructuring-struct-with-dtor-6344.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/6344 //@ run-pass #![allow(non_shorthand_field_patterns)] diff --git a/tests/ui/issues/issue-5439.rs b/tests/ui/structs/nonexistent-struct-field-error-5439.rs index 852b264dc5d..b2b3293ac91 100644 --- a/tests/ui/issues/issue-5439.rs +++ b/tests/ui/structs/nonexistent-struct-field-error-5439.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5439 struct Foo { foo: isize, } diff --git a/tests/ui/issues/issue-5439.stderr b/tests/ui/structs/nonexistent-struct-field-error-5439.stderr index 6d1d74e3045..b560772fbf0 100644 --- a/tests/ui/issues/issue-5439.stderr +++ b/tests/ui/structs/nonexistent-struct-field-error-5439.stderr @@ -1,5 +1,5 @@ error[E0560]: struct `Foo` has no field named `nonexistent` - --> $DIR/issue-5439.rs:11:31 + --> $DIR/nonexistent-struct-field-error-5439.rs:12:31 | LL | return Box::new(Foo { nonexistent: self, foo: i }); | ^^^^^^^^^^^ `Foo` does not have this field diff --git a/tests/ui/suggestions/attribute-typos.stderr b/tests/ui/suggestions/attribute-typos.stderr index a1a01c0abd6..1816a27dcdc 100644 --- a/tests/ui/suggestions/attribute-typos.stderr +++ b/tests/ui/suggestions/attribute-typos.stderr @@ -15,6 +15,7 @@ error: cannot find attribute `tests` in this scope | LL | #[tests] | ^^^^^ help: an attribute macro with a similar name exists: `test` + | --> $SRC_DIR/core/src/macros/mod.rs:LL:COL | = note: similarly named attribute macro `test` defined here diff --git a/tests/ui/suggestions/do-not-attempt-to-add-suggestions-with-no-changes.stderr b/tests/ui/suggestions/do-not-attempt-to-add-suggestions-with-no-changes.stderr index 0cd6267b3b3..c81ac34aaf4 100644 --- a/tests/ui/suggestions/do-not-attempt-to-add-suggestions-with-no-changes.stderr +++ b/tests/ui/suggestions/do-not-attempt-to-add-suggestions-with-no-changes.stderr @@ -3,6 +3,7 @@ error[E0573]: expected type, found module `result` | LL | impl result { | ^^^^^^ help: an enum with a similar name exists: `Result` + | --> $SRC_DIR/core/src/result.rs:LL:COL | = note: similarly named enum `Result` defined here diff --git a/tests/ui/suggestions/enum-method-probe.stderr b/tests/ui/suggestions/enum-method-probe.stderr index 5aa0fc44c7b..7d97495af82 100644 --- a/tests/ui/suggestions/enum-method-probe.stderr +++ b/tests/ui/suggestions/enum-method-probe.stderr @@ -99,10 +99,10 @@ error[E0624]: method `len` is private | LL | res.len(); | ^^^ private method + | --> $SRC_DIR/core/src/option.rs:LL:COL | = note: private method defined here - | note: the method `len` exists on the type `Vec<{integer}>` --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL help: consider using `Option::expect` to unwrap the `Vec<{integer}>` value, panicking if the value is an `Option::None` diff --git a/tests/ui/suggestions/import-trait-for-method-call.stderr b/tests/ui/suggestions/import-trait-for-method-call.stderr index 58b07fe7a42..177ab76cd1f 100644 --- a/tests/ui/suggestions/import-trait-for-method-call.stderr +++ b/tests/ui/suggestions/import-trait-for-method-call.stderr @@ -3,6 +3,7 @@ error[E0599]: no method named `finish` found for struct `DefaultHasher` in the c | LL | h.finish() | ^^^^^^ method not found in `DefaultHasher` + | --> $SRC_DIR/core/src/hash/mod.rs:LL:COL | = note: the method is available for `DefaultHasher` here diff --git a/tests/ui/suggestions/multi-suggestion.ascii.stderr b/tests/ui/suggestions/multi-suggestion.ascii.stderr index f2a146fbd52..9c8867a1771 100644 --- a/tests/ui/suggestions/multi-suggestion.ascii.stderr +++ b/tests/ui/suggestions/multi-suggestion.ascii.stderr @@ -3,10 +3,10 @@ error[E0423]: expected function, tuple struct or tuple variant, found struct `st | LL | let _ = std::collections::HashMap(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | --> $SRC_DIR/std/src/collections/hash/map.rs:LL:COL | = note: `std::collections::HashMap` defined here - | help: you might have meant to use an associated function to build this type | LL | let _ = std::collections::HashMap::new(); @@ -118,7 +118,7 @@ LL + let _ = Box::new_zeroed(); LL - let _ = Box {}; LL + let _ = Box::new_in(_, _); | - = and 12 other candidates + = and 13 other candidates help: consider using the `Default` trait | LL - let _ = Box {}; diff --git a/tests/ui/suggestions/multi-suggestion.unicode.stderr b/tests/ui/suggestions/multi-suggestion.unicode.stderr index 69df481579b..4fdab51493e 100644 --- a/tests/ui/suggestions/multi-suggestion.unicode.stderr +++ b/tests/ui/suggestions/multi-suggestion.unicode.stderr @@ -3,10 +3,10 @@ error[E0423]: expected function, tuple struct or tuple variant, found struct `st │ LL │ let _ = std::collections::HashMap(); │ ━━━━━━━━━━━━━━━━━━━━━━━━━━━ + ╰╴ ╭▸ $SRC_DIR/std/src/collections/hash/map.rs:LL:COL │ ╰ note: `std::collections::HashMap` defined here - ╰╴ help: you might have meant to use an associated function to build this type ╭╴ LL │ let _ = std::collections::HashMap::new(); @@ -34,7 +34,7 @@ LL │ wtf: Some(Box(U { note: constructor is not visible here due to private fields ╭▸ $SRC_DIR/alloc/src/boxed.rs:LL:COL │ - ╰ note: private field + ├ note: private field │ ╰ note: private field help: you might have meant to use an associated function to build this type @@ -118,7 +118,7 @@ LL + let _ = Box::new_zeroed(); LL - let _ = Box {}; LL + let _ = Box::new_in(_, _); │ - ╰ and 12 other candidates + ╰ and 13 other candidates help: consider using the `Default` trait ╭╴ LL - let _ = Box {}; diff --git a/tests/ui/suggestions/negative-literal-infered-to-unsigned.rs b/tests/ui/suggestions/negative-literal-infered-to-unsigned.rs new file mode 100644 index 00000000000..39797574b97 --- /dev/null +++ b/tests/ui/suggestions/negative-literal-infered-to-unsigned.rs @@ -0,0 +1,13 @@ +fn main() { + for x in -5..5 { + //~^ ERROR: the trait bound `usize: Neg` is not satisfied + //~| HELP: consider specifying an integer type that can be negative + do_something(x); + } + let x = -5; + //~^ ERROR: the trait bound `usize: Neg` is not satisfied + //~| HELP: consider specifying an integer type that can be negative + do_something(x); +} + +fn do_something(_val: usize) {} diff --git a/tests/ui/suggestions/negative-literal-infered-to-unsigned.stderr b/tests/ui/suggestions/negative-literal-infered-to-unsigned.stderr new file mode 100644 index 00000000000..b49ea224d2b --- /dev/null +++ b/tests/ui/suggestions/negative-literal-infered-to-unsigned.stderr @@ -0,0 +1,25 @@ +error[E0277]: the trait bound `usize: Neg` is not satisfied + --> $DIR/negative-literal-infered-to-unsigned.rs:2:14 + | +LL | for x in -5..5 { + | ^^ the trait `Neg` is not implemented for `usize` + | +help: consider specifying an integer type that can be negative + | +LL | for x in -5isize..5 { + | +++++ + +error[E0277]: the trait bound `usize: Neg` is not satisfied + --> $DIR/negative-literal-infered-to-unsigned.rs:7:13 + | +LL | let x = -5; + | ^^ the trait `Neg` is not implemented for `usize` + | +help: consider specifying an integer type that can be negative + | +LL | let x = -5isize; + | +++++ + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/suggestions/suggest-tryinto-edition-change.stderr b/tests/ui/suggestions/suggest-tryinto-edition-change.stderr index 0008b4fb5ed..8ab8a1716b1 100644 --- a/tests/ui/suggestions/suggest-tryinto-edition-change.stderr +++ b/tests/ui/suggestions/suggest-tryinto-edition-change.stderr @@ -44,6 +44,7 @@ error[E0599]: no method named `try_into` found for type `i32` in the current sco | LL | let _i: i16 = 0_i32.try_into().unwrap(); | ^^^^^^^^ + | --> $SRC_DIR/core/src/convert/mod.rs:LL:COL | = note: the method is available for `i32` here diff --git a/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.fixed b/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.fixed new file mode 100644 index 00000000000..2835743fca2 --- /dev/null +++ b/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.fixed @@ -0,0 +1,13 @@ +//@ run-rustfix + +use std::fmt::Display; + +struct S; + +impl S { + fn call(&self, _: impl Display) {} +} + +fn main() { + S.call((|| "hello")()); //~ ERROR [E0277] +} diff --git a/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.rs b/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.rs new file mode 100644 index 00000000000..848629a6700 --- /dev/null +++ b/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.rs @@ -0,0 +1,13 @@ +//@ run-rustfix + +use std::fmt::Display; + +struct S; + +impl S { + fn call(&self, _: impl Display) {} +} + +fn main() { + S.call(|| "hello"); //~ ERROR [E0277] +} diff --git a/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.stderr b/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.stderr new file mode 100644 index 00000000000..cb6df5af7fb --- /dev/null +++ b/tests/ui/suggestions/use-parentheses-to-call-closure-issue-145404.stderr @@ -0,0 +1,23 @@ +error[E0277]: `{closure@$DIR/use-parentheses-to-call-closure-issue-145404.rs:12:12: 12:14}` doesn't implement `std::fmt::Display` + --> $DIR/use-parentheses-to-call-closure-issue-145404.rs:12:12 + | +LL | S.call(|| "hello"); + | ---- ^^^^^^^^^^ unsatisfied trait bound + | | + | required by a bound introduced by this call + | + = help: the trait `std::fmt::Display` is not implemented for closure `{closure@$DIR/use-parentheses-to-call-closure-issue-145404.rs:12:12: 12:14}` +note: required by a bound in `S::call` + --> $DIR/use-parentheses-to-call-closure-issue-145404.rs:8:28 + | +LL | fn call(&self, _: impl Display) {} + | ^^^^^^^ required by this bound in `S::call` +help: use parentheses to call this closure + | +LL - S.call(|| "hello"); +LL + S.call((|| "hello")()); + | + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/target-feature/inline-always.aarch64.stderr b/tests/ui/target-feature/inline-always.aarch64.stderr new file mode 100644 index 00000000000..a9ffb425c52 --- /dev/null +++ b/tests/ui/target-feature/inline-always.aarch64.stderr @@ -0,0 +1,60 @@ +warning: call to `#[inline(always)]`-annotated `target_feature_identity` requires the same target features to be inlined + --> $DIR/inline-always.rs:19:5 + | +LL | target_feature_identity(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: function will not be inlined + = note: the following target features are on `target_feature_identity` but missing from `call_no_target_features`: neon, fp16 +note: `target_feature_identity` is defined here + --> $DIR/inline-always.rs:16:1 + | +LL | pub unsafe fn target_feature_identity() {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: `#[warn(inline_always_mismatching_target_features)]` on by default +help: add `#[target_feature]` attribute to `call_no_target_features` + | +LL + #[target_feature(enable = "neon,fp16")] +LL | unsafe fn call_no_target_features() { + | + +warning: call to `#[inline(always)]`-annotated `multiple_target_features` requires the same target features to be inlined + --> $DIR/inline-always.rs:22:5 + | +LL | multiple_target_features(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: function will not be inlined + = note: the following target features are on `multiple_target_features` but missing from `call_no_target_features`: fp16, sve, rdm +note: `multiple_target_features` is defined here + --> $DIR/inline-always.rs:52:1 + | +LL | fn multiple_target_features() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: add `#[target_feature]` attribute to `call_no_target_features` + | +LL + #[target_feature(enable = "fp16,sve,rdm")] +LL | unsafe fn call_no_target_features() { + | + +warning: call to `#[inline(always)]`-annotated `multiple_target_features` requires the same target features to be inlined + --> $DIR/inline-always.rs:28:5 + | +LL | multiple_target_features(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: function will not be inlined + = note: the following target features are on `multiple_target_features` but missing from `call_to_first_set`: rdm +note: `multiple_target_features` is defined here + --> $DIR/inline-always.rs:52:1 + | +LL | fn multiple_target_features() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: add `#[target_feature]` attribute to `call_to_first_set` + | +LL + #[target_feature(enable = "rdm")] +LL | unsafe fn call_to_first_set() { + | + +warning: 3 warnings emitted + diff --git a/tests/ui/target-feature/inline-always.rs b/tests/ui/target-feature/inline-always.rs new file mode 100644 index 00000000000..dbf46537caa --- /dev/null +++ b/tests/ui/target-feature/inline-always.rs @@ -0,0 +1,54 @@ +//@ add-core-stubs +//@ build-pass +//@ compile-flags: --crate-type=lib +//@ revisions: aarch64 +//@[aarch64] compile-flags: --target aarch64-unknown-linux-gnu +//@[aarch64] needs-llvm-components: aarch64 + +#![feature(no_core, target_feature_inline_always)] +#![no_core] + +extern crate minicore; +use minicore::*; + +#[inline(always)] +#[target_feature(enable = "neon,fp16")] +pub unsafe fn target_feature_identity() {} + +unsafe fn call_no_target_features() { + target_feature_identity(); + //~^ WARNING call to `#[inline(always)]`-annotated `target_feature_identity` requires the same target features to be inlined [inline_always_mismatching_target_features] + global_feature_enabled(); + multiple_target_features(); + //~^ WARNING call to `#[inline(always)]`-annotated `multiple_target_features` requires the same target features to be inlined [inline_always_mismatching_target_features] +} + +#[target_feature(enable = "fp16,sve")] +unsafe fn call_to_first_set() { + multiple_target_features(); + //~^ WARNING call to `#[inline(always)]`-annotated `multiple_target_features` requires the same target features to be inlined [inline_always_mismatching_target_features] +} + +/* You can't have "fhm" without "fp16" */ +#[target_feature(enable = "fhm")] +unsafe fn mismatching_features() { + target_feature_identity() +} + +#[target_feature(enable = "fp16")] +unsafe fn matching_target_features() { + target_feature_identity() +} + +#[inline(always)] +#[target_feature(enable = "neon")] +unsafe fn global_feature_enabled() { + +} + +#[inline(always)] +#[target_feature(enable = "fp16,sve")] +#[target_feature(enable="rdm")] +fn multiple_target_features() { + + } diff --git a/tests/ui/target-feature/invalid-attribute.rs b/tests/ui/target-feature/invalid-attribute.rs index b34a48aba26..a958700231a 100644 --- a/tests/ui/target-feature/invalid-attribute.rs +++ b/tests/ui/target-feature/invalid-attribute.rs @@ -61,6 +61,8 @@ trait Baz {} #[inline(always)] //~^ ERROR: cannot use `#[inline(always)]` +//~| NOTE: see issue #145574 <https://github.com/rust-lang/rust/issues/145574> for more information +//~| NOTE: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date #[target_feature(enable = "sse2")] unsafe fn test() {} diff --git a/tests/ui/target-feature/invalid-attribute.stderr b/tests/ui/target-feature/invalid-attribute.stderr index 7b75367b48c..d85bccce441 100644 --- a/tests/ui/target-feature/invalid-attribute.stderr +++ b/tests/ui/target-feature/invalid-attribute.stderr @@ -106,7 +106,7 @@ LL | #[target_feature(enable = "sse2")] = help: `#[target_feature]` can only be applied to functions error: `#[target_feature]` attribute cannot be used on statics - --> $DIR/invalid-attribute.rs:67:1 + --> $DIR/invalid-attribute.rs:69:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -114,7 +114,7 @@ LL | #[target_feature(enable = "sse2")] = help: `#[target_feature]` can only be applied to functions error: `#[target_feature]` attribute cannot be used on trait impl blocks - --> $DIR/invalid-attribute.rs:71:1 + --> $DIR/invalid-attribute.rs:73:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -122,7 +122,7 @@ LL | #[target_feature(enable = "sse2")] = help: `#[target_feature]` can only be applied to functions error: `#[target_feature]` attribute cannot be used on inherent impl blocks - --> $DIR/invalid-attribute.rs:77:1 + --> $DIR/invalid-attribute.rs:79:1 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -130,7 +130,7 @@ LL | #[target_feature(enable = "sse2")] = help: `#[target_feature]` can only be applied to functions error: `#[target_feature]` attribute cannot be used on expressions - --> $DIR/invalid-attribute.rs:98:5 + --> $DIR/invalid-attribute.rs:100:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -138,18 +138,22 @@ LL | #[target_feature(enable = "sse2")] = help: `#[target_feature]` can only be applied to functions error: `#[target_feature]` attribute cannot be used on closures - --> $DIR/invalid-attribute.rs:104:5 + --> $DIR/invalid-attribute.rs:106:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | = help: `#[target_feature]` can be applied to methods and functions -error: cannot use `#[inline(always)]` with `#[target_feature]` +error[E0658]: cannot use `#[inline(always)]` with `#[target_feature]` --> $DIR/invalid-attribute.rs:62:1 | LL | #[inline(always)] | ^^^^^^^^^^^^^^^^^ + | + = note: see issue #145574 <https://github.com/rust-lang/rust/issues/145574> for more information + = help: add `#![feature(target_feature_inline_always)]` 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: the feature named `foo` is not valid for this target --> $DIR/invalid-attribute.rs:20:18 @@ -158,7 +162,7 @@ LL | #[target_feature(enable = "foo")] | ^^^^^^^^^^^^^^ `foo` is not valid for this target error[E0046]: not all trait items implemented, missing: `foo` - --> $DIR/invalid-attribute.rs:73:1 + --> $DIR/invalid-attribute.rs:75:1 | LL | impl Quux for u8 {} | ^^^^^^^^^^^^^^^^ missing `foo` in implementation @@ -167,7 +171,7 @@ LL | fn foo(); | --------- `foo` from trait error: `#[target_feature(..)]` cannot be applied to safe trait method - --> $DIR/invalid-attribute.rs:87:5 + --> $DIR/invalid-attribute.rs:89:5 | LL | #[target_feature(enable = "sse2")] | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot be applied to safe trait method @@ -176,13 +180,13 @@ LL | fn foo() {} | -------- not an `unsafe` function error[E0053]: method `foo` has an incompatible type for trait - --> $DIR/invalid-attribute.rs:90:5 + --> $DIR/invalid-attribute.rs:92:5 | LL | fn foo() {} | ^^^^^^^^ expected safe fn, found unsafe fn | note: type in trait - --> $DIR/invalid-attribute.rs:82:5 + --> $DIR/invalid-attribute.rs:84:5 | LL | fn foo(); | ^^^^^^^^^ @@ -190,7 +194,7 @@ LL | fn foo(); found signature `#[target_features] fn()` error: the feature named `+sse2` is not valid for this target - --> $DIR/invalid-attribute.rs:109:18 + --> $DIR/invalid-attribute.rs:111:18 | LL | #[target_feature(enable = "+sse2")] | ^^^^^^^^^^^^^^^^ `+sse2` is not valid for this target @@ -199,5 +203,5 @@ LL | #[target_feature(enable = "+sse2")] error: aborting due to 24 previous errors -Some errors have detailed explanations: E0046, E0053, E0539. +Some errors have detailed explanations: E0046, E0053, E0539, E0658. For more information about an error, try `rustc --explain E0046`. diff --git a/tests/ui/target_modifiers/auxiliary/kcfi-normalize-ints.rs b/tests/ui/target_modifiers/auxiliary/kcfi-normalize-ints.rs new file mode 100644 index 00000000000..f97005a1450 --- /dev/null +++ b/tests/ui/target_modifiers/auxiliary/kcfi-normalize-ints.rs @@ -0,0 +1,7 @@ +//@ no-prefer-dynamic +//@ needs-sanitizer-kcfi +//@ compile-flags: -C panic=abort -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers + +#![feature(no_core)] +#![crate_type = "rlib"] +#![no_core] diff --git a/tests/ui/target_modifiers/auxiliary/no-sanitizers.rs b/tests/ui/target_modifiers/auxiliary/no-sanitizers.rs new file mode 100644 index 00000000000..1d47ff6826d --- /dev/null +++ b/tests/ui/target_modifiers/auxiliary/no-sanitizers.rs @@ -0,0 +1,6 @@ +//@ no-prefer-dynamic +//@ compile-flags: -C panic=abort + +#![feature(no_core)] +#![crate_type = "rlib"] +#![no_core] diff --git a/tests/ui/target_modifiers/auxiliary/safestack-and-kcfi.rs b/tests/ui/target_modifiers/auxiliary/safestack-and-kcfi.rs new file mode 100644 index 00000000000..029744d2a1f --- /dev/null +++ b/tests/ui/target_modifiers/auxiliary/safestack-and-kcfi.rs @@ -0,0 +1,10 @@ +//@ no-prefer-dynamic + +//@ needs-sanitizer-kcfi +//@ needs-sanitizer-safestack + +//@ compile-flags: -C panic=abort -Zsanitizer=safestack,kcfi + +#![feature(no_core)] +#![crate_type = "rlib"] +#![no_core] diff --git a/tests/ui/target_modifiers/sanitizer-kcfi-normalize-ints.rs b/tests/ui/target_modifiers/sanitizer-kcfi-normalize-ints.rs new file mode 100644 index 00000000000..cb9f701349a --- /dev/null +++ b/tests/ui/target_modifiers/sanitizer-kcfi-normalize-ints.rs @@ -0,0 +1,18 @@ +// For kCFI, the helper flag -Zsanitizer-cfi-normalize-integers should also be a target modifier. + +//@ needs-sanitizer-kcfi +//@ aux-build:kcfi-normalize-ints.rs +//@ compile-flags: -Cpanic=abort + +//@ revisions: ok wrong_flag wrong_sanitizer +//@[ok] compile-flags: -Zsanitizer=kcfi -Zsanitizer-cfi-normalize-integers +//@[wrong_flag] compile-flags: -Zsanitizer=kcfi +//@[ok] check-pass + +#![feature(no_core)] +//[wrong_flag]~^ ERROR mixing `-Zsanitizer-cfi-normalize-integers` will cause an ABI mismatch in crate `sanitizer_kcfi_normalize_ints` +//[wrong_sanitizer]~^^ ERROR mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizer_kcfi_normalize_ints` +#![crate_type = "rlib"] +#![no_core] + +extern crate kcfi_normalize_ints; diff --git a/tests/ui/target_modifiers/sanitizer-kcfi-normalize-ints.wrong_flag.stderr b/tests/ui/target_modifiers/sanitizer-kcfi-normalize-ints.wrong_flag.stderr new file mode 100644 index 00000000000..1db79b025e9 --- /dev/null +++ b/tests/ui/target_modifiers/sanitizer-kcfi-normalize-ints.wrong_flag.stderr @@ -0,0 +1,13 @@ +error: mixing `-Zsanitizer-cfi-normalize-integers` will cause an ABI mismatch in crate `sanitizer_kcfi_normalize_ints` + --> $DIR/sanitizer-kcfi-normalize-ints.rs:12:1 + | +LL | #![feature(no_core)] + | ^ + | + = help: the `-Zsanitizer-cfi-normalize-integers` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely + = note: unset `-Zsanitizer-cfi-normalize-integers` in this crate is incompatible with `-Zsanitizer-cfi-normalize-integers=` in dependency `kcfi_normalize_ints` + = help: set `-Zsanitizer-cfi-normalize-integers=` in this crate or unset `-Zsanitizer-cfi-normalize-integers` in `kcfi_normalize_ints` + = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer-cfi-normalize-integers` to silence this error + +error: aborting due to 1 previous error + diff --git a/tests/ui/target_modifiers/sanitizer-kcfi-normalize-ints.wrong_sanitizer.stderr b/tests/ui/target_modifiers/sanitizer-kcfi-normalize-ints.wrong_sanitizer.stderr new file mode 100644 index 00000000000..5b949c87350 --- /dev/null +++ b/tests/ui/target_modifiers/sanitizer-kcfi-normalize-ints.wrong_sanitizer.stderr @@ -0,0 +1,13 @@ +error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizer_kcfi_normalize_ints` + --> $DIR/sanitizer-kcfi-normalize-ints.rs:12:1 + | +LL | #![feature(no_core)] + | ^ + | + = help: the `-Zsanitizer` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely + = note: unset `-Zsanitizer` in this crate is incompatible with `-Zsanitizer=kcfi` in dependency `kcfi_normalize_ints` + = help: set `-Zsanitizer=kcfi` in this crate or unset `-Zsanitizer` in `kcfi_normalize_ints` + = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer` to silence this error + +error: aborting due to 1 previous error + diff --git a/tests/ui/target_modifiers/sanitizers-good-for-inconsistency.rs b/tests/ui/target_modifiers/sanitizers-good-for-inconsistency.rs new file mode 100644 index 00000000000..abda7be9e40 --- /dev/null +++ b/tests/ui/target_modifiers/sanitizers-good-for-inconsistency.rs @@ -0,0 +1,19 @@ +// AddressSanitizer, LeakSanitizer are good to be inconsistent (they are not a target modifiers) + +//@ revisions: wrong_address_san wrong_leak_san + +//@[wrong_address_san] needs-sanitizer-address +//@[wrong_leak_san] needs-sanitizer-leak + +//@ aux-build:no-sanitizers.rs +//@ compile-flags: -Cpanic=abort -C target-feature=-crt-static + +//@[wrong_address_san] compile-flags: -Zsanitizer=address +//@[wrong_leak_san] compile-flags: -Zsanitizer=leak +//@ check-pass + +#![feature(no_core)] +#![crate_type = "rlib"] +#![no_core] + +extern crate no_sanitizers; diff --git a/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_both.stderr b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_both.stderr new file mode 100644 index 00000000000..440a91c7707 --- /dev/null +++ b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_both.stderr @@ -0,0 +1,13 @@ +error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi` + --> $DIR/sanitizers-safestack-and-kcfi.rs:16:1 + | +LL | #![feature(no_core)] + | ^ + | + = help: the `-Zsanitizer` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely + = note: unset `-Zsanitizer` in this crate is incompatible with `-Zsanitizer=safestack,kcfi` in dependency `safestack_and_kcfi` + = help: set `-Zsanitizer=safestack,kcfi` in this crate or unset `-Zsanitizer` in `safestack_and_kcfi` + = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer` to silence this error + +error: aborting due to 1 previous error + diff --git a/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_kcfi.stderr b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_kcfi.stderr new file mode 100644 index 00000000000..6cdd7facc37 --- /dev/null +++ b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_kcfi.stderr @@ -0,0 +1,13 @@ +error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi` + --> $DIR/sanitizers-safestack-and-kcfi.rs:16:1 + | +LL | #![feature(no_core)] + | ^ + | + = help: the `-Zsanitizer` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely + = note: `-Zsanitizer=safestack` in this crate is incompatible with `-Zsanitizer=safestack,kcfi` in dependency `safestack_and_kcfi` + = help: set `-Zsanitizer=safestack,kcfi` in this crate or `-Zsanitizer=safestack` in `safestack_and_kcfi` + = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer` to silence this error + +error: aborting due to 1 previous error + diff --git a/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_safestack.stderr b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_safestack.stderr new file mode 100644 index 00000000000..ecfbcace39f --- /dev/null +++ b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.missed_safestack.stderr @@ -0,0 +1,13 @@ +error: mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi` + --> $DIR/sanitizers-safestack-and-kcfi.rs:16:1 + | +LL | #![feature(no_core)] + | ^ + | + = help: the `-Zsanitizer` flag modifies the ABI so Rust crates compiled with different values of this flag cannot be used together safely + = note: `-Zsanitizer=kcfi` in this crate is incompatible with `-Zsanitizer=safestack,kcfi` in dependency `safestack_and_kcfi` + = help: set `-Zsanitizer=safestack,kcfi` in this crate or `-Zsanitizer=kcfi` in `safestack_and_kcfi` + = help: if you are sure this will not cause problems, you may use `-Cunsafe-allow-abi-mismatch=sanitizer` to silence this error + +error: aborting due to 1 previous error + diff --git a/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.rs b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.rs new file mode 100644 index 00000000000..6c3ceb7e910 --- /dev/null +++ b/tests/ui/target_modifiers/sanitizers-safestack-and-kcfi.rs @@ -0,0 +1,23 @@ +//@ needs-sanitizer-kcfi +//@ needs-sanitizer-safestack + +//@ aux-build:safestack-and-kcfi.rs +//@ compile-flags: -Cpanic=abort + +//@ revisions: good good_reverted missed_safestack missed_kcfi missed_both +//@[good] compile-flags: -Zsanitizer=safestack,kcfi +//@[good_reverted] compile-flags: -Zsanitizer=kcfi,safestack +//@[missed_safestack] compile-flags: -Zsanitizer=kcfi +//@[missed_kcfi] compile-flags: -Zsanitizer=safestack +// [missed_both] no additional compile-flags: +//@[good] check-pass +//@[good_reverted] check-pass + +#![feature(no_core)] +//[missed_safestack]~^ ERROR mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi` +//[missed_kcfi]~^^ ERROR mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi` +//[missed_both]~^^^ ERROR mixing `-Zsanitizer` will cause an ABI mismatch in crate `sanitizers_safestack_and_kcfi` +#![crate_type = "rlib"] +#![no_core] + +extern crate safestack_and_kcfi; diff --git a/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr b/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr index 2288bd1129c..40936ce1ec3 100644 --- a/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr +++ b/tests/ui/traits/associated_type_bound/assoc_type_bound_with_struct.stderr @@ -3,10 +3,10 @@ error[E0404]: expected trait, found struct `String` | LL | struct Foo<T> where T: Bar, <T as Bar>::Baz: String { | ^^^^^^ not a trait + | --> $SRC_DIR/alloc/src/string.rs:LL:COL | = note: similarly named trait `ToString` defined here - | help: constrain the associated type to `String` | LL - struct Foo<T> where T: Bar, <T as Bar>::Baz: String { @@ -22,10 +22,10 @@ error[E0404]: expected trait, found struct `String` | LL | struct Qux<'a, T> where T: Bar, <&'a T as Bar>::Baz: String { | ^^^^^^ not a trait + | --> $SRC_DIR/alloc/src/string.rs:LL:COL | = note: similarly named trait `ToString` defined here - | help: constrain the associated type to `String` | LL - struct Qux<'a, T> where T: Bar, <&'a T as Bar>::Baz: String { @@ -41,10 +41,10 @@ error[E0404]: expected trait, found struct `String` | LL | fn foo<T: Bar>(_: T) where <T as Bar>::Baz: String { | ^^^^^^ not a trait + | --> $SRC_DIR/alloc/src/string.rs:LL:COL | = note: similarly named trait `ToString` defined here - | help: constrain the associated type to `String` | LL - fn foo<T: Bar>(_: T) where <T as Bar>::Baz: String { @@ -60,10 +60,10 @@ error[E0404]: expected trait, found struct `String` | LL | fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: String { | ^^^^^^ not a trait + | --> $SRC_DIR/alloc/src/string.rs:LL:COL | = note: similarly named trait `ToString` defined here - | help: constrain the associated type to `String` | LL - fn qux<'a, T: Bar>(_: &'a T) where <&'a T as Bar>::Baz: String { @@ -85,6 +85,7 @@ error[E0404]: expected trait, found struct `String` | LL | fn issue_95327() where <u8 as Unresolved>::Assoc: String {} | ^^^^^^ help: a trait with a similar name exists: `ToString` + | --> $SRC_DIR/alloc/src/string.rs:LL:COL | = note: similarly named trait `ToString` defined here diff --git a/tests/ui/traits/bound/suggest-complex-bound-on-method.fixed b/tests/ui/traits/bound/suggest-complex-bound-on-method.fixed new file mode 100644 index 00000000000..719835af0a9 --- /dev/null +++ b/tests/ui/traits/bound/suggest-complex-bound-on-method.fixed @@ -0,0 +1,23 @@ +//@ run-rustfix +#![allow(dead_code)] +struct Application; +// https://github.com/rust-lang/rust/issues/144734 +trait Trait { + type Error: std::error::Error; + + fn run(&self) -> Result<(), Self::Error>; +} + +#[derive(Debug)] +enum ApplicationError { + Quit, +} + +impl Application { + fn thing<T: Trait>(&self, t: T) -> Result<(), ApplicationError> where ApplicationError: From<<T as Trait>::Error> { + t.run()?; //~ ERROR E0277 + Ok(()) + } +} + +fn main() {} diff --git a/tests/ui/traits/bound/suggest-complex-bound-on-method.rs b/tests/ui/traits/bound/suggest-complex-bound-on-method.rs new file mode 100644 index 00000000000..39cec571242 --- /dev/null +++ b/tests/ui/traits/bound/suggest-complex-bound-on-method.rs @@ -0,0 +1,23 @@ +//@ run-rustfix +#![allow(dead_code)] +struct Application; +// https://github.com/rust-lang/rust/issues/144734 +trait Trait { + type Error: std::error::Error; + + fn run(&self) -> Result<(), Self::Error>; +} + +#[derive(Debug)] +enum ApplicationError { + Quit, +} + +impl Application { + fn thing<T: Trait>(&self, t: T) -> Result<(), ApplicationError> { + t.run()?; //~ ERROR E0277 + Ok(()) + } +} + +fn main() {} diff --git a/tests/ui/traits/bound/suggest-complex-bound-on-method.stderr b/tests/ui/traits/bound/suggest-complex-bound-on-method.stderr new file mode 100644 index 00000000000..ac45f049541 --- /dev/null +++ b/tests/ui/traits/bound/suggest-complex-bound-on-method.stderr @@ -0,0 +1,22 @@ +error[E0277]: `?` couldn't convert the error to `ApplicationError` + --> $DIR/suggest-complex-bound-on-method.rs:18:16 + | +LL | t.run()?; + | -----^ the trait `From<<T as Trait>::Error>` is not implemented for `ApplicationError` + | | + | this can't be annotated with `?` because it has type `Result<_, <T as Trait>::Error>` + | +note: `ApplicationError` needs to implement `From<<T as Trait>::Error>` + --> $DIR/suggest-complex-bound-on-method.rs:12:1 + | +LL | enum ApplicationError { + | ^^^^^^^^^^^^^^^^^^^^^ + = note: the question mark operation (`?`) implicitly performs a conversion on the error value using the `From` trait +help: consider introducing a `where` clause, but there might be an alternative better way to express this requirement + | +LL | fn thing<T: Trait>(&self, t: T) -> Result<(), ApplicationError> where ApplicationError: From<<T as Trait>::Error> { + | +++++++++++++++++++++++++++++++++++++++++++++++++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/constructor-const-fn.rs b/tests/ui/traits/const-traits/constructor-const-fn.rs index 4a7bf531df2..af40ad94d1c 100644 --- a/tests/ui/traits/const-traits/constructor-const-fn.rs +++ b/tests/ui/traits/const-traits/constructor-const-fn.rs @@ -1,7 +1,7 @@ //@ check-pass //@ compile-flags: -Znext-solver #![feature(const_trait_impl)] -const fn impls_fn<F: ~const Fn(u32) -> Foo>(_: &F) {} +const fn impls_fn<F: [const] Fn(u32) -> Foo>(_: &F) {} struct Foo(u32); diff --git a/tests/ui/traits/const-traits/enforce-deref-on-adjust.rs b/tests/ui/traits/const-traits/enforce-deref-on-adjust.rs index d5240b7e18d..cba207f0953 100644 --- a/tests/ui/traits/const-traits/enforce-deref-on-adjust.rs +++ b/tests/ui/traits/const-traits/enforce-deref-on-adjust.rs @@ -1,6 +1,6 @@ //@ check-pass -#![feature(const_deref)] +#![feature(const_convert)] #![feature(const_trait_impl)] use std::ops::Deref; 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 d5f80acc15b..50c985096d1 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 @@ -1,4 +1,4 @@ -#![feature(const_trait_impl, const_from)] +#![feature(const_trait_impl, const_convert)] //@ check-pass diff --git a/tests/ui/traits/const-traits/reservation-impl-ice.rs b/tests/ui/traits/const-traits/reservation-impl-ice.rs index efaea1cc6b2..3fbfe8c950d 100644 --- a/tests/ui/traits/const-traits/reservation-impl-ice.rs +++ b/tests/ui/traits/const-traits/reservation-impl-ice.rs @@ -1,7 +1,7 @@ //@ compile-flags: -Znext-solver -#![feature(const_from, never_type, const_trait_impl)] +#![feature(const_convert, never_type, const_trait_impl)] -const fn impls_from<T: ~const From<!>>() {} +const fn impls_from<T: [const] From<!>>() {} const fn foo() { // This previously ICE'd when encountering the reservation impl diff --git a/tests/ui/traits/const-traits/reservation-impl-ice.stderr b/tests/ui/traits/const-traits/reservation-impl-ice.stderr index a3fdcbac69e..d30c014d63f 100644 --- a/tests/ui/traits/const-traits/reservation-impl-ice.stderr +++ b/tests/ui/traits/const-traits/reservation-impl-ice.stderr @@ -17,8 +17,8 @@ LL | impls_from::<()>(); note: required by a bound in `impls_from` --> $DIR/reservation-impl-ice.rs:4:24 | -LL | const fn impls_from<T: ~const From<!>>() {} - | ^^^^^^^^^^^^^^ required by this bound in `impls_from` +LL | const fn impls_from<T: [const] From<!>>() {} + | ^^^^^^^^^^^^^^^ required by this bound in `impls_from` error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-5666.rs b/tests/ui/traits/dynamic-dispatch-trait-objects-5666.rs index 76e2f8229a0..e335949d832 100644 --- a/tests/ui/issues/issue-5666.rs +++ b/tests/ui/traits/dynamic-dispatch-trait-objects-5666.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5666 //@ run-pass struct Dog { @@ -14,7 +15,6 @@ impl Barks for Dog { } } - pub fn main() { let snoopy = Box::new(Dog{name: "snoopy".to_string()}); let bubbles = Box::new(Dog{name: "bubbles".to_string()}); diff --git a/tests/ui/traits/next-solver/opaques/different-bound-vars.current.stderr b/tests/ui/traits/next-solver/opaques/different-bound-vars.current.stderr new file mode 100644 index 00000000000..32e92e46a88 --- /dev/null +++ b/tests/ui/traits/next-solver/opaques/different-bound-vars.current.stderr @@ -0,0 +1,14 @@ +error: concrete type differs from previous defining opaque type use + --> $DIR/different-bound-vars.rs:13:37 + | +LL | let _: for<'b> fn(&'b ()) = foo::<U, T>(false); + | ^^^^^^^^^^^^^^^^^^ expected `for<'a> fn(&'a ())`, got `for<'b> fn(&'b ())` + | +note: previous use here + --> $DIR/different-bound-vars.rs:12:37 + | +LL | let _: for<'a> fn(&'a ()) = foo::<T, U>(false); + | ^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/next-solver/opaques/different-bound-vars.rs b/tests/ui/traits/next-solver/opaques/different-bound-vars.rs new file mode 100644 index 00000000000..5801a5edeb4 --- /dev/null +++ b/tests/ui/traits/next-solver/opaques/different-bound-vars.rs @@ -0,0 +1,20 @@ +// Check whether we support defining uses with different bound vars. +// This needs to handle both mismatches for the same opaque type storage +// entry, but also between different entries. + +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver +//@[next] check-pass + +fn foo<T, U>(b: bool) -> impl Sized { + if b { + let _: for<'a> fn(&'a ()) = foo::<T, U>(false); + let _: for<'b> fn(&'b ()) = foo::<U, T>(false); + //[current]~^ ERROR concrete type differs from previous defining opaque type use + } + + (|&()| ()) as for<'c> fn(&'c ()) +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.is_send.stderr b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.is_send.stderr index 6d2bbd8b08b..a188629a475 100644 --- a/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.is_send.stderr +++ b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.is_send.stderr @@ -1,16 +1,9 @@ -error[E0283]: type annotations needed: cannot satisfy `Foo: Send` - --> $DIR/dont-type_of-tait-in-defining-scope.rs:16:18 +error[E0282]: type annotations needed + --> $DIR/dont-type_of-tait-in-defining-scope.rs:15:12 | -LL | needs_send::<Foo>(); - | ^^^ - | - = note: cannot satisfy `Foo: Send` -note: required by a bound in `needs_send` - --> $DIR/dont-type_of-tait-in-defining-scope.rs:12:18 - | -LL | fn needs_send<T: Send>() {} - | ^^^^ required by this bound in `needs_send` +LL | fn test(_: Foo) { + | ^^^ cannot infer type error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.not_send.stderr b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.not_send.stderr index 6d2bbd8b08b..a188629a475 100644 --- a/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.not_send.stderr +++ b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.not_send.stderr @@ -1,16 +1,9 @@ -error[E0283]: type annotations needed: cannot satisfy `Foo: Send` - --> $DIR/dont-type_of-tait-in-defining-scope.rs:16:18 +error[E0282]: type annotations needed + --> $DIR/dont-type_of-tait-in-defining-scope.rs:15:12 | -LL | needs_send::<Foo>(); - | ^^^ - | - = note: cannot satisfy `Foo: Send` -note: required by a bound in `needs_send` - --> $DIR/dont-type_of-tait-in-defining-scope.rs:12:18 - | -LL | fn needs_send<T: Send>() {} - | ^^^^ required by this bound in `needs_send` +LL | fn test(_: Foo) { + | ^^^ cannot infer type error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.rs b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.rs index fddf892e1ef..8ff99d32f06 100644 --- a/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.rs +++ b/tests/ui/traits/next-solver/opaques/dont-type_of-tait-in-defining-scope.rs @@ -13,8 +13,8 @@ fn needs_send<T: Send>() {} #[define_opaque(Foo)] fn test(_: Foo) { - needs_send::<Foo>(); //~^ ERROR type annotations needed + needs_send::<Foo>(); } #[define_opaque(Foo)] diff --git a/tests/ui/traits/next-solver/opaques/non-defining-use-hir-typeck.rs b/tests/ui/traits/next-solver/opaques/non-defining-use-hir-typeck.rs new file mode 100644 index 00000000000..a55be5fde9e --- /dev/null +++ b/tests/ui/traits/next-solver/opaques/non-defining-use-hir-typeck.rs @@ -0,0 +1,28 @@ +//@ ignore-compare-mode-next-solver +//@ compile-flags: -Znext-solver +//@ check-pass +#![feature(type_alias_impl_trait)] + +// Make sure that we support non-defining uses in HIR typeck. +// Regression test for trait-system-refactor-initiative#135. + +fn non_defining_recurse<T>(b: bool) -> impl Sized { + if b { + // This results in an opaque type use `opaque<()> = ?unconstrained` + // during HIR typeck. + non_defining_recurse::<()>(false); + } +} + +trait Eq<T, U> {} +impl<T> Eq<T, T> for () {} +fn is_eq<T: Eq<U, V>, U, V>() {} +type Tait<T> = impl Sized; +#[define_opaque(Tait)] +fn non_defining_explicit<T>() { + is_eq::<(), Tait<_>, u32>(); // constrains opaque type args via hidden type + is_eq::<(), Tait<u64>, _>(); // constraints hidden type via args + is_eq::<(), Tait<T>, T>(); // actually defines +} + +fn main() {} diff --git a/tests/ui/traits/next-solver/opaques/universal-args-non-defining.rs b/tests/ui/traits/next-solver/opaques/universal-args-non-defining.rs new file mode 100644 index 00000000000..5e7e9738616 --- /dev/null +++ b/tests/ui/traits/next-solver/opaques/universal-args-non-defining.rs @@ -0,0 +1,16 @@ +//@ check-pass +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + +// The recursive call to `foo` results in the opaque type use `opaque<U, T> = ?unconstrained`. +// This needs to be supported and treated as a revealing use. + +fn foo<T, U>(b: bool) -> impl Sized { + if b { + foo::<U, T>(b); + } + 1u16 +} + +fn main() {} diff --git a/tests/ui/issues/issue-53568.rs b/tests/ui/traits/nll-ice-custom-type-ops-53568.rs index 9862d4ced12..9b240cdc190 100644 --- a/tests/ui/issues/issue-53568.rs +++ b/tests/ui/traits/nll-ice-custom-type-ops-53568.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/53568 // Regression test for an NLL-related ICE (#53568) -- we failed to // resolve inference variables in "custom type-ops". // diff --git a/tests/ui/issues/issue-5883.rs b/tests/ui/traits/opaque-trait-size-error-5883.rs index dd4753e0344..e39e24e7342 100644 --- a/tests/ui/issues/issue-5883.rs +++ b/tests/ui/traits/opaque-trait-size-error-5883.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5883 trait A {} struct Struct { diff --git a/tests/ui/issues/issue-5883.stderr b/tests/ui/traits/opaque-trait-size-error-5883.stderr index 2ca437b8c47..78de250b19a 100644 --- a/tests/ui/issues/issue-5883.stderr +++ b/tests/ui/traits/opaque-trait-size-error-5883.stderr @@ -1,19 +1,19 @@ error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time - --> $DIR/issue-5883.rs:9:6 + --> $DIR/opaque-trait-size-error-5883.rs:10:6 | LL | ) -> Struct { | ^^^^^^ doesn't have a size known at compile-time | = help: within `Struct`, the trait `Sized` is not implemented for `(dyn A + 'static)` note: required because it appears within the type `Struct` - --> $DIR/issue-5883.rs:3:8 + --> $DIR/opaque-trait-size-error-5883.rs:4:8 | LL | struct Struct { | ^^^^^^ = note: the return type of a function must have a statically known size error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time - --> $DIR/issue-5883.rs:8:8 + --> $DIR/opaque-trait-size-error-5883.rs:9:8 | LL | r: dyn A + 'static | ^^^^^^^^^^^^^^^ doesn't have a size known at compile-time diff --git a/tests/ui/traits/self-implements-kinds-in-default-methods-8171.rs b/tests/ui/traits/self-not-send-in-default-method-8171.rs index 59ea62c7690..59ea62c7690 100644 --- a/tests/ui/traits/self-implements-kinds-in-default-methods-8171.rs +++ b/tests/ui/traits/self-not-send-in-default-method-8171.rs diff --git a/tests/ui/issues/issue-6898.rs b/tests/ui/traits/trait-implementation-generic-access-6898.rs index c810acaf61b..e9437b1c522 100644 --- a/tests/ui/issues/issue-6898.rs +++ b/tests/ui/traits/trait-implementation-generic-access-6898.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/6898 //@ check-pass use std::mem; diff --git a/tests/ui/issues/issue-5988.rs b/tests/ui/traits/trait-implementation-restriction-5988.rs index b7527d9bea8..d3a5b10569b 100644 --- a/tests/ui/issues/issue-5988.rs +++ b/tests/ui/traits/trait-implementation-restriction-5988.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/5988 //@ run-pass trait B { diff --git a/tests/ui/traits/trait-implementation-and-usage-7563.rs b/tests/ui/traits/trait-object-lifetime-bounds-7563.rs index 8cfc7a14ffe..8cfc7a14ffe 100644 --- a/tests/ui/traits/trait-implementation-and-usage-7563.rs +++ b/tests/ui/traits/trait-object-lifetime-bounds-7563.rs diff --git a/tests/ui/traits/vtable/empty-supertrait-with-nonempty-supersupertrait.dump.stderr b/tests/ui/traits/vtable/empty-supertrait-with-nonempty-supersupertrait.dump.stderr new file mode 100644 index 00000000000..d90a786498e --- /dev/null +++ b/tests/ui/traits/vtable/empty-supertrait-with-nonempty-supersupertrait.dump.stderr @@ -0,0 +1,16 @@ +error: vtable entries: [ + MetadataDropInPlace, + MetadataSize, + MetadataAlign, + Method(<dyn OneTwo as One>::one - shim(reify)), + Method(<dyn OneTwo as Two>::two - shim(reify)), + TraitVPtr(<dyn OneTwo as Two>), + TraitVPtr(<dyn OneTwo as TwoAgain>), + ] + --> $DIR/empty-supertrait-with-nonempty-supersupertrait.rs:40:1 + | +LL | type T = dyn OneTwo; + | ^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/traits/vtable/empty-supertrait-with-nonempty-supersupertrait.rs b/tests/ui/traits/vtable/empty-supertrait-with-nonempty-supersupertrait.rs new file mode 100644 index 00000000000..507cda63868 --- /dev/null +++ b/tests/ui/traits/vtable/empty-supertrait-with-nonempty-supersupertrait.rs @@ -0,0 +1,49 @@ +//@ revisions: run dump +//@[run] run-pass +//@[dump] check-fail +//! Regression test for #145752 +//! Ensure that `OneTwo` contains a vptr for `TwoAgain` +#![allow(unused)] +#![cfg_attr(dump, feature(rustc_attrs))] + +trait One { + fn one(&self) { + panic!("don't call this"); + } +} +impl One for () {} + +trait Two { + fn two(&self) { + println!("good"); + } +} +impl Two for () {} + +trait TwoAgain: Two {} +impl<T: Two> TwoAgain for T {} + +trait OneTwo: One + TwoAgain {} +impl<T: One + Two> OneTwo for T {} + +fn main() { + (&()).two(); + (&() as &dyn OneTwo).two(); + (&() as &dyn OneTwo as &dyn Two).two(); + + // these two used to panic because they called `one` due to #145752 + (&() as &dyn OneTwo as &dyn TwoAgain).two(); + (&() as &dyn OneTwo as &dyn TwoAgain as &dyn Two).two(); +} + +#[cfg_attr(dump, rustc_dump_vtable)] +type T = dyn OneTwo; +//[dump]~^ ERROR vtable entries: [ +//[dump]~| ERROR MetadataDropInPlace, +//[dump]~| ERROR MetadataSize, +//[dump]~| ERROR MetadataAlign, +//[dump]~| ERROR Method(<dyn OneTwo as One>::one - shim(reify)), +//[dump]~| ERROR Method(<dyn OneTwo as Two>::two - shim(reify)), +//[dump]~| ERROR TraitVPtr(<dyn OneTwo as Two>), +//[dump]~| ERROR TraitVPtr(<dyn OneTwo as TwoAgain>), +//[dump]~| ERROR ] diff --git a/tests/ui/traits/vtable/multiple-auto.rs b/tests/ui/traits/vtable/multiple-auto.rs new file mode 100644 index 00000000000..87ee865868b --- /dev/null +++ b/tests/ui/traits/vtable/multiple-auto.rs @@ -0,0 +1,50 @@ +// Related to <https://github.com/rust-lang/rust/issues/113840> +// +// This test makes sure that multiple auto traits can reuse the +// same pointer for upcasting (e.g. `Send`/`Sync`) + +#![crate_type = "lib"] +#![feature(rustc_attrs, auto_traits)] + +// Markers +auto trait M0 {} +auto trait M1 {} +auto trait M2 {} + +// Just a trait with a method +trait T { + fn method(&self) {} +} + +trait A: M0 + M1 + M2 + T {} + +trait B: M0 + M1 + T + M2 {} + +trait C: M0 + T + M1 + M2 {} + +trait D: T + M0 + M1 + M2 {} + +struct S; + +impl M0 for S {} +impl M1 for S {} +impl M2 for S {} +impl T for S {} + +#[rustc_dump_vtable] +impl A for S {} +//~^ ERROR vtable entries + +#[rustc_dump_vtable] +impl B for S {} +//~^ ERROR vtable entries + +#[rustc_dump_vtable] +impl C for S {} +//~^ ERROR vtable entries + +#[rustc_dump_vtable] +impl D for S {} +//~^ ERROR vtable entries + +fn main() {} diff --git a/tests/ui/traits/vtable/multiple-auto.stderr b/tests/ui/traits/vtable/multiple-auto.stderr new file mode 100644 index 00000000000..0a7c3ebd36d --- /dev/null +++ b/tests/ui/traits/vtable/multiple-auto.stderr @@ -0,0 +1,46 @@ +error: vtable entries: [ + MetadataDropInPlace, + MetadataSize, + MetadataAlign, + Method(<S as T>::method), + ] + --> $DIR/multiple-auto.rs:35:1 + | +LL | impl A for S {} + | ^^^^^^^^^^^^ + +error: vtable entries: [ + MetadataDropInPlace, + MetadataSize, + MetadataAlign, + Method(<S as T>::method), + ] + --> $DIR/multiple-auto.rs:39:1 + | +LL | impl B for S {} + | ^^^^^^^^^^^^ + +error: vtable entries: [ + MetadataDropInPlace, + MetadataSize, + MetadataAlign, + Method(<S as T>::method), + ] + --> $DIR/multiple-auto.rs:43:1 + | +LL | impl C for S {} + | ^^^^^^^^^^^^ + +error: vtable entries: [ + MetadataDropInPlace, + MetadataSize, + MetadataAlign, + Method(<S as T>::method), + ] + --> $DIR/multiple-auto.rs:47:1 + | +LL | impl D for S {} + | ^^^^^^^^^^^^ + +error: aborting due to 4 previous errors + diff --git a/tests/ui/type-alias-impl-trait/constrain_in_projection2.next.stderr b/tests/ui/type-alias-impl-trait/constrain_in_projection2.next.stderr index 72a253c4be8..b50d1b60c43 100644 --- a/tests/ui/type-alias-impl-trait/constrain_in_projection2.next.stderr +++ b/tests/ui/type-alias-impl-trait/constrain_in_projection2.next.stderr @@ -1,24 +1,9 @@ -error[E0283]: type annotations needed: cannot satisfy `Foo: Trait<Bar>` - --> $DIR/constrain_in_projection2.rs:28:14 +error[E0282]: type annotations needed + --> $DIR/constrain_in_projection2.rs:28:13 | LL | let x = <Foo as Trait<Bar>>::Assoc::default(); - | ^^^ - | -note: multiple `impl`s satisfying `Foo: Trait<Bar>` found - --> $DIR/constrain_in_projection2.rs:18:1 - | -LL | impl Trait<()> for Foo { - | ^^^^^^^^^^^^^^^^^^^^^^ -... -LL | impl Trait<u32> for Foo { - | ^^^^^^^^^^^^^^^^^^^^^^^ - = note: associated types cannot be accessed directly on a `trait`, they can only be accessed through a specific `impl` -help: use the fully qualified path to an implementation - | -LL - let x = <Foo as Trait<Bar>>::Assoc::default(); -LL + let x = <<Type as Trait>::Assoc as Trait<Bar>>::Assoc::default(); - | + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cannot infer type error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0283`. +For more information about this error, try `rustc --explain E0282`. diff --git a/tests/ui/type-alias-impl-trait/constrain_in_projection2.rs b/tests/ui/type-alias-impl-trait/constrain_in_projection2.rs index 61773cf59d4..c4aa6f32eab 100644 --- a/tests/ui/type-alias-impl-trait/constrain_in_projection2.rs +++ b/tests/ui/type-alias-impl-trait/constrain_in_projection2.rs @@ -26,7 +26,7 @@ impl Trait<u32> for Foo { #[define_opaque(Bar)] fn bop() { let x = <Foo as Trait<Bar>>::Assoc::default(); - //[next]~^ ERROR: cannot satisfy `Foo: Trait<Bar>` + //[next]~^ ERROR: type annotations needed //[current]~^^ ERROR: `Foo: Trait<Bar>` is not satisfied //[current]~| ERROR: `Foo: Trait<Bar>` is not satisfied } diff --git a/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr b/tests/ui/type-alias-impl-trait/generic_nondefining_use.current.stderr index 71e415271ee..2a78860689b 100644 --- a/tests/ui/type-alias-impl-trait/generic_nondefining_use.stderr +++ b/tests/ui/type-alias-impl-trait/generic_nondefining_use.current.stderr @@ -1,5 +1,5 @@ error[E0792]: expected generic type parameter, found `u32` - --> $DIR/generic_nondefining_use.rs:16:21 + --> $DIR/generic_nondefining_use.rs:20:21 | LL | type OneTy<T> = impl Debug; | - this generic parameter must be used with a generic type parameter @@ -8,7 +8,7 @@ LL | fn concrete_ty() -> OneTy<u32> { | ^^^^^^^^^^ error[E0792]: expected generic lifetime parameter, found `'static` - --> $DIR/generic_nondefining_use.rs:23:5 + --> $DIR/generic_nondefining_use.rs:29:5 | LL | type OneLifetime<'a> = impl Debug; | -- cannot use static lifetime; use a bound lifetime instead or remove the lifetime parameter from the opaque type @@ -17,7 +17,7 @@ LL | 6u32 | ^^^^ error[E0792]: expected generic constant parameter, found `123` - --> $DIR/generic_nondefining_use.rs:28:24 + --> $DIR/generic_nondefining_use.rs:35:24 | LL | type OneConst<const X: usize> = impl Debug; | -------------- this generic parameter must be used with a generic constant parameter diff --git a/tests/ui/type-alias-impl-trait/generic_nondefining_use.next.stderr b/tests/ui/type-alias-impl-trait/generic_nondefining_use.next.stderr new file mode 100644 index 00000000000..2b53614ee3f --- /dev/null +++ b/tests/ui/type-alias-impl-trait/generic_nondefining_use.next.stderr @@ -0,0 +1,44 @@ +error: item does not constrain `OneTy::{opaque#0}` + --> $DIR/generic_nondefining_use.rs:20:4 + | +LL | fn concrete_ty() -> OneTy<u32> { + | ^^^^^^^^^^^ + | + = note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]` +note: this opaque type is supposed to be constrained + --> $DIR/generic_nondefining_use.rs:11:17 + | +LL | type OneTy<T> = impl Debug; + | ^^^^^^^^^^ +note: this use of `OneTy<u32>` does not have unique universal generic arguments + --> $DIR/generic_nondefining_use.rs:23:5 + | +LL | 5u32 + | ^^^^ + +error: non-defining use of `OneLifetime<'_>` in the defining scope + --> $DIR/generic_nondefining_use.rs:27:1 + | +LL | fn concrete_lifetime() -> OneLifetime<'static> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: item does not constrain `OneConst::{opaque#0}` + --> $DIR/generic_nondefining_use.rs:35:4 + | +LL | fn concrete_const() -> OneConst<{ 123 }> { + | ^^^^^^^^^^^^^^ + | + = note: consider removing `#[define_opaque]` or adding an empty `#[define_opaque()]` +note: this opaque type is supposed to be constrained + --> $DIR/generic_nondefining_use.rs:15:33 + | +LL | type OneConst<const X: usize> = impl Debug; + | ^^^^^^^^^^ +note: this use of `OneConst<123>` does not have unique universal generic arguments + --> $DIR/generic_nondefining_use.rs:38:5 + | +LL | 7u32 + | ^^^^ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/type-alias-impl-trait/generic_nondefining_use.rs b/tests/ui/type-alias-impl-trait/generic_nondefining_use.rs index cf38c93bd92..7250a9ac0b3 100644 --- a/tests/ui/type-alias-impl-trait/generic_nondefining_use.rs +++ b/tests/ui/type-alias-impl-trait/generic_nondefining_use.rs @@ -1,5 +1,9 @@ #![feature(type_alias_impl_trait)] +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@[next] compile-flags: -Znext-solver + use std::fmt::Debug; fn main() {} @@ -14,18 +18,22 @@ type OneConst<const X: usize> = impl Debug; #[define_opaque(OneTy)] fn concrete_ty() -> OneTy<u32> { - //~^ ERROR: expected generic type parameter, found `u32` + //[current]~^ ERROR: expected generic type parameter, found `u32` + //[next]~^^ ERROR: item does not constrain `OneTy::{opaque#0}` 5u32 } #[define_opaque(OneLifetime)] fn concrete_lifetime() -> OneLifetime<'static> { + //[next]~^ ERROR: non-defining use of `OneLifetime<'_>` in the defining scope 6u32 - //~^ ERROR: expected generic lifetime parameter, found `'static` + //[current]~^ ERROR: expected generic lifetime parameter, found `'static` + } #[define_opaque(OneConst)] fn concrete_const() -> OneConst<{ 123 }> { - //~^ ERROR: expected generic constant parameter, found `123` + //[current]~^ ERROR: expected generic constant parameter, found `123` + //[next]~^^ ERROR: item does not constrain `OneConst::{opaque#0}` 7u32 } diff --git a/tests/ui/type-alias-impl-trait/issue-87455-static-lifetime-ice.rs b/tests/ui/type-alias-impl-trait/issue-87455-static-lifetime-ice.rs index 987fad2efea..476babdfb05 100644 --- a/tests/ui/type-alias-impl-trait/issue-87455-static-lifetime-ice.rs +++ b/tests/ui/type-alias-impl-trait/issue-87455-static-lifetime-ice.rs @@ -1,6 +1,6 @@ //@ check-pass -use std::error::Error as StdError; +use std::error::Error; use std::pin::Pin; use std::task::{Context, Poll}; @@ -51,7 +51,7 @@ impl<S> Stream for SseKeepAlive<S> where S: TryStream + Send + 'static, S::Ok: ServerSentEvent, - S::Error: StdError + Send + Sync + 'static, + S::Error: Error + Send + Sync + 'static, { type Item = Result<SseComment<&'static str>, ()>; fn poll_next(self: Pin<&mut Self>, _cx: &mut Context) -> Poll<Option<Self::Item>> { @@ -65,7 +65,7 @@ pub fn keep<S>( where S: TryStream + Send + 'static, S::Ok: ServerSentEvent + Send, - S::Error: StdError + Send + Sync + 'static, + S::Error: Error + Send + Sync + 'static, { SseKeepAlive { event_stream } } diff --git a/tests/ui/type-alias-impl-trait/normalize-args-before-defining-use-check.rs b/tests/ui/type-alias-impl-trait/normalize-args-before-defining-use-check.rs new file mode 100644 index 00000000000..2879b8fe94c --- /dev/null +++ b/tests/ui/type-alias-impl-trait/normalize-args-before-defining-use-check.rs @@ -0,0 +1,33 @@ +#![feature(type_alias_impl_trait)] + +//@ revisions: current next +//@ ignore-compare-mode-next-solver (explicit revisions) +//@ [next] compile-flags: -Znext-solver +//@ check-pass + +// Regression test for trait-system-refactor-initiative#49. + +trait Mirror<'a> { + type Assoc; +} +impl<'a, T> Mirror<'a> for T { + type Assoc = T; +} + +type HrAmbigAlias<T> = impl Sized; +fn ret_tait<T>() -> for<'a> fn(HrAmbigAlias<<T as Mirror<'a>>::Assoc>) { + |_| () +} + +#[define_opaque(HrAmbigAlias)] +fn define_hr_ambig_alias<T>() { + let _: fn(T) = ret_tait::<T>(); +} + +type InUserType<T> = impl Sized; +#[define_opaque(InUserType)] +fn in_user_type<T>() { + let x: InUserType<<T as Mirror<'static>>::Assoc> = (); +} + +fn main() {} diff --git a/tests/ui/type-alias-impl-trait/split-paths-may-dangle.rs b/tests/ui/type-alias-impl-trait/split-paths-may-dangle.rs new file mode 100644 index 00000000000..61c5342cdbb --- /dev/null +++ b/tests/ui/type-alias-impl-trait/split-paths-may-dangle.rs @@ -0,0 +1,11 @@ +// Regression test for issue #146045 - ensure that the TAIT `SplitPaths` does not +// require the borrowed string to be live. +//@ check-pass +//@ edition:2015 + +pub fn repro() -> Option<std::path::PathBuf> { + let unparsed = std::ffi::OsString::new(); + std::env::split_paths(&unparsed).next() +} + +fn main() {} diff --git a/tests/ui/type/issue-7607-1.stderr b/tests/ui/type/issue-7607-1.stderr index db4c8f25dbc..69b6d62e987 100644 --- a/tests/ui/type/issue-7607-1.stderr +++ b/tests/ui/type/issue-7607-1.stderr @@ -3,6 +3,7 @@ error[E0412]: cannot find type `Fo` in this scope | LL | impl Fo { | ^^ help: a trait with a similar name exists: `Fn` + | --> $SRC_DIR/core/src/ops/function.rs:LL:COL | = note: similarly named trait `Fn` defined here diff --git a/tests/ui/type/pattern_types/validity.stderr b/tests/ui/type/pattern_types/validity.stderr index b545cd75ddb..e19915a58a3 100644 --- a/tests/ui/type/pattern_types/validity.stderr +++ b/tests/ui/type/pattern_types/validity.stderr @@ -4,7 +4,7 @@ error[E0080]: constructing invalid value: encountered 0, but expected something LL | const BAD: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { HEX_DUMP } @@ -34,7 +34,7 @@ error[E0080]: constructing invalid value at .0: encountered 0, but expected some LL | const BAD_AGGREGATE: (pattern_type!(u32 is 1..), u32) = (unsafe { std::mem::transmute(0) }, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 8, align: 4) { HEX_DUMP } @@ -45,7 +45,7 @@ error[E0080]: constructing invalid value at .0.0: encountered 0, but expected so LL | const BAD_FOO: Foo = Foo(Bar(unsafe { std::mem::transmute(0) })); | ^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { HEX_DUMP } @@ -66,7 +66,7 @@ error[E0080]: constructing invalid value: encountered 97, but expected something LL | const CHAR_OOB_PAT: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute('a') }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { HEX_DUMP } @@ -77,7 +77,7 @@ error[E0080]: constructing invalid value: encountered 0xffffffff, but expected a LL | const CHAR_OOB: pattern_type!(char is 'A'..'Z') = unsafe { std::mem::transmute(u32::MAX) }; | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ 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 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: 4, align: 4) { HEX_DUMP } diff --git a/tests/ui/typeck/issue-83693.stderr b/tests/ui/typeck/issue-83693.stderr index 34bca426116..0359b8af93a 100644 --- a/tests/ui/typeck/issue-83693.stderr +++ b/tests/ui/typeck/issue-83693.stderr @@ -3,6 +3,7 @@ error[E0412]: cannot find type `F` in this scope | LL | impl F { | ^ help: a trait with a similar name exists: `Fn` + | --> $SRC_DIR/core/src/ops/function.rs:LL:COL | = note: similarly named trait `Fn` defined here diff --git a/tests/ui/typeck/suggest-method-name-with-maybe-ty-mismatch-146008.rs b/tests/ui/typeck/suggest-method-name-with-maybe-ty-mismatch-146008.rs new file mode 100644 index 00000000000..671f280e814 --- /dev/null +++ b/tests/ui/typeck/suggest-method-name-with-maybe-ty-mismatch-146008.rs @@ -0,0 +1,14 @@ +struct LlamaModel; + +impl LlamaModel { + fn chat_template(&self) -> Result<&str, ()> { + todo!() + } +} + +fn template_from_str(_x: &str) {} + +fn main() { + let model = LlamaModel; + template_from_str(&model.chat_template); //~ ERROR attempted to take value of method `chat_template` on type `LlamaModel` +} diff --git a/tests/ui/typeck/suggest-method-name-with-maybe-ty-mismatch-146008.stderr b/tests/ui/typeck/suggest-method-name-with-maybe-ty-mismatch-146008.stderr new file mode 100644 index 00000000000..7f5dd0617b1 --- /dev/null +++ b/tests/ui/typeck/suggest-method-name-with-maybe-ty-mismatch-146008.stderr @@ -0,0 +1,14 @@ +error[E0615]: attempted to take value of method `chat_template` on type `LlamaModel` + --> $DIR/suggest-method-name-with-maybe-ty-mismatch-146008.rs:13:30 + | +LL | template_from_str(&model.chat_template); + | ^^^^^^^^^^^^^ method, not a field + | +help: use parentheses to call the method + | +LL | template_from_str(&model.chat_template()); + | ++ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0615`. diff --git a/tests/ui/ufcs/ufcs-partially-resolved.stderr b/tests/ui/ufcs/ufcs-partially-resolved.stderr index 69d6bd74a73..a854ecb0622 100644 --- a/tests/ui/ufcs/ufcs-partially-resolved.stderr +++ b/tests/ui/ufcs/ufcs-partially-resolved.stderr @@ -12,6 +12,7 @@ error[E0404]: expected trait, found enum `E` | LL | let _: <u8 as E>::N; | ^ help: a trait with a similar name exists: `Eq` + | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here @@ -42,6 +43,7 @@ error[E0404]: expected trait, found enum `E` | LL | <u8 as E>::N; | ^ help: a trait with a similar name exists: `Eq` + | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here @@ -63,6 +65,7 @@ error[E0404]: expected trait, found enum `E` | LL | let _: <u8 as E>::Y; | ^ help: a trait with a similar name exists: `Eq` + | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here @@ -72,6 +75,7 @@ error[E0404]: expected trait, found enum `E` | LL | <u8 as E>::Y; | ^ help: a trait with a similar name exists: `Eq` + | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here @@ -90,6 +94,7 @@ error[E0404]: expected trait, found enum `E` | LL | let _: <u8 as E>::N::NN; | ^ help: a trait with a similar name exists: `Eq` + | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here @@ -120,6 +125,7 @@ error[E0404]: expected trait, found enum `E` | LL | <u8 as E>::N::NN; | ^ help: a trait with a similar name exists: `Eq` + | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here @@ -141,6 +147,7 @@ error[E0404]: expected trait, found enum `E` | LL | let _: <u8 as E>::Y::NN; | ^ help: a trait with a similar name exists: `Eq` + | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here @@ -150,6 +157,7 @@ error[E0404]: expected trait, found enum `E` | LL | <u8 as E>::Y::NN; | ^ help: a trait with a similar name exists: `Eq` + | --> $SRC_DIR/core/src/cmp.rs:LL:COL | = note: similarly named trait `Eq` defined here diff --git a/tests/ui/uninhabited/missing-if-let-or-let-else.rs b/tests/ui/uninhabited/missing-if-let-or-let-else.rs new file mode 100644 index 00000000000..51fedb79756 --- /dev/null +++ b/tests/ui/uninhabited/missing-if-let-or-let-else.rs @@ -0,0 +1,24 @@ +fn a() { + let Some(x) = foo() { //~ ERROR expected one of + //~^ HELP you might have meant to use `if let` + let y = x; + } +} +fn b() { + let Some(x) = foo() { //~ ERROR expected one of + //~^ HELP you might have meant to use `let else` + return; + } +} +fn c() { + let Some(x) = foo() { //~ ERROR expected one of + //~^ HELP you might have meant to use `if let` + //~| HELP alternatively, you might have meant to use `let else` + // The parser check happens pre-macro-expansion, so we don't know for sure. + println!("{x}"); + } +} +fn foo() -> Option<i32> { + Some(42) +} +fn main() {} diff --git a/tests/ui/uninhabited/missing-if-let-or-let-else.stderr b/tests/ui/uninhabited/missing-if-let-or-let-else.stderr new file mode 100644 index 00000000000..4b78a0fa16e --- /dev/null +++ b/tests/ui/uninhabited/missing-if-let-or-let-else.stderr @@ -0,0 +1,39 @@ +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `{` + --> $DIR/missing-if-let-or-let-else.rs:2:25 + | +LL | let Some(x) = foo() { + | ^ expected one of `.`, `;`, `?`, `else`, or an operator + | +help: you might have meant to use `if let` + | +LL | if let Some(x) = foo() { + | ++ + +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `{` + --> $DIR/missing-if-let-or-let-else.rs:8:25 + | +LL | let Some(x) = foo() { + | ^ expected one of `.`, `;`, `?`, `else`, or an operator + | +help: you might have meant to use `let else` + | +LL | let Some(x) = foo() else { + | ++++ + +error: expected one of `.`, `;`, `?`, `else`, or an operator, found `{` + --> $DIR/missing-if-let-or-let-else.rs:14:25 + | +LL | let Some(x) = foo() { + | ^ expected one of `.`, `;`, `?`, `else`, or an operator + | +help: you might have meant to use `if let` + | +LL | if let Some(x) = foo() { + | ++ +help: alternatively, you might have meant to use `let else` + | +LL | let Some(x) = foo() else { + | ++++ + +error: aborting due to 3 previous errors + diff --git a/tests/ui/issues/issue-7344.rs b/tests/ui/unreachable-code/boolean-negation-in-unreachable-code-7344.rs index 406b24634f5..8fd091872c3 100644 --- a/tests/ui/issues/issue-7344.rs +++ b/tests/ui/unreachable-code/boolean-negation-in-unreachable-code-7344.rs @@ -1,3 +1,4 @@ +// https://github.com/rust-lang/rust/issues/7344 //@ run-pass #![allow(unused_must_use)] diff --git a/tests/ui/issues/auxiliary/issue-5844-aux.rs b/tests/ui/unsafe/auxiliary/aux-5844.rs index ea83378cad6..ea83378cad6 100644 --- a/tests/ui/issues/auxiliary/issue-5844-aux.rs +++ b/tests/ui/unsafe/auxiliary/aux-5844.rs diff --git a/tests/ui/unsafe/extern-function-requires-unsafe-5844.rs b/tests/ui/unsafe/extern-function-requires-unsafe-5844.rs new file mode 100644 index 00000000000..11863ce647a --- /dev/null +++ b/tests/ui/unsafe/extern-function-requires-unsafe-5844.rs @@ -0,0 +1,8 @@ +// https://github.com/rust-lang/rust/issues/5844 +//@aux-build:aux-5844.rs + +extern crate aux_5844; + +fn main() { + aux_5844::rand(); //~ ERROR: requires unsafe +} diff --git a/tests/ui/issues/issue-5844.stderr b/tests/ui/unsafe/extern-function-requires-unsafe-5844.stderr index bae917fa72c..44dee178991 100644 --- a/tests/ui/issues/issue-5844.stderr +++ b/tests/ui/unsafe/extern-function-requires-unsafe-5844.stderr @@ -1,8 +1,8 @@ error[E0133]: call to unsafe function `rand` is unsafe and requires unsafe function or block - --> $DIR/issue-5844.rs:6:5 + --> $DIR/extern-function-requires-unsafe-5844.rs:7:5 | -LL | issue_5844_aux::rand(); - | ^^^^^^^^^^^^^^^^^^^^^^ call to unsafe function +LL | aux_5844::rand(); + | ^^^^^^^^^^^^^^^^ call to unsafe function | = note: consult the function's documentation for information on how to avoid undefined behavior diff --git a/tests/ui/unstable-feature-bound/unstable_feature_bound_incompatible_stability.rs b/tests/ui/unstable-feature-bound/unstable_feature_bound_incompatible_stability.rs index 1a9652c1023..5a683884238 100644 --- a/tests/ui/unstable-feature-bound/unstable_feature_bound_incompatible_stability.rs +++ b/tests/ui/unstable-feature-bound/unstable_feature_bound_incompatible_stability.rs @@ -9,6 +9,6 @@ #[stable(feature = "a", since = "1.1.1")] #[unstable_feature_bound(feat_bar)] fn bar() {} -//~^ ERROR Item annotated with `#[unstable_feature_bound]` should not be stable +//~^ ERROR item annotated with `#[unstable_feature_bound]` should not be stable fn main() {} diff --git a/tests/ui/unstable-feature-bound/unstable_feature_bound_incompatible_stability.stderr b/tests/ui/unstable-feature-bound/unstable_feature_bound_incompatible_stability.stderr index 9cb6a181bef..9f07e63e454 100644 --- a/tests/ui/unstable-feature-bound/unstable_feature_bound_incompatible_stability.stderr +++ b/tests/ui/unstable-feature-bound/unstable_feature_bound_incompatible_stability.stderr @@ -1,4 +1,4 @@ -error: Item annotated with `#[unstable_feature_bound]` should not be stable +error: item annotated with `#[unstable_feature_bound]` should not be stable --> $DIR/unstable_feature_bound_incompatible_stability.rs:11:1 | LL | fn bar() {} diff --git a/tests/ui/wasm/wasm-import-module.rs b/tests/ui/wasm/wasm-import-module.rs index 2b3bca9a411..c38fcb1a000 100644 --- a/tests/ui/wasm/wasm-import-module.rs +++ b/tests/ui/wasm/wasm-import-module.rs @@ -1,12 +1,12 @@ #![feature(link_cfg)] -#[link(name = "...", wasm_import_module)] //~ ERROR: must be of the form +#[link(name = "...", wasm_import_module)] //~ ERROR: malformed `link` attribute input extern "C" {} -#[link(name = "...", wasm_import_module(x))] //~ ERROR: must be of the form +#[link(name = "...", wasm_import_module(x))] //~ ERROR: malformed `link` attribute input extern "C" {} -#[link(name = "...", wasm_import_module())] //~ ERROR: must be of the form +#[link(name = "...", wasm_import_module())] //~ ERROR: malformed `link` attribute input extern "C" {} #[link(wasm_import_module = "foo", name = "bar")] //~ ERROR: `wasm_import_module` is incompatible with other arguments diff --git a/tests/ui/wasm/wasm-import-module.stderr b/tests/ui/wasm/wasm-import-module.stderr index 84f437941a7..f5ea449839b 100644 --- a/tests/ui/wasm/wasm-import-module.stderr +++ b/tests/ui/wasm/wasm-import-module.stderr @@ -1,20 +1,77 @@ -error: wasm import module must be of the form `wasm_import_module = "string"` - --> $DIR/wasm-import-module.rs:3:22 +error[E0539]: malformed `link` attribute input + --> $DIR/wasm-import-module.rs:3:1 | LL | #[link(name = "...", wasm_import_module)] - | ^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^------------------^^ + | | + | expected this to be of the form `wasm_import_module = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", wasm_import_module)] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", wasm_import_module)] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", wasm_import_module)] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", wasm_import_module)] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: wasm import module must be of the form `wasm_import_module = "string"` - --> $DIR/wasm-import-module.rs:6:22 +error[E0539]: malformed `link` attribute input + --> $DIR/wasm-import-module.rs:6:1 | LL | #[link(name = "...", wasm_import_module(x))] - | ^^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^---------------------^^ + | | + | expected this to be of the form `wasm_import_module = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", wasm_import_module(x))] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", wasm_import_module(x))] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", wasm_import_module(x))] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", wasm_import_module(x))] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate -error: wasm import module must be of the form `wasm_import_module = "string"` - --> $DIR/wasm-import-module.rs:9:22 +error[E0539]: malformed `link` attribute input + --> $DIR/wasm-import-module.rs:9:1 | LL | #[link(name = "...", wasm_import_module())] - | ^^^^^^^^^^^^^^^^^^^^ + | ^^^^^^^^^^^^^^^^^^^^^--------------------^^ + | | + | expected this to be of the form `wasm_import_module = "..."` + | + = note: for more information, visit <https://doc.rust-lang.org/reference/items/external-blocks.html#the-link-attribute> +help: try changing it to one of the following valid forms of the attribute + | +LL - #[link(name = "...", wasm_import_module())] +LL + #[link(name = "...")] + | +LL - #[link(name = "...", wasm_import_module())] +LL + #[link(name = "...", import_name_type = "decorated|noprefix|undecorated")] + | +LL - #[link(name = "...", wasm_import_module())] +LL + #[link(name = "...", kind = "dylib|static|...")] + | +LL - #[link(name = "...", wasm_import_module())] +LL + #[link(name = "...", kind = "dylib|static|...", wasm_import_module = "...", import_name_type = "decorated|noprefix|undecorated")] + | + = and 1 other candidate error: `wasm_import_module` is incompatible with other arguments in `#[link]` attributes --> $DIR/wasm-import-module.rs:12:8 @@ -36,3 +93,4 @@ LL | #[link(wasm_import_module = "foo", cfg(false))] error: aborting due to 6 previous errors +For more information about this error, try `rustc --explain E0539`. |
