diff options
Diffstat (limited to 'tests')
642 files changed, 7819 insertions, 2745 deletions
diff --git a/tests/assembly/auxiliary/dwarf-mixed-versions-lto-aux.rs b/tests/assembly/auxiliary/dwarf-mixed-versions-lto-aux.rs new file mode 100644 index 00000000000..faff6e7e2d0 --- /dev/null +++ b/tests/assembly/auxiliary/dwarf-mixed-versions-lto-aux.rs @@ -0,0 +1,5 @@ +//@ compile-flags: -g --crate-type=rlib -Zdwarf-version=4 + +pub fn check_is_even(number: &u64) -> bool { + number % 2 == 0 +} diff --git a/tests/assembly/dwarf-mixed-versions-lto.rs b/tests/assembly/dwarf-mixed-versions-lto.rs new file mode 100644 index 00000000000..5b8e5ff4f4a --- /dev/null +++ b/tests/assembly/dwarf-mixed-versions-lto.rs @@ -0,0 +1,19 @@ +// This test ensures that if LTO occurs between crates with different DWARF versions, we +// will choose the highest DWARF version for the final binary. This matches Clang's behavior. + +//@ only-linux +//@ aux-build:dwarf-mixed-versions-lto-aux.rs +//@ compile-flags: -C lto -g -Zdwarf-version=5 +//@ assembly-output: emit-asm +//@ no-prefer-dynamic + +extern crate dwarf_mixed_versions_lto_aux; + +fn main() { + dwarf_mixed_versions_lto_aux::check_is_even(&0); +} + +// CHECK: .section .debug_info +// CHECK-NOT: {{\.(short|hword)}} 2 +// CHECK-NOT: {{\.(short|hword)}} 4 +// CHECK: {{\.(short|hword)}} 5 diff --git a/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs b/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs index fb3a325a41f..b3bfc66a5a5 100644 --- a/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs +++ b/tests/assembly/nvptx-kernel-abi/nvptx-kernel-args-abi-v7.rs @@ -242,22 +242,6 @@ pub unsafe extern "ptx-kernel" fn f_float_array_arg(_a: [f32; 5]) {} //pub unsafe extern "ptx-kernel" fn f_u128_array_arg(_a: [u128; 5]) {} // CHECK: .visible .entry f_u32_slice_arg( -// CHECK: .param .u64 f_u32_slice_arg_param_0 -// CHECK: .param .u64 f_u32_slice_arg_param_1 +// CHECK: .param .align 8 .b8 f_u32_slice_arg_param_0[16] #[no_mangle] pub unsafe extern "ptx-kernel" fn f_u32_slice_arg(_a: &[u32]) {} - -// CHECK: .visible .entry f_tuple_u8_u8_arg( -// CHECK: .param .align 1 .b8 f_tuple_u8_u8_arg_param_0[2] -#[no_mangle] -pub unsafe extern "ptx-kernel" fn f_tuple_u8_u8_arg(_a: (u8, u8)) {} - -// CHECK: .visible .entry f_tuple_u32_u32_arg( -// CHECK: .param .align 4 .b8 f_tuple_u32_u32_arg_param_0[8] -#[no_mangle] -pub unsafe extern "ptx-kernel" fn f_tuple_u32_u32_arg(_a: (u32, u32)) {} - -// CHECK: .visible .entry f_tuple_u8_u8_u32_arg( -// CHECK: .param .align 4 .b8 f_tuple_u8_u8_u32_arg_param_0[8] -#[no_mangle] -pub unsafe extern "ptx-kernel" fn f_tuple_u8_u8_u32_arg(_a: (u8, u8, u32)) {} diff --git a/tests/assembly/small_data_threshold.rs b/tests/assembly/small_data_threshold.rs index d3ba144600e..bed515915b8 100644 --- a/tests/assembly/small_data_threshold.rs +++ b/tests/assembly/small_data_threshold.rs @@ -58,35 +58,35 @@ static mut Z: u64 = 0; // Currently, only MIPS and RISCV successfully put any objects in the small data // sections so the U/V/W/X tests are skipped on Hexagon and M68K -//@ RISCV: .section .sdata -//@ RISCV-NOT: .section -//@ RISCV: U: -//@ RISCV: .section .sbss -//@ RISCV-NOT: .section -//@ RISCV: V: -//@ RISCV: .section .sdata -//@ RISCV-NOT: .section -//@ RISCV: W: -//@ RISCV: .section .sbss -//@ RISCV-NOT: .section -//@ RISCV: X: +// RISCV: .section .sdata +// RISCV-NOT: .section +// RISCV: U: +// RISCV: .section .sbss +// RISCV-NOT: .section +// RISCV: V: +// RISCV: .section .sdata +// RISCV-NOT: .section +// RISCV: W: +// RISCV: .section .sbss +// RISCV-NOT: .section +// RISCV: X: -//@ MIPS: .section .sdata -//@ MIPS-NOT: .section -//@ MIPS: U: -//@ MIPS: .section .sbss -//@ MIPS-NOT: .section -//@ MIPS: V: -//@ MIPS: .section .sdata -//@ MIPS-NOT: .section -//@ MIPS: W: -//@ MIPS: .section .sbss -//@ MIPS-NOT: .section -//@ MIPS: X: +// MIPS: .section .sdata +// MIPS-NOT: .section +// MIPS: U: +// MIPS: .section .sbss +// MIPS-NOT: .section +// MIPS: V: +// MIPS: .section .sdata +// MIPS-NOT: .section +// MIPS: W: +// MIPS: .section .sbss +// MIPS-NOT: .section +// MIPS: X: -//@ CHECK: .section .data.Y, -//@ CHECK-NOT: .section -//@ CHECK: Y: -//@ CHECK: .section .bss.Z, -//@ CHECK-NOT: .section -//@ CHECK: Z: +// CHECK: .section .data.Y, +// CHECK-NOT: .section +// CHECK: Y: +// CHECK: .section .bss.Z, +// CHECK-NOT: .section +// CHECK: Z: diff --git a/tests/assembly/targets/targets-amdgpu.rs b/tests/assembly/targets/targets-amdgpu.rs new file mode 100644 index 00000000000..501eed2e247 --- /dev/null +++ b/tests/assembly/targets/targets-amdgpu.rs @@ -0,0 +1,21 @@ +//@ assembly-output: emit-asm +// ignore-tidy-linelength +//@ revisions: amdgcn_amd_amdhsa +//@ [amdgcn_amd_amdhsa] compile-flags: --target amdgcn-amd-amdhsa -Ctarget-cpu=gfx900 +//@ [amdgcn_amd_amdhsa] needs-llvm-components: amdgpu + +// Sanity-check that each target can produce assembly code. + +#![feature(no_core, lang_items)] +#![no_std] +#![no_core] +#![crate_type = "lib"] + +#[lang = "sized"] +trait Sized {} + +pub fn test() -> u8 { + 42 +} + +// CHECK: .version diff --git a/tests/codegen/autodiff.rs b/tests/codegen/autodiff.rs new file mode 100644 index 00000000000..abf7fcf3e4b --- /dev/null +++ b/tests/codegen/autodiff.rs @@ -0,0 +1,33 @@ +//@ compile-flags: -C opt-level=3 -Clto=fat +//@ no-prefer-dynamic +//@ needs-enzyme +#![feature(autodiff)] + +use std::autodiff::autodiff; + +#[autodiff(d_square, Reverse, Duplicated, Active)] +#[no_mangle] +fn square(x: &f64) -> f64 { + x * x +} + +// CHECK:define internal fastcc double @diffesquare(double %x.0.val, ptr nocapture align 8 %"x'" +// CHECK-NEXT:invertstart: +// CHECK-NEXT: %_0 = fmul double %x.0.val, %x.0.val +// CHECK-NEXT: %0 = fadd fast double %x.0.val, %x.0.val +// CHECK-NEXT: %1 = load double, ptr %"x'", align 8 +// CHECK-NEXT: %2 = fadd fast double %1, %0 +// CHECK-NEXT: store double %2, ptr %"x'", align 8 +// CHECK-NEXT: ret double %_0 +// CHECK-NEXT:} + +fn main() { + let x = 3.0; + let output = square(&x); + assert_eq!(9.0, output); + + let mut df_dx = 0.0; + let output_ = d_square(&x, &mut df_dx, 1.0); + assert_eq!(output, output_); + assert_eq!(6.0, df_dx); +} diff --git a/tests/codegen/bigint-helpers.rs b/tests/codegen/bigint-helpers.rs new file mode 100644 index 00000000000..355cccb8150 --- /dev/null +++ b/tests/codegen/bigint-helpers.rs @@ -0,0 +1,13 @@ +//@ compile-flags: -C opt-level=3 + +#![crate_type = "lib"] +#![feature(bigint_helper_methods)] + +// CHECK-LABEL: @u32_carrying_add +#[no_mangle] +pub fn u32_carrying_add(a: u32, b: u32, c: bool) -> (u32, bool) { + // CHECK: @llvm.uadd.with.overflow.i32 + // CHECK: @llvm.uadd.with.overflow.i32 + // CHECK: or disjoint i1 + u32::carrying_add(a, b, c) +} diff --git a/tests/codegen/debug-column.rs b/tests/codegen/debug-column.rs index d14a5c29142..2aa0a8a864c 100644 --- a/tests/codegen/debug-column.rs +++ b/tests/codegen/debug-column.rs @@ -1,6 +1,6 @@ // Verify that debuginfo column numbers are 1-based byte offsets. // -//@ ignore-windows +//@ ignore-msvc //@ compile-flags: -C debuginfo=2 #[rustfmt::skip] diff --git a/tests/codegen/debug-fndef-size.rs b/tests/codegen/debug-fndef-size.rs index 27bf00adf0e..c58a8228967 100644 --- a/tests/codegen/debug-fndef-size.rs +++ b/tests/codegen/debug-fndef-size.rs @@ -1,4 +1,6 @@ -// Verify that `i32::cmp` FnDef type is declared with size 0 and align 1 in LLVM debuginfo. +// Verify that `i32::cmp` FnDef type is declared with a size of 0 and an +// alignment of 8 bits (1 byte) in LLVM debuginfo. + //@ compile-flags: -O -g -Cno-prepopulate-passes //@ ignore-msvc the types are mangled differently @@ -14,5 +16,5 @@ pub fn main() { // CHECK: %compare.dbg.spill = alloca [0 x i8], align 1 // CHECK: dbg{{.}}declare({{(metadata )?}}ptr %compare.dbg.spill, {{(metadata )?}}![[VAR:.*]], {{(metadata )?}}!DIExpression() -// CHECK: ![[TYPE:.*]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "fn(&i32, &i32) -> core::cmp::Ordering", baseType: !{{.*}}, align: 1, dwarfAddressSpace: {{.*}}) -// CHECK: ![[VAR]] = !DILocalVariable(name: "compare", scope: !{{.*}}, file: !{{.*}}, line: {{.*}}, type: ![[TYPE]], align: 1) +// CHECK: ![[TYPE:.*]] = !DIDerivedType(tag: DW_TAG_pointer_type, name: "fn(&i32, &i32) -> core::cmp::Ordering", baseType: !{{.*}}, align: 8, dwarfAddressSpace: {{.*}}) +// CHECK: ![[VAR]] = !DILocalVariable(name: "compare", scope: !{{.*}}, file: !{{.*}}, line: {{.*}}, type: ![[TYPE]], align: 8) diff --git a/tests/codegen/force-no-unwind-tables.rs b/tests/codegen/force-no-unwind-tables.rs index e823bedac0f..1de5e0858e0 100644 --- a/tests/codegen/force-no-unwind-tables.rs +++ b/tests/codegen/force-no-unwind-tables.rs @@ -1,5 +1,5 @@ //@ compile-flags: -C no-prepopulate-passes -C panic=abort -C force-unwind-tables=n -//@ ignore-windows +//@ ignore-windows: unwind tables are required for panics on Windows #![crate_type = "lib"] diff --git a/tests/codegen/intrinsics/disjoint_bitor.rs b/tests/codegen/intrinsics/disjoint_bitor.rs new file mode 100644 index 00000000000..fc45439ee0b --- /dev/null +++ b/tests/codegen/intrinsics/disjoint_bitor.rs @@ -0,0 +1,30 @@ +//@ compile-flags: -C no-prepopulate-passes -Z mir-opt-level=0 + +#![crate_type = "lib"] +#![feature(core_intrinsics)] + +use std::intrinsics::disjoint_bitor; + +// CHECK-LABEL: @disjoint_bitor_signed +#[no_mangle] +pub unsafe fn disjoint_bitor_signed(x: i32, y: i32) -> i32 { + // CHECK: or disjoint i32 %x, %y + disjoint_bitor(x, y) +} + +// CHECK-LABEL: @disjoint_bitor_unsigned +#[no_mangle] +pub unsafe fn disjoint_bitor_unsigned(x: u64, y: u64) -> u64 { + // CHECK: or disjoint i64 %x, %y + disjoint_bitor(x, y) +} + +// CHECK-LABEL: @disjoint_bitor_literal +#[no_mangle] +pub unsafe fn disjoint_bitor_literal() -> u8 { + // This is a separate check because even without any passes, + // LLVM will fold so it's not an instruction, which can assert in LLVM. + + // CHECK: store i8 3 + disjoint_bitor(1, 2) +} diff --git a/tests/codegen/terminating-catchpad.rs b/tests/codegen/terminating-catchpad.rs new file mode 100644 index 00000000000..17d88796300 --- /dev/null +++ b/tests/codegen/terminating-catchpad.rs @@ -0,0 +1,37 @@ +//@ revisions: emscripten wasi seh +//@[emscripten] compile-flags: --target wasm32-unknown-emscripten -Z emscripten-wasm-eh +//@[wasi] compile-flags: --target wasm32-wasip1 -C panic=unwind +//@[seh] compile-flags: --target x86_64-pc-windows-msvc +//@[emscripten] needs-llvm-components: webassembly +//@[wasi] needs-llvm-components: webassembly +//@[seh] needs-llvm-components: x86 + +// Ensure a catch-all generates: +// - `catchpad ... [ptr null]` on Wasm (otherwise LLVM gets confused) +// - `catchpad ... [ptr null, i32 64, ptr null]` on Windows (otherwise we catch SEH exceptions) + +#![feature(no_core, lang_items, rustc_attrs)] +#![crate_type = "lib"] +#![no_std] +#![no_core] + +#[lang = "sized"] +trait Sized {} + +unsafe extern "C-unwind" { + safe fn unwinds(); +} + +#[lang = "panic_cannot_unwind"] +fn panic_cannot_unwind() -> ! { + loop {} +} + +#[no_mangle] +#[rustc_nounwind] +pub fn doesnt_unwind() { + // emscripten: %catchpad = catchpad within %catchswitch [ptr null] + // wasi: %catchpad = catchpad within %catchswitch [ptr null] + // seh: %catchpad = catchpad within %catchswitch [ptr null, i32 64, ptr null] + unwinds(); +} diff --git a/tests/codegen/thread-local.rs b/tests/codegen/thread-local.rs index 2ee15811cc3..3cd81652f5a 100644 --- a/tests/codegen/thread-local.rs +++ b/tests/codegen/thread-local.rs @@ -1,6 +1,6 @@ //@ compile-flags: -O //@ aux-build:thread_local_aux.rs -//@ ignore-windows FIXME(#84933) +//@ ignore-windows FIXME(#134939) //@ ignore-wasm globals are used instead of thread locals //@ ignore-emscripten globals are used instead of thread locals //@ ignore-android does not use #[thread_local] diff --git a/tests/codegen/vtable-upcast.rs b/tests/codegen/vtable-upcast.rs index ae7b4bf7aee..9e13e8dd68a 100644 --- a/tests/codegen/vtable-upcast.rs +++ b/tests/codegen/vtable-upcast.rs @@ -2,7 +2,6 @@ //@ compile-flags: -C no-prepopulate-passes -Copt-level=0 #![crate_type = "lib"] -#![feature(trait_upcasting)] pub trait Base { fn base(&self); diff --git a/tests/coverage/assert_not.cov-map b/tests/coverage/assert_not.cov-map index 397eaa17caf..35568a98af4 100644 --- a/tests/coverage/assert_not.cov-map +++ b/tests/coverage/assert_not.cov-map @@ -1,15 +1,13 @@ Function name: assert_not::main -Raw bytes (31): 0x[01, 01, 01, 0d, 00, 05, 01, 06, 01, 01, 12, 05, 02, 05, 00, 14, 09, 01, 05, 00, 14, 0d, 01, 05, 00, 16, 02, 01, 01, 00, 02] +Raw bytes (29): 0x[01, 01, 00, 05, 01, 06, 01, 01, 12, 05, 02, 05, 00, 14, 09, 01, 05, 00, 14, 0d, 01, 05, 00, 16, 0d, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(3), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 5 - Code(Counter(0)) at (prev + 6, 1) to (start + 1, 18) - Code(Counter(1)) at (prev + 2, 5) to (start + 0, 20) - Code(Counter(2)) at (prev + 1, 5) to (start + 0, 20) - Code(Counter(3)) at (prev + 1, 5) to (start + 0, 22) -- Code(Expression(0, Sub)) at (prev + 1, 1) to (start + 0, 2) - = (c3 - Zero) +- Code(Counter(3)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c3 diff --git a/tests/coverage/bad_counter_ids.cov-map b/tests/coverage/bad_counter_ids.cov-map index 2b5399f33bb..ba306278449 100644 --- a/tests/coverage/bad_counter_ids.cov-map +++ b/tests/coverage/bad_counter_ids.cov-map @@ -9,15 +9,13 @@ Number of file 0 mappings: 2 Highest counter ID seen: c0 Function name: bad_counter_ids::eq_bad_message -Raw bytes (21): 0x[01, 01, 01, 01, 00, 03, 01, 29, 01, 02, 0f, 02, 02, 20, 00, 2b, 00, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 29, 01, 02, 0f, 01, 02, 20, 00, 2b, 00, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 41, 1) to (start + 2, 15) -- Code(Expression(0, Sub)) at (prev + 2, 32) to (start + 0, 43) - = (c0 - Zero) +- Code(Counter(0)) at (prev + 2, 32) to (start + 0, 43) - Code(Zero) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 @@ -64,27 +62,23 @@ Number of file 0 mappings: 3 Highest counter ID seen: c1 Function name: bad_counter_ids::ne_good -Raw bytes (16): 0x[01, 01, 01, 01, 00, 02, 01, 1a, 01, 02, 1f, 02, 03, 01, 00, 02] +Raw bytes (14): 0x[01, 01, 00, 02, 01, 1a, 01, 02, 1f, 01, 03, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 2 - Code(Counter(0)) at (prev + 26, 1) to (start + 2, 31) -- Code(Expression(0, Sub)) at (prev + 3, 1) to (start + 0, 2) - = (c0 - Zero) +- Code(Counter(0)) at (prev + 3, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: bad_counter_ids::ne_good_message -Raw bytes (21): 0x[01, 01, 01, 01, 00, 03, 01, 1f, 01, 02, 0f, 00, 02, 20, 00, 2b, 02, 01, 01, 00, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 1f, 01, 02, 0f, 00, 02, 20, 00, 2b, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 31, 1) to (start + 2, 15) - Code(Zero) at (prev + 2, 32) to (start + 0, 43) -- Code(Expression(0, Sub)) at (prev + 1, 1) to (start + 0, 2) - = (c0 - Zero) +- Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 diff --git a/tests/coverage/fn_sig_into_try.cov-map b/tests/coverage/fn_sig_into_try.cov-map index 374811dba9e..6d6034928c9 100644 --- a/tests/coverage/fn_sig_into_try.cov-map +++ b/tests/coverage/fn_sig_into_try.cov-map @@ -8,44 +8,38 @@ Number of file 0 mappings: 1 Highest counter ID seen: c0 Function name: fn_sig_into_try::b -Raw bytes (26): 0x[01, 01, 01, 01, 00, 04, 01, 11, 01, 03, 0f, 00, 03, 0f, 00, 10, 02, 01, 05, 00, 0c, 01, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 11, 01, 03, 0f, 00, 03, 0f, 00, 10, 01, 01, 05, 00, 0c, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 17, 1) to (start + 3, 15) - Code(Zero) at (prev + 3, 15) to (start + 0, 16) -- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12) - = (c0 - Zero) +- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 12) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: fn_sig_into_try::c -Raw bytes (26): 0x[01, 01, 01, 01, 00, 04, 01, 18, 01, 03, 17, 00, 03, 17, 00, 18, 02, 01, 05, 00, 0c, 01, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 18, 01, 03, 17, 00, 03, 17, 00, 18, 01, 01, 05, 00, 0c, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 24, 1) to (start + 3, 23) - Code(Zero) at (prev + 3, 23) to (start + 0, 24) -- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12) - = (c0 - Zero) +- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 12) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 Function name: fn_sig_into_try::d -Raw bytes (26): 0x[01, 01, 01, 01, 00, 04, 01, 1f, 01, 04, 0f, 00, 04, 0f, 00, 10, 02, 01, 05, 00, 0c, 01, 01, 01, 00, 02] +Raw bytes (24): 0x[01, 01, 00, 04, 01, 1f, 01, 04, 0f, 00, 04, 0f, 00, 10, 01, 01, 05, 00, 0c, 01, 01, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 4 - Code(Counter(0)) at (prev + 31, 1) to (start + 4, 15) - Code(Zero) at (prev + 4, 15) to (start + 0, 16) -- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 12) - = (c0 - Zero) +- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 12) - Code(Counter(0)) at (prev + 1, 1) to (start + 0, 2) Highest counter ID seen: c0 diff --git a/tests/coverage/inline-dead.cov-map b/tests/coverage/inline-dead.cov-map index 3e2ca2bc992..49cdc514fed 100644 --- a/tests/coverage/inline-dead.cov-map +++ b/tests/coverage/inline-dead.cov-map @@ -32,16 +32,13 @@ Number of file 0 mappings: 2 Highest counter ID seen: c0 Function name: inline_dead::main::{closure#0} -Raw bytes (23): 0x[01, 01, 02, 07, 00, 01, 00, 03, 01, 07, 17, 01, 16, 00, 01, 17, 00, 18, 02, 01, 05, 00, 06] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 07, 17, 01, 16, 00, 01, 17, 00, 18, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 2 -- expression 0 operands: lhs = Expression(1, Add), rhs = Zero -- expression 1 operands: lhs = Counter(0), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 7, 23) to (start + 1, 22) - Code(Zero) at (prev + 1, 23) to (start + 0, 24) -- Code(Expression(0, Sub)) at (prev + 1, 5) to (start + 0, 6) - = ((c0 + Zero) - Zero) +- Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6) Highest counter ID seen: c0 diff --git a/tests/coverage/issue-84561.cov-map b/tests/coverage/issue-84561.cov-map index efb9d43bf5b..c8f75cddcb5 100644 --- a/tests/coverage/issue-84561.cov-map +++ b/tests/coverage/issue-84561.cov-map @@ -59,10 +59,10 @@ Number of file 0 mappings: 1 Highest counter ID seen: c0 Function name: issue_84561::test3 -Raw bytes (317): 0x[01, 01, 1c, 1d, 21, 25, 29, 21, 25, 2d, 31, 21, 17, 25, 2d, 41, 45, 49, 4d, 51, 55, 33, 51, 49, 4d, 33, 37, 49, 4d, 51, 59, 55, 59, 55, 59, 47, 5d, 55, 59, 61, 65, 71, 75, 69, 6d, 69, 6d, 69, 5f, 6d, 00, 67, 79, 71, 75, 79, 7d, 7d, 81, 01, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 09, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 11, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 19, 02, 05, 00, 1f, 1d, 01, 05, 00, 0f, 02, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 25, 03, 20, 00, 30, 29, 00, 33, 00, 41, 06, 00, 4b, 00, 5a, 0a, 01, 05, 00, 0f, 2d, 05, 09, 03, 10, 31, 05, 0d, 00, 1b, 0e, 02, 0d, 00, 1c, 12, 04, 09, 05, 06, 35, 06, 05, 03, 06, 39, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 41, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 1a, 05, 09, 03, 0a, 33, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 22, 03, 0d, 00, 1d, 26, 03, 09, 00, 13, 2e, 03, 0d, 00, 1d, 47, 03, 05, 00, 0f, 47, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 42, 02, 0d, 00, 13, 61, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 4a, 02, 0d, 00, 13, 67, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 71, 04, 0d, 00, 13, 56, 02, 0d, 00, 17, 56, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, 5a, 02, 15, 00, 1b, 75, 04, 0d, 00, 13, 62, 03, 09, 00, 19, 79, 02, 05, 00, 0f, 6a, 03, 09, 00, 22, 7d, 02, 05, 00, 0f, 6e, 03, 09, 00, 2c, 81, 01, 02, 01, 00, 02] +Raw bytes (315): 0x[01, 01, 1b, 1d, 21, 25, 29, 21, 25, 2d, 31, 21, 17, 25, 2d, 41, 45, 49, 4d, 51, 55, 33, 51, 49, 4d, 33, 37, 49, 4d, 51, 59, 55, 59, 55, 59, 47, 5d, 55, 59, 61, 65, 71, 75, 69, 6d, 69, 6d, 69, 6d, 63, 79, 71, 75, 79, 7d, 7d, 81, 01, 33, 01, 08, 01, 03, 1c, 05, 04, 09, 01, 1c, 09, 02, 05, 04, 1f, 0d, 05, 05, 00, 1f, 11, 01, 05, 00, 1f, 15, 01, 09, 01, 1c, 19, 02, 05, 00, 1f, 1d, 01, 05, 00, 0f, 02, 00, 20, 00, 30, 21, 01, 05, 03, 0f, 25, 03, 20, 00, 30, 29, 00, 33, 00, 41, 06, 00, 4b, 00, 5a, 0a, 01, 05, 00, 0f, 2d, 05, 09, 03, 10, 31, 05, 0d, 00, 1b, 0e, 02, 0d, 00, 1c, 12, 04, 09, 05, 06, 35, 06, 05, 03, 06, 39, 04, 05, 03, 06, 3d, 04, 09, 04, 06, 41, 05, 08, 00, 0f, 45, 01, 09, 03, 0a, 1a, 05, 09, 03, 0a, 33, 05, 08, 00, 0f, 51, 01, 09, 00, 13, 22, 03, 0d, 00, 1d, 26, 03, 09, 00, 13, 2e, 03, 0d, 00, 1d, 47, 03, 05, 00, 0f, 47, 01, 0c, 00, 13, 5d, 01, 0d, 00, 13, 42, 02, 0d, 00, 13, 61, 04, 05, 02, 13, 65, 03, 0d, 00, 13, 4a, 02, 0d, 00, 13, 63, 03, 05, 00, 0f, 69, 01, 0c, 00, 13, 6d, 01, 0d, 03, 0e, 71, 04, 0d, 00, 13, 5a, 02, 0d, 00, 17, 5a, 01, 14, 00, 1b, 00, 01, 15, 00, 1b, 5a, 02, 15, 00, 1b, 75, 04, 0d, 00, 13, 5e, 03, 09, 00, 19, 79, 02, 05, 00, 0f, 66, 03, 09, 00, 22, 7d, 02, 05, 00, 0f, 6a, 03, 09, 00, 2c, 81, 01, 02, 01, 00, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 28 +Number of expressions: 27 - expression 0 operands: lhs = Counter(7), rhs = Counter(8) - expression 1 operands: lhs = Counter(9), rhs = Counter(10) - expression 2 operands: lhs = Counter(8), rhs = Counter(9) @@ -85,12 +85,11 @@ Number of expressions: 28 - expression 19 operands: lhs = Counter(28), rhs = Counter(29) - expression 20 operands: lhs = Counter(26), rhs = Counter(27) - expression 21 operands: lhs = Counter(26), rhs = Counter(27) -- expression 22 operands: lhs = Counter(26), rhs = Expression(23, Add) -- expression 23 operands: lhs = Counter(27), rhs = Zero -- expression 24 operands: lhs = Expression(25, Add), rhs = Counter(30) -- expression 25 operands: lhs = Counter(28), rhs = Counter(29) -- expression 26 operands: lhs = Counter(30), rhs = Counter(31) -- expression 27 operands: lhs = Counter(31), rhs = Counter(32) +- expression 22 operands: lhs = Counter(26), rhs = Counter(27) +- expression 23 operands: lhs = Expression(24, Add), rhs = Counter(30) +- expression 24 operands: lhs = Counter(28), rhs = Counter(29) +- expression 25 operands: lhs = Counter(30), rhs = Counter(31) +- expression 26 operands: lhs = Counter(31), rhs = Counter(32) Number of file 0 mappings: 51 - Code(Counter(0)) at (prev + 8, 1) to (start + 3, 28) - Code(Counter(1)) at (prev + 4, 9) to (start + 1, 28) @@ -142,26 +141,26 @@ Number of file 0 mappings: 51 - Code(Counter(25)) at (prev + 3, 13) to (start + 0, 19) - Code(Expression(18, Sub)) at (prev + 2, 13) to (start + 0, 19) = (c24 - c25) -- Code(Expression(25, Add)) at (prev + 3, 5) to (start + 0, 15) +- Code(Expression(24, Add)) at (prev + 3, 5) to (start + 0, 15) = (c28 + c29) - Code(Counter(26)) at (prev + 1, 12) to (start + 0, 19) - Code(Counter(27)) at (prev + 1, 13) to (start + 3, 14) - Code(Counter(28)) at (prev + 4, 13) to (start + 0, 19) -- Code(Expression(21, Sub)) at (prev + 2, 13) to (start + 0, 23) +- Code(Expression(22, Sub)) at (prev + 2, 13) to (start + 0, 23) = (c26 - c27) -- Code(Expression(21, Sub)) at (prev + 1, 20) to (start + 0, 27) +- Code(Expression(22, Sub)) at (prev + 1, 20) to (start + 0, 27) = (c26 - c27) - Code(Zero) at (prev + 1, 21) to (start + 0, 27) - Code(Expression(22, Sub)) at (prev + 2, 21) to (start + 0, 27) - = (c26 - (c27 + Zero)) + = (c26 - c27) - Code(Counter(29)) at (prev + 4, 13) to (start + 0, 19) -- Code(Expression(24, Sub)) at (prev + 3, 9) to (start + 0, 25) +- Code(Expression(23, Sub)) at (prev + 3, 9) to (start + 0, 25) = ((c28 + c29) - c30) - Code(Counter(30)) at (prev + 2, 5) to (start + 0, 15) -- Code(Expression(26, Sub)) at (prev + 3, 9) to (start + 0, 34) +- Code(Expression(25, Sub)) at (prev + 3, 9) to (start + 0, 34) = (c30 - c31) - Code(Counter(31)) at (prev + 2, 5) to (start + 0, 15) -- Code(Expression(27, Sub)) at (prev + 3, 9) to (start + 0, 44) +- Code(Expression(26, Sub)) at (prev + 3, 9) to (start + 0, 44) = (c31 - c32) - Code(Counter(32)) at (prev + 2, 1) to (start + 0, 2) Highest counter ID seen: c32 diff --git a/tests/coverage/loops_branches.cov-map b/tests/coverage/loops_branches.cov-map index 912141b6d5f..640d5f15be0 100644 --- a/tests/coverage/loops_branches.cov-map +++ b/tests/coverage/loops_branches.cov-map @@ -1,85 +1,70 @@ Function name: <loops_branches::DebugTest as core::fmt::Debug>::fmt -Raw bytes (116): 0x[01, 01, 06, 05, 00, 1d, 00, 0f, 13, 01, 19, 11, 15, 15, 19, 14, 01, 09, 05, 01, 10, 05, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 02, 01, 0d, 00, 0e, 05, 01, 0d, 00, 1e, 11, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, 19, 03, 0d, 00, 0e, 15, 00, 12, 00, 17, 19, 01, 10, 00, 14, 1d, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 06, 01, 11, 00, 12, 1d, 01, 11, 00, 22, 0a, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 16, 03, 09, 00, 0f, 01, 01, 05, 00, 06] +Raw bytes (112): 0x[01, 01, 04, 07, 0b, 01, 11, 09, 0d, 0d, 11, 14, 01, 09, 05, 01, 10, 05, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 05, 01, 0d, 00, 0e, 05, 01, 0d, 00, 1e, 09, 00, 1e, 00, 1f, 00, 01, 10, 01, 0a, 11, 03, 0d, 00, 0e, 0d, 00, 12, 00, 17, 11, 01, 10, 00, 14, 15, 01, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 15, 01, 11, 00, 12, 15, 01, 11, 00, 22, 02, 00, 22, 00, 23, 00, 01, 14, 01, 0e, 0e, 03, 09, 00, 0f, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 6 -- expression 0 operands: lhs = Counter(1), rhs = Zero -- expression 1 operands: lhs = Counter(7), rhs = Zero -- expression 2 operands: lhs = Expression(3, Add), rhs = Expression(4, Add) -- expression 3 operands: lhs = Counter(0), rhs = Counter(6) -- expression 4 operands: lhs = Counter(4), rhs = Counter(5) -- expression 5 operands: lhs = Counter(5), rhs = Counter(6) +Number of expressions: 4 +- expression 0 operands: lhs = Expression(1, Add), rhs = Expression(2, Add) +- expression 1 operands: lhs = Counter(0), rhs = Counter(4) +- expression 2 operands: lhs = Counter(2), rhs = Counter(3) +- expression 3 operands: lhs = Counter(3), rhs = Counter(4) Number of file 0 mappings: 20 - Code(Counter(0)) at (prev + 9, 5) to (start + 1, 16) - Code(Counter(1)) at (prev + 2, 16) to (start + 0, 21) - Code(Zero) at (prev + 1, 23) to (start + 0, 27) - Code(Zero) at (prev + 0, 28) to (start + 0, 30) -- Code(Expression(0, Sub)) at (prev + 1, 13) to (start + 0, 14) - = (c1 - Zero) +- Code(Counter(1)) at (prev + 1, 13) to (start + 0, 14) - Code(Counter(1)) at (prev + 1, 13) to (start + 0, 30) -- Code(Counter(4)) at (prev + 0, 30) to (start + 0, 31) +- Code(Counter(2)) at (prev + 0, 30) to (start + 0, 31) - Code(Zero) at (prev + 1, 16) to (start + 1, 10) -- Code(Counter(6)) at (prev + 3, 13) to (start + 0, 14) -- Code(Counter(5)) at (prev + 0, 18) to (start + 0, 23) -- Code(Counter(6)) at (prev + 1, 16) to (start + 0, 20) -- Code(Counter(7)) at (prev + 1, 20) to (start + 0, 25) +- Code(Counter(4)) at (prev + 3, 13) to (start + 0, 14) +- Code(Counter(3)) at (prev + 0, 18) to (start + 0, 23) +- Code(Counter(4)) at (prev + 1, 16) to (start + 0, 20) +- Code(Counter(5)) at (prev + 1, 20) to (start + 0, 25) - Code(Zero) at (prev + 1, 27) to (start + 0, 31) - Code(Zero) at (prev + 0, 32) to (start + 0, 34) -- Code(Expression(1, Sub)) at (prev + 1, 17) to (start + 0, 18) - = (c7 - Zero) -- Code(Counter(7)) at (prev + 1, 17) to (start + 0, 34) -- Code(Expression(2, Sub)) at (prev + 0, 34) to (start + 0, 35) - = ((c0 + c6) - (c4 + c5)) +- Code(Counter(5)) at (prev + 1, 17) to (start + 0, 18) +- Code(Counter(5)) at (prev + 1, 17) to (start + 0, 34) +- Code(Expression(0, Sub)) at (prev + 0, 34) to (start + 0, 35) + = ((c0 + c4) - (c2 + c3)) - Code(Zero) at (prev + 1, 20) to (start + 1, 14) -- Code(Expression(5, Sub)) at (prev + 3, 9) to (start + 0, 15) - = (c5 - c6) +- Code(Expression(3, Sub)) at (prev + 3, 9) to (start + 0, 15) + = (c3 - c4) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6) -Highest counter ID seen: c7 +Highest counter ID seen: c5 Function name: <loops_branches::DisplayTest as core::fmt::Display>::fmt -Raw bytes (122): 0x[01, 01, 09, 01, 00, 01, 00, 0d, 00, 0d, 00, 0d, 00, 1b, 1f, 01, 0d, 09, 1d, 09, 0d, 14, 01, 22, 05, 01, 11, 00, 01, 12, 01, 0a, 02, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 06, 01, 0d, 00, 0e, 02, 01, 0d, 00, 1e, 1d, 00, 1e, 00, 1f, 0d, 02, 0d, 00, 0e, 09, 00, 12, 00, 17, 0d, 01, 10, 00, 15, 00, 00, 16, 01, 0e, 12, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 0e, 01, 11, 00, 12, 12, 01, 11, 00, 22, 16, 00, 22, 00, 23, 22, 03, 09, 00, 0f, 01, 01, 05, 00, 06] +Raw bytes (112): 0x[01, 01, 04, 07, 0b, 01, 09, 05, 0d, 05, 09, 14, 01, 22, 05, 01, 11, 00, 01, 12, 01, 0a, 01, 02, 10, 00, 15, 00, 01, 17, 00, 1b, 00, 00, 1c, 00, 1e, 01, 01, 0d, 00, 0e, 01, 01, 0d, 00, 1e, 0d, 00, 1e, 00, 1f, 09, 02, 0d, 00, 0e, 05, 00, 12, 00, 17, 09, 01, 10, 00, 15, 00, 00, 16, 01, 0e, 09, 02, 14, 00, 19, 00, 01, 1b, 00, 1f, 00, 00, 20, 00, 22, 09, 01, 11, 00, 12, 09, 01, 11, 00, 22, 02, 00, 22, 00, 23, 0e, 03, 09, 00, 0f, 01, 01, 05, 00, 06] Number of files: 1 - file 0 => global file 1 -Number of expressions: 9 -- expression 0 operands: lhs = Counter(0), rhs = Zero -- expression 1 operands: lhs = Counter(0), rhs = Zero -- expression 2 operands: lhs = Counter(3), rhs = Zero -- expression 3 operands: lhs = Counter(3), rhs = Zero -- expression 4 operands: lhs = Counter(3), rhs = Zero -- expression 5 operands: lhs = Expression(6, Add), rhs = Expression(7, Add) -- expression 6 operands: lhs = Counter(0), rhs = Counter(3) -- expression 7 operands: lhs = Counter(2), rhs = Counter(7) -- expression 8 operands: lhs = Counter(2), rhs = Counter(3) +Number of expressions: 4 +- expression 0 operands: lhs = Expression(1, Add), rhs = Expression(2, Add) +- expression 1 operands: lhs = Counter(0), rhs = Counter(2) +- expression 2 operands: lhs = Counter(1), rhs = Counter(3) +- expression 3 operands: lhs = Counter(1), rhs = Counter(2) Number of file 0 mappings: 20 - Code(Counter(0)) at (prev + 34, 5) to (start + 1, 17) - Code(Zero) at (prev + 1, 18) to (start + 1, 10) -- Code(Expression(0, Sub)) at (prev + 2, 16) to (start + 0, 21) - = (c0 - Zero) +- Code(Counter(0)) at (prev + 2, 16) to (start + 0, 21) - Code(Zero) at (prev + 1, 23) to (start + 0, 27) - Code(Zero) at (prev + 0, 28) to (start + 0, 30) -- Code(Expression(1, Sub)) at (prev + 1, 13) to (start + 0, 14) - = (c0 - Zero) -- Code(Expression(0, Sub)) at (prev + 1, 13) to (start + 0, 30) - = (c0 - Zero) -- Code(Counter(7)) at (prev + 0, 30) to (start + 0, 31) -- Code(Counter(3)) at (prev + 2, 13) to (start + 0, 14) -- Code(Counter(2)) at (prev + 0, 18) to (start + 0, 23) -- Code(Counter(3)) at (prev + 1, 16) to (start + 0, 21) +- Code(Counter(0)) at (prev + 1, 13) to (start + 0, 14) +- Code(Counter(0)) at (prev + 1, 13) to (start + 0, 30) +- Code(Counter(3)) at (prev + 0, 30) to (start + 0, 31) +- Code(Counter(2)) at (prev + 2, 13) to (start + 0, 14) +- Code(Counter(1)) at (prev + 0, 18) to (start + 0, 23) +- Code(Counter(2)) at (prev + 1, 16) to (start + 0, 21) - Code(Zero) at (prev + 0, 22) to (start + 1, 14) -- Code(Expression(4, Sub)) at (prev + 2, 20) to (start + 0, 25) - = (c3 - Zero) +- Code(Counter(2)) at (prev + 2, 20) to (start + 0, 25) - Code(Zero) at (prev + 1, 27) to (start + 0, 31) - Code(Zero) at (prev + 0, 32) to (start + 0, 34) -- Code(Expression(3, Sub)) at (prev + 1, 17) to (start + 0, 18) - = (c3 - Zero) -- Code(Expression(4, Sub)) at (prev + 1, 17) to (start + 0, 34) - = (c3 - Zero) -- Code(Expression(5, Sub)) at (prev + 0, 34) to (start + 0, 35) - = ((c0 + c3) - (c2 + c7)) -- Code(Expression(8, Sub)) at (prev + 3, 9) to (start + 0, 15) - = (c2 - c3) +- Code(Counter(2)) at (prev + 1, 17) to (start + 0, 18) +- Code(Counter(2)) at (prev + 1, 17) to (start + 0, 34) +- Code(Expression(0, Sub)) at (prev + 0, 34) to (start + 0, 35) + = ((c0 + c2) - (c1 + c3)) +- Code(Expression(3, Sub)) at (prev + 3, 9) to (start + 0, 15) + = (c1 - c2) - Code(Counter(0)) at (prev + 1, 5) to (start + 0, 6) -Highest counter ID seen: c7 +Highest counter ID seen: c3 Function name: loops_branches::main Raw bytes (9): 0x[01, 01, 00, 01, 01, 37, 01, 05, 02] diff --git a/tests/coverage/no_spans_if_not.cov-map b/tests/coverage/no_spans_if_not.cov-map index 9cb7e6a6cff..6c389a24317 100644 --- a/tests/coverage/no_spans_if_not.cov-map +++ b/tests/coverage/no_spans_if_not.cov-map @@ -1,13 +1,11 @@ Function name: no_spans_if_not::affected_function -Raw bytes (21): 0x[01, 01, 01, 01, 00, 03, 01, 16, 1c, 01, 12, 02, 02, 0d, 00, 0f, 00, 02, 0d, 00, 0f] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 16, 1c, 01, 12, 01, 02, 0d, 00, 0f, 00, 02, 0d, 00, 0f] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 22, 28) to (start + 1, 18) -- Code(Expression(0, Sub)) at (prev + 2, 13) to (start + 0, 15) - = (c0 - Zero) +- Code(Counter(0)) at (prev + 2, 13) to (start + 0, 15) - Code(Zero) at (prev + 2, 13) to (start + 0, 15) Highest counter ID seen: c0 diff --git a/tests/coverage/tight_inf_loop.cov-map b/tests/coverage/tight_inf_loop.cov-map index 2d2d59bf013..77a8ffb8358 100644 --- a/tests/coverage/tight_inf_loop.cov-map +++ b/tests/coverage/tight_inf_loop.cov-map @@ -1,13 +1,11 @@ Function name: tight_inf_loop::main -Raw bytes (21): 0x[01, 01, 01, 01, 00, 03, 01, 01, 01, 01, 0d, 00, 02, 09, 00, 10, 02, 01, 06, 01, 02] +Raw bytes (19): 0x[01, 01, 00, 03, 01, 01, 01, 01, 0d, 00, 02, 09, 00, 10, 01, 01, 06, 01, 02] Number of files: 1 - file 0 => global file 1 -Number of expressions: 1 -- expression 0 operands: lhs = Counter(0), rhs = Zero +Number of expressions: 0 Number of file 0 mappings: 3 - Code(Counter(0)) at (prev + 1, 1) to (start + 1, 13) - Code(Zero) at (prev + 2, 9) to (start + 0, 16) -- Code(Expression(0, Sub)) at (prev + 1, 6) to (start + 1, 2) - = (c0 - Zero) +- Code(Counter(0)) at (prev + 1, 6) to (start + 1, 2) Highest counter ID seen: c0 diff --git a/tests/crashes/125810.rs b/tests/crashes/125810.rs deleted file mode 100644 index 4a152da8ddf..00000000000 --- a/tests/crashes/125810.rs +++ /dev/null @@ -1,10 +0,0 @@ -//@ known-bug: rust-lang/rust#125810 -#![feature(arbitrary_self_types, dispatch_from_dyn)] - -use std::ops::{Deref, DispatchFromDyn}; - -trait Trait<T: Deref<Target = Self> + DispatchFromDyn<T>> { - fn MONO_BUF(self: T) -> dyn Trait<T>; -} - -fn main() {} diff --git a/tests/crashes/131886.rs b/tests/crashes/131886.rs index c31c2d6aa8b..2c692dfb777 100644 --- a/tests/crashes/131886.rs +++ b/tests/crashes/131886.rs @@ -1,6 +1,6 @@ //@ known-bug: #131886 //@ compile-flags: -Zvalidate-mir --crate-type=lib -#![feature(trait_upcasting, type_alias_impl_trait)] +#![feature(type_alias_impl_trait)] type Tait = impl Sized; diff --git a/tests/crashes/132391.rs b/tests/crashes/132391.rs deleted file mode 100644 index 6c8c2c3a878..00000000000 --- a/tests/crashes/132391.rs +++ /dev/null @@ -1,8 +0,0 @@ -//@ known-bug: #123291 - -trait MyTrait { - #[repr(align)] - fn myfun(); -} - -pub fn main() {} diff --git a/tests/crashes/132981.rs b/tests/crashes/132981.rs index 8ff4fa36fd0..916c1559240 100644 --- a/tests/crashes/132981.rs +++ b/tests/crashes/132981.rs @@ -2,6 +2,10 @@ //@compile-flags: -Clink-dead-code=true --crate-type lib //@ only-x86_64 //@ ignore-windows +// The set of targets this crashes on is really fiddly, because it is deep in our ABI logic. It +// crashes on x86_64-unknown-linux-gnu, and i686-pc-windows-msvc, but not on +// x86_64-pc-windows-msvc. If you are trying to fix this crash, don't pay too much attention to the +// directives. #![feature(rust_cold_cc)] pub extern "rust-cold" fn foo(_: [usize; 3]) {} diff --git a/tests/crashes/134336.rs b/tests/crashes/134336.rs deleted file mode 100644 index 14b88e14f04..00000000000 --- a/tests/crashes/134336.rs +++ /dev/null @@ -1,11 +0,0 @@ -//@ known-bug: #134336 -#![expect(incomplete_features)] -#![feature(explicit_tail_calls)] - -trait Tr { - fn f(); -} - -fn g<T: Tr>() { - become T::f(); -} diff --git a/tests/crashes/134355.rs b/tests/crashes/134355.rs deleted file mode 100644 index b662341e6b1..00000000000 --- a/tests/crashes/134355.rs +++ /dev/null @@ -1,6 +0,0 @@ -//@ known-bug: #134355 - -//@compile-flags: --crate-type=lib -fn digit() -> str { - return { i32::MIN }; -} diff --git a/tests/crashes/135124.rs b/tests/crashes/135124.rs deleted file mode 100644 index d6655cb46fa..00000000000 --- a/tests/crashes/135124.rs +++ /dev/null @@ -1,9 +0,0 @@ -//@ known-bug: #135124 -trait A { - fn y(&self) - { - fn call() -> impl Sized {} - self.fold(call()); - } - fn fold(&self, &self._) {} -} diff --git a/tests/crashes/135470.rs b/tests/crashes/135470.rs new file mode 100644 index 00000000000..7d357a9317f --- /dev/null +++ b/tests/crashes/135470.rs @@ -0,0 +1,40 @@ +//@ known-bug: #135470 +//@ compile-flags: --edition=2021 -Copt-level=0 + +use std::future::Future; +trait Access { + type Lister; + + fn list() -> impl Future<Output = Self::Lister> { + async { todo!() } + } +} + +trait Foo {} +impl Access for dyn Foo { + type Lister = (); +} + +fn main() { + let svc = async { + async { <dyn Foo>::list() }.await; + }; + &svc as &dyn Service; +} + +trait UnaryService { + fn call2() {} +} +trait Unimplemented {} +impl<T: Unimplemented> UnaryService for T {} +struct Wrap<T>(T); +impl<T: Send> UnaryService for Wrap<T> {} + +trait Service { + fn call(&self); +} +impl<T: Send> Service for T { + fn call(&self) { + Wrap::<T>::call2(); + } +} diff --git a/tests/crashes/135528.rs b/tests/crashes/135528.rs new file mode 100644 index 00000000000..a1418f40be6 --- /dev/null +++ b/tests/crashes/135528.rs @@ -0,0 +1,18 @@ +//@ known-bug: #135528 +//@ compile-flags: -Zvalidate-mir -Zinline-mir=yes +#![feature(type_alias_impl_trait)] +type Tait = impl Copy; + +fn set(x: &isize) -> isize { + *x +} + +fn d(x: Tait) { + set(x); +} + +fn other_define() -> Tait { + () +} + +fn main() {} diff --git a/tests/crashes/135570.rs b/tests/crashes/135570.rs new file mode 100644 index 00000000000..a9eda97ef9d --- /dev/null +++ b/tests/crashes/135570.rs @@ -0,0 +1,12 @@ +//@ known-bug: #135570 +//@compile-flags: -Zvalidate-mir -Zmir-enable-passes=+Inline -Copt-level=0 -Zmir-enable-passes=+GVN +//@ only-x86_64 + +fn function_with_bytes<const BYTES: &'static [u8; 0xc7b889180b67b07d_bc1a3c88783d35b5_u128]>( +) -> &'static [u8] { + BYTES +} + +fn main() { + function_with_bytes::<b"aa">() == &[]; +} diff --git a/tests/crashes/135617.rs b/tests/crashes/135617.rs new file mode 100644 index 00000000000..ac524b823a0 --- /dev/null +++ b/tests/crashes/135617.rs @@ -0,0 +1,13 @@ +//@ known-bug: #135617 +trait Project { + const ASSOC: usize; +} + +fn foo() +where + for<'a> (): Project, +{ + [(); <() as Project>::ASSOC]; +} + +pub fn main() {} diff --git a/tests/crashes/135646.rs b/tests/crashes/135646.rs new file mode 100644 index 00000000000..67b0ad93db4 --- /dev/null +++ b/tests/crashes/135646.rs @@ -0,0 +1,5 @@ +//@ known-bug: #135646 +//@ compile-flags: --edition=2024 -Zpolonius=next +fn main() { + &{ [1, 2, 3][4] }; +} diff --git a/tests/crashes/135668.rs b/tests/crashes/135668.rs new file mode 100644 index 00000000000..8126a65606b --- /dev/null +++ b/tests/crashes/135668.rs @@ -0,0 +1,38 @@ +//@ known-bug: #135668 +//@ compile-flags: --edition=2021 +use std::future::Future; + +pub async fn foo() { + let _ = create_task().await; +} + +async fn create_task() -> impl Sized { + bind(documentation) +} + +async fn documentation() { + include_str!("nonexistent"); +} + +fn bind<F>(_filter: F) -> impl Sized +where + F: FilterBase, +{ + || -> <F as FilterBase>::Assoc { panic!() } +} + +trait FilterBase { + type Assoc; +} + +impl<F, R> FilterBase for F +where + F: Fn() -> R, + // Removing the below line makes it correctly error on both stable and beta + R: Future, + // Removing the below line makes it ICE on both stable and beta + R: Send, + // Removing the above two bounds makes it ICE on stable but correctly error on beta +{ + type Assoc = F; +} diff --git a/tests/crashes/135718.rs b/tests/crashes/135718.rs new file mode 100644 index 00000000000..c0e628f4c46 --- /dev/null +++ b/tests/crashes/135718.rs @@ -0,0 +1,50 @@ +//@ known-bug: #135718 + +struct Equal; + +struct Bar; + +trait TwiceNested {} +impl<M> TwiceNested for Bar where Bar: NestMakeEqual<NestEq = M> {} + +struct Sum; + +trait Not { + fn not(); +} + +impl<P> Not for Sum +where + Bar: NestMakeEqual<NestEq = P>, + Self: Problem<P>, +{ + fn not() {} +} + +trait NestMakeEqual { + type NestEq; +} + +trait MakeEqual { + type Eq; +} + +struct Foo; +impl MakeEqual for Foo { + type Eq = Equal; +} + +impl<O> NestMakeEqual for Bar +where + Foo: MakeEqual<Eq = O>, +{ + type NestEq = O; +} + +trait Problem<M> {} +impl Problem<()> for Sum where Bar: TwiceNested {} +impl Problem<Equal> for Sum where Bar: TwiceNested {} + +fn main() { + Sum::not(); +} diff --git a/tests/crashes/135720.rs b/tests/crashes/135720.rs new file mode 100644 index 00000000000..ee85bc4b66a --- /dev/null +++ b/tests/crashes/135720.rs @@ -0,0 +1,4 @@ +//@ known-bug: #135720 +#![feature(generic_const_exprs)] +type S<'l> = [i32; A]; +fn lint_me(x: S<()>) {} diff --git a/tests/crashes/135845.rs b/tests/crashes/135845.rs new file mode 100644 index 00000000000..ed038d8a1f1 --- /dev/null +++ b/tests/crashes/135845.rs @@ -0,0 +1,6 @@ +//@ known-bug: #135845 +struct S<'a, T: ?Sized>(&'a T); + +fn b<'a>() -> S<'static, _> { + S::<'a>(&0) +} diff --git a/tests/crashes/135863.rs b/tests/crashes/135863.rs new file mode 100644 index 00000000000..a0ff5988a0d --- /dev/null +++ b/tests/crashes/135863.rs @@ -0,0 +1,10 @@ +//@ known-bug: #135863 +struct A; + +impl A { + fn len(self: &&B) {} +} + +fn main() { + A.len() +} diff --git a/tests/crashes/136063.rs b/tests/crashes/136063.rs new file mode 100644 index 00000000000..078cc59dfa2 --- /dev/null +++ b/tests/crashes/136063.rs @@ -0,0 +1,6 @@ +//@ known-bug: #136063 +#![feature(generic_const_exprs)] +trait A<const B: u8 = X> {} +impl A<1> for bool {} +fn bar(arg : &dyn A<x>) { bar(true) } +pub fn main() {} diff --git a/tests/crashes/90110.rs b/tests/crashes/90110.rs deleted file mode 100644 index a27a1f42b7a..00000000000 --- a/tests/crashes/90110.rs +++ /dev/null @@ -1,57 +0,0 @@ -//@ known-bug: #90110 - -use std::fs::File; -use std::io::{BufReader, BufRead}; -use std::str::Split; -use std::path::Path; - -pub trait Parser<D> -where dyn Parser<D>: Sized -{ - fn new(split_header: Split<&str>) -> Self where Self: Sized; - fn parse_line(&self, split_line: &Split<&str>) -> D; -} - - -pub struct CsvReader<D> { - parser: Box<dyn Parser<D>>, - - reader: BufReader<File>, - buf: String, // Buffer we will read into. Avoids re-allocation on each line. - path: String, // Record this so we can return more informative error messages. - line: usize, // Same motivation for this. -} - -impl<D> CsvReader<D> -where dyn Parser<D>: Sized -{ - fn new<F>(path: &str, make_parser: F) -> CsvReader<D> - where F: Fn(Split<char>) -> dyn Parser<D> { - let file = match File::open(Path::new(path)) { - Err(err) => panic!("Couldn't read {}: {}", path, err), - Ok(file) => file, - }; - - let mut reader = BufReader::new(file); - - let mut buf = String::new(); - - let parser = Box::new(match reader.read_line(&mut buf) { - Err(err) => panic!("Failed to read the header line from {}: {}", path, err), - Ok(_) => { - let split_header = buf.split(','); - make_parser(split_header) - }, - }); - - CsvReader { - parser: parser, - reader, - buf, - path: path.to_string(), - line: 2, - } - } -} - -pub fn main() {} diff --git a/tests/mir-opt/building/enum_cast.droppy.built.after.mir b/tests/mir-opt/building/enum_cast.droppy.built.after.mir deleted file mode 100644 index f53c9199a49..00000000000 --- a/tests/mir-opt/building/enum_cast.droppy.built.after.mir +++ /dev/null @@ -1,71 +0,0 @@ -// MIR for `droppy` after built - -fn droppy() -> () { - let mut _0: (); - let _1: (); - let _2: Droppy; - let _4: Droppy; - let mut _5: isize; - let mut _6: u8; - let mut _7: bool; - let _8: Droppy; - scope 1 { - debug x => _2; - scope 2 { - debug y => _3; - } - scope 3 { - let _3: usize; - } - } - scope 4 { - debug z => _8; - } - - bb0: { - StorageLive(_1); - StorageLive(_2); - _2 = Droppy::C; - FakeRead(ForLet(None), _2); - StorageLive(_3); - StorageLive(_4); - _4 = move _2; - _5 = discriminant(_4); - _6 = copy _5 as u8 (IntToInt); - _7 = Le(copy _6, const 2_u8); - assume(move _7); - _3 = move _5 as usize (IntToInt); - drop(_4) -> [return: bb1, unwind: bb4]; - } - - bb1: { - StorageDead(_4); - FakeRead(ForLet(None), _3); - _1 = const (); - StorageDead(_3); - drop(_2) -> [return: bb2, unwind: bb5]; - } - - bb2: { - StorageDead(_2); - StorageDead(_1); - StorageLive(_8); - _8 = Droppy::B; - FakeRead(ForLet(None), _8); - _0 = const (); - drop(_8) -> [return: bb3, unwind: bb5]; - } - - bb3: { - StorageDead(_8); - return; - } - - bb4 (cleanup): { - drop(_2) -> [return: bb5, unwind terminate(cleanup)]; - } - - bb5 (cleanup): { - resume; - } -} diff --git a/tests/mir-opt/building/enum_cast.rs b/tests/mir-opt/building/enum_cast.rs index 7ff0cdbfe8d..4fb9a27e309 100644 --- a/tests/mir-opt/building/enum_cast.rs +++ b/tests/mir-opt/building/enum_cast.rs @@ -41,27 +41,6 @@ fn far(far: Far) -> isize { far as isize } -// EMIT_MIR enum_cast.droppy.built.after.mir -enum Droppy { - A, - B, - C, -} - -impl Drop for Droppy { - fn drop(&mut self) {} -} - -fn droppy() { - { - let x = Droppy::C; - // remove this entire test once `cenum_impl_drop_cast` becomes a hard error - #[allow(cenum_impl_drop_cast)] - let y = x as usize; - } - let z = Droppy::B; -} - #[repr(i16)] enum SignedAroundZero { A = -2, diff --git a/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff index 138586300ce..e9f48a85f9c 100644 --- a/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/branch_match_arms.main.InstrumentCoverage.diff @@ -27,18 +27,15 @@ } + coverage body span: $DIR/branch_match_arms.rs:14:11: 21:2 (#0) -+ coverage ExpressionId(0) => Expression { lhs: Counter(1), op: Add, rhs: Counter(2) }; -+ coverage ExpressionId(1) => Expression { lhs: Expression(0), op: Add, rhs: Counter(3) }; -+ coverage ExpressionId(2) => Expression { lhs: Counter(0), op: Subtract, rhs: Expression(1) }; -+ coverage Code(Counter(0)) => $DIR/branch_match_arms.rs:14:1: 15:21 (#0); -+ coverage Code(Counter(1)) => $DIR/branch_match_arms.rs:16:17: 16:33 (#0); -+ coverage Code(Counter(2)) => $DIR/branch_match_arms.rs:17:17: 17:33 (#0); -+ coverage Code(Counter(3)) => $DIR/branch_match_arms.rs:18:17: 18:33 (#0); -+ coverage Code(Expression(2)) => $DIR/branch_match_arms.rs:19:17: 19:33 (#0); -+ coverage Code(Counter(0)) => $DIR/branch_match_arms.rs:21:2: 21:2 (#0); ++ coverage Code { bcb: bcb0 } => $DIR/branch_match_arms.rs:14:1: 15:21 (#0); ++ coverage Code { bcb: bcb1 } => $DIR/branch_match_arms.rs:16:17: 16:33 (#0); ++ coverage Code { bcb: bcb3 } => $DIR/branch_match_arms.rs:17:17: 17:33 (#0); ++ coverage Code { bcb: bcb4 } => $DIR/branch_match_arms.rs:18:17: 18:33 (#0); ++ coverage Code { bcb: bcb5 } => $DIR/branch_match_arms.rs:19:17: 19:33 (#0); ++ coverage Code { bcb: bcb2 } => $DIR/branch_match_arms.rs:21:2: 21:2 (#0); + bb0: { -+ Coverage::CounterIncrement(0); ++ Coverage::VirtualCounter(bcb0); StorageLive(_1); _1 = Enum::A(const 0_u32); PlaceMention(_1); @@ -52,22 +49,22 @@ } bb2: { -+ Coverage::CounterIncrement(1); ++ Coverage::VirtualCounter(bcb1); falseEdge -> [real: bb8, imaginary: bb3]; } bb3: { -+ Coverage::CounterIncrement(2); ++ Coverage::VirtualCounter(bcb3); falseEdge -> [real: bb7, imaginary: bb4]; } bb4: { -+ Coverage::CounterIncrement(3); ++ Coverage::VirtualCounter(bcb4); falseEdge -> [real: bb6, imaginary: bb5]; } bb5: { -+ Coverage::ExpressionUsed(2); ++ Coverage::VirtualCounter(bcb5); StorageLive(_9); _9 = copy ((_1 as A).0: u32); StorageLive(_10); @@ -124,6 +121,7 @@ } bb13: { ++ Coverage::VirtualCounter(bcb2); StorageDead(_1); return; } diff --git a/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff b/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff index a91d88984a8..cbef6de917d 100644 --- a/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage.bar.InstrumentCoverage.diff @@ -5,10 +5,10 @@ let mut _0: bool; + coverage body span: $DIR/instrument_coverage.rs:29:18: 31:2 (#0) -+ coverage Code(Counter(0)) => $DIR/instrument_coverage.rs:29:1: 31:2 (#0); ++ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:29:1: 31:2 (#0); + bb0: { -+ Coverage::CounterIncrement(0); ++ Coverage::VirtualCounter(bcb0); _0 = const true; return; } diff --git a/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff index d7ea442518e..b166d79a412 100644 --- a/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage.main.InstrumentCoverage.diff @@ -8,20 +8,19 @@ let mut _3: !; + coverage body span: $DIR/instrument_coverage.rs:14:11: 20:2 (#0) -+ coverage ExpressionId(0) => Expression { lhs: Counter(1), op: Subtract, rhs: Counter(0) }; -+ coverage Code(Counter(0)) => $DIR/instrument_coverage.rs:14:1: 14:11 (#0); -+ coverage Code(Counter(1)) => $DIR/instrument_coverage.rs:16:12: 16:17 (#0); -+ coverage Code(Counter(0)) => $DIR/instrument_coverage.rs:17:13: 17:18 (#0); -+ coverage Code(Expression(0)) => $DIR/instrument_coverage.rs:18:10: 18:10 (#0); -+ coverage Code(Counter(0)) => $DIR/instrument_coverage.rs:20:2: 20:2 (#0); ++ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage.rs:14:1: 14:11 (#0); ++ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage.rs:16:12: 16:17 (#0); ++ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:17:13: 17:18 (#0); ++ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage.rs:18:10: 18:10 (#0); ++ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage.rs:20:2: 20:2 (#0); + bb0: { -+ Coverage::CounterIncrement(0); ++ Coverage::VirtualCounter(bcb0); goto -> bb1; } bb1: { -+ Coverage::CounterIncrement(1); ++ Coverage::VirtualCounter(bcb1); falseUnwind -> [real: bb2, unwind: bb6]; } @@ -35,13 +34,14 @@ } bb4: { ++ Coverage::VirtualCounter(bcb2); _0 = const (); StorageDead(_2); return; } bb5: { -+ Coverage::ExpressionUsed(0); ++ Coverage::VirtualCounter(bcb3); _1 = const (); StorageDead(_2); goto -> bb1; diff --git a/tests/mir-opt/coverage/instrument_coverage.rs b/tests/mir-opt/coverage/instrument_coverage.rs index c49786f9615..48647402d0f 100644 --- a/tests/mir-opt/coverage/instrument_coverage.rs +++ b/tests/mir-opt/coverage/instrument_coverage.rs @@ -8,9 +8,9 @@ // EMIT_MIR instrument_coverage.main.InstrumentCoverage.diff // CHECK-LABEL: fn main() // CHECK: coverage body span: -// CHECK: coverage Code(Counter({{[0-9]+}})) => +// CHECK: coverage Code { bcb: bcb{{[0-9]+}} } => // CHECK: bb0: -// CHECK: Coverage::CounterIncrement +// CHECK: Coverage::VirtualCounter fn main() { loop { if bar() { @@ -22,9 +22,9 @@ fn main() { // EMIT_MIR instrument_coverage.bar.InstrumentCoverage.diff // CHECK-LABEL: fn bar() // CHECK: coverage body span: -// CHECK: coverage Code(Counter({{[0-9]+}})) => +// CHECK: coverage Code { bcb: bcb{{[0-9]+}} } => // CHECK: bb0: -// CHECK: Coverage::CounterIncrement +// CHECK: Coverage::VirtualCounter #[inline(never)] fn bar() -> bool { true diff --git a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff index 2c7ec6e85eb..855f806aae1 100644 --- a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff +++ b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.CleanupPostBorrowck.diff @@ -8,15 +8,14 @@ coverage branch { true: BlockMarkerId(0), false: BlockMarkerId(1) } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0) coverage body span: $DIR/instrument_coverage_cleanup.rs:13:11: 15:2 (#0) - coverage ExpressionId(0) => Expression { lhs: Counter(0), op: Subtract, rhs: Counter(1) }; - coverage Code(Counter(0)) => $DIR/instrument_coverage_cleanup.rs:13:1: 14:36 (#0); - coverage Code(Expression(0)) => $DIR/instrument_coverage_cleanup.rs:14:37: 14:39 (#0); - coverage Code(Counter(1)) => $DIR/instrument_coverage_cleanup.rs:14:39: 14:39 (#0); - coverage Code(Counter(0)) => $DIR/instrument_coverage_cleanup.rs:15:2: 15:2 (#0); - coverage Branch { true_term: Expression(0), false_term: Counter(1) } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); + coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 14:36 (#0); + coverage Code { bcb: bcb3 } => $DIR/instrument_coverage_cleanup.rs:14:37: 14:39 (#0); + coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:39: 14:39 (#0); + coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:2: 15:2 (#0); + coverage Branch { true_bcb: bcb3, false_bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); bb0: { - Coverage::CounterIncrement(0); + Coverage::VirtualCounter(bcb0); - Coverage::SpanMarker; + nop; StorageLive(_1); @@ -28,7 +27,7 @@ } bb2: { - Coverage::CounterIncrement(1); + Coverage::VirtualCounter(bcb1); - Coverage::BlockMarker(1); + nop; _0 = const (); @@ -36,7 +35,7 @@ } bb3: { - Coverage::ExpressionUsed(0); + Coverage::VirtualCounter(bcb3); - Coverage::BlockMarker(0); + nop; _0 = const (); @@ -44,6 +43,7 @@ } bb4: { + Coverage::VirtualCounter(bcb2); StorageDead(_1); return; } diff --git a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff index c08265eb0e9..df1f1e8bc50 100644 --- a/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff +++ b/tests/mir-opt/coverage/instrument_coverage_cleanup.main.InstrumentCoverage.diff @@ -8,15 +8,14 @@ coverage branch { true: BlockMarkerId(0), false: BlockMarkerId(1) } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0) + coverage body span: $DIR/instrument_coverage_cleanup.rs:13:11: 15:2 (#0) -+ coverage ExpressionId(0) => Expression { lhs: Counter(0), op: Subtract, rhs: Counter(1) }; -+ coverage Code(Counter(0)) => $DIR/instrument_coverage_cleanup.rs:13:1: 14:36 (#0); -+ coverage Code(Expression(0)) => $DIR/instrument_coverage_cleanup.rs:14:37: 14:39 (#0); -+ coverage Code(Counter(1)) => $DIR/instrument_coverage_cleanup.rs:14:39: 14:39 (#0); -+ coverage Code(Counter(0)) => $DIR/instrument_coverage_cleanup.rs:15:2: 15:2 (#0); -+ coverage Branch { true_term: Expression(0), false_term: Counter(1) } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); ++ coverage Code { bcb: bcb0 } => $DIR/instrument_coverage_cleanup.rs:13:1: 14:36 (#0); ++ coverage Code { bcb: bcb3 } => $DIR/instrument_coverage_cleanup.rs:14:37: 14:39 (#0); ++ coverage Code { bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:39: 14:39 (#0); ++ coverage Code { bcb: bcb2 } => $DIR/instrument_coverage_cleanup.rs:15:2: 15:2 (#0); ++ coverage Branch { true_bcb: bcb3, false_bcb: bcb1 } => $DIR/instrument_coverage_cleanup.rs:14:8: 14:36 (#0); + bb0: { -+ Coverage::CounterIncrement(0); ++ Coverage::VirtualCounter(bcb0); Coverage::SpanMarker; StorageLive(_1); _1 = std::hint::black_box::<bool>(const true) -> [return: bb1, unwind: bb5]; @@ -27,20 +26,21 @@ } bb2: { -+ Coverage::CounterIncrement(1); ++ Coverage::VirtualCounter(bcb1); Coverage::BlockMarker(1); _0 = const (); goto -> bb4; } bb3: { -+ Coverage::ExpressionUsed(0); ++ Coverage::VirtualCounter(bcb3); Coverage::BlockMarker(0); _0 = const (); goto -> bb4; } bb4: { ++ Coverage::VirtualCounter(bcb2); StorageDead(_1); return; } diff --git a/tests/mir-opt/coverage/instrument_coverage_cleanup.rs b/tests/mir-opt/coverage/instrument_coverage_cleanup.rs index acc544a28af..e8af4d6174f 100644 --- a/tests/mir-opt/coverage/instrument_coverage_cleanup.rs +++ b/tests/mir-opt/coverage/instrument_coverage_cleanup.rs @@ -3,7 +3,7 @@ // but leaves the statements that were added by InstrumentCoverage. // // Removed statement kinds: BlockMarker, SpanMarker -// Retained statement kinds: CounterIncrement, ExpressionUsed +// Retained statement kinds: VirtualCounter //@ test-mir-pass: InstrumentCoverage //@ compile-flags: -Cinstrument-coverage -Zcoverage-options=branch -Zno-profiler-runtime @@ -16,6 +16,6 @@ fn main() { // CHECK-NOT: Coverage::BlockMarker // CHECK-NOT: Coverage::SpanMarker -// CHECK: Coverage::CounterIncrement +// CHECK: Coverage::VirtualCounter // CHECK-NOT: Coverage::BlockMarker // CHECK-NOT: Coverage::SpanMarker diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.rs b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.rs new file mode 100644 index 00000000000..635ad825a12 --- /dev/null +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.rs @@ -0,0 +1,15 @@ +// skip-filecheck +//@ compile-flags: -Zmir-enable-passes=+Inline,+GVN --crate-type lib +// EMIT_MIR_FOR_EACH_PANIC_STRATEGY +// EMIT_MIR dont_reset_cast_kind_without_updating_operand.test.GVN.diff + +fn test() { + let vp_ctx: &Box<()> = &Box::new(()); + let slf: *const () = &raw const **vp_ctx; + let bytes = std::ptr::slice_from_raw_parts(slf, 1); + let _x = foo(bytes); +} + +fn foo(bytes: *const [()]) -> *mut () { + bytes as *mut () +} diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.panic-abort.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.panic-abort.diff new file mode 100644 index 00000000000..37dd14e6c89 --- /dev/null +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.panic-abort.diff @@ -0,0 +1,180 @@ +- // MIR for `test` before GVN ++ // MIR for `test` after GVN + + fn test() -> () { + let mut _0: (); + let _1: &std::boxed::Box<()>; + let _2: &std::boxed::Box<()>; + let _3: std::boxed::Box<()>; + let mut _6: *const (); + let mut _8: *const [()]; + let mut _9: std::boxed::Box<()>; + let mut _10: *const (); + let mut _23: usize; + scope 1 { + debug vp_ctx => _1; + let _4: *const (); + scope 2 { + debug slf => _10; + let _5: *const [()]; + scope 3 { + debug bytes => _5; + let _7: *mut (); + scope 4 { + debug _x => _7; + } + scope 18 (inlined foo) { + } + } + scope 16 (inlined slice_from_raw_parts::<()>) { + scope 17 (inlined std::ptr::from_raw_parts::<[()], ()>) { + } + } + } + } + scope 5 (inlined Box::<()>::new) { + let mut _11: usize; + let mut _12: usize; + let mut _13: *mut u8; + scope 6 (inlined alloc::alloc::exchange_malloc) { + let _14: std::alloc::Layout; + let mut _15: std::result::Result<std::ptr::NonNull<[u8]>, std::alloc::AllocError>; + let mut _16: isize; + let mut _18: !; + scope 7 { + let _17: std::ptr::NonNull<[u8]>; + scope 8 { + scope 11 (inlined NonNull::<[u8]>::as_mut_ptr) { + scope 12 (inlined NonNull::<[u8]>::as_non_null_ptr) { + scope 13 (inlined NonNull::<[u8]>::cast::<u8>) { + let mut _22: *mut [u8]; + scope 14 (inlined NonNull::<[u8]>::as_ptr) { + } + } + } + scope 15 (inlined NonNull::<u8>::as_ptr) { + } + } + } + scope 10 (inlined <std::alloc::Global as Allocator>::allocate) { + } + } + scope 9 (inlined Layout::from_size_align_unchecked) { + let mut _19: bool; + let _20: (); + let mut _21: std::ptr::Alignment; + } + } + } + + bb0: { + StorageLive(_1); +- StorageLive(_2); ++ nop; + StorageLive(_3); + StorageLive(_11); + StorageLive(_12); + StorageLive(_13); +- _11 = SizeOf(()); +- _12 = AlignOf(()); ++ _11 = const 0_usize; ++ _12 = const 1_usize; + StorageLive(_14); + StorageLive(_16); + StorageLive(_17); + StorageLive(_19); + _19 = const false; +- switchInt(move _19) -> [0: bb6, otherwise: bb5]; ++ switchInt(const false) -> [0: bb6, otherwise: bb5]; + } + + bb1: { + StorageDead(_3); + StorageDead(_1); + return; + } + + bb2: { + unreachable; + } + + bb3: { +- _18 = handle_alloc_error(move _14) -> unwind unreachable; ++ _18 = handle_alloc_error(const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}) -> unwind unreachable; + } + + bb4: { + _17 = copy ((_15 as Ok).0: std::ptr::NonNull<[u8]>); + StorageLive(_22); + _22 = copy _17 as *mut [u8] (Transmute); + _13 = copy _22 as *mut u8 (PtrToPtr); + StorageDead(_22); + StorageDead(_15); + StorageDead(_17); + StorageDead(_16); + StorageDead(_14); + _3 = ShallowInitBox(move _13, ()); + StorageDead(_13); + StorageDead(_12); + StorageDead(_11); + _2 = &_3; + _1 = copy _2; +- StorageDead(_2); ++ nop; + StorageLive(_4); +- _9 = deref_copy _3; ++ _9 = copy _3; + _10 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); + _4 = copy _10; +- StorageLive(_5); ++ nop; + StorageLive(_6); +- _6 = copy _4; ++ _6 = copy _10; + StorageLive(_23); + _23 = const 1_usize; +- _5 = *const [()] from (copy _6, copy _23); ++ _5 = *const [()] from (copy _10, const 1_usize); + StorageDead(_23); + StorageDead(_6); + StorageLive(_7); + StorageLive(_8); + _8 = copy _5; +- _7 = copy _8 as *mut () (PtrToPtr); ++ _7 = copy _5 as *mut () (PtrToPtr); + StorageDead(_8); + StorageDead(_7); +- StorageDead(_5); ++ nop; + StorageDead(_4); + drop(_3) -> [return: bb1, unwind unreachable]; + } + + bb5: { +- _20 = Layout::from_size_align_unchecked::precondition_check(copy _11, copy _12) -> [return: bb6, unwind unreachable]; ++ _20 = Layout::from_size_align_unchecked::precondition_check(const 0_usize, const 1_usize) -> [return: bb6, unwind unreachable]; + } + + bb6: { + StorageDead(_19); + StorageLive(_21); +- _21 = copy _12 as std::ptr::Alignment (Transmute); +- _14 = Layout { size: copy _11, align: move _21 }; ++ _21 = const std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0); ++ _14 = const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}; + StorageDead(_21); + StorageLive(_15); +- _15 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], copy _14, const false) -> [return: bb7, unwind unreachable]; ++ _15 = std::alloc::Global::alloc_impl(const alloc::alloc::exchange_malloc::promoted[0], const Layout {{ size: 0_usize, align: std::ptr::Alignment(std::ptr::alignment::AlignmentEnum::_Align1Shl0) }}, const false) -> [return: bb7, unwind unreachable]; + } + + bb7: { + _16 = discriminant(_15); + switchInt(move _16) -> [0: bb4, 1: bb3, otherwise: bb2]; + } ++ } ++ ++ ALLOC0 (size: 8, align: 4) { ++ 01 00 00 00 00 00 00 00 │ ........ + } + diff --git a/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.panic-unwind.diff b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.panic-unwind.diff new file mode 100644 index 00000000000..6bac6805943 --- /dev/null +++ b/tests/mir-opt/dont_reset_cast_kind_without_updating_operand.test.GVN.panic-unwind.diff @@ -0,0 +1,88 @@ +- // MIR for `test` before GVN ++ // MIR for `test` after GVN + + fn test() -> () { + let mut _0: (); + let _1: &std::boxed::Box<()>; + let _2: &std::boxed::Box<()>; + let _3: std::boxed::Box<()>; + let mut _6: *const (); + let mut _8: *const [()]; + let mut _9: std::boxed::Box<()>; + let mut _10: *const (); + let mut _11: usize; + scope 1 { + debug vp_ctx => _1; + let _4: *const (); + scope 2 { + debug slf => _10; + let _5: *const [()]; + scope 3 { + debug bytes => _5; + let _7: *mut (); + scope 4 { + debug _x => _7; + } + scope 7 (inlined foo) { + } + } + scope 5 (inlined slice_from_raw_parts::<()>) { + scope 6 (inlined std::ptr::from_raw_parts::<[()], ()>) { + } + } + } + } + + bb0: { + StorageLive(_1); +- StorageLive(_2); ++ nop; + StorageLive(_3); + _3 = Box::<()>::new(const ()) -> [return: bb1, unwind continue]; + } + + bb1: { + _2 = &_3; + _1 = copy _2; +- StorageDead(_2); ++ nop; + StorageLive(_4); +- _9 = deref_copy _3; ++ _9 = copy _3; + _10 = copy ((_9.0: std::ptr::Unique<()>).0: std::ptr::NonNull<()>) as *const () (Transmute); + _4 = copy _10; +- StorageLive(_5); ++ nop; + StorageLive(_6); +- _6 = copy _4; ++ _6 = copy _10; + StorageLive(_11); + _11 = const 1_usize; +- _5 = *const [()] from (copy _6, copy _11); ++ _5 = *const [()] from (copy _10, const 1_usize); + StorageDead(_11); + StorageDead(_6); + StorageLive(_7); + StorageLive(_8); + _8 = copy _5; +- _7 = copy _8 as *mut () (PtrToPtr); ++ _7 = copy _5 as *mut () (PtrToPtr); + StorageDead(_8); + StorageDead(_7); +- StorageDead(_5); ++ nop; + StorageDead(_4); + drop(_3) -> [return: bb2, unwind: bb3]; + } + + bb2: { + StorageDead(_3); + StorageDead(_1); + return; + } + + bb3 (cleanup): { + resume; + } + } + diff --git a/tests/mir-opt/pattern_types.main.PreCodegen.after.mir b/tests/mir-opt/pattern_types.main.PreCodegen.after.mir index 8c99902f9b8..5ff90de9615 100644 --- a/tests/mir-opt/pattern_types.main.PreCodegen.after.mir +++ b/tests/mir-opt/pattern_types.main.PreCodegen.after.mir @@ -5,7 +5,7 @@ fn main() -> () { scope 1 { debug x => const 2_u32 is 1..=; scope 2 { - debug y => const 0_u32 is 1..=; + debug y => const {transmute(0x00000000): (u32) is 1..=}; } } diff --git a/tests/mir-opt/pattern_types.rs b/tests/mir-opt/pattern_types.rs index 217c64b90cb..0369ccf9a9d 100644 --- a/tests/mir-opt/pattern_types.rs +++ b/tests/mir-opt/pattern_types.rs @@ -7,6 +7,6 @@ use std::pat::pattern_type; fn main() { // CHECK: debug x => const 2_u32 is 1..= let x: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(2) }; - // CHECK: debug y => const 0_u32 is 1..= + // CHECK: debug y => const {transmute(0x00000000): (u32) is 1..=} let y: pattern_type!(u32 is 1..) = unsafe { std::mem::transmute(0) }; } diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir index 60c0b8afa53..3f000dcafb0 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-abort.mir @@ -19,16 +19,16 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { scope 2 { debug x => _9; } - scope 5 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) { + scope 5 (inlined iter::range::<impl Iterator for std::ops::RangeInclusive<u32>>::next) { } } - scope 3 (inlined RangeInclusive::<u32>::new) { + scope 3 (inlined std::ops::RangeInclusive::<u32>::new) { } - scope 4 (inlined <RangeInclusive<u32> as IntoIterator>::into_iter) { + scope 4 (inlined <std::ops::RangeInclusive<u32> as IntoIterator>::into_iter) { } bb0: { - _4 = RangeInclusive::<u32> { start: copy _1, end: copy _2, exhausted: const false }; + _4 = std::ops::RangeInclusive::<u32> { start: copy _1, end: copy _2, exhausted: const false }; StorageLive(_5); _5 = copy _4; goto -> bb1; @@ -37,7 +37,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb1: { StorageLive(_7); _6 = &mut _5; - _7 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind unreachable]; + _7 = <std::ops::RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind unreachable]; } bb2: { diff --git a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir index 7145da58ce1..23537173627 100644 --- a/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.inclusive_loop.PreCodegen.after.panic-unwind.mir @@ -19,16 +19,16 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { scope 2 { debug x => _9; } - scope 5 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) { + scope 5 (inlined iter::range::<impl Iterator for std::ops::RangeInclusive<u32>>::next) { } } - scope 3 (inlined RangeInclusive::<u32>::new) { + scope 3 (inlined std::ops::RangeInclusive::<u32>::new) { } - scope 4 (inlined <RangeInclusive<u32> as IntoIterator>::into_iter) { + scope 4 (inlined <std::ops::RangeInclusive<u32> as IntoIterator>::into_iter) { } bb0: { - _4 = RangeInclusive::<u32> { start: copy _1, end: copy _2, exhausted: const false }; + _4 = std::ops::RangeInclusive::<u32> { start: copy _1, end: copy _2, exhausted: const false }; StorageLive(_5); _5 = copy _4; goto -> bb1; @@ -37,7 +37,7 @@ fn inclusive_loop(_1: u32, _2: u32, _3: impl Fn(u32)) -> () { bb1: { StorageLive(_7); _6 = &mut _5; - _7 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind: bb8]; + _7 = <std::ops::RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _6) -> [return: bb2, unwind: bb8]; } bb2: { diff --git a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir index 8e038246fa2..13969e5d238 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-abort.mir @@ -1,13 +1,13 @@ // MIR for `range_inclusive_iter_next` after PreCodegen -fn range_inclusive_iter_next(_1: &mut RangeInclusive<u32>) -> Option<u32> { +fn range_inclusive_iter_next(_1: &mut std::ops::RangeInclusive<u32>) -> Option<u32> { debug it => _1; let mut _0: std::option::Option<u32>; - scope 1 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) { + scope 1 (inlined iter::range::<impl Iterator for std::ops::RangeInclusive<u32>>::next) { } bb0: { - _0 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _1) -> [return: bb1, unwind unreachable]; + _0 = <std::ops::RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _1) -> [return: bb1, unwind unreachable]; } bb1: { diff --git a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir index f54d003c662..98cd58284df 100644 --- a/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir +++ b/tests/mir-opt/pre-codegen/range_iter.range_inclusive_iter_next.PreCodegen.after.panic-unwind.mir @@ -1,13 +1,13 @@ // MIR for `range_inclusive_iter_next` after PreCodegen -fn range_inclusive_iter_next(_1: &mut RangeInclusive<u32>) -> Option<u32> { +fn range_inclusive_iter_next(_1: &mut std::ops::RangeInclusive<u32>) -> Option<u32> { debug it => _1; let mut _0: std::option::Option<u32>; - scope 1 (inlined iter::range::<impl Iterator for RangeInclusive<u32>>::next) { + scope 1 (inlined iter::range::<impl Iterator for std::ops::RangeInclusive<u32>>::next) { } bb0: { - _0 = <RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _1) -> [return: bb1, unwind continue]; + _0 = <std::ops::RangeInclusive<u32> as iter::range::RangeInclusiveIteratorImpl>::spec_next(move _1) -> [return: bb1, unwind continue]; } bb1: { diff --git a/tests/run-make/libs-through-symlinks/rmake.rs b/tests/run-make/libs-through-symlinks/rmake.rs index 4bb3d05abb7..894d6246445 100644 --- a/tests/run-make/libs-through-symlinks/rmake.rs +++ b/tests/run-make/libs-through-symlinks/rmake.rs @@ -21,6 +21,7 @@ //! <https://github.com/rust-lang/rust/pull/13903>. //@ ignore-cross-compile +//@ needs-symlink use run_make_support::{bare_rustc, cwd, path, rfs, rust_lib_name}; diff --git a/tests/run-make/split-debuginfo/Makefile b/tests/run-make/split-debuginfo/Makefile deleted file mode 100644 index 5f463ffe8cd..00000000000 --- a/tests/run-make/split-debuginfo/Makefile +++ /dev/null @@ -1,371 +0,0 @@ -# ignore-cross-compile -# ignore-riscv64 On this platform only `-Csplit-debuginfo=off` is supported, see #120518 - -include ../tools.mk - -all: off packed unpacked - -ifeq ($(UNAME),Darwin) -# If disabled, don't run `dsymutil`. -off: - rm -rf $(TMPDIR)/*.dSYM - $(RUSTC) foo.rs -g -C split-debuginfo=off - [ ! -d $(TMPDIR)/foo.dSYM ] - -# Packed by default, but only if debuginfo is requested -packed: - rm -rf $(TMPDIR)/*.dSYM - $(RUSTC) foo.rs - [ ! -d $(TMPDIR)/foo.dSYM ] - rm -rf $(TMPDIR)/*.dSYM - $(RUSTC) foo.rs -g - [ -d $(TMPDIR)/foo.dSYM ] - rm -rf $(TMPDIR)/*.dSYM - $(RUSTC) foo.rs -g -C split-debuginfo=packed - [ -d $(TMPDIR)/foo.dSYM ] - rm -rf $(TMPDIR)/*.dSYM - -# Object files are preserved with unpacked and `dsymutil` isn't run -unpacked: - $(RUSTC) foo.rs -g -C split-debuginfo=unpacked - ls $(TMPDIR)/*.o - [ ! -d $(TMPDIR)/foo.dSYM ] -else -ifdef IS_WINDOWS -# Windows only supports packed debuginfo - nothing to test. -off: -packed: -unpacked: -else -# Some non-Windows, non-Darwin platforms are not stable, and some are. -ifeq ($(UNAME),Linux) - UNSTABLEOPTS := -else - UNSTABLEOPTS := -Zunstable-options -endif - -# - Debuginfo in `.o` files -# - `.o` deleted -# - `.dwo` never created -# - `.dwp` never created -off: - $(RUSTC) foo.rs -g -C $(UNSTABLEOPTS) split-debuginfo=off - [ ! -f $(TMPDIR)/*.dwp ] - [ ! -f $(TMPDIR)/*.dwo ] - $(RUSTC) foo.rs -g - [ ! -f $(TMPDIR)/*.dwp ] - [ ! -f $(TMPDIR)/*.dwo ] - -packed: packed-split packed-single packed-lto packed-remapped packed-crosscrate - -# - Debuginfo in `.dwo` files -# - `.o` deleted -# - `.dwo` deleted -# - `.dwp` present -packed-split: - $(RUSTC) foo.rs -g $(UNSTABLEOPTS) -C split-debuginfo=packed -Zsplit-dwarf-kind=split - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - rm $(TMPDIR)/foo.dwp - rm $(TMPDIR)/$(call BIN,foo) - -# - Debuginfo in `.o` files -# - `.o` deleted -# - `.dwo` never created -# - `.dwp` present -packed-single: - $(RUSTC) foo.rs -g $(UNSTABLEOPTS) -C split-debuginfo=packed -Zsplit-dwarf-kind=single - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - rm $(TMPDIR)/foo.dwp - rm $(TMPDIR)/$(call BIN,foo) - -packed-lto: packed-lto-split packed-lto-single - -# - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated -# - `.o` never created -# - `.dwo` never created -# - `.dwp` never created -packed-lto-split: - $(RUSTC) baz.rs -g $(UNSTABLEOPTS) -Csplit-debuginfo=packed -Zsplit-dwarf-kind=split \ - --crate-type=rlib -Clinker-plugin-lto - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - rm $(TMPDIR)/libbaz.rlib - -# - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated -# - `.o` never created -# - `.dwo` never created -# - `.dwp` never created -packed-lto-single: - $(RUSTC) baz.rs -g $(UNSTABLEOPTS) -Csplit-debuginfo=packed -Zsplit-dwarf-kind=single \ - --crate-type=rlib -Clinker-plugin-lto - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - rm $(TMPDIR)/libbaz.rlib - -packed-remapped: packed-remapped-split packed-remapped-single packed-remapped-scope packed-remapped-wrong-scope - -# - Debuginfo in `.dwo` files -# - `.o` and binary refer to remapped `.dwo` paths which do not exist -# - `.o` deleted -# - `.dwo` deleted -# - `.dwp` present -packed-remapped-split: - $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \ - -Z split-dwarf-kind=split --remap-path-prefix $(TMPDIR)=/a foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - rm $(TMPDIR)/foo.dwp - rm $(TMPDIR)/$(call BIN,foo) - -# - Debuginfo in `.o` files -# - `.o` and binary refer to remapped `.o` paths which do not exist -# - `.o` deleted -# - `.dwo` never created -# - `.dwp` present -packed-remapped-single: - $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \ - -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - rm $(TMPDIR)/foo.dwp - rm $(TMPDIR)/$(call BIN,foo) - -# - Debuginfo in `.o` files -# - `.o` and binary refer to remapped `.o` paths which do not exist -# - `.o` deleted -# - `.dwo` never created -# - `.dwp` present -packed-remapped-scope: - $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \ - -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \ - -Z remap-path-scope=debuginfo foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - rm $(TMPDIR)/foo.dwp - rm $(TMPDIR)/$(call BIN,foo) - -# - Debuginfo in `.o` files -# - `.o` and binary refer to remapped `.o` paths which do not exist -# - `.o` deleted -# - `.dwo` never created -# - `.dwp` present -packed-remapped-wrong-scope: - $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=packed -C debuginfo=2 \ - -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \ - -Z remap-path-scope=macro foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (grep $(TMPDIR)) || exit 1 - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - rm $(TMPDIR)/foo.dwp - rm $(TMPDIR)/$(call BIN,foo) - -packed-crosscrate: packed-crosscrate-split packed-crosscrate-single - -# - Debuginfo in `.dwo` files -# - (bar) `.rlib` file created, contains `.dwo` -# - (bar) `.o` deleted -# - (bar) `.dwo` deleted -# - (bar) `.dwp` never created -# - (main) `.o` deleted -# - (main) `.dwo` deleted -# - (main) `.dwp` present -packed-crosscrate-split: - $(RUSTC) --crate-type lib $(UNSTABLEOPTS) -C split-debuginfo=packed \ - -Zsplit-dwarf-kind=split -C debuginfo=2 -g bar.rs - ls $(TMPDIR)/*.rlib - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - $(RUSTC) --extern bar=$(TMPDIR)/libbar.rlib $(UNSTABLEOPTS) \ - -C split-debuginfo=packed -Zsplit-dwarf-kind=split -C debuginfo=2 -g main.rs - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - rm $(TMPDIR)/main.dwp - rm $(TMPDIR)/$(call BIN,main) - -# - Debuginfo in `.o` files -# - (bar) `.rlib` file created, contains `.o` -# - (bar) `.o` deleted -# - (bar) `.dwo` never created -# - (bar) `.dwp` never created -# - (main) `.o` deleted -# - (main) `.dwo` never created -# - (main) `.dwp` present -packed-crosscrate-single: - $(RUSTC) --crate-type lib $(UNSTABLEOPTS) -C split-debuginfo=packed \ - -Zsplit-dwarf-kind=single -C debuginfo=2 -g bar.rs - ls $(TMPDIR)/*.rlib - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - $(RUSTC) --extern bar=$(TMPDIR)/libbar.rlib $(UNSTABLEOPTS) \ - -C split-debuginfo=packed -Zsplit-dwarf-kind=single -C debuginfo=2 -g main.rs - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - rm $(TMPDIR)/main.dwp - rm $(TMPDIR)/$(call BIN,main) - -unpacked: unpacked-split unpacked-single unpacked-lto unpacked-remapped unpacked-crosscrate - -# - Debuginfo in `.dwo` files -# - `.o` deleted -# - `.dwo` present -# - `.dwp` never created -unpacked-split: - $(RUSTC) foo.rs -g $(UNSTABLEOPTS) -C split-debuginfo=unpacked -Zsplit-dwarf-kind=split - ls $(TMPDIR)/*.o && exit 1 || exit 0 - rm $(TMPDIR)/*.dwo - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - rm $(TMPDIR)/$(call BIN,foo) - -# - Debuginfo in `.o` files -# - `.o` present -# - `.dwo` never created -# - `.dwp` never created -unpacked-single: - $(RUSTC) foo.rs -g $(UNSTABLEOPTS) -C split-debuginfo=unpacked -Zsplit-dwarf-kind=single - ls $(TMPDIR)/*.o - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - rm $(TMPDIR)/$(call BIN,foo) - -unpacked-lto: unpacked-lto-split unpacked-lto-single - -# - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated -# - `.o` present (bitcode) -# - `.dwo` never created -# - `.dwp` never created -unpacked-lto-split: - $(RUSTC) baz.rs -g $(UNSTABLEOPTS) -Csplit-debuginfo=unpacked -Zsplit-dwarf-kind=split \ - --crate-type=rlib -Clinker-plugin-lto - rm $(TMPDIR)/*.o - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - rm $(TMPDIR)/libbaz.rlib - -# - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated -# - `.o` present (bitcode) -# - `.dwo` never created -# - `.dwp` never created -unpacked-lto-single: - $(RUSTC) baz.rs -g $(UNSTABLEOPTS) -Csplit-debuginfo=unpacked -Zsplit-dwarf-kind=single \ - --crate-type=rlib -Clinker-plugin-lto - rm $(TMPDIR)/*.o - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - rm $(TMPDIR)/libbaz.rlib - -unpacked-remapped: unpacked-remapped-split unpacked-remapped-single unpacked-remapped-scope unpacked-remapped-wrong-scope - -# - Debuginfo in `.dwo` files -# - `.o` and binary refer to remapped `.dwo` paths which do not exist -# - `.o` deleted -# - `.dwo` present -# - `.dwp` never created -unpacked-remapped-split: - $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ - -Z split-dwarf-kind=split --remap-path-prefix $(TMPDIR)=/a foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 - ls $(TMPDIR)/*.o && exit 1 || exit 0 - rm $(TMPDIR)/*.dwo - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - rm $(TMPDIR)/$(call BIN,foo) - -# - Debuginfo in `.o` files -# - `.o` and binary refer to remapped `.o` paths which do not exist -# - `.o` present -# - `.dwo` never created -# - `.dwp` never created -unpacked-remapped-single: - $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ - -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 - rm $(TMPDIR)/*.o - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - rm $(TMPDIR)/$(call BIN,foo) - -# - Debuginfo in `.o` files -# - `.o` and binary refer to remapped `.o` paths which do not exist -# - `.o` present -# - `.dwo` never created -# - `.dwp` never created -unpacked-remapped-scope: - $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ - -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \ - -Z remap-path-scope=debuginfo foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (! grep $(TMPDIR)) || exit 1 - rm $(TMPDIR)/*.o - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - rm $(TMPDIR)/$(call BIN,foo) - -# - Debuginfo in `.o` files -# - `.o` and binary refer to remapped `.o` paths which do not exist -# - `.o` present -# - `.dwo` never created -# - `.dwp` never created -unpacked-remapped-wrong-scope: - $(RUSTC) $(UNSTABLEOPTS) -C split-debuginfo=unpacked -C debuginfo=2 \ - -Z split-dwarf-kind=single --remap-path-prefix $(TMPDIR)=/a \ - -Z remap-path-scope=macro foo.rs -g - objdump -Wi $(TMPDIR)/foo | grep DW_AT_GNU_dwo_name | (grep $(TMPDIR)) || exit 1 - rm $(TMPDIR)/*.o - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - rm $(TMPDIR)/$(call BIN,foo) - -unpacked-crosscrate: unpacked-crosscrate-split unpacked-crosscrate-single - -# - Debuginfo in `.dwo` files -# - (bar) `.rlib` file created, contains `.dwo` -# - (bar) `.o` deleted -# - (bar) `.dwo` present -# - (bar) `.dwp` never created -# - (main) `.o` deleted -# - (main) `.dwo` present -# - (main) `.dwp` never created -unpacked-crosscrate-split: - $(RUSTC) --crate-type lib $(UNSTABLEOPTS) -C split-debuginfo=unpacked \ - -Zsplit-dwarf-kind=split -C debuginfo=2 -g bar.rs - ls $(TMPDIR)/*.rlib - ls $(TMPDIR)/*.o && exit 1 || exit 0 - ls $(TMPDIR)/*.dwo - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - $(RUSTC) --extern bar=$(TMPDIR)/libbar.rlib $(UNSTABLEOPTS) \ - -C split-debuginfo=unpacked -Zsplit-dwarf-kind=split -C debuginfo=2 -g main.rs - ls $(TMPDIR)/*.o && exit 1 || exit 0 - rm $(TMPDIR)/*.dwo - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - rm $(TMPDIR)/$(call BIN,main) - -# - Debuginfo in `.o` files -# - (bar) `.rlib` file created, contains `.o` -# - (bar) `.o` present -# - (bar) `.dwo` never created -# - (bar) `.dwp` never created -# - (main) `.o` present -# - (main) `.dwo` never created -# - (main) `.dwp` never created -unpacked-crosscrate-single: - $(RUSTC) --crate-type lib $(UNSTABLEOPTS) -C split-debuginfo=unpacked \ - -Zsplit-dwarf-kind=single -C debuginfo=2 -g bar.rs - ls $(TMPDIR)/*.rlib - ls $(TMPDIR)/*.o - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - $(RUSTC) --extern bar=$(TMPDIR)/libbar.rlib $(UNSTABLEOPTS) \ - -C split-debuginfo=unpacked -Zsplit-dwarf-kind=single -C debuginfo=2 -g main.rs - ls $(TMPDIR)/*.o - ls $(TMPDIR)/*.dwo && exit 1 || exit 0 - ls $(TMPDIR)/*.dwp && exit 1 || exit 0 - rm $(TMPDIR)/$(call BIN,main) -endif -endif diff --git a/tests/run-make/split-debuginfo/rmake.rs b/tests/run-make/split-debuginfo/rmake.rs new file mode 100644 index 00000000000..530a5d119f1 --- /dev/null +++ b/tests/run-make/split-debuginfo/rmake.rs @@ -0,0 +1,1618 @@ +// ignore-tidy-linelength +//! Basic smoke tests for behavior of `-C split-debuginfo` and the combined behavior when used in +//! conjunction with other flags such as: +//! +//! - `--remap-path-prefix`: see +//! <https://doc.rust-lang.org/rustc/command-line-arguments.html#--remap-path-prefix-remap-source-names-in-output>. +//! - `-Z remap-path-scope`: see +//! - <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/remap-path-scope.html> +//! - <https://github.com/rust-lang/rust/issues/111540> +//! - RFC #3127 trim-paths: <https://github.com/rust-lang/rfcs/pull/3127> +//! - `-Z split-dwarf-kind`: see <https://github.com/rust-lang/rust/pull/89819>. +//! - `-Clinker-plugin-lto`: see <https://doc.rust-lang.org/rustc/linker-plugin-lto.html>. +//! +//! # Test implementation remark +//! +//! - The pattern match on enum variants are intentional, because I find that they are very +//! revealing with respect to the kind of test coverage that we have and don't have. +//! +//! # Known limitations +//! +//! - The linux test coverage of cross-interactions between `-C split-debuginfo` and other flags are +//! significantly higher than the lack of such coverage for Windows and Darwin. +//! - windows-gnu is not tested at all, see the `FIXME(#135531)`s below. +//! - This test for the most part merely checks for existence/absence of certain artifacts, it does +//! not sanity check if the debuginfo artifacts are actually usable or contains the expected +//! amount/quality of debuginfo, especially on windows-msvc and darwin. +//! - FIXME(#111540): this test has insufficient coverage in relation to trim-paths RFC, see also +//! the comment <https://github.com/rust-lang/rust/issues/111540#issuecomment-1994010274>. The +//! basic `llvm-dwarfdump` textual output inspection here is very fragile. The original `Makefile` +//! version used `objdump` (not to be confused with `llvm-objdump`) but inspected the wrong line +//! because it was looking at `DW_AT_GNU_dwo_name` when it should've been looking at +//! `DW_AT_comp_dir`. +//! - This test does not have good coverage for what values of `-Csplit-debuginfo` are stable vs +//! non-stable for the various targets, i.e. which values *should* be gated behind +//! `-Zunstable-options` for a given target. The `Makefile` version yolo'd a `-Zunstable-options` +//! for non-windows + non-linux + non-darwin, but had a misplaced interpolation which suggested to +//! me that that conditional `-Zunstable-options` never actually materialized. +//! +//! # Additional references +//! +//! - Apple `.dSYM` debug symbol bundles: <https://lldb.llvm.org/use/symbols.html>. +//! - LLVM `dsymutil`: <https://llvm.org/docs/CommandGuide/dsymutil.html>. + +// NOTE: this is a host test +//@ ignore-cross-compile + +// NOTE: this seems to be a host test, and testing on host `riscv64-gc-unknown-linux-gnu` reveals +// that this test is failing because of [MC: "error: A dwo section may not contain relocations" when +// building with fission + RISCV64 #56642](https://github.com/llvm/llvm-project/issues/56642). This +// test is ignored for now to unblock efforts to bring riscv64 targets to be exercised in CI, cf. +// [Enable riscv64gc-gnu testing #126641](https://github.com/rust-lang/rust/pull/126641). +//@ ignore-riscv64 (https://github.com/llvm/llvm-project/issues/56642) + +// FIXME(#135531): the `Makefile` version practically didn't test `-C split-debuginfo` on Windows +// at all, and lumped windows-msvc and windows-gnu together at that. +//@ ignore-windows-gnu + +#![deny(warnings)] + +use std::collections::BTreeSet; + +use run_make_support::rustc::Rustc; +use run_make_support::{ + cwd, has_extension, is_darwin, is_msvc, is_windows, llvm_dwarfdump, run_in_tmpdir, rustc, + shallow_find_directories, shallow_find_files, uname, +}; + +/// `-C debuginfo`. See <https://doc.rust-lang.org/rustc/codegen-options/index.html#debuginfo>. +#[derive(Debug, PartialEq, Copy, Clone)] +enum DebuginfoLevel { + /// `-C debuginfo=0` or `-C debuginfo=none` aka no debuginfo at all, default. + None, + /// `-C debuginfo=2` aka full debuginfo, aliased via `-g`. + Full, + /// The cli flag is not explicitly provided; default. + Unspecified, +} + +impl DebuginfoLevel { + fn cli_value(&self) -> &'static str { + // `-Cdebuginfo=...` + match self { + DebuginfoLevel::None => "none", + DebuginfoLevel::Full => "2", + DebuginfoLevel::Unspecified => unreachable!(), + } + } +} + +/// `-C split-debuginfo`. See +/// <https://doc.rust-lang.org/rustc/codegen-options/index.html#split-debuginfo>. +/// +/// Note that all three options are supported on Linux and Apple platforms, packed is supported on +/// Windows-MSVC, and all other platforms support off. Attempting to use an unsupported option +/// requires using the nightly channel with the `-Z unstable-options` flag. +#[derive(Debug, PartialEq, Copy, Clone)] +enum SplitDebuginfo { + /// `-C split-debuginfo=off`. Default for platforms with ELF binaries and windows-gnu (not + /// Windows MSVC and not macOS). Typically DWARF debug information can be found in the final + /// artifact in sections of the executable. + /// + /// - Not supported on Windows MSVC. + /// - On macOS this options prevents the final execution of `dsymutil` to generate debuginfo. + Off, + /// `-C split-debuginfo=unpacked`. Debug information will be found in separate files for each + /// compilation unit (object file). + /// + /// - Not supported on Windows MSVC. + /// - On macOS this means the original object files will contain debug information. + /// - On other Unix platforms this means that `*.dwo` files will contain debug information. + Unpacked, + /// `-C split-debuginfo=packed`. Default for Windows MSVC and macOS. "Packed" here means that + /// all the debug information is packed into a separate file from the main executable. + /// + /// - On Windows MSVC this is a `*.pdb` file. + /// - On macOS this is a `*.dSYM` folder. + /// - On other platforms this is a `*.dwp` file. + Packed, + /// The cli flag is not explicitly provided; uses platform default. + Unspecified, +} + +impl SplitDebuginfo { + fn cli_value(&self) -> &'static str { + // `-Csplit-debuginfo=...` + match self { + SplitDebuginfo::Off => "off", + SplitDebuginfo::Unpacked => "unpacked", + SplitDebuginfo::Packed => "packed", + SplitDebuginfo::Unspecified => unreachable!(), + } + } +} + +/// `-Z split-dwarf-kind` +#[derive(Debug, PartialEq, Copy, Clone)] +enum SplitDwarfKind { + /// `-Zsplit-dwarf-kind=split` + Split, + /// `-Zsplit-dwarf-kind=single` + Single, + Unspecified, +} + +impl SplitDwarfKind { + fn cli_value(&self) -> &'static str { + // `-Zsplit-dwarf-kind=...` + match self { + SplitDwarfKind::Split => "split", + SplitDwarfKind::Single => "single", + SplitDwarfKind::Unspecified => unreachable!(), + } + } +} + +/// `-C linker-plugin-lto` +#[derive(Debug, PartialEq, Copy, Clone)] +enum LinkerPluginLto { + /// Pass `-C linker-plugin-lto`. + Yes, + /// Don't pass `-C linker-plugin-lto`. + Unspecified, +} + +/// `--remap-path-prefix` or not. +#[derive(Debug, Clone)] +enum RemapPathPrefix { + /// `--remap-path-prefix=$prefix=$remapped_prefix`. + Yes { remapped_prefix: &'static str }, + /// Don't pass `--remap-path-prefix`. + Unspecified, +} + +/// `-Zremap-path-scope`. See +/// <https://doc.rust-lang.org/nightly/unstable-book/compiler-flags/remap-path-scope.html#remap-path-scope>. +#[derive(Debug, Clone)] +enum RemapPathScope { + /// Comma-separated list of remap scopes: `macro`, `diagnostics`, `debuginfo`, `object`, `all`. + Yes(&'static str), + Unspecified, +} + +/// Whether to pass `-Zunstable-options`. +#[derive(Debug, PartialEq, Copy, Clone)] +enum UnstableOptions { + Yes, + Unspecified, +} + +#[track_caller] +fn cwd_filenames() -> BTreeSet<String> { + let files = shallow_find_files(cwd(), |path| { + // Fiilter out source files + !has_extension(path, "rs") + }); + files.iter().map(|p| p.file_name().unwrap().to_os_string().into_string().unwrap()).collect() +} + +#[track_caller] +fn cwd_dwo_filenames() -> BTreeSet<String> { + let files = shallow_find_files(cwd(), |path| has_extension(path, "dwo")); + files.iter().map(|p| p.file_name().unwrap().to_os_string().into_string().unwrap()).collect() +} + +#[track_caller] +fn cwd_object_filenames() -> BTreeSet<String> { + let files = shallow_find_files(cwd(), |path| has_extension(path, "o")); + files.iter().map(|p| p.file_name().unwrap().to_os_string().into_string().unwrap()).collect() +} + +#[must_use] +struct FileAssertions<'expected> { + expected_files: BTreeSet<&'expected str>, +} + +impl<'expected> FileAssertions<'expected> { + #[track_caller] + fn assert_on(self, found_files: &BTreeSet<String>) { + let found_files: BTreeSet<_> = found_files.iter().map(|f| f.as_str()).collect(); + assert!( + found_files.is_superset(&self.expected_files), + "expected {:?} to exist, but only found {:?}", + self.expected_files, + found_files + ); + + let unexpected_files: BTreeSet<_> = + found_files.difference(&self.expected_files).copied().collect(); + assert!(unexpected_files.is_empty(), "found unexpected files: {:?}", unexpected_files); + } +} + +/// Windows MSVC only supports packed debuginfo. +mod windows_msvc_tests { + use super::*; + + pub(crate) fn split_debuginfo(split_kind: SplitDebuginfo, level: DebuginfoLevel) { + // NOTE: `-C debuginfo` and other flags are not exercised here on Windows MSVC. + run_in_tmpdir(|| { + println!("checking: split_kind={:?} + level={:?}", split_kind, level); + match (split_kind, level) { + (SplitDebuginfo::Off, _) => { + rustc() + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .run_fail() + .assert_stderr_contains( + "error: `-Csplit-debuginfo=off` is unstable on this platform", + ); + } + (SplitDebuginfo::Unpacked, _) => { + rustc() + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .run_fail() + .assert_stderr_contains( + "error: `-Csplit-debuginfo=unpacked` is unstable on this platform", + ); + } + (SplitDebuginfo::Packed, _) => { + rustc().input("foo.rs").split_debuginfo(split_kind.cli_value()).run(); + + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["foo.exe", "foo.pdb"]) } + .assert_on(&found_files); + } + (split_kind, level) => { + panic!( + "split_kind={:?} + level={:?} is not handled on Windows MSVC", + split_kind, level + ) + } + } + }); + } +} + +mod darwin_tests { + use super::*; + + pub(crate) fn split_debuginfo(split_kind: SplitDebuginfo, level: DebuginfoLevel) { + run_in_tmpdir(|| { + println!("checking: split_kind={:?} + level={:?}", split_kind, level); + + let dsym_directories = + || shallow_find_directories(cwd(), |path| has_extension(path, "dSYM")); + + match (split_kind, level) { + (_, DebuginfoLevel::Unspecified) => { + rustc().input("foo.rs").run(); + let directories = + shallow_find_directories(cwd(), |path| has_extension(path, "dSYM")); + assert!( + directories.is_empty(), + "expected no `*.dSYM` folder to be generated when `-Cdebuginfo` is not specified" + ); + } + (_, DebuginfoLevel::None) => { + rustc().input("foo.rs").debuginfo(level.cli_value()).run(); + let directories = dsym_directories(); + assert!( + directories.is_empty(), + "expected no `*.dSYM` folder to be generated when `-Cdebuginfo=none`" + ); + } + (SplitDebuginfo::Off, _) => { + rustc() + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .run(); + let directories = dsym_directories(); + assert!( + directories.is_empty(), + "expected no `*.dSYM` folder to be generated since we expect `-Csplit-debuginfo=off` to inhibit final debuginfo generation on macOS" + ); + } + (SplitDebuginfo::Unpacked, _) => { + rustc().input("foo.rs").split_debuginfo(split_kind.cli_value()).run(); + let directories = dsym_directories(); + assert!( + directories.is_empty(), + "expected no `*.dSYM` folder to be generated since we expect on macOS the object files to contain debuginfo instead" + ); + } + (SplitDebuginfo::Packed, DebuginfoLevel::Full) => { + rustc() + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .run(); + let directories = shallow_find_directories(cwd(), |path| { + path.file_name().unwrap() == "foo.dSYM" + }); + assert_eq!(directories.len(), 1, "failed to find `foo.dSYM`"); + } + (SplitDebuginfo::Unspecified, DebuginfoLevel::Full) => { + rustc().input("foo.rs").debuginfo(level.cli_value()).run(); + let directories = shallow_find_directories(cwd(), |path| { + path.file_name().unwrap() == "foo.dSYM" + }); + assert_eq!(directories.len(), 1, "failed to find `foo.dSYM`"); + } + } + }); + } +} + +mod shared_linux_other_tests { + use std::path::PathBuf; + + use super::*; + + fn rustc(unstable_options: UnstableOptions) -> Rustc { + if unstable_options == UnstableOptions::Yes { + let mut rustc = run_make_support::rustc(); + rustc.arg("-Zunstable-options"); + rustc + } else { + run_make_support::rustc() + } + } + + #[derive(PartialEq)] + pub(crate) enum CrossCrateTest { + Yes, + No, + } + + pub(crate) fn split_debuginfo( + cross_crate_test: CrossCrateTest, + unstable_options: UnstableOptions, + split_kind: SplitDebuginfo, + level: DebuginfoLevel, + split_dwarf_kind: SplitDwarfKind, + lto: LinkerPluginLto, + remap_path_prefix: RemapPathPrefix, + remap_path_scope: RemapPathScope, + ) { + run_in_tmpdir(|| { + println!( + "checking: unstable_options={:?} + split_kind={:?} + level={:?} + split_dwarf_kind={:?} + lto={:?} + remap_path_prefix={:?} + remap_path_scope={:?}", + unstable_options, + split_kind, + level, + split_dwarf_kind, + lto, + remap_path_prefix, + remap_path_scope + ); + + match cross_crate_test { + CrossCrateTest::Yes => cross_crate_split_debuginfo( + unstable_options, + split_kind, + level, + split_dwarf_kind, + lto, + remap_path_prefix, + remap_path_scope, + ), + CrossCrateTest::No => simple_split_debuginfo( + unstable_options, + split_kind, + level, + split_dwarf_kind, + lto, + remap_path_prefix, + remap_path_scope, + ), + } + }); + } + + fn cross_crate_split_debuginfo( + unstable_options: UnstableOptions, + split_kind: SplitDebuginfo, + level: DebuginfoLevel, + split_dwarf_kind: SplitDwarfKind, + lto: LinkerPluginLto, + remap_path_prefix: RemapPathPrefix, + remap_path_scope: RemapPathScope, + ) { + match (split_kind, level, split_dwarf_kind, lto, remap_path_prefix, remap_path_scope) { + // packed-crosscrate-split + // - Debuginfo in `.dwo` files + // - (bar) `.rlib` file created, contains `.dwo` + // - (bar) `.o` deleted + // - (bar) `.dwo` deleted + // - (bar) `.dwp` never created + // - (main) `.o` deleted + // - (main) `.dwo` deleted + // - (main) `.dwp` present + ( + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("bar.rs") + .crate_type("lib") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .run(); + + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["libbar.rlib"]) } + .assert_on(&found_files); + + rustc(unstable_options) + .extern_("bar", "libbar.rlib") + .input("main.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .run(); + + let found_files = cwd_filenames(); + FileAssertions { + expected_files: BTreeSet::from(["libbar.rlib", "main", "main.dwp"]), + } + .assert_on(&found_files); + } + + // packed-crosscrate-single + // - Debuginfo in `.o` files + // - (bar) `.rlib` file created, contains `.o` + // - (bar) `.o` deleted + // - (bar) `.dwo` never created + // - (bar) `.dwp` never created + // - (main) `.o` deleted + // - (main) `.dwo` never created + // - (main) `.dwp` present + ( + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("bar.rs") + .crate_type("lib") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .run(); + + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["libbar.rlib"]) } + .assert_on(&found_files); + + rustc(unstable_options) + .extern_("bar", "libbar.rlib") + .input("main.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .run(); + + let found_files = cwd_filenames(); + FileAssertions { + expected_files: BTreeSet::from(["libbar.rlib", "main", "main.dwp"]), + } + .assert_on(&found_files); + } + + // unpacked-crosscrate-split + // - Debuginfo in `.dwo` files + // - (bar) `.rlib` file created, contains `.dwo` + // - (bar) `.o` deleted + // - (bar) `.dwo` present + // - (bar) `.dwp` never created + // - (main) `.o` deleted + // - (main) `.dwo` present + // - (main) `.dwp` never created + ( + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("bar.rs") + .crate_type("lib") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .run(); + + let bar_found_files = cwd_filenames(); + + let bar_dwo_files = cwd_dwo_filenames(); + assert_eq!(bar_dwo_files.len(), 1); + + let mut bar_expected_files = BTreeSet::new(); + bar_expected_files.extend(bar_dwo_files); + bar_expected_files.insert("libbar.rlib".to_string()); + + FileAssertions { + expected_files: bar_expected_files.iter().map(String::as_ref).collect(), + } + .assert_on(&bar_found_files); + + rustc(unstable_options) + .extern_("bar", "libbar.rlib") + .input("main.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .run(); + + let overall_found_files = cwd_filenames(); + + let overall_dwo_files = cwd_dwo_filenames(); + assert_eq!(overall_dwo_files.len(), 2); + + let mut overall_expected_files = BTreeSet::new(); + overall_expected_files.extend(overall_dwo_files); + overall_expected_files.insert("main".to_string()); + overall_expected_files.insert("libbar.rlib".to_string()); + + FileAssertions { + expected_files: overall_expected_files.iter().map(String::as_ref).collect(), + } + .assert_on(&overall_found_files); + } + + // unpacked-crosscrate-single + // - Debuginfo in `.o` files + // - (bar) `.rlib` file created, contains `.o` + // - (bar) `.o` present + // - (bar) `.dwo` never created + // - (bar) `.dwp` never created + // - (main) `.o` present + // - (main) `.dwo` never created + // - (main) `.dwp` never created + ( + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("bar.rs") + .crate_type("lib") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .run(); + + let bar_found_files = cwd_filenames(); + + let bar_object_files = cwd_object_filenames(); + assert_eq!(bar_object_files.len(), 1); + + let mut bar_expected_files = BTreeSet::new(); + bar_expected_files.extend(bar_object_files); + bar_expected_files.insert("libbar.rlib".to_string()); + + FileAssertions { + expected_files: bar_expected_files.iter().map(String::as_ref).collect(), + } + .assert_on(&bar_found_files); + + rustc(unstable_options) + .extern_("bar", "libbar.rlib") + .input("main.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .run(); + + let overall_found_files = cwd_filenames(); + + let overall_object_files = cwd_object_filenames(); + assert_eq!(overall_object_files.len(), 2); + + let mut overall_expected_files = BTreeSet::new(); + overall_expected_files.extend(overall_object_files); + overall_expected_files.insert("main".to_string()); + overall_expected_files.insert("libbar.rlib".to_string()); + + FileAssertions { + expected_files: overall_expected_files.iter().map(String::as_ref).collect(), + } + .assert_on(&overall_found_files); + } + + _ => {} + } + } + + fn simple_split_debuginfo( + unstable_options: UnstableOptions, + split_kind: SplitDebuginfo, + level: DebuginfoLevel, + split_dwarf_kind: SplitDwarfKind, + lto: LinkerPluginLto, + remap_path_prefix: RemapPathPrefix, + remap_path_scope: RemapPathScope, + ) { + match (split_kind, level, split_dwarf_kind, lto, remap_path_prefix, remap_path_scope) { + // off (unspecified): + // - Debuginfo in `.o` files + // - `.o` deleted + // - `.dwo` never created + // - `.dwp` never created + ( + SplitDebuginfo::Unspecified, + DebuginfoLevel::Full, + SplitDwarfKind::Unspecified, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options).input("foo.rs").debuginfo(level.cli_value()).run(); + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["foo"]) }.assert_on(&found_files); + } + + // off: + // - Debuginfo in `.o` files + // - `.o` deleted + // - `.dwo` never created + // - `.dwp` never created + ( + SplitDebuginfo::Off, + DebuginfoLevel::Full, + SplitDwarfKind::Unspecified, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .run(); + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["foo"]) }.assert_on(&found_files); + } + + // packed-split: + // - Debuginfo in `.dwo` files + // - `.o` deleted + // - `.dwo` deleted + // - `.dwp` present + ( + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .run(); + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["foo", "foo.dwp"]) } + .assert_on(&found_files); + } + + // packed-single: + // - Debuginfo in `.o` files + // - `.o` deleted + // - `.dwo` never created + // - `.dwp` present + ( + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .run(); + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["foo", "foo.dwp"]) } + .assert_on(&found_files); + } + + // packed-lto-split:: + // - `rmeta` file added to `rlib`, no object files are generated and thus no + // debuginfo is generated. + // - `.o` never created + // - `.dwo` never created + // - `.dwp` never created + ( + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Yes, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("baz.rs") + .crate_type("rlib") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .arg("-Clinker-plugin-lto") + .run(); + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["libbaz.rlib"]) } + .assert_on(&found_files); + } + + // packed-lto-single: + // - `rmeta` file added to `rlib`, no object files are generated and thus no + // debuginfo is generated + // - `.o` never created + // - `.dwo` never created + // - `.dwp` never created + ( + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Yes, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("baz.rs") + .crate_type("rlib") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .arg("-Clinker-plugin-lto") + .run(); + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["libbaz.rlib"]) } + .assert_on(&found_files); + } + + // packed-remapped-split: + // - Debuginfo in `.dwo` files + // - `.o` and binary refer to remapped `.dwo` paths which do not exist + // - `.o` deleted + // - `.dwo` deleted + // - `.dwp` present + ( + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix }, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .remap_path_prefix(cwd(), remapped_prefix) + .run(); + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["foo", "foo.dwp"]) } + .assert_on(&found_files); + + check_path_remap(cwd(), RemapExpectation::Remapped); + } + + // packed-remapped-single: + // - `.o` and binary refer to remapped `.o` paths which do not exist + // - `.o` deleted + // - `.dwo` never created + // - `.dwp` present + ( + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix }, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .remap_path_prefix(cwd(), remapped_prefix) + .run(); + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["foo", "foo.dwp"]) } + .assert_on(&found_files); + + check_path_remap(cwd(), RemapExpectation::Remapped); + } + + // packed-remapped-scope: + // - Debuginfo in `.o` files + // - `.o` and binary refer to remapped `.o` paths which do not exist + // - `.o` deleted + // - `.dwo` never created + // - `.dwp` present + ( + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix }, + RemapPathScope::Yes(scope @ "debuginfo"), + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .remap_path_prefix(cwd(), remapped_prefix) + .arg(format!("-Zremap-path-scope={scope}")) + .run(); + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["foo", "foo.dwp"]) } + .assert_on(&found_files); + + check_path_remap(cwd(), RemapExpectation::Remapped); + } + + // packed-remapped-wrong-scope: + // - `.o` and binary refer to un-remapped `.o` paths because remap path scope is + // macro. + // - `.o` deleted + // - `.dwo` never created + // - `.dwp` present + ( + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix }, + RemapPathScope::Yes(scope @ "macro"), + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .remap_path_prefix(cwd(), remapped_prefix) + .arg(format!("-Zremap-path-scope={scope}")) + .run(); + let found_files = cwd_filenames(); + FileAssertions { expected_files: BTreeSet::from(["foo", "foo.dwp"]) } + .assert_on(&found_files); + + check_path_remap(cwd(), RemapExpectation::NoRemap); + } + + // unpacked-split + // - Debuginfo in `.dwo` files + // - `.o` deleted + // - `.dwo` present + // - `.dwp` never created + ( + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .run(); + let found_files = cwd_filenames(); + + let dwo_files = cwd_dwo_filenames(); + assert_eq!(dwo_files.len(), 1); + + let mut expected_files = BTreeSet::new(); + expected_files.extend(dwo_files); + expected_files.insert("foo".to_string()); + + FileAssertions { + expected_files: expected_files.iter().map(String::as_str).collect(), + } + .assert_on(&found_files); + } + + // unpacked-single + // - Debuginfo in `.o` files + // - `.o` present + // - `.dwo` never created + // - `.dwp` never created + ( + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .run(); + let found_files = cwd_filenames(); + + let object_files = cwd_object_filenames(); + assert_eq!(object_files.len(), 1); + + let mut expected_files = BTreeSet::new(); + expected_files.extend(object_files); + expected_files.insert("foo".to_string()); + + FileAssertions { + expected_files: expected_files.iter().map(String::as_str).collect(), + } + .assert_on(&found_files); + } + + // unpacked-lto-split + // - `rmeta` file added to `rlib`, no object files are generated and thus no debuginfo + // is generated + // - `.o` not present + // - `.dwo` never created + // - `.dwp` never created + ( + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Yes, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("baz.rs") + .crate_type("rlib") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .arg("-Clinker-plugin-lto") + .run(); + + let found_files = cwd_filenames(); + + FileAssertions { expected_files: BTreeSet::from(["libbaz.rlib"]) } + .assert_on(&found_files); + } + + // unpacked-lto-single + // - rmeta file added to rlib, no object files are generated and thus no debuginfo is generated + // - `.o` present (bitcode) + // - `.dwo` never created + // - `.dwp` never created + ( + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Yes, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("baz.rs") + .crate_type("rlib") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .arg("-Clinker-plugin-lto") + .run(); + + let found_files = cwd_filenames(); + + let object_files = cwd_object_filenames(); + assert_eq!(object_files.len(), 1); + + let mut expected_files = BTreeSet::new(); + expected_files.extend(object_files); + expected_files.insert("libbaz.rlib".to_string()); + + FileAssertions { + expected_files: expected_files.iter().map(String::as_ref).collect(), + } + .assert_on(&found_files); + } + + // unpacked-remapped-split + // - Debuginfo in `.dwo` files + // - `.o` and binary refer to remapped `.dwo` paths which do not exist + // - `.o` deleted + // - `.dwo` present + // - `.dwp` never created + ( + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix }, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .remap_path_prefix(cwd(), remapped_prefix) + .run(); + + let found_files = cwd_filenames(); + + let dwo_files = cwd_dwo_filenames(); + assert_eq!(dwo_files.len(), 1); + + let mut expected_files = BTreeSet::new(); + expected_files.extend(dwo_files); + expected_files.insert("foo".to_string()); + + FileAssertions { + expected_files: expected_files.iter().map(String::as_ref).collect(), + } + .assert_on(&found_files); + + check_path_remap(cwd(), RemapExpectation::Remapped); + } + + // unpacked-remapped-single + // - Debuginfo in `.o` files + // - `.o` and binary refer to remapped `.o` paths which do not exist + // - `.o` present + // - `.dwo` never created + // - `.dwp` never created + ( + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix }, + RemapPathScope::Unspecified, + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .remap_path_prefix(cwd(), remapped_prefix) + .run(); + + let found_files = cwd_filenames(); + + let object_files = cwd_object_filenames(); + assert_eq!(object_files.len(), 1); + + let mut expected_files = BTreeSet::new(); + expected_files.extend(object_files); + expected_files.insert("foo".to_string()); + + FileAssertions { + expected_files: expected_files.iter().map(String::as_ref).collect(), + } + .assert_on(&found_files); + + check_path_remap(cwd(), RemapExpectation::Remapped); + } + + // unpacked-remapped-scope + // - Debuginfo in `.o` files + // - `.o` and binary refer to remapped `.o` paths which do not exist + // - `.o` present + // - `.dwo` never created + // - `.dwp` never created + ( + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix }, + RemapPathScope::Yes(scope @ "debuginfo"), + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .remap_path_prefix(cwd(), remapped_prefix) + .arg(format!("-Zremap-path-scope={scope}")) + .run(); + + let found_files = cwd_filenames(); + + let object_files = cwd_object_filenames(); + assert_eq!(object_files.len(), 1); + + let mut expected_files = BTreeSet::new(); + expected_files.extend(object_files); + expected_files.insert("foo".to_string()); + + FileAssertions { + expected_files: expected_files.iter().map(String::as_ref).collect(), + } + .assert_on(&found_files); + + check_path_remap(cwd(), RemapExpectation::Remapped); + } + + // unpacked-remapped-wrong-scope + // - Debuginfo in `.o` files + // - `.o` and binary refer to un-remapped `.o` paths because remap path scope is macro + // - `.o` present + // - `.dwo` never created + // - `.dwp` never created + ( + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix }, + RemapPathScope::Yes(scope @ "macro"), + ) => { + rustc(unstable_options) + .input("foo.rs") + .split_debuginfo(split_kind.cli_value()) + .debuginfo(level.cli_value()) + .arg(format!("-Zsplit-dwarf-kind={}", split_dwarf_kind.cli_value())) + .remap_path_prefix(cwd(), remapped_prefix) + .arg(format!("-Zremap-path-scope={scope}")) + .run(); + + let found_files = cwd_filenames(); + + let object_files = cwd_object_filenames(); + assert_eq!(object_files.len(), 1); + + let mut expected_files = BTreeSet::new(); + expected_files.extend(object_files); + expected_files.insert("foo".to_string()); + + FileAssertions { + expected_files: expected_files.iter().map(String::as_ref).collect(), + } + .assert_on(&found_files); + + check_path_remap(cwd(), RemapExpectation::NoRemap); + } + + (split_kind, level, split_dwarf_kind, lto, remap_path_prefix, remap_path_scope) => { + panic!( + "split_kind={:?} + level={:?} + split_dwarf_kind={:?} + lto={:?} + remap_path_prefix={:?} + remap_path_scope={:?} is not handled on linux/other", + split_kind, level, split_dwarf_kind, lto, remap_path_prefix, remap_path_scope + ) + } + } + } + + #[derive(PartialEq)] + enum RemapExpectation { + Remapped, + NoRemap, + } + + #[track_caller] + fn check_path_remap(cwd_path: PathBuf, remap_expectation: RemapExpectation) { + let cwd_path = cwd_path.to_str().unwrap(); + let output = llvm_dwarfdump().input("foo").arg("--debug-info").run().stdout_utf8(); + let output_lines: Vec<_> = output.lines().collect(); + + // Look for `DW_AT_comp_dir` and `DW_AT_GNU_dwo_name` via `llvm-dwarfdump`. Note: space + // between uses tabs. + // + // ```text + // 0x0000000b: DW_TAG_compile_unit + // DW_AT_stmt_list (0x00000000) + // DW_AT_comp_dir ("/__MY_REMAPPED_PATH") # this could be e.g. /home/repos/rust/ if not remapped + // DW_AT_GNU_dwo_name ("foo.foo.fc848df41df7a00d-cgu.0.rcgu.dwo") + // ``` + // + // FIXME: this is very fragile because the output format can be load-bearing, but doing this + // via `object` + `gimli` is rather difficult. + let mut window = output_lines.windows(2); + while let Some([first_ln, second_ln]) = window.next() { + let first_ln = first_ln.trim(); + let second_ln = second_ln.trim(); + + if !second_ln.starts_with("DW_AT_GNU_dwo_name") { + continue; + } + + let Some((comp_dir_attr_name, comp_dir_attr_val)) = first_ln.split_once("\t") else { + continue; + }; + + println!("comp_dir_attr_name: `{}`", comp_dir_attr_name); + println!("cwd_path_string: `{}`", cwd_path); + + if comp_dir_attr_name != "DW_AT_comp_dir" { + continue; + } + + println!("comp_dir_attr_val: `{}`", comp_dir_attr_val); + + // Possibly `("/__MY_REMAPPED_PATH")` or `($cwd_path_string)`. + // + // FIXME: this check is insufficiently precise, it should probably also match on suffix + // (`.o` vs `.dwo` reference). But also, string matching is just very fragile. + let comp_dir_attr_val = comp_dir_attr_val.trim(); + + match remap_expectation { + RemapExpectation::Remapped => { + assert!( + !comp_dir_attr_val.contains(&cwd_path), + "unexpected non-remapped path found in `DW_AT_comp_dir`: {}", + comp_dir_attr_val + ); + } + RemapExpectation::NoRemap => { + assert!( + comp_dir_attr_val.contains(&cwd_path), + "failed to find un-remapped path in `DW_AT_comp_dir`: {}", + comp_dir_attr_val + ); + } + } + } + } +} + +fn main() { + // ENHANCEMENT: we are only checking that split-debuginfo is splitting is some way, shape or + // form, we do not sanity check the actual debuginfo artifacts on non-Linux! It may be possible + // to also sanity check the debuginfo artifacts, but I did not want to do that during the port + // to rmake.rs initially. + + // ENHANCEMENT: the Linux checks have significantly more coverage for interaction between `-C + // split-debuginfo` and other flags compared to windows-msvc or windows-gnu or darwin or some + // other non-linux targets. It would be cool if their test coverage could be improved. + + // NOTE: these combinations are not exhaustive, because while porting to rmake.rs initially I + // tried to preserve the existing test behavior closely. Notably, no attempt was made to + // exhaustively cover all cases in the 6-fold Cartesian product of `{,-Csplit=debuginfo=...}` x + // `{,-Cdebuginfo=...}` x `{,--remap-path-prefix}` x `{,-Zremap-path-scope=...}` x + // `{,-Zsplit-dwarf-kind=...}` x `{,-Clinker-plugin-lto}`. If you really want to, you can + // identify which combination isn't exercised with a 6-layers nested for loop iterating through + // each of the cli flag enum variants. + + if is_msvc() { + // FIXME: the windows-msvc test coverage is sparse at best. + + windows_msvc_tests::split_debuginfo(SplitDebuginfo::Off, DebuginfoLevel::Unspecified); + windows_msvc_tests::split_debuginfo(SplitDebuginfo::Unpacked, DebuginfoLevel::Unspecified); + windows_msvc_tests::split_debuginfo(SplitDebuginfo::Packed, DebuginfoLevel::Unspecified); + + windows_msvc_tests::split_debuginfo(SplitDebuginfo::Off, DebuginfoLevel::None); + windows_msvc_tests::split_debuginfo(SplitDebuginfo::Unpacked, DebuginfoLevel::None); + windows_msvc_tests::split_debuginfo(SplitDebuginfo::Packed, DebuginfoLevel::None); + + windows_msvc_tests::split_debuginfo(SplitDebuginfo::Off, DebuginfoLevel::Full); + windows_msvc_tests::split_debuginfo(SplitDebuginfo::Unpacked, DebuginfoLevel::Full); + windows_msvc_tests::split_debuginfo(SplitDebuginfo::Packed, DebuginfoLevel::Full); + } else if is_windows() { + // FIXME(#135531): the `Makefile` version didn't test windows at all. I don't know about the + // intended behavior on windows-gnu to expand test coverage while porting this to rmake.rs, + // but the test coverage here really should be expanded since some windows-gnu targets are + // Tier 1. + } else if is_darwin() { + // FIXME: the darwin test coverage is sparse at best. + + // Expect no `.dSYM` generation if debuginfo is not requested (special case). + darwin_tests::split_debuginfo(SplitDebuginfo::Unspecified, DebuginfoLevel::Unspecified); + + darwin_tests::split_debuginfo(SplitDebuginfo::Off, DebuginfoLevel::Unspecified); + darwin_tests::split_debuginfo(SplitDebuginfo::Unpacked, DebuginfoLevel::Unspecified); + darwin_tests::split_debuginfo(SplitDebuginfo::Packed, DebuginfoLevel::Unspecified); + + darwin_tests::split_debuginfo(SplitDebuginfo::Off, DebuginfoLevel::None); + darwin_tests::split_debuginfo(SplitDebuginfo::Unpacked, DebuginfoLevel::None); + darwin_tests::split_debuginfo(SplitDebuginfo::Packed, DebuginfoLevel::None); + + darwin_tests::split_debuginfo(SplitDebuginfo::Off, DebuginfoLevel::Full); + darwin_tests::split_debuginfo(SplitDebuginfo::Unpacked, DebuginfoLevel::Full); + darwin_tests::split_debuginfo(SplitDebuginfo::Packed, DebuginfoLevel::Full); + } else { + // Unix as well as the non-linux + non-windows + non-darwin targets. + + // FIXME: this `uname` check is very funny, it really should be refined (e.g. llvm bug + // <https://github.com/llvm/llvm-project/issues/56642> for riscv64 targets). + + // NOTE: some options are not stable on non-linux + non-windows + non-darwin targets... + let unstable_options = + if uname() == "Linux" { UnstableOptions::Unspecified } else { UnstableOptions::Yes }; + + // FIXME: we should add a test with scope `split-debuginfo,split-debuginfo-path` that greps + // the entire `.dwp` file for remapped paths (i.e. without going through objdump or + // readelf). See <https://github.com/rust-lang/rust/pull/118518#discussion_r1452180392>. + + use shared_linux_other_tests::CrossCrateTest; + + // unspecified `-Csplit-debuginfo` + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Unspecified, + DebuginfoLevel::Full, + SplitDwarfKind::Unspecified, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // off + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Off, + DebuginfoLevel::Full, + SplitDwarfKind::Unspecified, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // packed-split + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // packed-single + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // packed-lto-split + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Yes, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // packed-lto-single + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Yes, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // FIXME: the remapping tests probably need to be reworked, see + // <https://github.com/rust-lang/rust/pull/118518#discussion_r1452174338>. + + // packed-remapped-split + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix: "/__MY_REMAPPED_PATH__" }, + RemapPathScope::Unspecified, + ); + + // packed-remapped-single + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix: "/__MY_REMAPPED_PATH__" }, + RemapPathScope::Unspecified, + ); + + // packed-remapped-scope + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix: "/__MY_REMAPPED_PATH__" }, + RemapPathScope::Yes("debuginfo"), + ); + + // packed-remapped-wrong-scope + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix: "/__MY_REMAPPED_PATH__" }, + RemapPathScope::Yes("macro"), + ); + + // packed-crosscrate-split + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::Yes, + unstable_options, + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // packed-crosscrate-single + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::Yes, + unstable_options, + SplitDebuginfo::Packed, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // unpacked-split + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // unpacked-single + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // unpacked-lto-split + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Yes, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // unpacked-lto-single + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Yes, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // unpacked-remapped-split + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix: "/__MY_REMAPPED_PATH__" }, + RemapPathScope::Unspecified, + ); + + // unpacked-remapped-single + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix: "/__MY_REMAPPED_PATH__" }, + RemapPathScope::Unspecified, + ); + + // unpacked-remapped-scope + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix: "/__MY_REMAPPED_PATH__" }, + RemapPathScope::Yes("debuginfo"), + ); + + // unpacked-remapped-wrong-scope + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::No, + unstable_options, + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Yes { remapped_prefix: "/__MY_REMAPPED_PATH__" }, + RemapPathScope::Yes("macro"), + ); + + // unpacked-crosscrate-split + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::Yes, + unstable_options, + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Split, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + + // unpacked-crosscrate-single + shared_linux_other_tests::split_debuginfo( + CrossCrateTest::Yes, + unstable_options, + SplitDebuginfo::Unpacked, + DebuginfoLevel::Full, + SplitDwarfKind::Single, + LinkerPluginLto::Unspecified, + RemapPathPrefix::Unspecified, + RemapPathScope::Unspecified, + ); + } +} diff --git a/tests/run-make/wasm-export-all-symbols/rmake.rs b/tests/run-make/wasm-export-all-symbols/rmake.rs index 0c0a785c67c..4148cc29ec2 100644 --- a/tests/run-make/wasm-export-all-symbols/rmake.rs +++ b/tests/run-make/wasm-export-all-symbols/rmake.rs @@ -20,13 +20,16 @@ fn test(args: &[&str]) { rustc().input("main.rs").target("wasm32-wasip1").args(args).run(); verify_exports(Path::new("foo.wasm"), &[("foo", Func), ("FOO", Global), ("memory", Memory)]); - verify_exports(Path::new("main.wasm"), &[ - ("foo", Func), - ("FOO", Global), - ("_start", Func), - ("__main_void", Func), - ("memory", Memory), - ]); + verify_exports( + Path::new("main.wasm"), + &[ + ("foo", Func), + ("FOO", Global), + ("_start", Func), + ("__main_void", Func), + ("memory", Memory), + ], + ); } fn verify_exports(path: &Path, exports: &[(&str, wasmparser::ExternalKind)]) { diff --git a/tests/rustdoc-json/primitives/primitive_impls.rs b/tests/rustdoc-json/primitives/primitive_impls.rs index 77d1d68f8e4..58c222ce4f0 100644 --- a/tests/rustdoc-json/primitives/primitive_impls.rs +++ b/tests/rustdoc-json/primitives/primitive_impls.rs @@ -1,4 +1,4 @@ -#![feature(no_core)] +#![feature(no_core, lang_items)] #![feature(rustc_attrs)] #![feature(rustdoc_internals)] #![no_core] @@ -6,6 +6,9 @@ //@ set impl_i32 = "$.index[*][?(@.docs=='Only core can do this')].id" +#[lang = "sized"] +trait Sized {} + /// Only core can do this impl i32 { //@ set identity = "$.index[*][?(@.docs=='Do Nothing')].id" diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.rs b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.rs index 6b1aa455d98..18ac37280c0 100644 --- a/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.rs +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.rs @@ -2,9 +2,12 @@ // feature. #![deny(warnings)] -#![feature(no_core)] +#![feature(no_core, lang_items)] #![no_core] +#[lang = "sized"] +trait Sized {} + /// ```{class="} /// main; /// ``` diff --git a/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr index 385b2ccacc1..cc13cc0fe53 100644 --- a/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr +++ b/tests/rustdoc-ui/custom_code_classes_in_docs-warning3.stderr @@ -1,5 +1,5 @@ error: unclosed quote string `"` - --> $DIR/custom_code_classes_in_docs-warning3.rs:8:1 + --> $DIR/custom_code_classes_in_docs-warning3.rs:11:1 | LL | / /// ```{class="} LL | | /// main; @@ -17,7 +17,7 @@ LL | #![deny(warnings)] = note: `#[deny(rustdoc::invalid_codeblock_attributes)]` implied by `#[deny(warnings)]` error: unclosed quote string `"` - --> $DIR/custom_code_classes_in_docs-warning3.rs:8:1 + --> $DIR/custom_code_classes_in_docs-warning3.rs:11:1 | LL | / /// ```{class="} LL | | /// main; diff --git a/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.rs b/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.rs index 5c9e2978e48..6fddaa49fac 100644 --- a/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.rs +++ b/tests/rustdoc-ui/doctest/relative-path-include-bytes-132203.rs @@ -1,4 +1,4 @@ -//@ ignore-windows +//@ ignore-windows different error message //@ revisions: edition2015 edition2024 //@[edition2015]edition:2015 //@[edition2015]check-fail diff --git a/tests/rustdoc/assoc-consts.rs b/tests/rustdoc/assoc-consts.rs index cb8e839541c..247b5b180a8 100644 --- a/tests/rustdoc/assoc-consts.rs +++ b/tests/rustdoc/assoc-consts.rs @@ -45,7 +45,7 @@ pub fn f(_: &(ToString + 'static)) {} impl Bar { //@ has assoc_consts/struct.Bar.html '//*[@id="associatedconstant.F"]' \ - // "const F: fn(_: &(dyn ToString + 'static))" + // "const F: fn(&(dyn ToString + 'static))" pub const F: fn(_: &(ToString + 'static)) = f; } diff --git a/tests/rustdoc/cfg_doc_reexport.rs b/tests/rustdoc/cfg_doc_reexport.rs index f8101e2a958..44ec3663284 100644 --- a/tests/rustdoc/cfg_doc_reexport.rs +++ b/tests/rustdoc/cfg_doc_reexport.rs @@ -1,9 +1,12 @@ #![feature(doc_cfg)] -#![feature(no_core)] +#![feature(no_core, lang_items)] #![crate_name = "foo"] #![no_core] +#[lang = "sized"] +trait Sized {} + //@ has 'foo/index.html' //@ has - '//dt/*[@class="stab portability"]' 'foobar' //@ has - '//dt/*[@class="stab portability"]' 'bar' diff --git a/tests/rustdoc/cross-crate-primitive-doc.rs b/tests/rustdoc/cross-crate-primitive-doc.rs index ca33dedcbae..0ffde5b0f2d 100644 --- a/tests/rustdoc/cross-crate-primitive-doc.rs +++ b/tests/rustdoc/cross-crate-primitive-doc.rs @@ -2,9 +2,12 @@ //@ compile-flags: --extern-html-root-url=primitive_doc=../ -Z unstable-options //@ only-linux -#![feature(no_core)] +#![feature(no_core, lang_items)] #![no_core] +#[lang = "sized"] +trait Sized {} + extern crate primitive_doc; //@ has 'cross_crate_primitive_doc/fn.foo.html' '//a[@href="../primitive_doc/primitive.usize.html"]' 'usize' diff --git a/tests/rustdoc/fn-pointer-arg-name.rs b/tests/rustdoc/fn-pointer-arg-name.rs index 3bde6e9ecfa..0ee1964511a 100644 --- a/tests/rustdoc/fn-pointer-arg-name.rs +++ b/tests/rustdoc/fn-pointer-arg-name.rs @@ -3,3 +3,11 @@ //@ has foo/fn.f.html //@ has - '//pre[@class="rust item-decl"]' 'pub fn f(callback: fn(len: usize, foo: u32))' pub fn f(callback: fn(len: usize, foo: u32)) {} + +//@ has foo/fn.g.html +//@ has - '//pre[@class="rust item-decl"]' 'pub fn g(_: fn(usize, u32))' +pub fn g(_: fn(usize, _: u32)) {} + +//@ has foo/fn.mixed.html +//@ has - '//pre[@class="rust item-decl"]' 'pub fn mixed(_: fn(_: usize, foo: u32))' +pub fn mixed(_: fn(usize, foo: u32)) {} diff --git a/tests/rustdoc/inherent-projections.rs b/tests/rustdoc/inherent-projections.rs index 4fc769f70f5..ced4db9a490 100644 --- a/tests/rustdoc/inherent-projections.rs +++ b/tests/rustdoc/inherent-projections.rs @@ -13,7 +13,7 @@ impl Owner { } // Make sure we handle bound vars correctly. -//@ has 'inherent_projections/fn.user.html' '//pre[@class="rust item-decl"]' "user(_: for<'a> fn(_: Carrier<'a>::Focus))" +//@ has 'inherent_projections/fn.user.html' '//pre[@class="rust item-decl"]' "user(_: for<'a> fn(Carrier<'a>::Focus))" pub fn user(_: for<'a> fn(Carrier<'a>::Focus)) {} pub struct Carrier<'a>(&'a ()); diff --git a/tests/rustdoc/intra-doc/no-doc-primitive.rs b/tests/rustdoc/intra-doc/no-doc-primitive.rs index 1f8622ab867..79825643b98 100644 --- a/tests/rustdoc/intra-doc/no-doc-primitive.rs +++ b/tests/rustdoc/intra-doc/no-doc-primitive.rs @@ -6,8 +6,13 @@ #![rustc_coherence_is_core] #![crate_type = "rlib"] + //@ has no_doc_primitive/index.html //! A [`char`] and its [`char::len_utf8`]. + +#[lang = "sized"] +trait Sized {} + impl char { pub fn len_utf8(self) -> usize { 42 diff --git a/tests/rustdoc/macro-higher-kinded-function.rs b/tests/rustdoc/macro-higher-kinded-function.rs index f14125d1309..738ea8fb3f1 100644 --- a/tests/rustdoc/macro-higher-kinded-function.rs +++ b/tests/rustdoc/macro-higher-kinded-function.rs @@ -11,10 +11,10 @@ macro_rules! gen { } //@ has 'foo/struct.Providers.html' -//@ has - '//*[@class="rust item-decl"]//code' "pub a: for<'tcx> fn(_: TyCtxt<'tcx>, _: u8) -> i8," -//@ has - '//*[@class="rust item-decl"]//code' "pub b: for<'tcx> fn(_: TyCtxt<'tcx>, _: u16) -> i16," -//@ has - '//*[@id="structfield.a"]/code' "a: for<'tcx> fn(_: TyCtxt<'tcx>, _: u8) -> i8" -//@ has - '//*[@id="structfield.b"]/code' "b: for<'tcx> fn(_: TyCtxt<'tcx>, _: u16) -> i16" +//@ has - '//*[@class="rust item-decl"]//code' "pub a: for<'tcx> fn(TyCtxt<'tcx>, u8) -> i8," +//@ has - '//*[@class="rust item-decl"]//code' "pub b: for<'tcx> fn(TyCtxt<'tcx>, u16) -> i16," +//@ has - '//*[@id="structfield.a"]/code' "a: for<'tcx> fn(TyCtxt<'tcx>, u8) -> i8" +//@ has - '//*[@id="structfield.b"]/code' "b: for<'tcx> fn(TyCtxt<'tcx>, u16) -> i16" gen! { (a, 'tcx, [u8], [i8]) (b, 'tcx, [u16], [i16]) diff --git a/tests/rustdoc/reexport-trait-from-hidden-111064-2.rs b/tests/rustdoc/reexport-trait-from-hidden-111064-2.rs index 2b21f9862b4..61060b3ff7c 100644 --- a/tests/rustdoc/reexport-trait-from-hidden-111064-2.rs +++ b/tests/rustdoc/reexport-trait-from-hidden-111064-2.rs @@ -1,8 +1,11 @@ // Regression test for <https://github.com/rust-lang/rust/issues/111064>. -#![feature(no_core)] +#![feature(no_core, lang_items)] #![no_core] #![crate_name = "foo"] +#[lang = "sized"] +trait Sized {} + //@ files "foo" "['sidebar-items.js', 'all.html', 'hidden', 'index.html', 'struct.Bar.html', \ // 'visible']" //@ files "foo/hidden" "['inner']" diff --git a/tests/rustdoc/safe-intrinsic.rs b/tests/rustdoc/safe-intrinsic.rs index 07af04ace60..1edc1d9f79b 100644 --- a/tests/rustdoc/safe-intrinsic.rs +++ b/tests/rustdoc/safe-intrinsic.rs @@ -1,10 +1,13 @@ #![feature(intrinsics)] -#![feature(no_core)] +#![feature(no_core, lang_items)] #![feature(rustc_attrs)] #![no_core] #![crate_name = "foo"] +#[lang = "sized"] +trait Sized {} + //@ has 'foo/fn.abort.html' //@ has - '//pre[@class="rust item-decl"]' 'pub fn abort() -> !' #[rustc_intrinsic] diff --git a/tests/rustdoc/type-layout.rs b/tests/rustdoc/type-layout.rs index 5f34c8b99e0..6de435dbcc1 100644 --- a/tests/rustdoc/type-layout.rs +++ b/tests/rustdoc/type-layout.rs @@ -86,11 +86,11 @@ pub enum WithNiche { } //@ hasraw type_layout/enum.Uninhabited.html 'Size: ' -//@ hasraw - '0 bytes (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)' +//@ hasraw - '0 bytes (<a href="{{channel}}/reference/glossary.html#uninhabited">uninhabited</a>)' pub enum Uninhabited {} //@ hasraw type_layout/struct.Uninhabited2.html 'Size: ' -//@ hasraw - '8 bytes (<a href="https://doc.rust-lang.org/stable/reference/glossary.html#uninhabited">uninhabited</a>)' +//@ hasraw - '8 bytes (<a href="{{channel}}/reference/glossary.html#uninhabited">uninhabited</a>)' pub struct Uninhabited2(std::convert::Infallible, u64); pub trait Project { type Assoc; } diff --git a/tests/ui-fulldeps/stable-mir/check_abi.rs b/tests/ui-fulldeps/stable-mir/check_abi.rs index 8caf3032afc..ef2d5b4854b 100644 --- a/tests/ui-fulldeps/stable-mir/check_abi.rs +++ b/tests/ui-fulldeps/stable-mir/check_abi.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 #![feature(rustc_private)] #![feature(assert_matches)] diff --git a/tests/ui-fulldeps/stable-mir/check_allocation.rs b/tests/ui-fulldeps/stable-mir/check_allocation.rs index 072c8ba6a44..c102f86a228 100644 --- a/tests/ui-fulldeps/stable-mir/check_allocation.rs +++ b/tests/ui-fulldeps/stable-mir/check_allocation.rs @@ -5,7 +5,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/check_attribute.rs b/tests/ui-fulldeps/stable-mir/check_attribute.rs index 22481e275a9..11cb63f3f8a 100644 --- a/tests/ui-fulldeps/stable-mir/check_attribute.rs +++ b/tests/ui-fulldeps/stable-mir/check_attribute.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/check_binop.rs b/tests/ui-fulldeps/stable-mir/check_binop.rs index 8c44e285108..65b3ffd27ab 100644 --- a/tests/ui-fulldeps/stable-mir/check_binop.rs +++ b/tests/ui-fulldeps/stable-mir/check_binop.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/check_crate_defs.rs b/tests/ui-fulldeps/stable-mir/check_crate_defs.rs index ed093903381..71cca94c34f 100644 --- a/tests/ui-fulldeps/stable-mir/check_crate_defs.rs +++ b/tests/ui-fulldeps/stable-mir/check_crate_defs.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 #![feature(rustc_private)] #![feature(assert_matches)] diff --git a/tests/ui-fulldeps/stable-mir/check_def_ty.rs b/tests/ui-fulldeps/stable-mir/check_def_ty.rs index 482dbd22d5f..37b9a83e33e 100644 --- a/tests/ui-fulldeps/stable-mir/check_def_ty.rs +++ b/tests/ui-fulldeps/stable-mir/check_def_ty.rs @@ -5,7 +5,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/check_defs.rs b/tests/ui-fulldeps/stable-mir/check_defs.rs index bf1f1a2ceab..cd3d76d8760 100644 --- a/tests/ui-fulldeps/stable-mir/check_defs.rs +++ b/tests/ui-fulldeps/stable-mir/check_defs.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/check_foreign.rs b/tests/ui-fulldeps/stable-mir/check_foreign.rs index 4acbabbb6be..bc3956b3090 100644 --- a/tests/ui-fulldeps/stable-mir/check_foreign.rs +++ b/tests/ui-fulldeps/stable-mir/check_foreign.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/check_instance.rs b/tests/ui-fulldeps/stable-mir/check_instance.rs index 464350b1045..72a138f907e 100644 --- a/tests/ui-fulldeps/stable-mir/check_instance.rs +++ b/tests/ui-fulldeps/stable-mir/check_instance.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/check_intrinsics.rs b/tests/ui-fulldeps/stable-mir/check_intrinsics.rs index 6edebaf756c..2f772b97886 100644 --- a/tests/ui-fulldeps/stable-mir/check_intrinsics.rs +++ b/tests/ui-fulldeps/stable-mir/check_intrinsics.rs @@ -8,7 +8,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 #![feature(rustc_private)] #![feature(assert_matches)] diff --git a/tests/ui-fulldeps/stable-mir/check_item_kind.rs b/tests/ui-fulldeps/stable-mir/check_item_kind.rs index 23b54e6c60b..647ce534589 100644 --- a/tests/ui-fulldeps/stable-mir/check_item_kind.rs +++ b/tests/ui-fulldeps/stable-mir/check_item_kind.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/check_normalization.rs b/tests/ui-fulldeps/stable-mir/check_normalization.rs index 928173b154b..de14202adb9 100644 --- a/tests/ui-fulldeps/stable-mir/check_normalization.rs +++ b/tests/ui-fulldeps/stable-mir/check_normalization.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/check_trait_queries.rs b/tests/ui-fulldeps/stable-mir/check_trait_queries.rs index 304a7ce9255..23c2844d3f1 100644 --- a/tests/ui-fulldeps/stable-mir/check_trait_queries.rs +++ b/tests/ui-fulldeps/stable-mir/check_trait_queries.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/check_transform.rs b/tests/ui-fulldeps/stable-mir/check_transform.rs index bcf79c456b0..d9fc924933f 100644 --- a/tests/ui-fulldeps/stable-mir/check_transform.rs +++ b/tests/ui-fulldeps/stable-mir/check_transform.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 #![feature(rustc_private)] #![feature(assert_matches)] diff --git a/tests/ui-fulldeps/stable-mir/check_ty_fold.rs b/tests/ui-fulldeps/stable-mir/check_ty_fold.rs index e21508c9b46..9fa4929d68e 100644 --- a/tests/ui-fulldeps/stable-mir/check_ty_fold.rs +++ b/tests/ui-fulldeps/stable-mir/check_ty_fold.rs @@ -5,7 +5,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/compilation-result.rs b/tests/ui-fulldeps/stable-mir/compilation-result.rs index d921de73f43..b8a9e720e54 100644 --- a/tests/ui-fulldeps/stable-mir/compilation-result.rs +++ b/tests/ui-fulldeps/stable-mir/compilation-result.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/crate-info.rs b/tests/ui-fulldeps/stable-mir/crate-info.rs index 53be8eb10c1..7f0e9b50335 100644 --- a/tests/ui-fulldeps/stable-mir/crate-info.rs +++ b/tests/ui-fulldeps/stable-mir/crate-info.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/projections.rs b/tests/ui-fulldeps/stable-mir/projections.rs index fdb7eeed1b0..3cc71247e67 100644 --- a/tests/ui-fulldeps/stable-mir/projections.rs +++ b/tests/ui-fulldeps/stable-mir/projections.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/smir_internal.rs b/tests/ui-fulldeps/stable-mir/smir_internal.rs index 6f5478c08bf..453e5372de4 100644 --- a/tests/ui-fulldeps/stable-mir/smir_internal.rs +++ b/tests/ui-fulldeps/stable-mir/smir_internal.rs @@ -5,7 +5,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/smir_serde.rs b/tests/ui-fulldeps/stable-mir/smir_serde.rs index 7dbf892f9e4..2c74276d550 100644 --- a/tests/ui-fulldeps/stable-mir/smir_serde.rs +++ b/tests/ui-fulldeps/stable-mir/smir_serde.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui-fulldeps/stable-mir/smir_visitor.rs b/tests/ui-fulldeps/stable-mir/smir_visitor.rs index 666000d3b07..0a6415d490e 100644 --- a/tests/ui-fulldeps/stable-mir/smir_visitor.rs +++ b/tests/ui-fulldeps/stable-mir/smir_visitor.rs @@ -4,7 +4,6 @@ //@ ignore-stage1 //@ ignore-cross-compile //@ ignore-remote -//@ ignore-windows-gnu mingw has troubles with linking https://github.com/rust-lang/rust/pull/116837 //@ edition: 2021 #![feature(rustc_private)] diff --git a/tests/ui/abi/abi-sysv64-arg-passing.rs b/tests/ui/abi/abi-sysv64-arg-passing.rs index 04942e984a8..c18752418a1 100644 --- a/tests/ui/abi/abi-sysv64-arg-passing.rs +++ b/tests/ui/abi/abi-sysv64-arg-passing.rs @@ -29,7 +29,8 @@ //@ ignore-aarch64 //@ ignore-windows -// note: windows is ignored as rust_test_helpers does not have the sysv64 abi on windows +// Windows is ignored because bootstrap doesn't yet know to compile rust_test_helpers with +// the sysv64 ABI on Windows. #[allow(dead_code)] #[allow(improper_ctypes)] diff --git a/tests/ui/abi/large-byval-align.rs b/tests/ui/abi/large-byval-align.rs index e39170df72b..ddd579f264e 100644 --- a/tests/ui/abi/large-byval-align.rs +++ b/tests/ui/abi/large-byval-align.rs @@ -1,6 +1,5 @@ //@ compile-flags: -Copt-level=0 //@ only-x86_64 -//@ ignore-windows //@ min-llvm-version: 19 //@ build-pass diff --git a/tests/ui/amdgpu-require-explicit-cpu.nocpu.stderr b/tests/ui/amdgpu-require-explicit-cpu.nocpu.stderr new file mode 100644 index 00000000000..7480a8ed38f --- /dev/null +++ b/tests/ui/amdgpu-require-explicit-cpu.nocpu.stderr @@ -0,0 +1,4 @@ +error: target requires explicitly specifying a cpu with `-C target-cpu` + +error: aborting due to 1 previous error + diff --git a/tests/ui/amdgpu-require-explicit-cpu.rs b/tests/ui/amdgpu-require-explicit-cpu.rs new file mode 100644 index 00000000000..46778a1094f --- /dev/null +++ b/tests/ui/amdgpu-require-explicit-cpu.rs @@ -0,0 +1,17 @@ +//@ revisions: nocpu cpu +//@ no-prefer-dynamic +//@ compile-flags: --crate-type=cdylib --target=amdgcn-amd-amdhsa +//@ needs-llvm-components: amdgpu +//@ needs-rust-lld +//@[nocpu] error-pattern: target requires explicitly specifying a cpu +//@[nocpu] build-fail +//@[cpu] compile-flags: -Ctarget-cpu=gfx900 +//@[cpu] build-pass + +#![feature(no_core, lang_items)] +#![no_core] + +#[lang="sized"] +trait Sized {} + +pub fn foo() {} diff --git a/tests/ui/argument-suggestions/basic.stderr b/tests/ui/argument-suggestions/basic.stderr index 2d52df21233..83f0f630fe8 100644 --- a/tests/ui/argument-suggestions/basic.stderr +++ b/tests/ui/argument-suggestions/basic.stderr @@ -57,7 +57,7 @@ note: function defined here --> $DIR/basic.rs:16:4 | LL | fn swapped(_i: u32, _s: &str) {} - | ^^^^^^^ ------- -------- + | ^^^^^^^ help: swap these arguments | LL | swapped(1, ""); @@ -76,7 +76,7 @@ note: function defined here --> $DIR/basic.rs:17:4 | LL | fn permuted(_x: X, _y: Y, _z: Z) {} - | ^^^^^^^^ ----- ----- ----- + | ^^^^^^^^ help: reorder these arguments | LL | permuted(X {}, Y {}, Z {}); diff --git a/tests/ui/argument-suggestions/complex.stderr b/tests/ui/argument-suggestions/complex.stderr index bb3817421df..20c7c2fd7a5 100644 --- a/tests/ui/argument-suggestions/complex.stderr +++ b/tests/ui/argument-suggestions/complex.stderr @@ -8,7 +8,7 @@ note: function defined here --> $DIR/complex.rs:11:4 | LL | fn complex(_i: u32, _s: &str, _e: E, _f: F, _g: G, _x: X, _y: Y, _z: Z ) {} - | ^^^^^^^ ------- -------- ----- ----- ----- ----- ----- ----- + | ^^^^^^^ ------- ----- help: did you mean | LL | complex(/* u32 */, &"", /* E */, F::X2, G{}, X {}, Y {}, Z {}); diff --git a/tests/ui/argument-suggestions/extern-fn-arg-names.stderr b/tests/ui/argument-suggestions/extern-fn-arg-names.stderr index 47fbfc98c67..2aa4983624c 100644 --- a/tests/ui/argument-suggestions/extern-fn-arg-names.stderr +++ b/tests/ui/argument-suggestions/extern-fn-arg-names.stderr @@ -14,7 +14,7 @@ note: function defined here --> $DIR/extern-fn-arg-names.rs:2:8 | LL | fn dstfn(src: i32, dst: err); - | ^^^^^ + | ^^^^^ --- help: provide the argument | LL | dstfn(1, /* dst */); diff --git a/tests/ui/argument-suggestions/extra_arguments.stderr b/tests/ui/argument-suggestions/extra_arguments.stderr index 8c95cc86a27..5ed42a9ddd2 100644 --- a/tests/ui/argument-suggestions/extra_arguments.stderr +++ b/tests/ui/argument-suggestions/extra_arguments.stderr @@ -44,7 +44,7 @@ note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg<T>(_a: T) {} - | ^^^^^^^ ----- + | ^^^^^^^ help: remove the extra argument | LL - one_arg(1, 1); @@ -61,7 +61,7 @@ note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg<T>(_a: T) {} - | ^^^^^^^ ----- + | ^^^^^^^ help: remove the extra argument | LL - one_arg(1, ""); @@ -80,7 +80,7 @@ note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg<T>(_a: T) {} - | ^^^^^^^ ----- + | ^^^^^^^ help: remove the extra arguments | LL - one_arg(1, "", 1.0); @@ -97,7 +97,7 @@ note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} - | ^^^^^^^^^^^^ ------- ------- + | ^^^^^^^^^^^^ help: remove the extra argument | LL - two_arg_same(1, 1, 1); @@ -114,7 +114,7 @@ note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} - | ^^^^^^^^^^^^ ------- ------- + | ^^^^^^^^^^^^ help: remove the extra argument | LL - two_arg_same(1, 1, 1.0); @@ -131,7 +131,7 @@ note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} - | ^^^^^^^^^^^^ ------- -------- + | ^^^^^^^^^^^^ help: remove the extra argument | LL - two_arg_diff(1, 1, ""); @@ -148,7 +148,7 @@ note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} - | ^^^^^^^^^^^^ ------- -------- + | ^^^^^^^^^^^^ help: remove the extra argument | LL - two_arg_diff(1, "", ""); @@ -167,7 +167,7 @@ note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} - | ^^^^^^^^^^^^ ------- -------- + | ^^^^^^^^^^^^ help: remove the extra arguments | LL - two_arg_diff(1, 1, "", ""); @@ -186,7 +186,7 @@ note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} - | ^^^^^^^^^^^^ ------- -------- + | ^^^^^^^^^^^^ help: remove the extra arguments | LL - two_arg_diff(1, "", 1, ""); @@ -203,7 +203,7 @@ note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} - | ^^^^^^^^^^^^ ------- ------- + | ^^^^^^^^^^^^ help: remove the extra argument | LL - two_arg_same(1, 1, ""); @@ -220,7 +220,7 @@ note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} - | ^^^^^^^^^^^^ ------- -------- + | ^^^^^^^^^^^^ help: remove the extra argument | LL - two_arg_diff(1, 1, ""); @@ -240,7 +240,7 @@ note: function defined here --> $DIR/extra_arguments.rs:3:4 | LL | fn two_arg_same(_a: i32, _b: i32) {} - | ^^^^^^^^^^^^ ------- ------- + | ^^^^^^^^^^^^ help: remove the extra argument | LL - 1, @@ -261,7 +261,7 @@ note: function defined here --> $DIR/extra_arguments.rs:4:4 | LL | fn two_arg_diff(_a: i32, _b: &str) {} - | ^^^^^^^^^^^^ ------- -------- + | ^^^^^^^^^^^^ help: remove the extra argument | LL - 1, @@ -335,7 +335,7 @@ note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg<T>(_a: T) {} - | ^^^^^^^ ----- + | ^^^^^^^ help: remove the extra argument | LL - one_arg(1, panic!()); @@ -352,7 +352,7 @@ note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg<T>(_a: T) {} - | ^^^^^^^ ----- + | ^^^^^^^ help: remove the extra argument | LL - one_arg(panic!(), 1); @@ -369,7 +369,7 @@ note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg<T>(_a: T) {} - | ^^^^^^^ ----- + | ^^^^^^^ help: remove the extra argument | LL - one_arg(stringify!($e), 1); @@ -386,7 +386,7 @@ note: function defined here --> $DIR/extra_arguments.rs:2:4 | LL | fn one_arg<T>(_a: T) {} - | ^^^^^^^ ----- + | ^^^^^^^ help: remove the extra argument | LL - one_arg(for _ in 1.. {}, 1); diff --git a/tests/ui/argument-suggestions/invalid_arguments.stderr b/tests/ui/argument-suggestions/invalid_arguments.stderr index d26f33d098b..a50058149b8 100644 --- a/tests/ui/argument-suggestions/invalid_arguments.stderr +++ b/tests/ui/argument-suggestions/invalid_arguments.stderr @@ -150,7 +150,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^^^^^ ------- ------- error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:29:3 @@ -164,7 +164,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^^^^^ ------- -------- error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:30:3 @@ -178,7 +178,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:8:4 | LL | fn three_arg_diff(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^^^^^ ------- -------- error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:32:3 @@ -249,7 +249,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} - | ^^^^^^^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^^^^^^^ ------- ------- error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:39:3 @@ -263,7 +263,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} - | ^^^^^^^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^^^^^^^ ------- -------- error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:40:3 @@ -277,7 +277,7 @@ note: function defined here --> $DIR/invalid_arguments.rs:9:4 | LL | fn three_arg_repeat(_a: i32, _b: i32, _c: &str) {} - | ^^^^^^^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^^^^^^^ ------- -------- error[E0308]: arguments to this function are incorrect --> $DIR/invalid_arguments.rs:42:3 diff --git a/tests/ui/argument-suggestions/issue-100478.stderr b/tests/ui/argument-suggestions/issue-100478.stderr index 94709f0ebc6..6299571d998 100644 --- a/tests/ui/argument-suggestions/issue-100478.stderr +++ b/tests/ui/argument-suggestions/issue-100478.stderr @@ -11,7 +11,7 @@ note: function defined here --> $DIR/issue-100478.rs:30:4 | LL | fn three_diff(_a: T1, _b: T2, _c: T3) {} - | ^^^^^^^^^^ ------ ------ ------ + | ^^^^^^^^^^ ------ ------ help: provide the arguments | LL | three_diff(/* T1 */, T2::new(0), /* T3 */); @@ -31,7 +31,7 @@ note: function defined here --> $DIR/issue-100478.rs:31:4 | LL | fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {} - | ^^^^^^^^^^^^ ------ ------ ------ ------ + | ^^^^^^^^^^^^ help: did you mean | LL | four_shuffle(T1::default(), T2::default(), T3::default(), T4::default()); @@ -50,7 +50,7 @@ note: function defined here --> $DIR/issue-100478.rs:31:4 | LL | fn four_shuffle(_a: T1, _b: T2, _c: T3, _d: T4) {} - | ^^^^^^^^^^^^ ------ ------ ------ ------ + | ^^^^^^^^^^^^ ------ help: swap these arguments | LL | four_shuffle(T1::default(), T2::default(), T3::default(), /* T4 */); @@ -69,7 +69,7 @@ note: function defined here --> $DIR/issue-100478.rs:29:4 | LL | fn foo(p1: T1, p2: Arc<T2>, p3: T3, p4: Arc<T4>, p5: T5, p6: T6, p7: T7, p8: Arc<T8>) {} - | ^^^ ------ ----------- ------ ----------- ------ ------ ------ ----------- + | ^^^ ----------- help: provide the argument | LL | foo(p1, /* Arc<T2> */, p3, p4, p5, p6, p7, p8); diff --git a/tests/ui/argument-suggestions/issue-101097.stderr b/tests/ui/argument-suggestions/issue-101097.stderr index 6e21f19ab4f..45aa2dba5d5 100644 --- a/tests/ui/argument-suggestions/issue-101097.stderr +++ b/tests/ui/argument-suggestions/issue-101097.stderr @@ -13,18 +13,6 @@ note: function defined here | LL | fn f( | ^ -LL | a1: A, - | ----- -LL | a2: A, - | ----- -LL | b1: B, - | ----- -LL | b2: B, - | ----- -LL | c1: C, - | ----- -LL | c2: C, - | ----- help: did you mean | LL | f(A, A, B, B, C, C); @@ -41,18 +29,6 @@ note: function defined here | LL | fn f( | ^ -LL | a1: A, - | ----- -LL | a2: A, - | ----- -LL | b1: B, - | ----- -LL | b2: B, - | ----- -LL | c1: C, - | ----- -LL | c2: C, - | ----- help: did you mean | LL | f(A, A, B, B, C, C); @@ -72,14 +48,7 @@ note: function defined here | LL | fn f( | ^ -LL | a1: A, - | ----- -LL | a2: A, - | ----- -LL | b1: B, - | ----- -LL | b2: B, - | ----- +... LL | c1: C, | ----- LL | c2: C, @@ -104,18 +73,6 @@ note: function defined here | LL | fn f( | ^ -LL | a1: A, - | ----- -LL | a2: A, - | ----- -LL | b1: B, - | ----- -LL | b2: B, - | ----- -LL | c1: C, - | ----- -LL | c2: C, - | ----- help: did you mean | LL | f(A, A, B, B, C, C); @@ -137,18 +94,9 @@ note: function defined here | LL | fn f( | ^ -LL | a1: A, - | ----- -LL | a2: A, - | ----- +... LL | b1: B, | ----- -LL | b2: B, - | ----- -LL | c1: C, - | ----- -LL | c2: C, - | ----- help: did you mean | LL | f(A, A, /* B */, B, C, C); diff --git a/tests/ui/argument-suggestions/issue-109425.stderr b/tests/ui/argument-suggestions/issue-109425.stderr index 2cd53ed528e..232dc0183c8 100644 --- a/tests/ui/argument-suggestions/issue-109425.stderr +++ b/tests/ui/argument-suggestions/issue-109425.stderr @@ -29,7 +29,7 @@ note: function defined here --> $DIR/issue-109425.rs:4:4 | LL | fn i(_: u32) {} - | ^ ------ + | ^ help: remove the extra arguments | LL - i(0, 1, 2,); // i(0,) @@ -48,7 +48,7 @@ note: function defined here --> $DIR/issue-109425.rs:4:4 | LL | fn i(_: u32) {} - | ^ ------ + | ^ help: remove the extra arguments | LL - i(0, 1, 2); // i(0) @@ -67,7 +67,7 @@ note: function defined here --> $DIR/issue-109425.rs:5:4 | LL | fn is(_: u32, _: &str) {} - | ^^ ------ ------- + | ^^ help: remove the extra arguments | LL - is(0, 1, 2, ""); // is(0, "") @@ -86,7 +86,7 @@ note: function defined here --> $DIR/issue-109425.rs:5:4 | LL | fn is(_: u32, _: &str) {} - | ^^ ------ ------- + | ^^ help: remove the extra arguments | LL - is((), 1, "", ()); @@ -105,7 +105,7 @@ note: function defined here --> $DIR/issue-109425.rs:5:4 | LL | fn is(_: u32, _: &str) {} - | ^^ ------ ------- + | ^^ help: remove the extra arguments | LL - is(1, (), "", ()); @@ -124,7 +124,7 @@ note: function defined here --> $DIR/issue-109425.rs:6:4 | LL | fn s(_: &str) {} - | ^ ------- + | ^ help: remove the extra arguments | LL - s(0, 1, ""); // s("") diff --git a/tests/ui/argument-suggestions/issue-109831.stderr b/tests/ui/argument-suggestions/issue-109831.stderr index 12be0887121..cee87223866 100644 --- a/tests/ui/argument-suggestions/issue-109831.stderr +++ b/tests/ui/argument-suggestions/issue-109831.stderr @@ -38,7 +38,7 @@ note: function defined here --> $DIR/issue-109831.rs:4:4 | LL | fn f(b1: B, b2: B, a2: C) {} - | ^ ----- ----- ----- + | ^ ----- ----- help: remove the extra argument | LL - f(A, A, B, C); diff --git a/tests/ui/argument-suggestions/issue-96638.stderr b/tests/ui/argument-suggestions/issue-96638.stderr index 6492acbad94..509b2a157de 100644 --- a/tests/ui/argument-suggestions/issue-96638.stderr +++ b/tests/ui/argument-suggestions/issue-96638.stderr @@ -10,7 +10,7 @@ note: function defined here --> $DIR/issue-96638.rs:1:4 | LL | fn f(_: usize, _: &usize, _: usize) {} - | ^ -------- --------- -------- + | ^ -------- -------- help: provide the argument | LL | f(/* usize */, &x, /* usize */); diff --git a/tests/ui/argument-suggestions/issue-97197.stderr b/tests/ui/argument-suggestions/issue-97197.stderr index 3768367a5e6..1cf19fc1bc8 100644 --- a/tests/ui/argument-suggestions/issue-97197.stderr +++ b/tests/ui/argument-suggestions/issue-97197.stderr @@ -8,7 +8,7 @@ note: function defined here --> $DIR/issue-97197.rs:6:8 | LL | pub fn g(a1: (), a2: bool, a3: bool, a4: bool, a5: bool, a6: ()) -> () {} - | ^ ------ -------- -------- -------- -------- ------ + | ^ -------- -------- -------- -------- help: provide the arguments | LL | g((), /* bool */, /* bool */, /* bool */, /* bool */, ()); diff --git a/tests/ui/argument-suggestions/issue-97484.stderr b/tests/ui/argument-suggestions/issue-97484.stderr index a7708f6e0d7..e09d1928f74 100644 --- a/tests/ui/argument-suggestions/issue-97484.stderr +++ b/tests/ui/argument-suggestions/issue-97484.stderr @@ -12,7 +12,7 @@ note: function defined here --> $DIR/issue-97484.rs:9:4 | LL | fn foo(a: &A, d: D, e: &E, g: G) {} - | ^^^ ----- ---- ----- ---- + | ^^^ ----- help: consider borrowing here | LL | foo(&&A, B, C, D, &E, F, G); diff --git a/tests/ui/argument-suggestions/missing_arguments.stderr b/tests/ui/argument-suggestions/missing_arguments.stderr index 3a27a51d032..fc219b9ce2c 100644 --- a/tests/ui/argument-suggestions/missing_arguments.stderr +++ b/tests/ui/argument-suggestions/missing_arguments.stderr @@ -40,7 +40,7 @@ note: function defined here --> $DIR/missing_arguments.rs:2:4 | LL | fn two_same(_a: i32, _b: i32) {} - | ^^^^^^^^ ------- ------- + | ^^^^^^^^ ------- help: provide the argument | LL | two_same(1, /* i32 */); @@ -72,7 +72,7 @@ note: function defined here --> $DIR/missing_arguments.rs:3:4 | LL | fn two_diff(_a: i32, _b: f32) {} - | ^^^^^^^^ ------- ------- + | ^^^^^^^^ ------- help: provide the argument | LL | two_diff(1, /* f32 */); @@ -88,7 +88,7 @@ note: function defined here --> $DIR/missing_arguments.rs:3:4 | LL | fn two_diff(_a: i32, _b: f32) {} - | ^^^^^^^^ ------- ------- + | ^^^^^^^^ ------- help: provide the argument | LL | two_diff(/* i32 */, 1.0); @@ -120,7 +120,7 @@ note: function defined here --> $DIR/missing_arguments.rs:4:4 | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} - | ^^^^^^^^^^ ------- ------- ------- + | ^^^^^^^^^^ ------- ------- help: provide the arguments | LL | three_same(1, /* i32 */, /* i32 */); @@ -136,7 +136,7 @@ note: function defined here --> $DIR/missing_arguments.rs:4:4 | LL | fn three_same(_a: i32, _b: i32, _c: i32) {} - | ^^^^^^^^^^ ------- ------- ------- + | ^^^^^^^^^^ ------- help: provide the argument | LL | three_same(1, 1, /* i32 */); @@ -152,7 +152,7 @@ note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ ------- help: provide the argument | LL | three_diff(/* i32 */, 1.0, ""); @@ -168,7 +168,7 @@ note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ ------- help: provide the argument | LL | three_diff(1, /* f32 */, ""); @@ -184,7 +184,7 @@ note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ -------- help: provide the argument | LL | three_diff(1, 1.0, /* &str */); @@ -200,7 +200,7 @@ note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ ------- ------- help: provide the arguments | LL | three_diff(/* i32 */, /* f32 */, ""); @@ -219,7 +219,7 @@ note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ ------- -------- help: provide the arguments | LL | three_diff(/* i32 */, 1.0, /* &str */); @@ -235,7 +235,7 @@ note: function defined here --> $DIR/missing_arguments.rs:5:4 | LL | fn three_diff(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ ------- -------- help: provide the arguments | LL | three_diff(1, /* f32 */, /* &str */); @@ -267,7 +267,7 @@ note: function defined here --> $DIR/missing_arguments.rs:6:4 | LL | fn four_repeated(_a: i32, _b: f32, _c: f32, _d: &str) {} - | ^^^^^^^^^^^^^ ------- ------- ------- -------- + | ^^^^^^^^^^^^^ ------- ------- help: provide the arguments | LL | four_repeated(1, /* f32 */, /* f32 */, ""); @@ -299,7 +299,7 @@ note: function defined here --> $DIR/missing_arguments.rs:7:4 | LL | fn complex(_a: i32, _b: f32, _c: i32, _d: f32, _e: &str) {} - | ^^^^^^^ ------- ------- ------- ------- -------- + | ^^^^^^^ ------- ------- ------- help: provide the arguments | LL | complex(1, /* f32 */, /* i32 */, /* f32 */, ""); diff --git a/tests/ui/argument-suggestions/mixed_cases.stderr b/tests/ui/argument-suggestions/mixed_cases.stderr index bec5d4dc16b..c19cd68c771 100644 --- a/tests/ui/argument-suggestions/mixed_cases.stderr +++ b/tests/ui/argument-suggestions/mixed_cases.stderr @@ -10,7 +10,7 @@ note: function defined here --> $DIR/mixed_cases.rs:5:4 | LL | fn two_args(_a: i32, _b: f32) {} - | ^^^^^^^^ ------- ------- + | ^^^^^^^^ ------- help: remove the extra argument | LL - two_args(1, "", X {}); @@ -30,7 +30,7 @@ note: function defined here --> $DIR/mixed_cases.rs:6:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ ------- help: did you mean | LL | three_args(1, /* f32 */, ""); @@ -49,7 +49,7 @@ note: function defined here --> $DIR/mixed_cases.rs:6:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ ------- -------- help: provide the argument | LL | three_args(1, /* f32 */, /* &str */); @@ -67,7 +67,7 @@ note: function defined here --> $DIR/mixed_cases.rs:6:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ ------- help: did you mean | LL | three_args(1, /* f32 */, ""); @@ -86,7 +86,7 @@ note: function defined here --> $DIR/mixed_cases.rs:6:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ ------- help: swap these arguments | LL | three_args(1, /* f32 */, ""); @@ -106,7 +106,7 @@ note: function defined here --> $DIR/mixed_cases.rs:6:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ ------- help: did you mean | LL | three_args(1, /* f32 */, ""); diff --git a/tests/ui/argument-suggestions/permuted_arguments.stderr b/tests/ui/argument-suggestions/permuted_arguments.stderr index 655807a7f38..f6bec520984 100644 --- a/tests/ui/argument-suggestions/permuted_arguments.stderr +++ b/tests/ui/argument-suggestions/permuted_arguments.stderr @@ -11,7 +11,7 @@ note: function defined here --> $DIR/permuted_arguments.rs:5:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ help: reorder these arguments | LL | three_args(1, 1.0, ""); @@ -32,7 +32,7 @@ note: function defined here --> $DIR/permuted_arguments.rs:6:4 | LL | fn many_args(_a: i32, _b: f32, _c: &str, _d: X, _e: Y) {} - | ^^^^^^^^^ ------- ------- -------- ----- ----- + | ^^^^^^^^^ help: reorder these arguments | LL | many_args(1, 1.0, "", X {}, Y {}); diff --git a/tests/ui/argument-suggestions/suggest-better-removing-issue-126246.stderr b/tests/ui/argument-suggestions/suggest-better-removing-issue-126246.stderr index 730f20cfb88..48c647764df 100644 --- a/tests/ui/argument-suggestions/suggest-better-removing-issue-126246.stderr +++ b/tests/ui/argument-suggestions/suggest-better-removing-issue-126246.stderr @@ -38,7 +38,7 @@ note: function defined here --> $DIR/suggest-better-removing-issue-126246.rs:1:4 | LL | fn add_one(x: i32) -> i32 { - | ^^^^^^^ ------ + | ^^^^^^^ help: remove the extra argument | LL - add_one(2, 2); @@ -55,7 +55,7 @@ note: function defined here --> $DIR/suggest-better-removing-issue-126246.rs:1:4 | LL | fn add_one(x: i32) -> i32 { - | ^^^^^^^ ------ + | ^^^^^^^ help: remove the extra argument | LL - add_one(no_such_local, 10); @@ -72,7 +72,7 @@ note: function defined here --> $DIR/suggest-better-removing-issue-126246.rs:1:4 | LL | fn add_one(x: i32) -> i32 { - | ^^^^^^^ ------ + | ^^^^^^^ help: remove the extra argument | LL - add_one(10, no_such_local); @@ -89,7 +89,7 @@ note: function defined here --> $DIR/suggest-better-removing-issue-126246.rs:5:4 | LL | fn add_two(x: i32, y: i32) -> i32 { - | ^^^^^^^ ------ ------ + | ^^^^^^^ help: remove the extra argument | LL - add_two(10, no_such_local, 10); @@ -106,7 +106,7 @@ note: function defined here --> $DIR/suggest-better-removing-issue-126246.rs:5:4 | LL | fn add_two(x: i32, y: i32) -> i32 { - | ^^^^^^^ ------ ------ + | ^^^^^^^ help: remove the extra argument | LL - add_two(no_such_local, 10, 10); @@ -123,7 +123,7 @@ note: function defined here --> $DIR/suggest-better-removing-issue-126246.rs:5:4 | LL | fn add_two(x: i32, y: i32) -> i32 { - | ^^^^^^^ ------ ------ + | ^^^^^^^ help: remove the extra argument | LL - add_two(10, 10, no_such_local); diff --git a/tests/ui/argument-suggestions/swapped_arguments.stderr b/tests/ui/argument-suggestions/swapped_arguments.stderr index dabf5e952b2..22db77b3b93 100644 --- a/tests/ui/argument-suggestions/swapped_arguments.stderr +++ b/tests/ui/argument-suggestions/swapped_arguments.stderr @@ -10,7 +10,7 @@ note: function defined here --> $DIR/swapped_arguments.rs:3:4 | LL | fn two_args(_a: i32, _b: f32) {} - | ^^^^^^^^ ------- ------- + | ^^^^^^^^ help: swap these arguments | LL | two_args(1, 1.0); @@ -28,7 +28,7 @@ note: function defined here --> $DIR/swapped_arguments.rs:4:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ help: swap these arguments | LL | three_args(1, 1.0, ""); @@ -46,7 +46,7 @@ note: function defined here --> $DIR/swapped_arguments.rs:4:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ help: swap these arguments | LL | three_args(1, 1.0, ""); @@ -64,7 +64,7 @@ note: function defined here --> $DIR/swapped_arguments.rs:4:4 | LL | fn three_args(_a: i32, _b: f32, _c: &str) {} - | ^^^^^^^^^^ ------- ------- -------- + | ^^^^^^^^^^ help: swap these arguments | LL | three_args(1, 1.0, ""); @@ -84,7 +84,7 @@ note: function defined here --> $DIR/swapped_arguments.rs:5:4 | LL | fn four_args(_a: i32, _b: f32, _c: &str, _d: X) {} - | ^^^^^^^^^ ------- ------- -------- ----- + | ^^^^^^^^^ help: did you mean | LL | four_args(1, 1.0, "", X {}); diff --git a/tests/ui/associated-consts/issue-58022.stderr b/tests/ui/associated-consts/issue-58022.stderr index 82cbc9ed3b0..37cb162b2b2 100644 --- a/tests/ui/associated-consts/issue-58022.stderr +++ b/tests/ui/associated-consts/issue-58022.stderr @@ -1,12 +1,3 @@ -error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type - --> $DIR/issue-58022.rs:4:25 - | -LL | const SIZE: usize; - | ------------------ `Foo::SIZE` defined here -LL | -LL | fn new(slice: &[u8; Foo::SIZE]) -> Self; - | ^^^^^^^^^ cannot refer to the associated constant of trait - error[E0277]: the size for values of type `[u8]` cannot be known at compilation time --> $DIR/issue-58022.rs:13:41 | @@ -21,6 +12,15 @@ LL | pub struct Bar<T: ?Sized>(T); | ^^^ = note: the return type of a function must have a statically known size +error[E0790]: cannot refer to the associated constant on trait without specifying the corresponding `impl` type + --> $DIR/issue-58022.rs:4:25 + | +LL | const SIZE: usize; + | ------------------ `Foo::SIZE` defined here +LL | +LL | fn new(slice: &[u8; Foo::SIZE]) -> Self; + | ^^^^^^^^^ cannot refer to the associated constant of trait + error[E0423]: expected function, tuple struct or tuple variant, found trait `Foo` --> $DIR/issue-58022.rs:15:9 | diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs index aa8667a00ca..b25d8a34aca 100644 --- a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs +++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.rs @@ -1,8 +1,5 @@ //@ edition: 2021 -// Test doesn't fail until monomorphization time, unfortunately. -//@ build-fail - fn main() { let _ = async { A.first().await.second().await; diff --git a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr index 8126c6e1394..4ca6ef89819 100644 --- a/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr +++ b/tests/ui/async-await/in-trait/indirect-recursion-issue-112047.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in an async fn requires boxing - --> $DIR/indirect-recursion-issue-112047.rs:34:5 + --> $DIR/indirect-recursion-issue-112047.rs:31:5 | LL | async fn second(self) { | ^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/binding/expr-match-generic.rs b/tests/ui/binding/expr-match-generic.rs index 975eec42fd0..dcc069b9fb3 100644 --- a/tests/ui/binding/expr-match-generic.rs +++ b/tests/ui/binding/expr-match-generic.rs @@ -5,7 +5,7 @@ type compare<T> = extern "Rust" fn(T, T) -> bool; fn test_generic<T:Clone>(expected: T, eq: compare<T>) { let actual: T = match true { true => { expected.clone() }, _ => panic!("wat") }; - assert!((eq(expected, actual))); + assert!(eq(expected, actual)); } fn test_bool() { diff --git a/tests/ui/binding/expr-match.rs b/tests/ui/binding/expr-match.rs index 049beaaf51b..ce502ae1490 100644 --- a/tests/ui/binding/expr-match.rs +++ b/tests/ui/binding/expr-match.rs @@ -1,20 +1,17 @@ //@ run-pass - - - // Tests for using match as an expression fn test_basic() { let mut rs: bool = match true { true => { true } false => { false } }; - assert!((rs)); + assert!(rs); rs = match false { true => { false } false => { true } }; - assert!((rs)); + assert!(rs); } fn test_inferrence() { let rs = match true { true => { true } false => { false } }; - assert!((rs)); + assert!(rs); } fn test_alt_as_alt_head() { @@ -25,7 +22,7 @@ fn test_alt_as_alt_head() { true => { false } false => { true } }; - assert!((rs)); + assert!(rs); } fn test_alt_as_block_result() { @@ -34,7 +31,7 @@ fn test_alt_as_block_result() { true => { false } false => { match true { true => { true } false => { false } } } }; - assert!((rs)); + assert!(rs); } pub fn main() { diff --git a/tests/ui/binop/binops.rs b/tests/ui/binop/binops.rs index 0adbb49b14a..7142190a45b 100644 --- a/tests/ui/binop/binops.rs +++ b/tests/ui/binop/binops.rs @@ -5,23 +5,23 @@ fn test_nil() { assert_eq!((), ()); - assert!((!(() != ()))); - assert!((!(() < ()))); - assert!((() <= ())); - assert!((!(() > ()))); - assert!((() >= ())); + assert!(!(() != ())); + assert!(!(() < ())); + assert!(() <= ()); + assert!(!(() > ())); + assert!(() >= ()); } fn test_bool() { - assert!((!(true < false))); - assert!((!(true <= false))); - assert!((true > false)); - assert!((true >= false)); + assert!(!(true < false)); + assert!(!(true <= false)); + assert!(true > false); + assert!(true >= false); - assert!((false < true)); - assert!((false <= true)); - assert!((!(false > true))); - assert!((!(false >= true))); + assert!(false < true); + assert!(false <= true); + assert!(!(false > true)); + assert!(!(false >= true)); // Bools support bitwise binops assert_eq!(false & false, false); @@ -76,9 +76,9 @@ fn test_class() { } assert_eq!(q, r); r.y = 17; - assert!((r.y != q.y)); + assert!(r.y != q.y); assert_eq!(r.y, 17); - assert!((q != r)); + assert!(q != r); } pub fn main() { diff --git a/tests/ui/binop/structured-compare.rs b/tests/ui/binop/structured-compare.rs index 164760cd7a0..7d1eff45302 100644 --- a/tests/ui/binop/structured-compare.rs +++ b/tests/ui/binop/structured-compare.rs @@ -17,14 +17,14 @@ pub fn main() { let a = (1, 2, 3); let b = (1, 2, 3); assert_eq!(a, b); - assert!((a != (1, 2, 4))); - assert!((a < (1, 2, 4))); - assert!((a <= (1, 2, 4))); - assert!(((1, 2, 4) > a)); - assert!(((1, 2, 4) >= a)); + assert!(a != (1, 2, 4)); + assert!(a < (1, 2, 4)); + assert!(a <= (1, 2, 4)); + assert!((1, 2, 4) > a); + assert!((1, 2, 4) >= a); let x = foo::large; let y = foo::small; - assert!((x != y)); + assert!(x != y); assert_eq!(x, foo::large); - assert!((x != foo::small)); + assert!(x != foo::small); } diff --git a/tests/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr b/tests/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr index 11ee8f7bb91..6e0c69a4eb0 100644 --- a/tests/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr +++ b/tests/ui/borrowck/borrowck-thread-local-static-borrow-outlives-fn.stderr @@ -4,7 +4,7 @@ error[E0712]: thread-local variable borrowed past end of function LL | assert_static(&FOO); | ^^^^ thread-local variables cannot be borrowed beyond the end of the function LL | } - | - end of enclosing function is here + | - end of enclosing function is here error: aborting due to 1 previous error diff --git a/tests/ui/c-variadic/variadic-ffi-1.stderr b/tests/ui/c-variadic/variadic-ffi-1.stderr index 7a54d043356..7eca4cb61bc 100644 --- a/tests/ui/c-variadic/variadic-ffi-1.stderr +++ b/tests/ui/c-variadic/variadic-ffi-1.stderr @@ -14,7 +14,7 @@ note: function defined here --> $DIR/variadic-ffi-1.rs:15:8 | LL | fn foo(f: isize, x: u8, ...); - | ^^^ + | ^^^ - - help: provide the arguments | LL | foo(/* isize */, /* u8 */); @@ -30,7 +30,7 @@ note: function defined here --> $DIR/variadic-ffi-1.rs:15:8 | LL | fn foo(f: isize, x: u8, ...); - | ^^^ + | ^^^ - help: provide the argument | LL | foo(1, /* u8 */); diff --git a/tests/ui/cenum_impl_drop_cast.rs b/tests/ui/cenum_impl_drop_cast.rs index 96e3d967e2c..f681434dd86 100644 --- a/tests/ui/cenum_impl_drop_cast.rs +++ b/tests/ui/cenum_impl_drop_cast.rs @@ -1,5 +1,3 @@ -#![deny(cenum_impl_drop_cast)] - enum E { A = 0, } @@ -14,5 +12,4 @@ fn main() { let e = E::A; let i = e as u32; //~^ ERROR cannot cast enum `E` into integer `u32` because it implements `Drop` - //~| WARN this was previously accepted } diff --git a/tests/ui/cenum_impl_drop_cast.stderr b/tests/ui/cenum_impl_drop_cast.stderr index 541d15d021d..35c69f4b4b7 100644 --- a/tests/ui/cenum_impl_drop_cast.stderr +++ b/tests/ui/cenum_impl_drop_cast.stderr @@ -1,31 +1,8 @@ error: cannot cast enum `E` into integer `u32` because it implements `Drop` - --> $DIR/cenum_impl_drop_cast.rs:15:13 + --> $DIR/cenum_impl_drop_cast.rs:13:13 | LL | let i = e as u32; | ^^^^^^^^ - | - = 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 #73333 <https://github.com/rust-lang/rust/issues/73333> -note: the lint level is defined here - --> $DIR/cenum_impl_drop_cast.rs:1:9 - | -LL | #![deny(cenum_impl_drop_cast)] - | ^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error -Future incompatibility report: Future breakage diagnostic: -error: cannot cast enum `E` into integer `u32` because it implements `Drop` - --> $DIR/cenum_impl_drop_cast.rs:15:13 - | -LL | let i = e as u32; - | ^^^^^^^^ - | - = 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 #73333 <https://github.com/rust-lang/rust/issues/73333> -note: the lint level is defined here - --> $DIR/cenum_impl_drop_cast.rs:1:9 - | -LL | #![deny(cenum_impl_drop_cast)] - | ^^^^^^^^^^^^^^^^^^^^ - diff --git a/tests/ui/cfg/conditional-compile.rs b/tests/ui/cfg/conditional-compile.rs index a4f334dd696..dff280054d6 100644 --- a/tests/ui/cfg/conditional-compile.rs +++ b/tests/ui/cfg/conditional-compile.rs @@ -85,7 +85,7 @@ pub fn main() { pub fn main() { // Exercise some of the configured items in ways that wouldn't be possible // if they had the FALSE definition - assert!((b)); + assert!(b); let _x: t = true; let _y: tg = tg::bar; diff --git a/tests/ui/check-cfg/cargo-build-script.stderr b/tests/ui/check-cfg/cargo-build-script.stderr index df0bc47571c..03a7156a4d6 100644 --- a/tests/ui/check-cfg/cargo-build-script.stderr +++ b/tests/ui/check-cfg/cargo-build-script.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `has_foo` LL | #[cfg(has_foo)] | ^^^^^^^ | - = help: expected names are: `has_bar` and 30 more + = help: expected names are: `has_bar` and 31 more = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] diff --git a/tests/ui/check-cfg/cargo-feature.none.stderr b/tests/ui/check-cfg/cargo-feature.none.stderr index 58813a1f677..b83d1794984 100644 --- a/tests/ui/check-cfg/cargo-feature.none.stderr +++ b/tests/ui/check-cfg/cargo-feature.none.stderr @@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable` LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ | - = help: expected names are: `docsrs`, `feature`, and `test` and 30 more + = help: expected names are: `docsrs`, `feature`, and `test` and 31 more = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] diff --git a/tests/ui/check-cfg/cargo-feature.some.stderr b/tests/ui/check-cfg/cargo-feature.some.stderr index 5a12be81338..2cddcbbcd7f 100644 --- a/tests/ui/check-cfg/cargo-feature.some.stderr +++ b/tests/ui/check-cfg/cargo-feature.some.stderr @@ -25,7 +25,7 @@ warning: unexpected `cfg` condition name: `tokio_unstable` LL | #[cfg(tokio_unstable)] | ^^^^^^^^^^^^^^ | - = help: expected names are: `CONFIG_NVME`, `docsrs`, `feature`, and `test` and 30 more + = help: expected names are: `CONFIG_NVME`, `docsrs`, `feature`, and `test` and 31 more = help: consider using a Cargo feature instead = help: or consider adding in `Cargo.toml` the `check-cfg` lint config for the lint: [lints.rust] diff --git a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr index 7c276c58170..68e1259dbb8 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-duplicate.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `value` LL | #[cfg(value)] | ^^^^^ | - = help: expected names are: `bar`, `bee`, `cow`, and `foo` and 30 more + = help: expected names are: `bar`, `bee`, `cow`, and `foo` and 31 more = help: to expect this configuration use `--check-cfg=cfg(value)` = 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/cfg-value-for-cfg-name-multiple.stderr b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr index 9687a043e83..138c7fc7584 100644 --- a/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr +++ b/tests/ui/check-cfg/cfg-value-for-cfg-name-multiple.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_value` LL | #[cfg(my_value)] | ^^^^^^^^ | - = help: expected names are: `bar` and `foo` and 30 more + = help: expected names are: `bar` and `foo` and 31 more = help: to expect this configuration use `--check-cfg=cfg(my_value)` = 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/exhaustive-names-values.empty_cfg.stderr b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr index 7e77ba63a12..e7b8f355057 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.empty_cfg.stderr @@ -14,7 +14,7 @@ warning: unexpected `cfg` condition value: `value` LL | #[cfg(target_vendor = "value")] | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs` + = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition name: `feature` diff --git a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr index 10302f0a7e4..95af0a90929 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.feature.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.feature.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `feature` and 30 more + = help: expected names are: `feature` and 31 more = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` = 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 @@ -15,7 +15,7 @@ warning: unexpected `cfg` condition value: `value` LL | #[cfg(target_vendor = "value")] | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs` + = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` diff --git a/tests/ui/check-cfg/exhaustive-names-values.full.stderr b/tests/ui/check-cfg/exhaustive-names-values.full.stderr index 10302f0a7e4..95af0a90929 100644 --- a/tests/ui/check-cfg/exhaustive-names-values.full.stderr +++ b/tests/ui/check-cfg/exhaustive-names-values.full.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `unknown_key` LL | #[cfg(unknown_key = "value")] | ^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `feature` and 30 more + = help: expected names are: `feature` and 31 more = help: to expect this configuration use `--check-cfg=cfg(unknown_key, values("value"))` = 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 @@ -15,7 +15,7 @@ warning: unexpected `cfg` condition value: `value` LL | #[cfg(target_vendor = "value")] | ^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs` + = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration warning: unexpected `cfg` condition value: `unk` diff --git a/tests/ui/check-cfg/mix.stderr b/tests/ui/check-cfg/mix.stderr index 033aaef848f..be4d7c77276 100644 --- a/tests/ui/check-cfg/mix.stderr +++ b/tests/ui/check-cfg/mix.stderr @@ -44,7 +44,7 @@ warning: unexpected `cfg` condition name: `uu` LL | #[cfg_attr(uu, unix)] | ^^ | - = help: expected names are: `feature` and 30 more + = help: expected names are: `feature` and 31 more = help: to expect this configuration use `--check-cfg=cfg(uu)` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/raw-keywords.edition2015.stderr b/tests/ui/check-cfg/raw-keywords.edition2015.stderr index f19ded9cb67..8ca33e088fc 100644 --- a/tests/ui/check-cfg/raw-keywords.edition2015.stderr +++ b/tests/ui/check-cfg/raw-keywords.edition2015.stderr @@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `r#false` LL | #[cfg(r#false)] | ^^^^^^^ | - = help: expected names are: `async`, `edition2015`, `edition2021`, and `r#true` and 30 more + = help: expected names are: `async`, `edition2015`, `edition2021`, and `r#true` and 31 more = help: to expect this configuration use `--check-cfg=cfg(r#false)` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/raw-keywords.edition2021.stderr b/tests/ui/check-cfg/raw-keywords.edition2021.stderr index 6096148a259..cce55720bdd 100644 --- a/tests/ui/check-cfg/raw-keywords.edition2021.stderr +++ b/tests/ui/check-cfg/raw-keywords.edition2021.stderr @@ -14,7 +14,7 @@ warning: unexpected `cfg` condition name: `r#false` LL | #[cfg(r#false)] | ^^^^^^^ | - = help: expected names are: `r#async`, `edition2015`, `edition2021`, and `r#true` and 30 more + = help: expected names are: `r#async`, `edition2015`, `edition2021`, and `r#true` and 31 more = help: to expect this configuration use `--check-cfg=cfg(r#false)` = note: see <https://doc.rust-lang.org/nightly/rustc/check-cfg.html> for more information about checking conditional configuration diff --git a/tests/ui/check-cfg/report-in-external-macros.cargo.stderr b/tests/ui/check-cfg/report-in-external-macros.cargo.stderr index a6584d777a3..989a01f2244 100644 --- a/tests/ui/check-cfg/report-in-external-macros.cargo.stderr +++ b/tests/ui/check-cfg/report-in-external-macros.cargo.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_lib_cfg` LL | cfg_macro::my_lib_macro!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `feature` and 30 more + = help: expected names are: `feature` and 31 more = note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate = help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg = help: the macro `cfg_macro::my_lib_macro` may come from an old version of the `cfg_macro` crate, try updating your dependency with `cargo update -p cfg_macro` diff --git a/tests/ui/check-cfg/report-in-external-macros.rustc.stderr b/tests/ui/check-cfg/report-in-external-macros.rustc.stderr index 914b5a0efe3..95d10e014f3 100644 --- a/tests/ui/check-cfg/report-in-external-macros.rustc.stderr +++ b/tests/ui/check-cfg/report-in-external-macros.rustc.stderr @@ -4,7 +4,7 @@ warning: unexpected `cfg` condition name: `my_lib_cfg` LL | cfg_macro::my_lib_macro!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = help: expected names are: `feature` and 30 more + = help: expected names are: `feature` and 31 more = note: using a cfg inside a macro will use the cfgs from the destination crate and not the ones from the defining crate = help: try referring to `cfg_macro::my_lib_macro` crate for guidance on how handle this unexpected cfg = help: to expect this configuration use `--check-cfg=cfg(my_lib_cfg)` diff --git a/tests/ui/check-cfg/target_feature.stderr b/tests/ui/check-cfg/target_feature.stderr index bf54d17f6ec..70852423bdb 100644 --- a/tests/ui/check-cfg/target_feature.stderr +++ b/tests/ui/check-cfg/target_feature.stderr @@ -127,6 +127,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `isa-68881` `isa-68882` `jsconv` +`kl` `lahfsahf` `lasx` `lbt` @@ -271,6 +272,7 @@ LL | cfg!(target_feature = "_UNEXPECTED_VALUE"); `vsx` `wfxt` `wide-arithmetic` +`widekl` `x87` `xop` `xsave` diff --git a/tests/ui/check-cfg/well-known-names.stderr b/tests/ui/check-cfg/well-known-names.stderr index 4ff90261158..000315443f8 100644 --- a/tests/ui/check-cfg/well-known-names.stderr +++ b/tests/ui/check-cfg/well-known-names.stderr @@ -5,6 +5,7 @@ LL | #[cfg(list_all_well_known_cfgs)] | ^^^^^^^^^^^^^^^^^^^^^^^^ | = help: expected names are: `clippy` +`contract_checks` `debug_assertions` `doc` `doctest` diff --git a/tests/ui/check-cfg/well-known-values.stderr b/tests/ui/check-cfg/well-known-values.stderr index ffebd7e5531..6421cb8f2c2 100644 --- a/tests/ui/check-cfg/well-known-values.stderr +++ b/tests/ui/check-cfg/well-known-values.stderr @@ -138,7 +138,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_arch = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_arch` are: `aarch64`, `arm`, `arm64ec`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64`, and `xtensa` + = note: expected values for `target_arch` are: `aarch64`, `amdgpu`, `arm`, `arm64ec`, `avr`, `bpf`, `csky`, `hexagon`, `loongarch64`, `m68k`, `mips`, `mips32r6`, `mips64`, `mips64r6`, `msp430`, `nvptx64`, `powerpc`, `powerpc64`, `riscv32`, `riscv64`, `s390x`, `sparc`, `sparc64`, `wasm32`, `wasm64`, `x86`, `x86_64`, and `xtensa` = 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`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `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` @@ -230,7 +230,7 @@ warning: unexpected `cfg` condition value: `_UNEXPECTED_VALUE` LL | target_vendor = "_UNEXPECTED_VALUE", | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ | - = note: expected values for `target_vendor` are: `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs` + = note: expected values for `target_vendor` are: `amd`, `apple`, `espressif`, `fortanix`, `ibm`, `kmc`, `mti`, `nintendo`, `nvidia`, `pc`, `risc0`, `sony`, `sun`, `unikraft`, `unknown`, `uwp`, `win7`, and `wrs` = 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`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `visionos`, `vita`, `vxworks`, `wasi`, `watchos`, `windows`, `xous`, and `zkvm` + = note: expected values for `target_os` are: `aix`, `amdhsa`, `android`, `cuda`, `dragonfly`, `emscripten`, `espidf`, `freebsd`, `fuchsia`, `haiku`, `hermit`, `horizon`, `hurd`, `illumos`, `ios`, `l4re`, `linux`, `macos`, `netbsd`, `none`, `nto`, `nuttx`, `openbsd`, `psp`, `psx`, `redox`, `rtems`, `solaris`, `solid_asp3`, `teeos`, `trusty`, `tvos`, `uefi`, `unknown`, `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-40883.rs b/tests/ui/codegen/StackColoring-not-blowup-stack-issue-40883.rs index a4646d67c68..a4646d67c68 100644 --- a/tests/ui/issues/issue-40883.rs +++ b/tests/ui/codegen/StackColoring-not-blowup-stack-issue-40883.rs diff --git a/tests/ui/codegen/issue-99551.rs b/tests/ui/codegen/issue-99551.rs index 9bacbaa6edc..f498718310d 100644 --- a/tests/ui/codegen/issue-99551.rs +++ b/tests/ui/codegen/issue-99551.rs @@ -1,5 +1,4 @@ //@ build-pass -#![feature(trait_upcasting)] pub trait A {} pub trait B {} diff --git a/tests/ui/const-generics/std/const-generics-range.full.stderr b/tests/ui/const-generics/std/const-generics-range.full.stderr index 5bf48ad7385..2b5c63e6643 100644 --- a/tests/ui/const-generics/std/const-generics-range.full.stderr +++ b/tests/ui/const-generics/std/const-generics-range.full.stderr @@ -4,7 +4,7 @@ error[E0741]: `std::ops::Range<usize>` must implement `ConstParamTy` to be used LL | struct _Range<const R: std::ops::Range<usize>>; | ^^^^^^^^^^^^^^^^^^^^^^ -error[E0741]: `RangeFrom<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter +error[E0741]: `std::ops::RangeFrom<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter --> $DIR/const-generics-range.rs:13:28 | LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>; @@ -16,7 +16,7 @@ error[E0741]: `RangeFull` must implement `ConstParamTy` to be used as the type o LL | struct _RangeFull<const R: std::ops::RangeFull>; | ^^^^^^^^^^^^^^^^^^^ -error[E0741]: `RangeInclusive<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter +error[E0741]: `std::ops::RangeInclusive<usize>` must implement `ConstParamTy` to be used as the type of a const generic parameter --> $DIR/const-generics-range.rs:24:33 | LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>; diff --git a/tests/ui/const-generics/std/const-generics-range.min.stderr b/tests/ui/const-generics/std/const-generics-range.min.stderr index fd23b9b248a..04e3fe74453 100644 --- a/tests/ui/const-generics/std/const-generics-range.min.stderr +++ b/tests/ui/const-generics/std/const-generics-range.min.stderr @@ -10,7 +10,7 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more LL + #![feature(adt_const_params)] | -error: `RangeFrom<usize>` is forbidden as the type of a const generic parameter +error: `std::ops::RangeFrom<usize>` is forbidden as the type of a const generic parameter --> $DIR/const-generics-range.rs:13:28 | LL | struct _RangeFrom<const R: std::ops::RangeFrom<usize>>; @@ -34,7 +34,7 @@ help: add `#![feature(adt_const_params)]` to the crate attributes to enable more LL + #![feature(adt_const_params)] | -error: `RangeInclusive<usize>` is forbidden as the type of a const generic parameter +error: `std::ops::RangeInclusive<usize>` is forbidden as the type of a const generic parameter --> $DIR/const-generics-range.rs:24:33 | LL | struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>; diff --git a/tests/ui/const-generics/std/const-generics-range.rs b/tests/ui/const-generics/std/const-generics-range.rs index f959f1e2949..3a238ed177e 100644 --- a/tests/ui/const-generics/std/const-generics-range.rs +++ b/tests/ui/const-generics/std/const-generics-range.rs @@ -11,7 +11,7 @@ const RANGE : _Range<{ 0 .. 1000 }> = _Range; // `RangeFrom` should be usable within const generics: struct _RangeFrom<const R: std::ops::RangeFrom<usize>>; -//[min]~^ ERROR `RangeFrom<usize>` is forbidden +//[min]~^ ERROR `std::ops::RangeFrom<usize>` is forbidden const RANGE_FROM : _RangeFrom<{ 0 .. }> = _RangeFrom; // `RangeFull` should be usable within const generics: @@ -22,7 +22,7 @@ const RANGE_FULL : _RangeFull<{ .. }> = _RangeFull; // Regression test for #70155 // `RangeInclusive` should be usable within const generics: struct _RangeInclusive<const R: std::ops::RangeInclusive<usize>>; -//[min]~^ ERROR `RangeInclusive<usize>` is forbidden +//[min]~^ ERROR `std::ops::RangeInclusive<usize>` is forbidden const RANGE_INCLUSIVE : _RangeInclusive<{ 0 ..= 999 }> = _RangeInclusive; // `RangeTo` should be usable within const generics: diff --git a/tests/ui/const-ptr/forbidden_slices.stderr b/tests/ui/const-ptr/forbidden_slices.stderr index fad078ad2b2..2e0c04dcf1e 100644 --- a/tests/ui/const-ptr/forbidden_slices.stderr +++ b/tests/ui/const-ptr/forbidden_slices.stderr @@ -190,7 +190,7 @@ LL | from_ptr_range(ptr..ptr.add(1)) error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: `ptr_offset_from_unsigned` called on pointers into different allocations + = note: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation | note: inside `std::ptr::const_ptr::<impl *const u32>::sub_ptr` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -205,7 +205,7 @@ LL | pub static R9: &[u32] = unsafe { from_ptr_range(&D0..(&D0 as *const u32).ad error[E0080]: could not evaluate static initializer --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: `ptr_offset_from_unsigned` called on pointers into different allocations + = note: `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation | note: inside `std::ptr::const_ptr::<impl *const u32>::sub_ptr` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/consts/const-slice-array-deref.rs b/tests/ui/consts/const-slice-array-deref.rs index 9d84ed4bdb0..99563ac968c 100644 --- a/tests/ui/consts/const-slice-array-deref.rs +++ b/tests/ui/consts/const-slice-array-deref.rs @@ -1,6 +1,5 @@ const ONE: [u16] = [1]; //~^ ERROR the size for values of type `[u16]` cannot be known at compilation time -//~| ERROR the size for values of type `[u16]` cannot be known at compilation time //~| ERROR mismatched types const TWO: &'static u16 = &ONE[0]; diff --git a/tests/ui/consts/const-slice-array-deref.stderr b/tests/ui/consts/const-slice-array-deref.stderr index 6e69744144e..346685380cc 100644 --- a/tests/ui/consts/const-slice-array-deref.stderr +++ b/tests/ui/consts/const-slice-array-deref.stderr @@ -12,22 +12,13 @@ error[E0308]: mismatched types LL | const ONE: [u16] = [1]; | ^^^ expected `[u16]`, found `[u16; 1]` -error[E0277]: the size for values of type `[u16]` cannot be known at compilation time - --> $DIR/const-slice-array-deref.rs:1:20 - | -LL | const ONE: [u16] = [1]; - | ^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `[u16]` - = note: constant expressions must have a statically known size - error[E0161]: cannot move a value of type `[u16]` - --> $DIR/const-slice-array-deref.rs:6:28 + --> $DIR/const-slice-array-deref.rs:5:28 | LL | const TWO: &'static u16 = &ONE[0]; | ^^^ the size of `[u16]` cannot be statically determined -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0161, E0277, E0308. For more information about an error, try `rustc --explain E0161`. diff --git a/tests/ui/consts/const-unsized.rs b/tests/ui/consts/const-unsized.rs index 18682aa6eb6..e8af3323ceb 100644 --- a/tests/ui/consts/const-unsized.rs +++ b/tests/ui/consts/const-unsized.rs @@ -2,19 +2,19 @@ use std::fmt::Debug; const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync)); //~^ ERROR the size for values of type -//~| ERROR the size for values of type +//~| ERROR cannot move out of a shared reference const CONST_FOO: str = *"foo"; //~^ ERROR the size for values of type -//~| ERROR the size for values of type +//~| ERROR cannot move out of a shared reference static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); //~^ ERROR the size for values of type -//~| ERROR the size for values of type +//~| ERROR cannot move out of a shared reference static STATIC_BAR: str = *"bar"; //~^ ERROR the size for values of type -//~| ERROR the size for values of type +//~| ERROR cannot move out of a shared reference fn main() { println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATIC_BAR); diff --git a/tests/ui/consts/const-unsized.stderr b/tests/ui/consts/const-unsized.stderr index 0b69cad9651..7931d7adafd 100644 --- a/tests/ui/consts/const-unsized.stderr +++ b/tests/ui/consts/const-unsized.stderr @@ -6,15 +6,6 @@ LL | const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync)); | = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)` -error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time - --> $DIR/const-unsized.rs:3:35 - | -LL | const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)` - = note: constant expressions must have a statically known size - error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/const-unsized.rs:7:18 | @@ -23,15 +14,6 @@ LL | const CONST_FOO: str = *"foo"; | = help: the trait `Sized` is not implemented for `str` -error[E0277]: the size for values of type `str` cannot be known at compilation time - --> $DIR/const-unsized.rs:7:24 - | -LL | const CONST_FOO: str = *"foo"; - | ^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `str` - = note: constant expressions must have a statically known size - error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time --> $DIR/const-unsized.rs:11:18 | @@ -40,15 +22,6 @@ LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); | = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)` -error[E0277]: the size for values of type `(dyn Debug + Sync + 'static)` cannot be known at compilation time - --> $DIR/const-unsized.rs:11:37 - | -LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `(dyn Debug + Sync + 'static)` - = note: constant expressions must have a statically known size - error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/const-unsized.rs:15:20 | @@ -57,14 +30,29 @@ LL | static STATIC_BAR: str = *"bar"; | = help: the trait `Sized` is not implemented for `str` -error[E0277]: the size for values of type `str` cannot be known at compilation time +error[E0507]: cannot move out of a shared reference + --> $DIR/const-unsized.rs:3:35 + | +LL | const CONST_0: dyn Debug + Sync = *(&0 as &(dyn Debug + Sync)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ move occurs because value has type `dyn Debug + Sync`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of a shared reference + --> $DIR/const-unsized.rs:7:24 + | +LL | const CONST_FOO: str = *"foo"; + | ^^^^^^ move occurs because value has type `str`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of a shared reference + --> $DIR/const-unsized.rs:11:37 + | +LL | static STATIC_1: dyn Debug + Sync = *(&1 as &(dyn Debug + Sync)); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ move occurs because value has type `dyn Debug + Sync`, which does not implement the `Copy` trait + +error[E0507]: cannot move out of a shared reference --> $DIR/const-unsized.rs:15:26 | LL | static STATIC_BAR: str = *"bar"; - | ^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `str` - = note: constant expressions must have a statically known size + | ^^^^^^ move occurs because value has type `str`, which does not implement the `Copy` trait error[E0161]: cannot move a value of type `str` --> $DIR/const-unsized.rs:20:48 @@ -80,5 +68,5 @@ LL | println!("{:?} {:?} {:?} {:?}", &CONST_0, &CONST_FOO, &STATIC_1, &STATI error: aborting due to 10 previous errors -Some errors have detailed explanations: E0161, E0277. +Some errors have detailed explanations: E0161, E0277, E0507. For more information about an error, try `rustc --explain E0161`. diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.rs b/tests/ui/consts/const_refs_to_static-ice-121413.rs index 7ef67d9a984..432ae1ad5e3 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.rs +++ b/tests/ui/consts/const_refs_to_static-ice-121413.rs @@ -9,11 +9,9 @@ const REF_INTERIOR_MUT: &usize = { //~^ ERROR failed to resolve: use of undeclared type `AtomicUsize` //~| WARN trait objects without an explicit `dyn` are deprecated //~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time - //~| ERROR the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time //~| WARN this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2021! //~| HELP if this is a dyn-compatible trait, use `dyn` //~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)` - //~| HELP the trait `Sized` is not implemented for `(dyn Sync + 'static)` unsafe { &*(&FOO as *const _ as *const usize) } }; pub fn main() {} diff --git a/tests/ui/consts/const_refs_to_static-ice-121413.stderr b/tests/ui/consts/const_refs_to_static-ice-121413.stderr index 7beb43d84fb..8665d9b6852 100644 --- a/tests/ui/consts/const_refs_to_static-ice-121413.stderr +++ b/tests/ui/consts/const_refs_to_static-ice-121413.stderr @@ -31,16 +31,7 @@ LL | static FOO: Sync = AtomicUsize::new(0); | = help: the trait `Sized` is not implemented for `(dyn Sync + 'static)` -error[E0277]: the size for values of type `(dyn Sync + 'static)` cannot be known at compilation time - --> $DIR/const_refs_to_static-ice-121413.rs:8:24 - | -LL | static FOO: Sync = AtomicUsize::new(0); - | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `(dyn Sync + 'static)` - = note: constant expressions must have a statically known size - -error: aborting due to 3 previous errors; 1 warning emitted +error: aborting due to 2 previous errors; 1 warning emitted Some errors have detailed explanations: E0277, E0433. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/consts/offset_from_ub.rs b/tests/ui/consts/offset_from_ub.rs index 0232b03a813..88356900605 100644 --- a/tests/ui/consts/offset_from_ub.rs +++ b/tests/ui/consts/offset_from_ub.rs @@ -17,7 +17,7 @@ pub const DIFFERENT_ALLOC: usize = { let uninit2 = std::mem::MaybeUninit::<Struct>::uninit(); let field_ptr: *const Struct = &uninit2 as *const _ as *const Struct; let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; //~ERROR evaluation of constant value failed - //~| pointers into different allocations + //~| not both derived from the same allocation offset as usize }; @@ -37,7 +37,7 @@ pub const DIFFERENT_INT: isize = { // offset_from with two different integers: l let ptr1 = 8 as *const u8; let ptr2 = 16 as *const u8; unsafe { ptr_offset_from(ptr2, ptr1) } //~ERROR evaluation of constant value failed - //~| dangling pointer + //~| not both derived from the same allocation }; const OUT_OF_BOUNDS_1: isize = { @@ -46,7 +46,7 @@ const OUT_OF_BOUNDS_1: isize = { let end_ptr = (start_ptr).wrapping_add(length); // First ptr is out of bounds unsafe { ptr_offset_from(end_ptr, start_ptr) } //~ERROR evaluation of constant value failed - //~| expected a pointer to 10 bytes of memory + //~| the memory range between them is not in-bounds of an allocation }; const OUT_OF_BOUNDS_2: isize = { @@ -55,7 +55,7 @@ const OUT_OF_BOUNDS_2: isize = { let end_ptr = (start_ptr).wrapping_add(length); // Second ptr is out of bounds unsafe { ptr_offset_from(start_ptr, end_ptr) } //~ERROR evaluation of constant value failed - //~| expected a pointer to the end of 10 bytes of memory + //~| the memory range between them is not in-bounds of an allocation }; pub const DIFFERENT_ALLOC_UNSIGNED: usize = { @@ -64,7 +64,7 @@ pub const DIFFERENT_ALLOC_UNSIGNED: usize = { let uninit2 = std::mem::MaybeUninit::<Struct>::uninit(); let field_ptr: *const Struct = &uninit2 as *const _ as *const Struct; unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) } //~ERROR evaluation of constant value failed - //~| pointers into different allocations + //~| not both derived from the same allocation }; pub const TOO_FAR_APART1: isize = { diff --git a/tests/ui/consts/offset_from_ub.stderr b/tests/ui/consts/offset_from_ub.stderr index ac4597ff011..1379365cc25 100644 --- a/tests/ui/consts/offset_from_ub.stderr +++ b/tests/ui/consts/offset_from_ub.stderr @@ -2,12 +2,12 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:19:27 | LL | let offset = unsafe { ptr_offset_from(field_ptr, base_ptr) }; - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on pointers into different allocations + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: `ptr_offset_from` called on pointers into different allocations + = note: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL @@ -27,25 +27,25 @@ error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:39:14 | LL | unsafe { ptr_offset_from(ptr2, ptr1) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from` origin: expected a pointer to $BYTES bytes of memory, but got 0x8[noalloc] which is a dangling pointer (it has no provenance) + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers that are not both derived from the same allocation error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:48:14 | LL | unsafe { ptr_offset_from(end_ptr, start_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from` origin: expected a pointer to $BYTES bytes of memory, but got ALLOC0 which is only $BYTES bytes from the end of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:57:14 | LL | unsafe { ptr_offset_from(start_ptr, end_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ out-of-bounds `offset_from` origin: expected a pointer to the end of $BYTES bytes of memory, but got ALLOC1+0xa which does not have enough space to the beginning of the allocation + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from` called on two different pointers where the memory range between them is not in-bounds of an allocation error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:66:14 | LL | unsafe { ptr_offset_from_unsigned(field_ptr, base_ptr) } - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on pointers into different allocations + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `ptr_offset_from_unsigned` called on two different pointers that are not both derived from the same allocation error[E0080]: evaluation of constant value failed --> $DIR/offset_from_ub.rs:73:14 @@ -80,7 +80,7 @@ LL | unsafe { ptr_offset_from_unsigned(ptr2, ptr1) } error[E0080]: evaluation of constant value failed --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL | - = note: out-of-bounds `offset_from` origin: expected a pointer to $BYTES bytes of memory, but got a null pointer + = note: `ptr_offset_from` called on two different pointers that are not both derived from the same allocation | note: inside `std::ptr::const_ptr::<impl *const u8>::offset_from` --> $SRC_DIR/core/src/ptr/const_ptr.rs:LL:COL diff --git a/tests/ui/contracts/contract-annotation-limitations.rs b/tests/ui/contracts/contract-annotation-limitations.rs new file mode 100644 index 00000000000..10b3bacab5c --- /dev/null +++ b/tests/ui/contracts/contract-annotation-limitations.rs @@ -0,0 +1,28 @@ +//! Test for some of the existing limitations and the current error messages. +//! Some of these limitations may be removed in the future. + +#![feature(contracts)] +//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features] +#![allow(dead_code)] + +/// Represent a 5-star system. +struct Stars(u8); + +impl Stars { + fn is_valid(&self) -> bool { + self.0 <= 5 + } +} + +trait ParseStars { + #[core::contracts::ensures(|ret| ret.is_none_or(Stars::is_valid))] + //~^ ERROR contract annotations is only supported in functions with bodies + fn parse_string(input: String) -> Option<Stars>; + + #[core::contracts::ensures(|ret| ret.is_none_or(Stars::is_valid))] + //~^ ERROR contract annotations is only supported in functions with bodies + fn parse<T>(input: T) -> Option<Stars> where T: for<'a> Into<&'a str>; +} + +fn main() { +} diff --git a/tests/ui/contracts/contract-annotation-limitations.stderr b/tests/ui/contracts/contract-annotation-limitations.stderr new file mode 100644 index 00000000000..14338cf4b86 --- /dev/null +++ b/tests/ui/contracts/contract-annotation-limitations.stderr @@ -0,0 +1,23 @@ +error: contract annotations is only supported in functions with bodies + --> $DIR/contract-annotation-limitations.rs:18:5 + | +LL | #[core::contracts::ensures(|ret| ret.is_none_or(Stars::is_valid))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: contract annotations is only supported in functions with bodies + --> $DIR/contract-annotation-limitations.rs:22:5 + | +LL | #[core::contracts::ensures(|ret| ret.is_none_or(Stars::is_valid))] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-annotation-limitations.rs:4:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: aborting due to 2 previous errors; 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-generics.chk_const_fail.stderr b/tests/ui/contracts/contract-attributes-generics.chk_const_fail.stderr new file mode 100644 index 00000000000..0630811d4f7 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-generics.chk_const_fail.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-generics.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-generics.chk_fail_post.stderr b/tests/ui/contracts/contract-attributes-generics.chk_fail_post.stderr new file mode 100644 index 00000000000..0630811d4f7 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-generics.chk_fail_post.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-generics.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-generics.chk_fail_pre.stderr b/tests/ui/contracts/contract-attributes-generics.chk_fail_pre.stderr new file mode 100644 index 00000000000..0630811d4f7 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-generics.chk_fail_pre.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-generics.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-generics.chk_pass.stderr b/tests/ui/contracts/contract-attributes-generics.chk_pass.stderr new file mode 100644 index 00000000000..0630811d4f7 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-generics.chk_pass.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-generics.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-generics.rs b/tests/ui/contracts/contract-attributes-generics.rs new file mode 100644 index 00000000000..fd79c6abedd --- /dev/null +++ b/tests/ui/contracts/contract-attributes-generics.rs @@ -0,0 +1,71 @@ +//! Test that contracts can be applied to generic functions. + +//@ revisions: unchk_pass chk_pass chk_fail_pre chk_fail_post chk_const_fail +// +//@ [unchk_pass] run-pass +//@ [chk_pass] run-pass +// +//@ [chk_fail_pre] run-fail +//@ [chk_fail_post] run-fail +//@ [chk_const_fail] run-fail +// +//@ [unchk_pass] compile-flags: -Zcontract-checks=no +// +//@ [chk_pass] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_pre] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_post] compile-flags: -Zcontract-checks=yes +//@ [chk_const_fail] compile-flags: -Zcontract-checks=yes + +#![feature(contracts)] +//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features] + +use std::ops::Sub; + +/// Dummy fn contract that precondition fails for val < 0, and post-condition fail for val == 1 +#[core::contracts::requires(val > 0u8.into())] +#[core::contracts::ensures(|ret| *ret > 0u8.into())] +fn decrement<T>(val: T) -> T +where T: PartialOrd + Sub<Output=T> + From<u8> +{ + val - 1u8.into() +} + +/// Create a structure that takes a constant parameter. +#[allow(dead_code)] +struct Capped<const MAX: usize>(usize); + +/// Now declare a function to create stars which shouldn't exceed 5 stars. +// Add redundant braces to ensure the built-in macro can handle this syntax. +#[allow(unused_braces)] +#[core::contracts::requires(num <= 5)] +unsafe fn stars_unchecked(num: usize) -> Capped<{ 5 }> { + Capped(num) +} + + +fn main() { + check_decrement(); + check_stars(); +} + +fn check_stars() { + // This should always pass. + let _ = unsafe { stars_unchecked(3) }; + + // This violates the contract. + #[cfg(any(unchk_pass, chk_const_fail))] + let _ = unsafe { stars_unchecked(10) }; +} + +fn check_decrement() { + // This should always pass + assert_eq!(decrement(10u8), 9u8); + + // This should fail requires but pass with no contract check. + #[cfg(any(unchk_pass, chk_fail_pre))] + assert_eq!(decrement(-2i128), -3i128); + + // This should fail ensures but pass with no contract check. + #[cfg(any(unchk_pass, chk_fail_post))] + assert_eq!(decrement(1i32), 0i32); +} diff --git a/tests/ui/contracts/contract-attributes-generics.unchk_pass.stderr b/tests/ui/contracts/contract-attributes-generics.unchk_pass.stderr new file mode 100644 index 00000000000..0630811d4f7 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-generics.unchk_pass.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-generics.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-nest.chk_fail_post.stderr b/tests/ui/contracts/contract-attributes-nest.chk_fail_post.stderr new file mode 100644 index 00000000000..9ca95b8bb01 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-nest.chk_fail_post.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-nest.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-nest.chk_fail_pre.stderr b/tests/ui/contracts/contract-attributes-nest.chk_fail_pre.stderr new file mode 100644 index 00000000000..9ca95b8bb01 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-nest.chk_fail_pre.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-nest.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-nest.chk_pass.stderr b/tests/ui/contracts/contract-attributes-nest.chk_pass.stderr new file mode 100644 index 00000000000..9ca95b8bb01 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-nest.chk_pass.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-nest.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-nest.rs b/tests/ui/contracts/contract-attributes-nest.rs new file mode 100644 index 00000000000..e1e61b88f28 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-nest.rs @@ -0,0 +1,45 @@ +//@ revisions: unchk_pass unchk_fail_pre unchk_fail_post chk_pass chk_fail_pre chk_fail_post +// +//@ [unchk_pass] run-pass +//@ [unchk_fail_pre] run-pass +//@ [unchk_fail_post] run-pass +//@ [chk_pass] run-pass +// +//@ [chk_fail_pre] run-fail +//@ [chk_fail_post] run-fail +// +//@ [unchk_pass] compile-flags: -Zcontract-checks=no +//@ [unchk_fail_pre] compile-flags: -Zcontract-checks=no +//@ [unchk_fail_post] compile-flags: -Zcontract-checks=no +// +//@ [chk_pass] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_pre] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_post] compile-flags: -Zcontract-checks=yes + +#![feature(contracts)] +//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features] + +#[core::contracts::requires(x.baz > 0)] +#[core::contracts::ensures(|ret| *ret > 100)] +fn nest(x: Baz) -> i32 +{ + loop { + return x.baz + 50; + } +} + +struct Baz { baz: i32 } + +const BAZ_PASS_PRE_POST: Baz = Baz { baz: 100 }; +#[cfg(any(unchk_fail_post, chk_fail_post))] +const BAZ_FAIL_POST: Baz = Baz { baz: 10 }; +#[cfg(any(unchk_fail_pre, chk_fail_pre))] +const BAZ_FAIL_PRE: Baz = Baz { baz: -10 }; + +fn main() { + assert_eq!(nest(BAZ_PASS_PRE_POST), 150); + #[cfg(any(unchk_fail_pre, chk_fail_pre))] + nest(BAZ_FAIL_PRE); + #[cfg(any(unchk_fail_post, chk_fail_post))] + nest(BAZ_FAIL_POST); +} diff --git a/tests/ui/contracts/contract-attributes-nest.unchk_fail_post.stderr b/tests/ui/contracts/contract-attributes-nest.unchk_fail_post.stderr new file mode 100644 index 00000000000..9ca95b8bb01 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-nest.unchk_fail_post.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-nest.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-nest.unchk_fail_pre.stderr b/tests/ui/contracts/contract-attributes-nest.unchk_fail_pre.stderr new file mode 100644 index 00000000000..9ca95b8bb01 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-nest.unchk_fail_pre.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-nest.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-nest.unchk_pass.stderr b/tests/ui/contracts/contract-attributes-nest.unchk_pass.stderr new file mode 100644 index 00000000000..9ca95b8bb01 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-nest.unchk_pass.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-nest.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-tail.chk_fail_post.stderr b/tests/ui/contracts/contract-attributes-tail.chk_fail_post.stderr new file mode 100644 index 00000000000..f87e7e19fa3 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-tail.chk_fail_post.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-tail.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-tail.chk_fail_pre.stderr b/tests/ui/contracts/contract-attributes-tail.chk_fail_pre.stderr new file mode 100644 index 00000000000..f87e7e19fa3 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-tail.chk_fail_pre.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-tail.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-tail.chk_pass.stderr b/tests/ui/contracts/contract-attributes-tail.chk_pass.stderr new file mode 100644 index 00000000000..f87e7e19fa3 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-tail.chk_pass.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-tail.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-tail.rs b/tests/ui/contracts/contract-attributes-tail.rs new file mode 100644 index 00000000000..ce4a6be5b82 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-tail.rs @@ -0,0 +1,43 @@ +//@ revisions: unchk_pass unchk_fail_pre unchk_fail_post chk_pass chk_fail_pre chk_fail_post +// +//@ [unchk_pass] run-pass +//@ [unchk_fail_pre] run-pass +//@ [unchk_fail_post] run-pass +//@ [chk_pass] run-pass +// +//@ [chk_fail_pre] run-fail +//@ [chk_fail_post] run-fail +// +//@ [unchk_pass] compile-flags: -Zcontract-checks=no +//@ [unchk_fail_pre] compile-flags: -Zcontract-checks=no +//@ [unchk_fail_post] compile-flags: -Zcontract-checks=no +// +//@ [chk_pass] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_pre] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_post] compile-flags: -Zcontract-checks=yes + +#![feature(contracts)] +//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features] + +#[core::contracts::requires(x.baz > 0)] +#[core::contracts::ensures(|ret| *ret > 100)] +fn tail(x: Baz) -> i32 +{ + x.baz + 50 +} + +struct Baz { baz: i32 } + +const BAZ_PASS_PRE_POST: Baz = Baz { baz: 100 }; +#[cfg(any(unchk_fail_post, chk_fail_post))] +const BAZ_FAIL_POST: Baz = Baz { baz: 10 }; +#[cfg(any(unchk_fail_pre, chk_fail_pre))] +const BAZ_FAIL_PRE: Baz = Baz { baz: -10 }; + +fn main() { + assert_eq!(tail(BAZ_PASS_PRE_POST), 150); + #[cfg(any(unchk_fail_pre, chk_fail_pre))] + tail(BAZ_FAIL_PRE); + #[cfg(any(unchk_fail_post, chk_fail_post))] + tail(BAZ_FAIL_POST); +} diff --git a/tests/ui/contracts/contract-attributes-tail.unchk_fail_post.stderr b/tests/ui/contracts/contract-attributes-tail.unchk_fail_post.stderr new file mode 100644 index 00000000000..f87e7e19fa3 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-tail.unchk_fail_post.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-tail.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-tail.unchk_fail_pre.stderr b/tests/ui/contracts/contract-attributes-tail.unchk_fail_pre.stderr new file mode 100644 index 00000000000..f87e7e19fa3 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-tail.unchk_fail_pre.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-tail.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-attributes-tail.unchk_pass.stderr b/tests/ui/contracts/contract-attributes-tail.unchk_pass.stderr new file mode 100644 index 00000000000..f87e7e19fa3 --- /dev/null +++ b/tests/ui/contracts/contract-attributes-tail.unchk_pass.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-attributes-tail.rs:19:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-captures-via-closure-copy.rs b/tests/ui/contracts/contract-captures-via-closure-copy.rs new file mode 100644 index 00000000000..32c6d2bf4fe --- /dev/null +++ b/tests/ui/contracts/contract-captures-via-closure-copy.rs @@ -0,0 +1,26 @@ +//@ run-fail +//@ compile-flags: -Zcontract-checks=yes + +#![feature(contracts)] +//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features] + +struct Baz { + baz: i32 +} + +#[track_caller] +#[core::contracts::requires(x.baz > 0)] +#[core::contracts::ensures({let old = x.baz; move |ret:&Baz| ret.baz == old*2 })] +// Relevant thing is this: ^^^^^^^^^^^^^^^ +// because we are capturing state that is Copy +fn doubler(x: Baz) -> Baz { + Baz { baz: x.baz + 10 } +} + +fn main() { + assert_eq!(doubler(Baz { baz: 10 }).baz, 20); + assert_eq!(doubler(Baz { baz: 100 }).baz, 200); + // This is a *run-fail* test because it is still exercising the + // contract machinery, specifically because this second invocation + // of `doubler` shows how the code does not meet its contract. +} diff --git a/tests/ui/contracts/contract-captures-via-closure-copy.stderr b/tests/ui/contracts/contract-captures-via-closure-copy.stderr new file mode 100644 index 00000000000..d92db601608 --- /dev/null +++ b/tests/ui/contracts/contract-captures-via-closure-copy.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-captures-via-closure-copy.rs:4:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contract-captures-via-closure-noncopy.rs b/tests/ui/contracts/contract-captures-via-closure-noncopy.rs new file mode 100644 index 00000000000..976f64c7fd9 --- /dev/null +++ b/tests/ui/contracts/contract-captures-via-closure-noncopy.rs @@ -0,0 +1,23 @@ +//@ compile-flags: -Zcontract-checks=yes + +#![feature(contracts)] +//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features] + +struct Baz { + baz: i32 +} + +#[track_caller] +#[core::contracts::requires(x.baz > 0)] +#[core::contracts::ensures({let old = x; move |ret:&Baz| ret.baz == old.baz*2 })] +// Relevant thing is this: ^^^^^^^^^^^ +// because we are capturing state that is non-Copy. +//~^^^ ERROR trait bound `Baz: std::marker::Copy` is not satisfied +fn doubler(x: Baz) -> Baz { + Baz { baz: x.baz + 10 } +} + +fn main() { + assert_eq!(doubler(Baz { baz: 10 }).baz, 20); + assert_eq!(doubler(Baz { baz: 100 }).baz, 200); +} diff --git a/tests/ui/contracts/contract-captures-via-closure-noncopy.stderr b/tests/ui/contracts/contract-captures-via-closure-noncopy.stderr new file mode 100644 index 00000000000..4a47671fee1 --- /dev/null +++ b/tests/ui/contracts/contract-captures-via-closure-noncopy.stderr @@ -0,0 +1,36 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-captures-via-closure-noncopy.rs:3:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +error[E0277]: the trait bound `Baz: std::marker::Copy` is not satisfied in `{closure@$DIR/contract-captures-via-closure-noncopy.rs:12:42: 12:57}` + --> $DIR/contract-captures-via-closure-noncopy.rs:12:1 + | +LL | #[core::contracts::ensures({let old = x; move |ret:&Baz| ret.baz == old.baz*2 })] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^------------------------------------^^^^ + | | | + | | within this `{closure@$DIR/contract-captures-via-closure-noncopy.rs:12:42: 12:57}` + | | this tail expression is of type `{closure@contract-captures-via-closure-noncopy.rs:12:42}` + | unsatisfied trait bound + | + = help: within `{closure@$DIR/contract-captures-via-closure-noncopy.rs:12:42: 12:57}`, the trait `std::marker::Copy` is not implemented for `Baz` +note: required because it's used within this closure + --> $DIR/contract-captures-via-closure-noncopy.rs:12:42 + | +LL | #[core::contracts::ensures({let old = x; move |ret:&Baz| ret.baz == old.baz*2 })] + | ^^^^^^^^^^^^^^^ +note: required by a bound in `build_check_ensures` + --> $SRC_DIR/core/src/contracts.rs:LL:COL +help: consider annotating `Baz` with `#[derive(Copy)]` + | +LL + #[derive(Copy)] +LL | struct Baz { + | + +error: aborting due to 1 previous error; 1 warning emitted + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/contracts/contracts-ensures-early-fn-exit.chk_fail_ret.stderr b/tests/ui/contracts/contracts-ensures-early-fn-exit.chk_fail_ret.stderr new file mode 100644 index 00000000000..d693fad446a --- /dev/null +++ b/tests/ui/contracts/contracts-ensures-early-fn-exit.chk_fail_ret.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contracts-ensures-early-fn-exit.rs:16:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contracts-ensures-early-fn-exit.chk_fail_try.stderr b/tests/ui/contracts/contracts-ensures-early-fn-exit.chk_fail_try.stderr new file mode 100644 index 00000000000..d693fad446a --- /dev/null +++ b/tests/ui/contracts/contracts-ensures-early-fn-exit.chk_fail_try.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contracts-ensures-early-fn-exit.rs:16:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contracts-ensures-early-fn-exit.chk_fail_yeet.stderr b/tests/ui/contracts/contracts-ensures-early-fn-exit.chk_fail_yeet.stderr new file mode 100644 index 00000000000..d693fad446a --- /dev/null +++ b/tests/ui/contracts/contracts-ensures-early-fn-exit.chk_fail_yeet.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contracts-ensures-early-fn-exit.rs:16:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contracts-ensures-early-fn-exit.chk_pass.stderr b/tests/ui/contracts/contracts-ensures-early-fn-exit.chk_pass.stderr new file mode 100644 index 00000000000..d693fad446a --- /dev/null +++ b/tests/ui/contracts/contracts-ensures-early-fn-exit.chk_pass.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contracts-ensures-early-fn-exit.rs:16:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contracts-ensures-early-fn-exit.rs b/tests/ui/contracts/contracts-ensures-early-fn-exit.rs new file mode 100644 index 00000000000..034cead3b4e --- /dev/null +++ b/tests/ui/contracts/contracts-ensures-early-fn-exit.rs @@ -0,0 +1,49 @@ +//@ revisions: unchk_pass chk_pass chk_fail_try chk_fail_ret chk_fail_yeet +// +//@ [unchk_pass] run-pass +//@ [chk_pass] run-pass +//@ [chk_fail_try] run-fail +//@ [chk_fail_ret] run-fail +//@ [chk_fail_yeet] run-fail +// +//@ [unchk_pass] compile-flags: -Zcontract-checks=no +//@ [chk_pass] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_try] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_ret] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_yeet] compile-flags: -Zcontract-checks=yes +//! This test ensures that ensures clauses are checked for different return points of a function. + +#![feature(contracts)] +//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features] +#![feature(yeet_expr)] + +/// This ensures will fail in different return points depending on the input. +#[core::contracts::ensures(|ret: &Option<u32>| ret.is_some())] +fn try_sum(x: u32, y: u32, z: u32) -> Option<u32> { + // Use Yeet to return early. + if x == u32::MAX && (y > 0 || z > 0) { do yeet } + + // Use `?` to early return. + let partial = x.checked_add(y)?; + + // Explicitly use `return` clause. + if u32::MAX - partial < z { + return None; + } + + Some(partial + z) +} + +fn main() { + // This should always succeed + assert_eq!(try_sum(0, 1, 2), Some(3)); + + #[cfg(any(unchk_pass, chk_fail_yeet))] + assert_eq!(try_sum(u32::MAX, 1, 1), None); + + #[cfg(any(unchk_pass, chk_fail_try))] + assert_eq!(try_sum(u32::MAX - 10, 12, 0), None); + + #[cfg(any(unchk_pass, chk_fail_ret))] + assert_eq!(try_sum(u32::MAX - 10, 2, 100), None); +} diff --git a/tests/ui/contracts/contracts-ensures-early-fn-exit.unchk_pass.stderr b/tests/ui/contracts/contracts-ensures-early-fn-exit.unchk_pass.stderr new file mode 100644 index 00000000000..d693fad446a --- /dev/null +++ b/tests/ui/contracts/contracts-ensures-early-fn-exit.unchk_pass.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contracts-ensures-early-fn-exit.rs:16:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.rs b/tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.rs new file mode 100644 index 00000000000..f01a852fbff --- /dev/null +++ b/tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.rs @@ -0,0 +1,15 @@ +//@ run-pass +//@ compile-flags: -Zcontract-checks=yes +#![feature(contracts)] +//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features] + +#[core::contracts::ensures(|ret| *ret > 0)] +fn outer() -> i32 { + let inner_closure = || -> i32 { 0 }; + inner_closure(); + 10 +} + +fn main() { + outer(); +} diff --git a/tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.stderr b/tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.stderr new file mode 100644 index 00000000000..49a372b53c7 --- /dev/null +++ b/tests/ui/contracts/contracts-ensures-is-not-inherited-when-nesting.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contracts-ensures-is-not-inherited-when-nesting.rs:3:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/contracts-requires-is-not-inherited-when-nesting.rs b/tests/ui/contracts/contracts-requires-is-not-inherited-when-nesting.rs new file mode 100644 index 00000000000..2c2a4a69785 --- /dev/null +++ b/tests/ui/contracts/contracts-requires-is-not-inherited-when-nesting.rs @@ -0,0 +1,17 @@ +//@ run-pass +//@ compile-flags: -Zcontract-checks=yes +#![feature(contracts)] +//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features] + +struct Outer { outer: std::cell::Cell<i32> } + +#[core::contracts::requires(x.outer.get() > 0)] +fn outer(x: Outer) { + let inner_closure = || { }; + x.outer.set(0); + inner_closure(); +} + +fn main() { + outer(Outer { outer: 1.into() }); +} diff --git a/tests/ui/contracts/contracts-requires-is-not-inherited-when-nesting.stderr b/tests/ui/contracts/contracts-requires-is-not-inherited-when-nesting.stderr new file mode 100644 index 00000000000..48898c4434a --- /dev/null +++ b/tests/ui/contracts/contracts-requires-is-not-inherited-when-nesting.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contracts-requires-is-not-inherited-when-nesting.rs:3:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/disallow-contract-annotation-on-non-fn.rs b/tests/ui/contracts/disallow-contract-annotation-on-non-fn.rs new file mode 100644 index 00000000000..69be906782a --- /dev/null +++ b/tests/ui/contracts/disallow-contract-annotation-on-non-fn.rs @@ -0,0 +1,53 @@ +//! Checks for compilation errors related to adding contracts to non-function items. + +#![feature(contracts)] +//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features] +#![allow(dead_code)] + +#[core::contracts::requires(true)] +//~^ ERROR contract annotations can only be used on functions +struct Dummy(usize); + +#[core::contracts::ensures(|v| v == 100)] +//~^ ERROR contract annotations can only be used on functions +const MAX_VAL: usize = 100; + +// FIXME: Improve the error message here. The macro thinks this is a function. +#[core::contracts::ensures(|v| v == 100)] +//~^ ERROR contract annotations is only supported in functions with bodies +type NewDummy = fn(usize) -> Dummy; + +#[core::contracts::ensures(|v| v == 100)] +//~^ ERROR contract annotations is only supported in functions with bodies +const NEW_DUMMY_FN : fn(usize) -> Dummy = || { Dummy(0) }; + +#[core::contracts::requires(true)] +//~^ ERROR contract annotations can only be used on functions +impl Dummy { + + // This should work + #[core::contracts::ensures(|ret| ret.0 == v)] + fn new(v: usize) -> Dummy { + Dummy(v) + } +} + +#[core::contracts::ensures(|dummy| dummy.0 > 0)] +//~^ ERROR contract annotations can only be used on functions +impl From<usize> for Dummy { + // This should work. + #[core::contracts::ensures(|ret| ret.0 == v)] + fn from(value: usize) -> Self { + Dummy::new(value) + } +} + +/// You should not be able to annotate a trait either. +#[core::contracts::requires(true)] +//~^ ERROR contract annotations can only be used on functions +pub trait DummyBuilder { + fn build() -> Dummy; +} + +fn main() { +} diff --git a/tests/ui/contracts/disallow-contract-annotation-on-non-fn.stderr b/tests/ui/contracts/disallow-contract-annotation-on-non-fn.stderr new file mode 100644 index 00000000000..0a7fff8183e --- /dev/null +++ b/tests/ui/contracts/disallow-contract-annotation-on-non-fn.stderr @@ -0,0 +1,53 @@ +error: contract annotations can only be used on functions + --> $DIR/disallow-contract-annotation-on-non-fn.rs:7:1 + | +LL | #[core::contracts::requires(true)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: contract annotations can only be used on functions + --> $DIR/disallow-contract-annotation-on-non-fn.rs:11:1 + | +LL | #[core::contracts::ensures(|v| v == 100)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: contract annotations is only supported in functions with bodies + --> $DIR/disallow-contract-annotation-on-non-fn.rs:16:1 + | +LL | #[core::contracts::ensures(|v| v == 100)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: contract annotations is only supported in functions with bodies + --> $DIR/disallow-contract-annotation-on-non-fn.rs:20:1 + | +LL | #[core::contracts::ensures(|v| v == 100)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: contract annotations can only be used on functions + --> $DIR/disallow-contract-annotation-on-non-fn.rs:24:1 + | +LL | #[core::contracts::requires(true)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: contract annotations can only be used on functions + --> $DIR/disallow-contract-annotation-on-non-fn.rs:35:1 + | +LL | #[core::contracts::ensures(|dummy| dummy.0 > 0)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +error: contract annotations can only be used on functions + --> $DIR/disallow-contract-annotation-on-non-fn.rs:46:1 + | +LL | #[core::contracts::requires(true)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/disallow-contract-annotation-on-non-fn.rs:3:12 + | +LL | #![feature(contracts)] + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +error: aborting due to 7 previous errors; 1 warning emitted + diff --git a/tests/ui/contracts/internal_machinery/contract-ast-extensions-nest.rs b/tests/ui/contracts/internal_machinery/contract-ast-extensions-nest.rs new file mode 100644 index 00000000000..6d8cd3949ee --- /dev/null +++ b/tests/ui/contracts/internal_machinery/contract-ast-extensions-nest.rs @@ -0,0 +1,44 @@ +//@ revisions: unchk_pass unchk_fail_pre unchk_fail_post chk_pass chk_fail_pre chk_fail_post +// +//@ [unchk_pass] run-pass +//@ [unchk_fail_pre] run-pass +//@ [unchk_fail_post] run-pass +//@ [chk_pass] run-pass +// +//@ [chk_fail_pre] run-fail +//@ [chk_fail_post] run-fail +// +//@ [unchk_pass] compile-flags: -Zcontract-checks=no +//@ [unchk_fail_pre] compile-flags: -Zcontract-checks=no +//@ [unchk_fail_post] compile-flags: -Zcontract-checks=no +// +//@ [chk_pass] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_pre] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_post] compile-flags: -Zcontract-checks=yes + +#![feature(contracts_internals)] + +fn nest(x: Baz) -> i32 + contract_requires(|| x.baz > 0) + contract_ensures(|ret| *ret > 100) +{ + loop { + return x.baz + 50; + } +} + +struct Baz { baz: i32 } + +const BAZ_PASS_PRE_POST: Baz = Baz { baz: 100 }; +#[cfg(any(unchk_fail_post, chk_fail_post))] +const BAZ_FAIL_POST: Baz = Baz { baz: 10 }; +#[cfg(any(unchk_fail_pre, chk_fail_pre))] +const BAZ_FAIL_PRE: Baz = Baz { baz: -10 }; + +fn main() { + assert_eq!(nest(BAZ_PASS_PRE_POST), 150); + #[cfg(any(unchk_fail_pre, chk_fail_pre))] + nest(BAZ_FAIL_PRE); + #[cfg(any(unchk_fail_post, chk_fail_post))] + nest(BAZ_FAIL_POST); +} diff --git a/tests/ui/contracts/internal_machinery/contract-ast-extensions-tail.rs b/tests/ui/contracts/internal_machinery/contract-ast-extensions-tail.rs new file mode 100644 index 00000000000..07ec26f921b --- /dev/null +++ b/tests/ui/contracts/internal_machinery/contract-ast-extensions-tail.rs @@ -0,0 +1,42 @@ +//@ revisions: unchk_pass unchk_fail_pre unchk_fail_post chk_pass chk_fail_pre chk_fail_post +// +//@ [unchk_pass] run-pass +//@ [unchk_fail_pre] run-pass +//@ [unchk_fail_post] run-pass +//@ [chk_pass] run-pass +// +//@ [chk_fail_pre] run-fail +//@ [chk_fail_post] run-fail +// +//@ [unchk_pass] compile-flags: -Zcontract-checks=no +//@ [unchk_fail_pre] compile-flags: -Zcontract-checks=no +//@ [unchk_fail_post] compile-flags: -Zcontract-checks=no +// +//@ [chk_pass] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_pre] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_post] compile-flags: -Zcontract-checks=yes + +#![feature(contracts_internals)] + +fn tail(x: Baz) -> i32 + contract_requires(|| x.baz > 0) + contract_ensures(|ret| *ret > 100) +{ + x.baz + 50 +} + +struct Baz { baz: i32 } + +const BAZ_PASS_PRE_POST: Baz = Baz { baz: 100 }; +#[cfg(any(unchk_fail_post, chk_fail_post))] +const BAZ_FAIL_POST: Baz = Baz { baz: 10 }; +#[cfg(any(unchk_fail_pre, chk_fail_pre))] +const BAZ_FAIL_PRE: Baz = Baz { baz: -10 }; + +fn main() { + assert_eq!(tail(BAZ_PASS_PRE_POST), 150); + #[cfg(any(unchk_fail_pre, chk_fail_pre))] + tail(BAZ_FAIL_PRE); + #[cfg(any(unchk_fail_post, chk_fail_post))] + tail(BAZ_FAIL_POST); +} diff --git a/tests/ui/contracts/internal_machinery/contract-intrinsics.rs b/tests/ui/contracts/internal_machinery/contract-intrinsics.rs new file mode 100644 index 00000000000..ae692afd146 --- /dev/null +++ b/tests/ui/contracts/internal_machinery/contract-intrinsics.rs @@ -0,0 +1,36 @@ +//@ revisions: default unchk_pass chk_pass chk_fail_ensures chk_fail_requires +// +//@ [default] run-pass +//@ [unchk_pass] run-pass +//@ [chk_pass] run-pass +//@ [chk_fail_requires] run-fail +//@ [chk_fail_ensures] run-fail +// +//@ [unchk_pass] compile-flags: -Zcontract-checks=no +//@ [chk_pass] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_requires] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_ensures] compile-flags: -Zcontract-checks=yes +#![feature(cfg_contract_checks, contracts_internals, core_intrinsics)] + +fn main() { + #[cfg(any(default, unchk_pass))] // default: disabled + assert_eq!(core::intrinsics::contract_checks(), false); + + #[cfg(chk_pass)] // explicitly enabled + assert_eq!(core::intrinsics::contract_checks(), true); + + // always pass + core::intrinsics::contract_check_requires(|| true); + + // fail if enabled + #[cfg(any(default, unchk_pass, chk_fail_requires))] + core::intrinsics::contract_check_requires(|| false); + + let doubles_to_two = { let old = 2; move |ret| ret + ret == old }; + // Always pass + core::intrinsics::contract_check_ensures(&1, doubles_to_two); + + // Fail if enabled + #[cfg(any(default, unchk_pass, chk_fail_ensures))] + core::intrinsics::contract_check_ensures(&2, doubles_to_two); +} diff --git a/tests/ui/contracts/internal_machinery/contract-lang-items.chk_fail_post.stderr b/tests/ui/contracts/internal_machinery/contract-lang-items.chk_fail_post.stderr new file mode 100644 index 00000000000..a60ce160265 --- /dev/null +++ b/tests/ui/contracts/internal_machinery/contract-lang-items.chk_fail_post.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-lang-items.rs:15:12 + | +LL | #![feature(contracts)] // to access core::contracts + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/internal_machinery/contract-lang-items.chk_pass.stderr b/tests/ui/contracts/internal_machinery/contract-lang-items.chk_pass.stderr new file mode 100644 index 00000000000..a60ce160265 --- /dev/null +++ b/tests/ui/contracts/internal_machinery/contract-lang-items.chk_pass.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-lang-items.rs:15:12 + | +LL | #![feature(contracts)] // to access core::contracts + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/internal_machinery/contract-lang-items.rs b/tests/ui/contracts/internal_machinery/contract-lang-items.rs new file mode 100644 index 00000000000..e91bbed294d --- /dev/null +++ b/tests/ui/contracts/internal_machinery/contract-lang-items.rs @@ -0,0 +1,39 @@ +//@ revisions: unchk_pass unchk_fail_post chk_pass chk_fail_post +// +//@ [unchk_pass] run-pass +//@ [unchk_fail_post] run-pass +//@ [chk_pass] run-pass +// +//@ [chk_fail_post] run-fail +// +//@ [unchk_pass] compile-flags: -Zcontract-checks=no +//@ [unchk_fail_post] compile-flags: -Zcontract-checks=no +// +//@ [chk_pass] compile-flags: -Zcontract-checks=yes +//@ [chk_fail_post] compile-flags: -Zcontract-checks=yes + +#![feature(contracts)] // to access core::contracts +//~^ WARN the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes [incomplete_features] +#![feature(contracts_internals)] // to access check_requires lang item + +fn foo(x: Baz) -> i32 { + let injected_checker = { + core::contracts::build_check_ensures(|ret| *ret > 100) + }; + + let ret = x.baz + 50; + injected_checker(ret) +} + +struct Baz { baz: i32 } + + +const BAZ_PASS_PRE_POST: Baz = Baz { baz: 100 }; +#[cfg(any(unchk_fail_post, chk_fail_post))] +const BAZ_FAIL_POST: Baz = Baz { baz: 10 }; + +fn main() { + assert_eq!(foo(BAZ_PASS_PRE_POST), 150); + #[cfg(any(unchk_fail_post, chk_fail_post))] + foo(BAZ_FAIL_POST); +} diff --git a/tests/ui/contracts/internal_machinery/contract-lang-items.unchk_fail_post.stderr b/tests/ui/contracts/internal_machinery/contract-lang-items.unchk_fail_post.stderr new file mode 100644 index 00000000000..a60ce160265 --- /dev/null +++ b/tests/ui/contracts/internal_machinery/contract-lang-items.unchk_fail_post.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-lang-items.rs:15:12 + | +LL | #![feature(contracts)] // to access core::contracts + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/internal_machinery/contract-lang-items.unchk_pass.stderr b/tests/ui/contracts/internal_machinery/contract-lang-items.unchk_pass.stderr new file mode 100644 index 00000000000..a60ce160265 --- /dev/null +++ b/tests/ui/contracts/internal_machinery/contract-lang-items.unchk_pass.stderr @@ -0,0 +1,11 @@ +warning: the feature `contracts` is incomplete and may not be safe to use and/or cause compiler crashes + --> $DIR/contract-lang-items.rs:15:12 + | +LL | #![feature(contracts)] // to access core::contracts + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = note: `#[warn(incomplete_features)]` on by default + +warning: 1 warning emitted + diff --git a/tests/ui/contracts/internal_machinery/contracts-lowering-ensures-is-not-inherited-when-nesting.rs b/tests/ui/contracts/internal_machinery/contracts-lowering-ensures-is-not-inherited-when-nesting.rs new file mode 100644 index 00000000000..960ccaed358 --- /dev/null +++ b/tests/ui/contracts/internal_machinery/contracts-lowering-ensures-is-not-inherited-when-nesting.rs @@ -0,0 +1,15 @@ +//@ run-pass +//@ compile-flags: -Zcontract-checks=yes +#![feature(contracts_internals)] + +fn outer() -> i32 + contract_ensures(|ret| *ret > 0) +{ + let inner_closure = || -> i32 { 0 }; + inner_closure(); + 10 +} + +fn main() { + outer(); +} diff --git a/tests/ui/contracts/internal_machinery/contracts-lowering-requires-is-not-inherited-when-nesting.rs b/tests/ui/contracts/internal_machinery/contracts-lowering-requires-is-not-inherited-when-nesting.rs new file mode 100644 index 00000000000..bee703de16a --- /dev/null +++ b/tests/ui/contracts/internal_machinery/contracts-lowering-requires-is-not-inherited-when-nesting.rs @@ -0,0 +1,17 @@ +//@ run-pass +//@ compile-flags: -Zcontract-checks=yes +#![feature(contracts_internals)] + +struct Outer { outer: std::cell::Cell<i32> } + +fn outer(x: Outer) + contract_requires(|| x.outer.get() > 0) +{ + let inner_closure = || { }; + x.outer.set(0); + inner_closure(); +} + +fn main() { + outer(Outer { outer: 1.into() }); +} diff --git a/tests/ui/contracts/internal_machinery/internal-feature-gating.rs b/tests/ui/contracts/internal_machinery/internal-feature-gating.rs new file mode 100644 index 00000000000..1b76eef6780 --- /dev/null +++ b/tests/ui/contracts/internal_machinery/internal-feature-gating.rs @@ -0,0 +1,20 @@ +// gate-test-contracts_internals + +fn main() { + // intrinsics are guarded by contracts_internals feature gate. + core::intrinsics::contract_checks(); + //~^ ERROR use of unstable library feature `contracts_internals` + core::intrinsics::contract_check_requires(|| true); + //~^ ERROR use of unstable library feature `contracts_internals` + core::intrinsics::contract_check_ensures(&1, |_|true); + //~^ ERROR use of unstable library feature `contracts_internals` + + core::contracts::build_check_ensures(|_: &()| true); + //~^ ERROR use of unstable library feature `contracts_internals` + + // ast extensions are guarded by contracts_internals feature gate + fn identity_1() -> i32 contract_requires(|| true) { 10 } + //~^ ERROR contract internal machinery is for internal use only + fn identity_2() -> i32 contract_ensures(|_| true) { 10 } + //~^ ERROR contract internal machinery is for internal use only +} diff --git a/tests/ui/contracts/internal_machinery/internal-feature-gating.stderr b/tests/ui/contracts/internal_machinery/internal-feature-gating.stderr new file mode 100644 index 00000000000..c0e1522f54c --- /dev/null +++ b/tests/ui/contracts/internal_machinery/internal-feature-gating.stderr @@ -0,0 +1,63 @@ +error[E0658]: contract internal machinery is for internal use only + --> $DIR/internal-feature-gating.rs:16:45 + | +LL | fn identity_1() -> i32 contract_requires(|| true) { 10 } + | ^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = help: add `#![feature(contracts_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]: contract internal machinery is for internal use only + --> $DIR/internal-feature-gating.rs:18:44 + | +LL | fn identity_2() -> i32 contract_ensures(|_| true) { 10 } + | ^^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = help: add `#![feature(contracts_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]: use of unstable library feature `contracts_internals` + --> $DIR/internal-feature-gating.rs:5:5 + | +LL | core::intrinsics::contract_checks(); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = help: add `#![feature(contracts_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]: use of unstable library feature `contracts_internals` + --> $DIR/internal-feature-gating.rs:7:5 + | +LL | core::intrinsics::contract_check_requires(|| true); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = help: add `#![feature(contracts_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]: use of unstable library feature `contracts_internals` + --> $DIR/internal-feature-gating.rs:9:5 + | +LL | core::intrinsics::contract_check_ensures(&1, |_|true); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = help: add `#![feature(contracts_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]: use of unstable library feature `contracts_internals` + --> $DIR/internal-feature-gating.rs:12:5 + | +LL | core::contracts::build_check_ensures(|_: &()| true); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = help: add `#![feature(contracts_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 6 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/crate-loading/crateresolve1.rs b/tests/ui/crate-loading/crateresolve1.rs index 9200b6a6231..91c34c82558 100644 --- a/tests/ui/crate-loading/crateresolve1.rs +++ b/tests/ui/crate-loading/crateresolve1.rs @@ -2,11 +2,11 @@ //@ aux-build:crateresolve1-2.rs //@ aux-build:crateresolve1-3.rs -//@ normalize-stderr: "\.nll/" -> "/" +//@ normalize-stderr: "crateresolve1\..+/auxiliary/" -> "crateresolve1/auxiliary/" //@ normalize-stderr: "\\\?\\" -> "" //@ normalize-stderr: "(lib)?crateresolve1-([123])\.[a-z]+" -> "libcrateresolve1-$2.somelib" -// NOTE: This test is duplicated at `tests/ui/error-codes/E0464.rs`. +// NOTE: This test is duplicated at `tests/ui/error-codes/E0464.rs` and `E0523.rs`. extern crate crateresolve1; //~^ ERROR multiple candidates for `rlib` dependency `crateresolve1` found diff --git a/tests/ui/crate-loading/crateresolve2.rs b/tests/ui/crate-loading/crateresolve2.rs index bec692eb8d2..6446740a321 100644 --- a/tests/ui/crate-loading/crateresolve2.rs +++ b/tests/ui/crate-loading/crateresolve2.rs @@ -4,7 +4,7 @@ //@ aux-build:crateresolve2-2.rs //@ aux-build:crateresolve2-3.rs -//@ normalize-stderr: "\.nll/" -> "/" +//@ normalize-stderr: "crateresolve2\..+/auxiliary/" -> "crateresolve2/auxiliary/" //@ normalize-stderr: "\\\?\\" -> "" extern crate crateresolve2; diff --git a/tests/ui/debuginfo/dwarf-versions.one.stderr b/tests/ui/debuginfo/dwarf-versions.one.stderr new file mode 100644 index 00000000000..bfc3a0152c6 --- /dev/null +++ b/tests/ui/debuginfo/dwarf-versions.one.stderr @@ -0,0 +1,6 @@ +error: requested DWARF version 1 is not supported + | + = help: supported DWARF versions are 2, 3, 4 and 5 + +error: aborting due to 1 previous error + diff --git a/tests/ui/debuginfo/dwarf-versions.rs b/tests/ui/debuginfo/dwarf-versions.rs new file mode 100644 index 00000000000..806ade51a99 --- /dev/null +++ b/tests/ui/debuginfo/dwarf-versions.rs @@ -0,0 +1,38 @@ +// This test verifies the expected behavior of various options passed to +// `-Zdwarf-version`: 2 - 5 (valid) with all other options being invalid. + +//@ revisions: zero one two three four five six + +//@[zero] compile-flags: -Zdwarf-version=0 +//@[zero] error-pattern: requested DWARF version 0 is not supported + +//@[one] compile-flags: -Zdwarf-version=1 +//@[one] error-pattern: requested DWARF version 1 is not supported + +//@[two] compile-flags: -Zdwarf-version=2 +//@[two] check-pass + +//@[three] compile-flags: -Zdwarf-version=3 +//@[three] check-pass + +//@[four] compile-flags: -Zdwarf-version=4 +//@[four] check-pass + +//@[five] compile-flags: -Zdwarf-version=5 +//@[five] check-pass + +//@[six] compile-flags: -Zdwarf-version=6 +//@[six] error-pattern: requested DWARF version 6 is not supported + +//@ compile-flags: -g --target x86_64-unknown-linux-gnu --crate-type cdylib +//@ needs-llvm-components: x86 + +#![feature(no_core, lang_items)] + +#![no_core] +#![no_std] + +#[lang = "sized"] +pub trait Sized {} + +pub fn foo() {} diff --git a/tests/ui/debuginfo/dwarf-versions.six.stderr b/tests/ui/debuginfo/dwarf-versions.six.stderr new file mode 100644 index 00000000000..32ab4e1471d --- /dev/null +++ b/tests/ui/debuginfo/dwarf-versions.six.stderr @@ -0,0 +1,6 @@ +error: requested DWARF version 6 is not supported + | + = help: supported DWARF versions are 2, 3, 4 and 5 + +error: aborting due to 1 previous error + diff --git a/tests/ui/debuginfo/dwarf-versions.zero.stderr b/tests/ui/debuginfo/dwarf-versions.zero.stderr new file mode 100644 index 00000000000..d58d7d3ed1c --- /dev/null +++ b/tests/ui/debuginfo/dwarf-versions.zero.stderr @@ -0,0 +1,6 @@ +error: requested DWARF version 0 is not supported + | + = help: supported DWARF versions are 2, 3, 4 and 5 + +error: aborting due to 1 previous error + diff --git a/tests/ui/diagnostic-width/E0271.ascii.stderr b/tests/ui/diagnostic-width/E0271.ascii.stderr index 93555b336a6..9a9c12a938f 100644 --- a/tests/ui/diagnostic-width/E0271.ascii.stderr +++ b/tests/ui/diagnostic-width/E0271.ascii.stderr @@ -15,7 +15,7 @@ note: expected this to be `Foo` LL | type Error = E; | ^ = note: required for the cast from `Box<Result<..., ()>>` to `Box<...>` - = note: the full name for the type has been written to '$TEST_BUILD_DIR/diagnostic-width/E0271.ascii/E0271.long-type-hash.txt' + = note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt' = note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/diagnostic-width/E0271.rs b/tests/ui/diagnostic-width/E0271.rs index 2faf09d46c6..06187721041 100644 --- a/tests/ui/diagnostic-width/E0271.rs +++ b/tests/ui/diagnostic-width/E0271.rs @@ -1,7 +1,7 @@ //@ revisions: ascii unicode //@[ascii] compile-flags: --diagnostic-width=40 -Zwrite-long-types-to-disk=yes //@[unicode] compile-flags: -Zunstable-options --error-format=human-unicode --diagnostic-width=40 -Zwrite-long-types-to-disk=yes -//@ normalize-stderr: "long-type-\d+" -> "long-type-hash" +//@ normalize-stderr: "'\$TEST_BUILD_DIR/.*\.long-type-\d+.txt'" -> "'$$TEST_BUILD_DIR/$$FILE.long-type-hash.txt'" trait Future { type Error; } diff --git a/tests/ui/diagnostic-width/E0271.unicode.stderr b/tests/ui/diagnostic-width/E0271.unicode.stderr index 1e9acf603b2..9c3deae6660 100644 --- a/tests/ui/diagnostic-width/E0271.unicode.stderr +++ b/tests/ui/diagnostic-width/E0271.unicode.stderr @@ -15,7 +15,7 @@ note: expected this to be `Foo` LL │ type Error = E; │ ━ ├ note: required for the cast from `Box<Result<..., ()>>` to `Box<...>` - ├ note: the full name for the type has been written to '$TEST_BUILD_DIR/diagnostic-width/E0271.unicode/E0271.long-type-hash.txt' + ├ note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt' ╰ note: consider using `--verbose` to print the full type name to the console error: aborting due to 1 previous error diff --git a/tests/ui/diagnostic-width/binop.rs b/tests/ui/diagnostic-width/binop.rs new file mode 100644 index 00000000000..60ba40b8047 --- /dev/null +++ b/tests/ui/diagnostic-width/binop.rs @@ -0,0 +1,17 @@ +//@ compile-flags: --diagnostic-width=60 -Zwrite-long-types-to-disk=yes +// The regex below normalizes the long type file name to make it suitable for compare-modes. +//@ normalize-stderr: "'\$TEST_BUILD_DIR/.*\.long-type-\d+.txt'" -> "'$$TEST_BUILD_DIR/$$FILE.long-type-hash.txt'" +type A = (i32, i32, i32, i32); +type B = (A, A, A, A); +type C = (B, B, B, B); +type D = (C, C, C, C); + +fn foo(x: D) { + x + x; //~ ERROR cannot add `(... +} + +fn bar(x: D) { + !x; //~ ERROR cannot apply unary operator `!` to type `(... +} + +fn main() {} diff --git a/tests/ui/diagnostic-width/binop.stderr b/tests/ui/diagnostic-width/binop.stderr new file mode 100644 index 00000000000..fd69129c33e --- /dev/null +++ b/tests/ui/diagnostic-width/binop.stderr @@ -0,0 +1,24 @@ +error[E0369]: cannot add `(..., ..., ..., ...)` to `(..., ..., ..., ...)` + --> $DIR/binop.rs:10:7 + | +LL | x + x; + | - ^ - (..., ..., ..., ...) + | | + | (..., ..., ..., ...) + | + = note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt' + = note: consider using `--verbose` to print the full type name to the console + +error[E0600]: cannot apply unary operator `!` to type `(..., ..., ..., ...)` + --> $DIR/binop.rs:14:5 + | +LL | !x; + | ^^ cannot apply unary operator `!` + | + = note: the full name for the type has been written to '$TEST_BUILD_DIR/$FILE.long-type-hash.txt' + = note: consider using `--verbose` to print the full type name to the console + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0369, E0600. +For more information about an error, try `rustc --explain E0369`. diff --git a/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.rs b/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.rs index a4eb669e321..1702fc1ed49 100644 --- a/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.rs +++ b/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.rs @@ -1,5 +1,5 @@ -#![feature(dyn_star, trait_upcasting)] -//~^ WARN the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes +#![expect(incomplete_features)] +#![feature(dyn_star)] trait A: B {} trait B {} diff --git a/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr b/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr index 1f7bfb1d5bd..289d85072e6 100644 --- a/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr +++ b/tests/ui/dyn-star/no-unsize-coerce-dyn-trait.stderr @@ -1,12 +1,3 @@ -warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/no-unsize-coerce-dyn-trait.rs:1:12 - | -LL | #![feature(dyn_star, trait_upcasting)] - | ^^^^^^^^ - | - = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information - = note: `#[warn(incomplete_features)]` on by default - error[E0308]: mismatched types --> $DIR/no-unsize-coerce-dyn-trait.rs:11:26 | @@ -18,6 +9,6 @@ LL | let y: Box<dyn* B> = x; = note: expected struct `Box<dyn* B>` found struct `Box<dyn* A>` -error: aborting due to 1 previous error; 1 warning emitted +error: aborting due to 1 previous error For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/dyn-star/upcast.rs b/tests/ui/dyn-star/upcast.rs index e8e89fc5101..01e1b94f87e 100644 --- a/tests/ui/dyn-star/upcast.rs +++ b/tests/ui/dyn-star/upcast.rs @@ -1,6 +1,6 @@ //@ known-bug: #104800 -#![feature(dyn_star, trait_upcasting)] +#![feature(dyn_star)] trait Foo: Bar { fn hello(&self); diff --git a/tests/ui/dyn-star/upcast.stderr b/tests/ui/dyn-star/upcast.stderr index 801e1c233c1..3f244d4b6ae 100644 --- a/tests/ui/dyn-star/upcast.stderr +++ b/tests/ui/dyn-star/upcast.stderr @@ -1,7 +1,7 @@ warning: the feature `dyn_star` is incomplete and may not be safe to use and/or cause compiler crashes --> $DIR/upcast.rs:3:12 | -LL | #![feature(dyn_star, trait_upcasting)] +LL | #![feature(dyn_star)] | ^^^^^^^^ | = note: see issue #102425 <https://github.com/rust-lang/rust/issues/102425> for more information diff --git a/tests/ui/editions/auxiliary/nested_macro_rules_dep_2021.rs b/tests/ui/editions/auxiliary/nested_macro_rules_dep_2021.rs new file mode 100644 index 00000000000..36d3e712dc0 --- /dev/null +++ b/tests/ui/editions/auxiliary/nested_macro_rules_dep_2021.rs @@ -0,0 +1,23 @@ +//@ edition: 2021 + +#[macro_export] +macro_rules! make_macro_with_input { + ($i:ident) => { + macro_rules! macro_inner_input { + () => { + pub fn $i() {} + }; + } + }; +} + +#[macro_export] +macro_rules! make_macro { + () => { + macro_rules! macro_inner { + () => { + pub fn gen() {} + }; + } + }; +} diff --git a/tests/ui/editions/auxiliary/nested_macro_rules_dep_2024.rs b/tests/ui/editions/auxiliary/nested_macro_rules_dep_2024.rs new file mode 100644 index 00000000000..4012398fe66 --- /dev/null +++ b/tests/ui/editions/auxiliary/nested_macro_rules_dep_2024.rs @@ -0,0 +1,23 @@ +//@ edition: 2024 + +#[macro_export] +macro_rules! make_macro_with_input { + ($i:ident) => { + macro_rules! macro_inner_input { + () => { + pub fn $i() {} + }; + } + }; +} + +#[macro_export] +macro_rules! make_macro { + () => { + macro_rules! macro_inner { + () => { + pub fn gen() {} + }; + } + }; +} diff --git a/tests/ui/editions/nested-macro-rules-edition.e2021.stderr b/tests/ui/editions/nested-macro-rules-edition.e2021.stderr new file mode 100644 index 00000000000..eac80262364 --- /dev/null +++ b/tests/ui/editions/nested-macro-rules-edition.e2021.stderr @@ -0,0 +1,27 @@ +error: expected identifier, found reserved keyword `gen` + --> $DIR/nested-macro-rules-edition.rs:30:5 + | +LL | macro_inner_input!{} + | ^^^^^^^^^^^^^^^^^^^^ expected identifier, found reserved keyword + | + = note: this error originates in the macro `macro_inner_input` (in Nightly builds, run with -Z macro-backtrace for more info) +help: escape `gen` to use it as an identifier + | +LL | nested_macro_rules_dep::make_macro_with_input!{r#gen} + | ++ + +error: expected identifier, found reserved keyword `gen` + --> $DIR/nested-macro-rules-edition.rs:35:5 + | +LL | macro_inner!{} + | ^^^^^^^^^^^^^^ expected identifier, found reserved keyword + | + = note: this error originates in the macro `macro_inner` (in Nightly builds, run with -Z macro-backtrace for more info) +help: escape `gen` to use it as an identifier + --> $DIR/auxiliary/nested_macro_rules_dep_2024.rs:19:24 + | +LL | pub fn r#gen() {} + | ++ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/editions/nested-macro-rules-edition.rs b/tests/ui/editions/nested-macro-rules-edition.rs new file mode 100644 index 00000000000..28d568f7750 --- /dev/null +++ b/tests/ui/editions/nested-macro-rules-edition.rs @@ -0,0 +1,39 @@ +// This checks the behavior of how nested macro_rules definitions are handled +// with regards to edition spans. Prior to https://github.com/rust-lang/rust/pull/133274, +// the compiler would compile the inner macro with the edition of the local crate. +// Afterwards, it uses the edition where the macro was *defined*. +// +// Unfortunately macro_rules compiler discards the edition of any *input* that +// was used to generate the macro. This is possibly not the behavior that we +// want. If we want to keep with the philosophy that code should follow the +// edition rules of the crate where it is written, then presumably we would +// want the input tokens to retain the edition of where they were written. +// +// See https://github.com/rust-lang/rust/issues/135669 for more. +// +// This has two revisions, one where local=2021 and the dep=2024. The other +// revision is vice-versa. + +//@ revisions: e2021 e2024 +//@[e2021] edition:2021 +//@[e2024] edition:2024 +//@[e2021] aux-crate: nested_macro_rules_dep=nested_macro_rules_dep_2024.rs +//@[e2024] aux-crate: nested_macro_rules_dep=nested_macro_rules_dep_2021.rs +//@[e2024] check-pass + +mod with_input { + // If we change the macro_rules input behavior, then this should pass when + // local edition is 2021 because `gen` is written in a context with 2021 + // behavior. For local edition 2024, the reverse would be true and this + // should fail. + nested_macro_rules_dep::make_macro_with_input!{gen} + macro_inner_input!{} + //[e2021]~^ ERROR found reserved keyword +} +mod no_input { + nested_macro_rules_dep::make_macro!{} + macro_inner!{} + //[e2021]~^ ERROR found reserved keyword +} + +fn main() {} diff --git a/tests/ui/issues/issue-48838.rs b/tests/ui/enum/closure-in-enum-issue-48838.rs index 057a424dfef..057a424dfef 100644 --- a/tests/ui/issues/issue-48838.rs +++ b/tests/ui/enum/closure-in-enum-issue-48838.rs diff --git a/tests/ui/issues/issue-48838.stderr b/tests/ui/enum/closure-in-enum-issue-48838.stderr index 504ea3e8010..17e6c343334 100644 --- a/tests/ui/issues/issue-48838.stderr +++ b/tests/ui/enum/closure-in-enum-issue-48838.stderr @@ -1,11 +1,11 @@ error[E0308]: mismatched types - --> $DIR/issue-48838.rs:2:14 + --> $DIR/closure-in-enum-issue-48838.rs:2:14 | LL | Square = |x| x, | ^^^^^ expected `isize`, found closure | = note: expected type `isize` - found closure `{closure@$DIR/issue-48838.rs:2:14: 2:17}` + found closure `{closure@$DIR/closure-in-enum-issue-48838.rs:2:14: 2:17}` error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-40350.rs b/tests/ui/enum/enum-inside-enum-issue-40350.rs index 50d74f27b63..50d74f27b63 100644 --- a/tests/ui/issues/issue-40350.rs +++ b/tests/ui/enum/enum-inside-enum-issue-40350.rs diff --git a/tests/ui/error-codes/E0060.stderr b/tests/ui/error-codes/E0060.stderr index 8387b15b970..aadf1ea93cb 100644 --- a/tests/ui/error-codes/E0060.stderr +++ b/tests/ui/error-codes/E0060.stderr @@ -8,7 +8,7 @@ note: function defined here --> $DIR/E0060.rs:2:8 | LL | fn printf(_: *const u8, ...) -> u32; - | ^^^^^^ + | ^^^^^^ - help: provide the argument | LL | unsafe { printf(/* *const u8 */); } diff --git a/tests/ui/error-codes/E0061.stderr b/tests/ui/error-codes/E0061.stderr index 7b180c07120..4a420cd118a 100644 --- a/tests/ui/error-codes/E0061.stderr +++ b/tests/ui/error-codes/E0061.stderr @@ -8,7 +8,7 @@ note: function defined here --> $DIR/E0061.rs:1:4 | LL | fn f(a: u16, b: &str) {} - | ^ ------ ------- + | ^ ------- help: provide the argument | LL | f(0, /* &str */); diff --git a/tests/ui/error-codes/E0462.rs b/tests/ui/error-codes/E0462.rs index 12214331445..45d35c345cb 100644 --- a/tests/ui/error-codes/E0462.rs +++ b/tests/ui/error-codes/E0462.rs @@ -1,6 +1,6 @@ //@ aux-build:found-staticlib.rs -//@ normalize-stderr: "\.nll/" -> "/" +//@ normalize-stderr: "E0462\..+/auxiliary/" -> "E0462/auxiliary/" //@ normalize-stderr: "\\\?\\" -> "" //@ normalize-stderr: "(lib)?found_staticlib\.[a-z]+" -> "libfound_staticlib.somelib" diff --git a/tests/ui/error-codes/E0464.rs b/tests/ui/error-codes/E0464.rs index aaf4d3a8f50..d1303ae91b1 100644 --- a/tests/ui/error-codes/E0464.rs +++ b/tests/ui/error-codes/E0464.rs @@ -2,7 +2,7 @@ //@ aux-build:crateresolve1-2.rs //@ aux-build:crateresolve1-3.rs -//@ normalize-stderr: "\.nll/" -> "/" +//@ normalize-stderr: "E0464\..+/auxiliary/" -> "E0464/auxiliary/" //@ normalize-stderr: "\\\?\\" -> "" //@ normalize-stderr: "(lib)?crateresolve1-([123])\.[a-z]+" -> "libcrateresolve1-$2.somelib" diff --git a/tests/ui/error-codes/E0523.rs b/tests/ui/error-codes/E0523.rs index aaf4d3a8f50..7c1869c055b 100644 --- a/tests/ui/error-codes/E0523.rs +++ b/tests/ui/error-codes/E0523.rs @@ -2,7 +2,7 @@ //@ aux-build:crateresolve1-2.rs //@ aux-build:crateresolve1-3.rs -//@ normalize-stderr: "\.nll/" -> "/" +//@ normalize-stderr: "E0523\..+/auxiliary/" -> "E0523/auxiliary/" //@ normalize-stderr: "\\\?\\" -> "" //@ normalize-stderr: "(lib)?crateresolve1-([123])\.[a-z]+" -> "libcrateresolve1-$2.somelib" diff --git a/tests/ui/error-codes/E0746.stderr b/tests/ui/error-codes/E0746.stderr index ce3e9736969..ec785561415 100644 --- a/tests/ui/error-codes/E0746.stderr +++ b/tests/ui/error-codes/E0746.stderr @@ -1,4 +1,4 @@ -error[E0746]: return type cannot have an unboxed trait object +error[E0746]: return type cannot be a trait object without pointer indirection --> $DIR/E0746.rs:8:13 | LL | fn foo() -> dyn Trait { Struct } @@ -13,7 +13,7 @@ help: alternatively, box the return type, and wrap all of the returned values in LL | fn foo() -> Box<dyn Trait> { Box::new(Struct) } | ++++ + +++++++++ + -error[E0746]: return type cannot have an unboxed trait object +error[E0746]: return type cannot be a trait object without pointer indirection --> $DIR/E0746.rs:11:13 | LL | fn bar() -> dyn Trait { diff --git a/tests/ui/explicit-tail-calls/become-trait-fn.rs b/tests/ui/explicit-tail-calls/become-trait-fn.rs new file mode 100644 index 00000000000..03255f15dd0 --- /dev/null +++ b/tests/ui/explicit-tail-calls/become-trait-fn.rs @@ -0,0 +1,19 @@ +// regression test for <https://github.com/rust-lang/rust/issues/134336> +// this previously caused an ICE, because we would compare `#[track_caller]` of +// the callee and the caller (in tailcalls specifically), leading to a problem +// since `T::f`'s instance can't be resolved (we do not know if the function is +// or isn't marked with `#[track_caller]`!) +// +//@ check-pass +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +trait Tr { + fn f(); +} + +fn g<T: Tr>() { + become T::f(); +} + +fn main() {} diff --git a/tests/ui/explicit-tail-calls/callee_is_track_caller.rs b/tests/ui/explicit-tail-calls/callee_is_track_caller.rs new file mode 100644 index 00000000000..bcb93fda8c8 --- /dev/null +++ b/tests/ui/explicit-tail-calls/callee_is_track_caller.rs @@ -0,0 +1,15 @@ +//@ check-pass +// FIXME(explicit_tail_calls): make this run-pass, once tail calls are properly implemented +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +fn a(x: u32) -> u32 { + become b(x); +} + +#[track_caller] +fn b(x: u32) -> u32 { x + 42 } + +fn main() { + assert_eq!(a(12), 54); +} diff --git a/tests/ui/explicit-tail-calls/caller_is_track_caller.rs b/tests/ui/explicit-tail-calls/caller_is_track_caller.rs new file mode 100644 index 00000000000..4e5f3f12f83 --- /dev/null +++ b/tests/ui/explicit-tail-calls/caller_is_track_caller.rs @@ -0,0 +1,16 @@ +#![expect(incomplete_features)] +#![feature(explicit_tail_calls)] + +#[track_caller] +fn a() { + become b(); //~ error: a function marked with `#[track_caller]` cannot perform a tail-call +} + +fn b() {} + +#[track_caller] +fn c() { + become a(); //~ error: a function marked with `#[track_caller]` cannot perform a tail-call +} + +fn main() {} diff --git a/tests/ui/explicit-tail-calls/caller_is_track_caller.stderr b/tests/ui/explicit-tail-calls/caller_is_track_caller.stderr new file mode 100644 index 00000000000..79b9b45986c --- /dev/null +++ b/tests/ui/explicit-tail-calls/caller_is_track_caller.stderr @@ -0,0 +1,14 @@ +error: a function marked with `#[track_caller]` cannot perform a tail-call + --> $DIR/caller_is_track_caller.rs:6:5 + | +LL | become b(); + | ^^^^^^^^^^ + +error: a function marked with `#[track_caller]` cannot perform a tail-call + --> $DIR/caller_is_track_caller.rs:13:5 + | +LL | become a(); + | ^^^^^^^^^^ + +error: aborting due to 2 previous errors + diff --git a/tests/ui/expr/block.rs b/tests/ui/expr/block.rs index bf626c9ead3..70f5c274c21 100644 --- a/tests/ui/expr/block.rs +++ b/tests/ui/expr/block.rs @@ -4,7 +4,7 @@ // Tests for standalone blocks as expressions -fn test_basic() { let rs: bool = { true }; assert!((rs)); } +fn test_basic() { let rs: bool = { true }; assert!(rs); } struct RS { v1: isize, v2: isize } diff --git a/tests/ui/expr/if/expr-if.rs b/tests/ui/expr/if/expr-if.rs index ae869c4b77a..68c2fc22130 100644 --- a/tests/ui/expr/if/expr-if.rs +++ b/tests/ui/expr/if/expr-if.rs @@ -1,43 +1,43 @@ //@ run-pass // Tests for if as expressions -fn test_if() { let rs: bool = if true { true } else { false }; assert!((rs)); } +fn test_if() { let rs: bool = if true { true } else { false }; assert!(rs); } fn test_else() { let rs: bool = if false { false } else { true }; - assert!((rs)); + assert!(rs); } fn test_elseif1() { let rs: bool = if true { true } else if true { false } else { false }; - assert!((rs)); + assert!(rs); } fn test_elseif2() { let rs: bool = if false { false } else if true { true } else { false }; - assert!((rs)); + assert!(rs); } fn test_elseif3() { let rs: bool = if false { false } else if false { false } else { true }; - assert!((rs)); + assert!(rs); } fn test_inferrence() { let rs = if true { true } else { false }; - assert!((rs)); + assert!(rs); } fn test_if_as_if_condition() { let rs1 = if if false { false } else { true } { true } else { false }; - assert!((rs1)); + assert!(rs1); let rs2 = if if true { false } else { true } { false } else { true }; - assert!((rs2)); + assert!(rs2); } fn test_if_as_block_result() { let rs = if true { if false { false } else { true } } else { false }; - assert!((rs)); + assert!(rs); } pub fn main() { diff --git a/tests/ui/issues/issue-41272.rs b/tests/ui/expr/if/if-let-no-match-guards-issue-41272.rs index 255bbfe90a1..255bbfe90a1 100644 --- a/tests/ui/issues/issue-41272.rs +++ b/tests/ui/expr/if/if-let-no-match-guards-issue-41272.rs diff --git a/tests/ui/extern-flag/empty-extern-arg.stderr b/tests/ui/extern-flag/empty-extern-arg.stderr index 2785b12a0ae..b9a128e02e1 100644 --- a/tests/ui/extern-flag/empty-extern-arg.stderr +++ b/tests/ui/extern-flag/empty-extern-arg.stderr @@ -8,6 +8,10 @@ error: unwinding panics are not supported without std = note: since the core library is usually precompiled with panic="unwind", rebuilding your crate with panic="abort" may not be enough to fix the problem error: requires `sized` lang_item + --> $DIR/empty-extern-arg.rs:6:11 + | +LL | fn main() {} + | ^^ error: aborting due to 4 previous errors diff --git a/tests/ui/feature-gates/feature-gate-cfg-contract-checks.rs b/tests/ui/feature-gates/feature-gate-cfg-contract-checks.rs new file mode 100644 index 00000000000..cd9bf12b5e7 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-contract-checks.rs @@ -0,0 +1,5 @@ +#![crate_type = "lib"] + +pub fn contract_checks_are_enabled() -> bool { + cfg!(contract_checks) //~ ERROR `cfg(contract_checks)` is experimental +} diff --git a/tests/ui/feature-gates/feature-gate-cfg-contract-checks.stderr b/tests/ui/feature-gates/feature-gate-cfg-contract-checks.stderr new file mode 100644 index 00000000000..89c6d077f97 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-cfg-contract-checks.stderr @@ -0,0 +1,13 @@ +error[E0658]: `cfg(contract_checks)` is experimental and subject to change + --> $DIR/feature-gate-cfg-contract-checks.rs:4:10 + | +LL | cfg!(contract_checks) + | ^^^^^^^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = help: add `#![feature(cfg_contract_checks)]` 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/feature-gate-cfg-target-thread-local.rs b/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.rs index 3ab5a500dfd..131a10ea03b 100644 --- a/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.rs +++ b/tests/ui/feature-gates/feature-gate-cfg-target-thread-local.rs @@ -1,4 +1,4 @@ -//@ ignore-windows +//@ ignore-windows FIXME(134939): thread_local + no_mangle doesn't work on Windows //@ aux-build:cfg-target-thread-local.rs #![feature(thread_local)] diff --git a/tests/ui/feature-gates/feature-gate-contracts.rs b/tests/ui/feature-gates/feature-gate-contracts.rs new file mode 100644 index 00000000000..5544f1d82ee --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-contracts.rs @@ -0,0 +1,11 @@ +#![crate_type = "lib"] + +#[core::contracts::requires(x > 0)] +pub fn requires_needs_it(x: i32) { } +//~^^ ERROR use of unstable library feature `contracts` +//~^^^ ERROR contracts are incomplete + +#[core::contracts::ensures(|ret| *ret > 0)] +pub fn ensures_needs_it() -> i32 { 10 } +//~^^ ERROR use of unstable library feature `contracts` +//~^^^ ERROR contracts are incomplete diff --git a/tests/ui/feature-gates/feature-gate-contracts.stderr b/tests/ui/feature-gates/feature-gate-contracts.stderr new file mode 100644 index 00000000000..4403e7df50b --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-contracts.stderr @@ -0,0 +1,43 @@ +error[E0658]: use of unstable library feature `contracts` + --> $DIR/feature-gate-contracts.rs:3:3 + | +LL | #[core::contracts::requires(x > 0)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = help: add `#![feature(contracts)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error[E0658]: use of unstable library feature `contracts` + --> $DIR/feature-gate-contracts.rs:8:3 + | +LL | #[core::contracts::ensures(|ret| *ret > 0)] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = help: add `#![feature(contracts)]` 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]: contracts are incomplete + --> $DIR/feature-gate-contracts.rs:3:1 + | +LL | #[core::contracts::requires(x > 0)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = help: add `#![feature(contracts)]` 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]: contracts are incomplete + --> $DIR/feature-gate-contracts.rs:8:1 + | +LL | #[core::contracts::ensures(|ret| *ret > 0)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: see issue #128044 <https://github.com/rust-lang/rust/issues/128044> for more information + = help: add `#![feature(contracts)]` 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 4 previous errors + +For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-fn_align.rs b/tests/ui/feature-gates/feature-gate-fn_align.rs index ea873dba269..06784a45d76 100644 --- a/tests/ui/feature-gates/feature-gate-fn_align.rs +++ b/tests/ui/feature-gates/feature-gate-fn_align.rs @@ -2,3 +2,8 @@ #[repr(align(16))] //~ ERROR `repr(align)` attributes on functions are unstable fn requires_alignment() {} + +trait MyTrait { + #[repr(align)] //~ ERROR `repr(align)` attributes on functions are unstable + fn myfun(); +} diff --git a/tests/ui/feature-gates/feature-gate-fn_align.stderr b/tests/ui/feature-gates/feature-gate-fn_align.stderr index eec332792b7..cd9900c6051 100644 --- a/tests/ui/feature-gates/feature-gate-fn_align.stderr +++ b/tests/ui/feature-gates/feature-gate-fn_align.stderr @@ -8,6 +8,16 @@ LL | #[repr(align(16))] = help: add `#![feature(fn_align)]` to the crate attributes to enable = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date -error: aborting due to 1 previous error +error[E0658]: `repr(align)` attributes on functions are unstable + --> $DIR/feature-gate-fn_align.rs:7:12 + | +LL | #[repr(align)] + | ^^^^^ + | + = note: see issue #82232 <https://github.com/rust-lang/rust/issues/82232> for more information + = help: add `#![feature(fn_align)]` to the crate attributes to enable + = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/feature-gates/feature-gate-keylocker_x86.rs b/tests/ui/feature-gates/feature-gate-keylocker_x86.rs new file mode 100644 index 00000000000..cef80ad41a8 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-keylocker_x86.rs @@ -0,0 +1,6 @@ +//@ only-x86_64 +#[target_feature(enable = "kl")] +//~^ ERROR: currently unstable +unsafe fn foo() {} + +fn main() {} diff --git a/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr b/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr new file mode 100644 index 00000000000..ed814d3a3ce --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-keylocker_x86.stderr @@ -0,0 +1,13 @@ +error[E0658]: the target feature `kl` is currently unstable + --> $DIR/feature-gate-keylocker_x86.rs:2:18 + | +LL | #[target_feature(enable = "kl")] + | ^^^^^^^^^^^^^ + | + = note: see issue #134813 <https://github.com/rust-lang/rust/issues/134813> for more information + = help: add `#![feature(keylocker_x86)]` 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/feature-gate-new_range.rs b/tests/ui/feature-gates/feature-gate-new_range.rs new file mode 100644 index 00000000000..ecb73546d6a --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-new_range.rs @@ -0,0 +1,10 @@ +#![feature(new_range_api)] + +fn main() { + let a: core::range::RangeFrom<u8> = 1..; + //~^ mismatched types + let b: core::range::Range<u8> = 2..3; + //~^ mismatched types + let c: core::range::RangeInclusive<u8> = 4..=5; + //~^ mismatched types +} diff --git a/tests/ui/feature-gates/feature-gate-new_range.stderr b/tests/ui/feature-gates/feature-gate-new_range.stderr new file mode 100644 index 00000000000..c4241390418 --- /dev/null +++ b/tests/ui/feature-gates/feature-gate-new_range.stderr @@ -0,0 +1,48 @@ +error[E0308]: mismatched types + --> $DIR/feature-gate-new_range.rs:4:41 + | +LL | let a: core::range::RangeFrom<u8> = 1..; + | -------------------------- ^^^ expected `RangeFrom<u8>`, found `RangeFrom<{integer}>` + | | + | expected due to this + | + = note: expected struct `std::range::RangeFrom<u8>` + found struct `std::ops::RangeFrom<{integer}>` +help: call `Into::into` on this expression to convert `std::ops::RangeFrom<{integer}>` into `std::range::RangeFrom<u8>` + | +LL | let a: core::range::RangeFrom<u8> = 1...into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/feature-gate-new_range.rs:6:37 + | +LL | let b: core::range::Range<u8> = 2..3; + | ---------------------- ^^^^ expected `Range<u8>`, found `Range<{integer}>` + | | + | expected due to this + | + = note: expected struct `std::range::Range<u8>` + found struct `std::ops::Range<{integer}>` +help: call `Into::into` on this expression to convert `std::ops::Range<{integer}>` into `std::range::Range<u8>` + | +LL | let b: core::range::Range<u8> = 2..3.into(); + | +++++++ + +error[E0308]: mismatched types + --> $DIR/feature-gate-new_range.rs:8:46 + | +LL | let c: core::range::RangeInclusive<u8> = 4..=5; + | ------------------------------- ^^^^^ expected `RangeInclusive<u8>`, found `RangeInclusive<{integer}>` + | | + | expected due to this + | + = note: expected struct `std::range::RangeInclusive<u8>` + found struct `std::ops::RangeInclusive<{integer}>` +help: call `Into::into` on this expression to convert `std::ops::RangeInclusive<{integer}>` into `std::range::RangeInclusive<u8>` + | +LL | let c: core::range::RangeInclusive<u8> = 4..=5.into(); + | +++++++ + +error: aborting due to 3 previous errors + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/feature-gates/feature-gate-trait_upcasting.rs b/tests/ui/feature-gates/feature-gate-trait_upcasting.rs deleted file mode 100644 index e4102f1cfa7..00000000000 --- a/tests/ui/feature-gates/feature-gate-trait_upcasting.rs +++ /dev/null @@ -1,13 +0,0 @@ -trait Foo {} - -trait Bar: Foo {} - -impl Foo for () {} - -impl Bar for () {} - -fn main() { - let bar: &dyn Bar = &(); - let foo: &dyn Foo = bar; - //~^ ERROR trait upcasting coercion is experimental [E0658] -} diff --git a/tests/ui/feature-gates/feature-gate-trait_upcasting.stderr b/tests/ui/feature-gates/feature-gate-trait_upcasting.stderr deleted file mode 100644 index 6fd277ae8cc..00000000000 --- a/tests/ui/feature-gates/feature-gate-trait_upcasting.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0658]: cannot cast `dyn Bar` to `dyn Foo`, trait upcasting coercion is experimental - --> $DIR/feature-gate-trait_upcasting.rs:11:25 - | -LL | let foo: &dyn Foo = bar; - | ^^^ - | - = note: see issue #65991 <https://github.com/rust-lang/rust/issues/65991> for more information - = help: add `#![feature(trait_upcasting)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: required when coercing `&dyn Bar` into `&dyn Foo` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/fn/error-recovery-mismatch.rs b/tests/ui/fn/error-recovery-mismatch.rs new file mode 100644 index 00000000000..a50a30c8c78 --- /dev/null +++ b/tests/ui/fn/error-recovery-mismatch.rs @@ -0,0 +1,20 @@ +// Used to ICE due to a size mismatch between the actual fake signature of `fold` and the +// generated signature used reporting the parameter mismatch at the call site. +// See issue #135124 + +trait A { + fn y(&self) + { + fn call() -> impl Sized {} + self.fold(call(), call()); + } + fn fold<T>(&self, _: T, &self._) {} + //~^ ERROR unexpected `self` parameter in function + //~| ERROR expected one of `)` or `,`, found `.` + //~| ERROR identifier `self` is bound more than once in this parameter list + //~| WARNING anonymous parameters are deprecated + //~| WARNING this is accepted in the current edition + //~| ERROR the placeholder `_` is not allowed within types +} + +fn main() {} diff --git a/tests/ui/fn/error-recovery-mismatch.stderr b/tests/ui/fn/error-recovery-mismatch.stderr new file mode 100644 index 00000000000..ad4652c11c1 --- /dev/null +++ b/tests/ui/fn/error-recovery-mismatch.stderr @@ -0,0 +1,46 @@ +error: unexpected `self` parameter in function + --> $DIR/error-recovery-mismatch.rs:11:29 + | +LL | fn fold<T>(&self, _: T, &self._) {} + | ^^^^^ must be the first parameter of an associated function + +error: expected one of `)` or `,`, found `.` + --> $DIR/error-recovery-mismatch.rs:11:34 + | +LL | fn fold<T>(&self, _: T, &self._) {} + | ^ + | | + | expected one of `)` or `,` + | help: missing `,` + +error[E0415]: identifier `self` is bound more than once in this parameter list + --> $DIR/error-recovery-mismatch.rs:11:30 + | +LL | fn fold<T>(&self, _: T, &self._) {} + | ^^^^ used as parameter more than once + +warning: anonymous parameters are deprecated and will be removed in the next edition + --> $DIR/error-recovery-mismatch.rs:11:35 + | +LL | fn fold<T>(&self, _: T, &self._) {} + | ^ help: try naming the parameter or explicitly ignoring it: `_: _` + | + = warning: this is accepted in the current edition (Rust 2015) but is a hard error in Rust 2018! + = note: for more information, see issue #41686 <https://github.com/rust-lang/rust/issues/41686> + = note: `#[warn(anonymous_parameters)]` on by default + +error[E0121]: the placeholder `_` is not allowed within types on item signatures for functions + --> $DIR/error-recovery-mismatch.rs:11:35 + | +LL | fn fold<T>(&self, _: T, &self._) {} + | ^ not allowed in type signatures + | +help: use type parameters instead + | +LL | fn fold<T, U>(&self, _: T, &self.U) {} + | +++ ~ + +error: aborting due to 4 previous errors; 1 warning emitted + +Some errors have detailed explanations: E0121, E0415. +For more information about an error, try `rustc --explain E0121`. diff --git a/tests/ui/fn/param-mismatch-foreign.rs b/tests/ui/fn/param-mismatch-foreign.rs new file mode 100644 index 00000000000..2ab2bf95448 --- /dev/null +++ b/tests/ui/fn/param-mismatch-foreign.rs @@ -0,0 +1,11 @@ +extern "C" { + fn foo(x: i32, y: u32, z: i32); + //~^ NOTE function defined here +} + +fn main() { + foo(1i32, 2i32); + //~^ ERROR this function takes 3 arguments but 2 arguments were supplied + //~| NOTE argument #2 of type `u32` is missing + //~| HELP provide the argument +} diff --git a/tests/ui/fn/param-mismatch-foreign.stderr b/tests/ui/fn/param-mismatch-foreign.stderr new file mode 100644 index 00000000000..1182908891c --- /dev/null +++ b/tests/ui/fn/param-mismatch-foreign.stderr @@ -0,0 +1,19 @@ +error[E0061]: this function takes 3 arguments but 2 arguments were supplied + --> $DIR/param-mismatch-foreign.rs:7:5 + | +LL | foo(1i32, 2i32); + | ^^^ ---- argument #2 of type `u32` is missing + | +note: function defined here + --> $DIR/param-mismatch-foreign.rs:2:8 + | +LL | fn foo(x: i32, y: u32, z: i32); + | ^^^ - +help: provide the argument + | +LL | foo(1i32, /* u32 */, 2i32); + | ~~~~~~~~~~~~~~~~~~~~~~~ + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0061`. diff --git a/tests/ui/fn/param-mismatch-trait-fn.rs b/tests/ui/fn/param-mismatch-trait-fn.rs new file mode 100644 index 00000000000..69ded6a9068 --- /dev/null +++ b/tests/ui/fn/param-mismatch-trait-fn.rs @@ -0,0 +1,10 @@ +trait Foo { + fn same_type<T>(_: T, _: T); +} + +fn f<T: Foo, X, Y>(x: X, y: Y) { + T::same_type([x], Some(y)); + //~^ ERROR mismatched types +} + +fn main() {} diff --git a/tests/ui/fn/param-mismatch-trait-fn.stderr b/tests/ui/fn/param-mismatch-trait-fn.stderr new file mode 100644 index 00000000000..28e1bcaaf49 --- /dev/null +++ b/tests/ui/fn/param-mismatch-trait-fn.stderr @@ -0,0 +1,23 @@ +error[E0308]: mismatched types + --> $DIR/param-mismatch-trait-fn.rs:6:23 + | +LL | T::same_type([x], Some(y)); + | ------------ --- ^^^^^^^ expected `[X; 1]`, found `Option<Y>` + | | | + | | expected all arguments to be this `[X; 1]` type because they need to match the type of this parameter + | arguments to this function are incorrect + | + = note: expected array `[X; 1]` + found enum `Option<Y>` +note: associated function defined here + --> $DIR/param-mismatch-trait-fn.rs:2:8 + | +LL | fn same_type<T>(_: T, _: T); + | ^^^^^^^^^ - - - this parameter needs to match the `[X; 1]` type of parameter #1 + | | | + | | parameter #2 needs to match the `[X; 1]` type of this parameter + | parameter #1 and parameter #2 both reference this parameter `T` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/for-loop-while/break.rs b/tests/ui/for-loop-while/break.rs index 77774792262..442e07e148c 100644 --- a/tests/ui/for-loop-while/break.rs +++ b/tests/ui/for-loop-while/break.rs @@ -8,18 +8,18 @@ pub fn main() { assert_eq!(i, 20); let xs = [1, 2, 3, 4, 5, 6]; for x in &xs { - if *x == 3 { break; } assert!((*x <= 3)); + if *x == 3 { break; } assert!(*x <= 3); } i = 0; - while i < 10 { i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0)); } + while i < 10 { i += 1; if i % 2 == 0 { continue; } assert!(i % 2 != 0); } i = 0; loop { - i += 1; if i % 2 == 0 { continue; } assert!((i % 2 != 0)); + i += 1; if i % 2 == 0 { continue; } assert!(i % 2 != 0); if i >= 10 { break; } } let ys = vec![1, 2, 3, 4, 5, 6]; for x in &ys { if *x % 2 == 0 { continue; } - assert!((*x % 2 != 0)); + assert!(*x % 2 != 0); } } diff --git a/tests/ui/for-loop-while/while-cont.rs b/tests/ui/for-loop-while/while-cont.rs index 1640b7e1803..73a08c26f9a 100644 --- a/tests/ui/for-loop-while/while-cont.rs +++ b/tests/ui/for-loop-while/while-cont.rs @@ -3,7 +3,7 @@ pub fn main() { let mut i = 1; while i > 0 { - assert!((i > 0)); + assert!(i > 0); println!("{}", i); i -= 1; continue; diff --git a/tests/ui/for-loop-while/while-loop-constraints-2.rs b/tests/ui/for-loop-while/while-loop-constraints-2.rs index 654f6769902..1d2d9c2ecfe 100644 --- a/tests/ui/for-loop-while/while-loop-constraints-2.rs +++ b/tests/ui/for-loop-while/while-loop-constraints-2.rs @@ -11,5 +11,5 @@ pub fn main() { while false { x = y; y = z; } println!("{}", y); } - assert!((y == 42 && z == 50)); + assert!(y == 42 && z == 50); } diff --git a/tests/ui/force-inlining/deny-async.rs b/tests/ui/force-inlining/deny-async.rs index bdf6271bd2a..7c95a53c26f 100644 --- a/tests/ui/force-inlining/deny-async.rs +++ b/tests/ui/force-inlining/deny-async.rs @@ -1,6 +1,6 @@ -//@ check-fail //@ compile-flags: --crate-type=lib //@ edition: 2021 + #![allow(internal_features)] #![feature(rustc_attrs)] @@ -20,5 +20,7 @@ pub fn callee_justified() { async fn async_caller() { callee(); + //~^ ERROR `callee` could not be inlined callee_justified(); + //~^ ERROR `callee_justified` could not be inlined } diff --git a/tests/ui/force-inlining/deny-async.stderr b/tests/ui/force-inlining/deny-async.stderr index 302ca419071..d6516ed875c 100644 --- a/tests/ui/force-inlining/deny-async.stderr +++ b/tests/ui/force-inlining/deny-async.stderr @@ -20,5 +20,22 @@ LL | pub fn callee_justified() { | = note: incompatible due to: #[rustc_no_mir_inline] -error: aborting due to 2 previous errors +error: `callee` could not be inlined into `async_caller::{closure#0}` but is required to be inlined + --> $DIR/deny-async.rs:22:5 + | +LL | callee(); + | ^^^^^^^^ ...`callee` called here + | + = note: could not be inlined due to: #[rustc_no_mir_inline] + +error: `callee_justified` could not be inlined into `async_caller::{closure#0}` but is required to be inlined + --> $DIR/deny-async.rs:24:5 + | +LL | callee_justified(); + | ^^^^^^^^^^^^^^^^^^ ...`callee_justified` called here + | + = note: could not be inlined due to: #[rustc_no_mir_inline] + = note: `callee_justified` is required to be inlined to: the test requires it + +error: aborting due to 4 previous errors diff --git a/tests/ui/generics/generic-tag-match.rs b/tests/ui/generics/generic-tag-match.rs index dd0291e9d87..378b51df287 100644 --- a/tests/ui/generics/generic-tag-match.rs +++ b/tests/ui/generics/generic-tag-match.rs @@ -7,7 +7,7 @@ enum foo<T> { arm(T), } fn altfoo<T>(f: foo<T>) { let mut hit = false; match f { foo::arm::<T>(_x) => { println!("in arm"); hit = true; } } - assert!((hit)); + assert!(hit); } pub fn main() { altfoo::<isize>(foo::arm::<isize>(10)); } diff --git a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs index 046ced072ba..901d4b39cf3 100644 --- a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs +++ b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.rs @@ -20,7 +20,7 @@ impl DynIncompatible for B { } fn car() -> dyn DynIncompatible { //~ ERROR the trait `DynIncompatible` is not dyn compatible -//~^ ERROR return type cannot have an unboxed trait object +//~^ ERROR return type cannot be a trait object without pointer indirection if true { return A; } diff --git a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr index 2869702d7fc..c2fd11fe23d 100644 --- a/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr +++ b/tests/ui/impl-trait/dyn-incompatible-trait-in-return-position-dyn-trait.stderr @@ -26,6 +26,26 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o LL | fn foo() -> Self where Self: Sized; | +++++++++++++++++ +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:22:13 + | +LL | fn car() -> dyn DynIncompatible { + | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL | fn car() -> impl DynIncompatible { + | ~~~~ +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn car() -> Box<dyn DynIncompatible> { +LL | +LL | if true { +LL ~ return Box::new(A); +LL | } +LL ~ Box::new(B) + | + error[E0038]: the trait `DynIncompatible` is not dyn compatible --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:30:17 | @@ -54,23 +74,6 @@ help: alternatively, consider constraining `foo` so it does not apply to trait o LL | fn foo() -> Self where Self: Sized; | +++++++++++++++++ -error[E0746]: return type cannot have an unboxed trait object - --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:22:13 - | -LL | fn car() -> dyn DynIncompatible { - | ^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: if there were a single returned type, you could use `impl Trait` instead -help: box the return type, and wrap all of the returned values in `Box::new` - | -LL ~ fn car() -> Box<dyn DynIncompatible> { -LL | -LL | if true { -LL ~ return Box::new(A); -LL | } -LL ~ Box::new(B) - | - error[E0038]: the trait `DynIncompatible` is not dyn compatible --> $DIR/dyn-incompatible-trait-in-return-position-dyn-trait.rs:32:16 | diff --git a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs index af368203de0..ccf0a1ad3d4 100644 --- a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs +++ b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.rs @@ -6,9 +6,11 @@ impl Trait for u32 {} fn fuz() -> (usize, Trait) { (42, Struct) } //~^ ERROR E0277 +//~| ERROR E0277 //~| ERROR E0308 fn bar() -> (usize, dyn Trait) { (42, Struct) } //~^ ERROR E0277 +//~| ERROR E0277 //~| ERROR E0308 fn bap() -> Trait { Struct } //~^ ERROR E0746 diff --git a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr index 9ed3d21c13c..11491a55738 100644 --- a/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr +++ b/tests/ui/impl-trait/dyn-trait-return-should-be-impl-trait.stderr @@ -1,49 +1,25 @@ -error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:35 - | -LL | fn fuz() -> (usize, Trait) { (42, Struct) } - | ^^^^^^ expected `dyn Trait`, found `Struct` - | - = note: expected trait object `(dyn Trait + 'static)` - found struct `Struct` - = help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well - error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time --> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:13 | LL | fn fuz() -> (usize, Trait) { (42, Struct) } - | ^^^^^^^^^^^^^^ ------------ this returned value is of type `(usize, (dyn Trait + 'static))` - | | - | doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` = note: required because it appears within the type `(usize, (dyn Trait + 'static))` = note: the return type of a function must have a statically known size -error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:10:39 - | -LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } - | ^^^^^^ expected `dyn Trait`, found `Struct` - | - = note: expected trait object `(dyn Trait + 'static)` - found struct `Struct` - = help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well - error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:10:13 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:13 | LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } - | ^^^^^^^^^^^^^^^^^^ ------------ this returned value is of type `(usize, (dyn Trait + 'static))` - | | - | doesn't have a size known at compile-time + | ^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time | = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` = note: required because it appears within the type `(usize, (dyn Trait + 'static))` = note: the return type of a function must have a statically known size -error[E0746]: return type cannot have an unboxed trait object - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:13:13 +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13 | LL | fn bap() -> Trait { Struct } | ^^^^^ doesn't have a size known at compile-time @@ -57,8 +33,8 @@ help: alternatively, box the return type, and wrap all of the returned values in LL | fn bap() -> Box<dyn Trait> { Box::new(Struct) } | +++++++ + +++++++++ + -error[E0746]: return type cannot have an unboxed trait object - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:15:13 +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:17:13 | LL | fn ban() -> dyn Trait { Struct } | ^^^^^^^^^ doesn't have a size known at compile-time @@ -72,8 +48,8 @@ help: alternatively, box the return type, and wrap all of the returned values in LL | fn ban() -> Box<dyn Trait> { Box::new(Struct) } | ++++ + +++++++++ + -error[E0746]: return type cannot have an unboxed trait object - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:17:13 +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13 | LL | fn bak() -> dyn Trait { unimplemented!() } | ^^^^^^^^^ doesn't have a size known at compile-time @@ -87,14 +63,17 @@ help: alternatively, box the return type, and wrap all of the returned values in LL | fn bak() -> Box<dyn Trait> { Box::new(unimplemented!()) } | ++++ + +++++++++ + -error[E0746]: return type cannot have an unboxed trait object - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:19:13 +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:21:13 | LL | fn bal() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time | - = help: if there were a single returned type, you could use `impl Trait` instead -help: box the return type, and wrap all of the returned values in `Box::new` +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL | fn bal() -> impl Trait { + | ~~~~ +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` | LL ~ fn bal() -> Box<dyn Trait> { LL | if true { @@ -103,14 +82,17 @@ LL | } LL ~ Box::new(42) | -error[E0746]: return type cannot have an unboxed trait object - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:25:13 +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:27:13 | LL | fn bax() -> dyn Trait { | ^^^^^^^^^ doesn't have a size known at compile-time | - = help: if there were a single returned type, you could use `impl Trait` instead -help: box the return type, and wrap all of the returned values in `Box::new` +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL | fn bax() -> impl Trait { + | ~~~~ +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` | LL ~ fn bax() -> Box<dyn Trait> { LL | if true { @@ -119,8 +101,86 @@ LL | } else { LL ~ Box::new(42) | +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:62:13 + | +LL | fn bat() -> dyn Trait { + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL | fn bat() -> impl Trait { + | ~~~~ +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn bat() -> Box<dyn Trait> { +LL | if true { +LL ~ return Box::new(0); +LL | } +LL ~ Box::new(42) + | + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:68:13 + | +LL | fn bay() -> dyn Trait { + | ^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL | fn bay() -> impl Trait { + | ~~~~ +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn bay() -> Box<dyn Trait> { +LL | if true { +LL ~ Box::new(0) +LL | } else { +LL ~ Box::new(42) + | + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:35 + | +LL | fn fuz() -> (usize, Trait) { (42, Struct) } + | ^^^^^^ expected `dyn Trait`, found `Struct` + | + = note: expected trait object `(dyn Trait + 'static)` + found struct `Struct` + = help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well + +error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:7:30 + | +LL | fn fuz() -> (usize, Trait) { (42, Struct) } + | ^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` + = note: required because it appears within the type `(usize, (dyn Trait + 'static))` + = note: tuples must have a statically known size to be initialized + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:34:16 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:39 + | +LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } + | ^^^^^^ expected `dyn Trait`, found `Struct` + | + = note: expected trait object `(dyn Trait + 'static)` + found struct `Struct` + = help: `Struct` implements `Trait` so you could box the found value and coerce it to the trait object `Box<dyn Trait>`, you will have to change the expected type as well + +error[E0277]: the size for values of type `(dyn Trait + 'static)` cannot be known at compilation time + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:11:34 + | +LL | fn bar() -> (usize, dyn Trait) { (42, Struct) } + | ^^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: within `(usize, (dyn Trait + 'static))`, the trait `Sized` is not implemented for `(dyn Trait + 'static)` + = note: required because it appears within the type `(usize, (dyn Trait + 'static))` + = note: tuples must have a statically known size to be initialized + +error[E0308]: mismatched types + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:36:16 | LL | fn bam() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -137,7 +197,7 @@ LL | return Box::new(Struct); | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:36:5 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:38:5 | LL | fn bam() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -154,7 +214,7 @@ LL | Box::new(42) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:40:16 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:42:16 | LL | fn baq() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -171,7 +231,7 @@ LL | return Box::new(0); | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:42:5 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:44:5 | LL | fn baq() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -188,7 +248,7 @@ LL | Box::new(42) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:46:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:48:9 | LL | fn baz() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -205,7 +265,7 @@ LL | Box::new(Struct) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:48:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:50:9 | LL | fn baz() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -222,7 +282,7 @@ LL | Box::new(42) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:53:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:55:9 | LL | fn baw() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -239,7 +299,7 @@ LL | Box::new(0) | +++++++++ + error[E0308]: mismatched types - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:55:9 + --> $DIR/dyn-trait-return-should-be-impl-trait.rs:57:9 | LL | fn baw() -> Box<dyn Trait> { | -------------- expected `Box<(dyn Trait + 'static)>` because of return type @@ -255,45 +315,7 @@ help: store this in the heap by calling `Box::new` LL | Box::new(42) | +++++++++ + -error[E0746]: return type cannot have an unboxed trait object - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:60:13 - | -LL | fn bat() -> dyn Trait { - | ^^^^^^^^^ doesn't have a size known at compile-time - | -help: consider returning an `impl Trait` instead of a `dyn Trait` - | -LL | fn bat() -> impl Trait { - | ~~~~ -help: alternatively, box the return type, and wrap all of the returned values in `Box::new` - | -LL ~ fn bat() -> Box<dyn Trait> { -LL | if true { -LL ~ return Box::new(0); -LL | } -LL ~ Box::new(42) - | - -error[E0746]: return type cannot have an unboxed trait object - --> $DIR/dyn-trait-return-should-be-impl-trait.rs:66:13 - | -LL | fn bay() -> dyn Trait { - | ^^^^^^^^^ doesn't have a size known at compile-time - | -help: consider returning an `impl Trait` instead of a `dyn Trait` - | -LL | fn bay() -> impl Trait { - | ~~~~ -help: alternatively, box the return type, and wrap all of the returned values in `Box::new` - | -LL ~ fn bay() -> Box<dyn Trait> { -LL | if true { -LL ~ Box::new(0) -LL | } else { -LL ~ Box::new(42) - | - -error: aborting due to 19 previous errors +error: aborting due to 21 previous errors Some errors have detailed explanations: E0277, E0308, E0746. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/impl-trait/in-trait/dump.rs b/tests/ui/impl-trait/in-trait/dump.rs new file mode 100644 index 00000000000..47198d51150 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dump.rs @@ -0,0 +1,15 @@ +//@ compile-flags: -Zverbose-internals + +#![feature(precise_capturing_in_traits, rustc_attrs)] +#![rustc_hidden_type_of_opaques] + +trait Foo { + fn hello(&self) -> impl Sized; +} + +fn hello<'s, T: Foo>(x: &'s T) -> impl Sized + use<'s, T> { +//~^ ERROR <T as Foo>::{synthetic#0}<'s/#1> + x.hello() +} + +fn main() {} diff --git a/tests/ui/impl-trait/in-trait/dump.stderr b/tests/ui/impl-trait/in-trait/dump.stderr new file mode 100644 index 00000000000..95805840385 --- /dev/null +++ b/tests/ui/impl-trait/in-trait/dump.stderr @@ -0,0 +1,8 @@ +error: <T as Foo>::{synthetic#0}<'s/#1> + --> $DIR/dump.rs:10:35 + | +LL | fn hello<'s, T: Foo>(x: &'s T) -> impl Sized + use<'s, T> { + | ^^^^^^^^^^^^^^^^^^^^^^^ + +error: aborting due to 1 previous error + diff --git a/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs b/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs index a8a6288eb56..719edd525de 100644 --- a/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs +++ b/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.rs @@ -63,7 +63,7 @@ fn dog() -> impl std::fmt::Display { } } -fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object +fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection match 13 { 0 => { return 0i32; @@ -74,7 +74,7 @@ fn hat() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed } } -fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object +fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection match 13 { 0 => 0i32, 1 => 1u32, @@ -82,7 +82,7 @@ fn pug() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed } } -fn man() -> dyn std::fmt::Display { //~ ERROR return type cannot have an unboxed trait object +fn man() -> dyn std::fmt::Display { //~ ERROR return type cannot be a trait object without pointer indirection if false { 0i32 } else { diff --git a/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr b/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr index 54849c112f5..17eaed436df 100644 --- a/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr +++ b/tests/ui/impl-trait/point-to-type-err-cause-on-impl-trait-return.stderr @@ -1,3 +1,62 @@ +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13 + | +LL | fn hat() -> dyn std::fmt::Display { + | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL | fn hat() -> impl std::fmt::Display { + | ~~~~ +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn hat() -> Box<dyn std::fmt::Display> { +LL | match 13 { +LL | 0 => { +LL ~ return Box::new(0i32); +LL | } +LL | _ => { +LL ~ Box::new(1u32) + | + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:77:13 + | +LL | fn pug() -> dyn std::fmt::Display { + | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL | fn pug() -> impl std::fmt::Display { + | ~~~~ +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn pug() -> Box<dyn std::fmt::Display> { +LL | match 13 { +LL ~ 0 => Box::new(0i32), +LL ~ 1 => Box::new(1u32), +LL ~ _ => Box::new(2u32), + | + +error[E0746]: return type cannot be a trait object without pointer indirection + --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:85:13 + | +LL | fn man() -> dyn std::fmt::Display { + | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time + | +help: consider returning an `impl Trait` instead of a `dyn Trait` + | +LL | fn man() -> impl std::fmt::Display { + | ~~~~ +help: alternatively, box the return type, and wrap all of the returned values in `Box::new` + | +LL ~ fn man() -> Box<dyn std::fmt::Display> { +LL | if false { +LL ~ Box::new(0i32) +LL | } else { +LL ~ Box::new(1u32) + | + error[E0308]: mismatched types --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:5:5 | @@ -165,62 +224,6 @@ help: change the type of the numeric literal from `u32` to `i32` LL | 1i32 | ~~~ -error[E0746]: return type cannot have an unboxed trait object - --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:66:13 - | -LL | fn hat() -> dyn std::fmt::Display { - | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | -help: consider returning an `impl Trait` instead of a `dyn Trait` - | -LL | fn hat() -> impl std::fmt::Display { - | ~~~~ -help: alternatively, box the return type, and wrap all of the returned values in `Box::new` - | -LL ~ fn hat() -> Box<dyn std::fmt::Display> { -LL | match 13 { -LL | 0 => { -LL ~ return Box::new(0i32); -LL | } -LL | _ => { -LL ~ Box::new(1u32) - | - -error[E0746]: return type cannot have an unboxed trait object - --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:77:13 - | -LL | fn pug() -> dyn std::fmt::Display { - | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | -help: consider returning an `impl Trait` instead of a `dyn Trait` - | -LL | fn pug() -> impl std::fmt::Display { - | ~~~~ -help: alternatively, box the return type, and wrap all of the returned values in `Box::new` - | -LL ~ fn pug() -> Box<dyn std::fmt::Display> { -LL | match 13 { -LL ~ 0 => Box::new(0i32), -LL ~ 1 => Box::new(1u32), -LL ~ _ => Box::new(2u32), - | - -error[E0746]: return type cannot have an unboxed trait object - --> $DIR/point-to-type-err-cause-on-impl-trait-return.rs:85:13 - | -LL | fn man() -> dyn std::fmt::Display { - | ^^^^^^^^^^^^^^^^^^^^^ doesn't have a size known at compile-time - | - = help: if there were a single returned type, you could use `impl Trait` instead -help: box the return type, and wrap all of the returned values in `Box::new` - | -LL ~ fn man() -> Box<dyn std::fmt::Display> { -LL | if false { -LL ~ Box::new(0i32) -LL | } else { -LL ~ Box::new(1u32) - | - error: aborting due to 12 previous errors Some errors have detailed explanations: E0308, E0746. diff --git a/tests/ui/impl-trait/precise-capturing/rpitit-outlives-2.rs b/tests/ui/impl-trait/precise-capturing/rpitit-outlives-2.rs new file mode 100644 index 00000000000..6f7e1a0eaef --- /dev/null +++ b/tests/ui/impl-trait/precise-capturing/rpitit-outlives-2.rs @@ -0,0 +1,19 @@ +//@ check-pass + +// Ensure that we skip uncaptured args from RPITITs when comptuing outlives. + +#![feature(precise_capturing_in_traits)] + +struct Invariant<T>(*mut T); + +trait Foo { + fn hello<'s: 's>(&'s self) -> Invariant<impl Sized + use<Self>>; +} + +fn outlives_static(_: impl Sized + 'static) {} + +fn hello<'s, T: Foo + 'static>(x: &'s T) { + outlives_static(x.hello()); +} + +fn main() {} diff --git a/tests/ui/impl-trait/precise-capturing/rpitit-outlives.rs b/tests/ui/impl-trait/precise-capturing/rpitit-outlives.rs new file mode 100644 index 00000000000..94d81d766f7 --- /dev/null +++ b/tests/ui/impl-trait/precise-capturing/rpitit-outlives.rs @@ -0,0 +1,18 @@ +//@ check-pass + +// Ensure that we skip uncaptured args from RPITITs when collecting the regions +// to enforce member constraints in opaque type inference. + +#![feature(precise_capturing_in_traits)] + +struct Invariant<T>(*mut T); + +trait Foo { + fn hello<'s: 's>(&'s self) -> Invariant<impl Sized + use<Self>>; +} + +fn hello<'s, T: Foo>(x: &'s T) -> Invariant<impl Sized> { + x.hello() +} + +fn main() {} diff --git a/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr b/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr index 9814187e179..7f3691123ee 100644 --- a/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr +++ b/tests/ui/impl-trait/recursive-coroutine-indirect.current.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in a coroutine requires boxing - --> $DIR/recursive-coroutine-indirect.rs:11:18 + --> $DIR/recursive-coroutine-indirect.rs:8:18 | LL | #[coroutine] move || { | ^^^^^^^ diff --git a/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr b/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr index 9814187e179..7f3691123ee 100644 --- a/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr +++ b/tests/ui/impl-trait/recursive-coroutine-indirect.next.stderr @@ -1,5 +1,5 @@ error[E0733]: recursion in a coroutine requires boxing - --> $DIR/recursive-coroutine-indirect.rs:11:18 + --> $DIR/recursive-coroutine-indirect.rs:8:18 | LL | #[coroutine] move || { | ^^^^^^^ diff --git a/tests/ui/impl-trait/recursive-coroutine-indirect.rs b/tests/ui/impl-trait/recursive-coroutine-indirect.rs index cec2176049b..f0727ad3742 100644 --- a/tests/ui/impl-trait/recursive-coroutine-indirect.rs +++ b/tests/ui/impl-trait/recursive-coroutine-indirect.rs @@ -2,9 +2,6 @@ //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -//@[next] build-fail -// Deeply normalizing writeback results of opaques makes this into a post-mono error :( - #![feature(coroutines)] #![allow(unconditional_recursion)] fn coroutine_hold() -> impl Sized { diff --git a/tests/ui/impl-trait/unsized_coercion5.old.stderr b/tests/ui/impl-trait/unsized_coercion5.old.stderr index e56c026b037..72aa92ef6b9 100644 --- a/tests/ui/impl-trait/unsized_coercion5.old.stderr +++ b/tests/ui/impl-trait/unsized_coercion5.old.stderr @@ -1,5 +1,5 @@ error[E0277]: the size for values of type `impl Trait + ?Sized` cannot be known at compilation time - --> $DIR/unsized_coercion5.rs:17:32 + --> $DIR/unsized_coercion5.rs:15:32 | LL | let y: Box<dyn Send> = x as Box<dyn Trait + Send>; | ^ doesn't have a size known at compile-time diff --git a/tests/ui/impl-trait/unsized_coercion5.rs b/tests/ui/impl-trait/unsized_coercion5.rs index 81f8a6afe9a..51ae4f20671 100644 --- a/tests/ui/impl-trait/unsized_coercion5.rs +++ b/tests/ui/impl-trait/unsized_coercion5.rs @@ -5,8 +5,6 @@ //@[next] compile-flags: -Znext-solver //@[next] check-pass -#![feature(trait_upcasting)] - trait Trait {} impl Trait for u32 {} diff --git a/tests/ui/inference/issue-71584.rs b/tests/ui/inference/issue-71584.rs index 7e4d45ec4a0..61568e5467c 100644 --- a/tests/ui/inference/issue-71584.rs +++ b/tests/ui/inference/issue-71584.rs @@ -1,4 +1,4 @@ -//@ ignore-windows different list of satisfying impls +//@ ignore-windows FIXME: We get an extra E0283 on Windows fn main() { let n: u32 = 1; let mut d: u64 = 2; diff --git a/tests/ui/inference/issue-72616.stderr b/tests/ui/inference/issue-72616.stderr index a26f9a1ff56..3848fcf61d9 100644 --- a/tests/ui/inference/issue-72616.stderr +++ b/tests/ui/inference/issue-72616.stderr @@ -26,7 +26,7 @@ LL | if String::from("a") == "a".try_into().unwrap() {} | ^^^^^^^^ | = note: multiple `impl`s satisfying `_: TryFrom<&str>` found in the following crates: `core`, `std`: - - impl TryFrom<&str> for std::sys_common::net::LookupHost; + - impl TryFrom<&str> for std::sys::net::connection::socket::LookupHost; - impl<T, U> TryFrom<U> for T where U: Into<T>; = note: required for `&str` to implement `TryInto<_>` diff --git a/tests/ui/issues/issue-17954.stderr b/tests/ui/issues/issue-17954.stderr index bba7e725b12..0dddea83364 100644 --- a/tests/ui/issues/issue-17954.stderr +++ b/tests/ui/issues/issue-17954.stderr @@ -5,7 +5,7 @@ LL | let a = &FOO; | ^^^^ thread-local variables cannot be borrowed beyond the end of the function ... LL | } - | - end of enclosing function is here + | - end of enclosing function is here error: aborting due to 1 previous error diff --git a/tests/ui/issues/issue-18107.rs b/tests/ui/issues/issue-18107.rs index 4bf5b6c0f30..b1b6ff4f7ad 100644 --- a/tests/ui/issues/issue-18107.rs +++ b/tests/ui/issues/issue-18107.rs @@ -2,7 +2,7 @@ pub trait AbstractRenderer {} fn _create_render(_: &()) -> dyn AbstractRenderer -//~^ ERROR return type cannot have an unboxed trait object +//~^ ERROR return type cannot be a trait object without pointer indirection { match 0 { _ => unimplemented!() diff --git a/tests/ui/issues/issue-18107.stderr b/tests/ui/issues/issue-18107.stderr index 705f7d0df12..6956d6a34aa 100644 --- a/tests/ui/issues/issue-18107.stderr +++ b/tests/ui/issues/issue-18107.stderr @@ -1,4 +1,4 @@ -error[E0746]: return type cannot have an unboxed trait object +error[E0746]: return type cannot be a trait object without pointer indirection --> $DIR/issue-18107.rs:4:5 | LL | dyn AbstractRenderer diff --git a/tests/ui/issues/issue-4935.stderr b/tests/ui/issues/issue-4935.stderr index 7ee895d91c7..918f74256c0 100644 --- a/tests/ui/issues/issue-4935.stderr +++ b/tests/ui/issues/issue-4935.stderr @@ -8,7 +8,7 @@ note: function defined here --> $DIR/issue-4935.rs:3:4 | LL | fn foo(a: usize) {} - | ^^^ -------- + | ^^^ help: remove the extra argument | LL - fn main() { foo(5, 6) } diff --git a/tests/ui/issues/issue-5883.rs b/tests/ui/issues/issue-5883.rs index f9dd2c54d99..dd4753e0344 100644 --- a/tests/ui/issues/issue-5883.rs +++ b/tests/ui/issues/issue-5883.rs @@ -6,7 +6,7 @@ struct Struct { fn new_struct( r: dyn A + 'static //~ ERROR the size for values of type -) -> Struct { +) -> Struct { //~ ERROR the size for values of type Struct { r: r } } diff --git a/tests/ui/issues/issue-5883.stderr b/tests/ui/issues/issue-5883.stderr index d481d0ef94e..d7278ec32f5 100644 --- a/tests/ui/issues/issue-5883.stderr +++ b/tests/ui/issues/issue-5883.stderr @@ -1,4 +1,18 @@ error[E0277]: the size for values of type `(dyn A + 'static)` cannot be known at compilation time + --> $DIR/issue-5883.rs:9: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 + | +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 | LL | r: dyn A + 'static @@ -15,6 +29,6 @@ help: function arguments must have a statically known size, borrowed types alway LL | r: &dyn A + 'static | + -error: aborting due to 1 previous error +error: aborting due to 2 previous errors For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/issue-76191.stderr b/tests/ui/issues/issue-76191.stderr index 3702bfb7769..3b89ec7cb9c 100644 --- a/tests/ui/issues/issue-76191.stderr +++ b/tests/ui/issues/issue-76191.stderr @@ -21,7 +21,7 @@ LL | RANGE => {} | `RANGE` is interpreted as a constant, not a new binding | = note: expected type `i32` - found struct `RangeInclusive<i32>` + found struct `std::ops::RangeInclusive<i32>` help: you may want to move the range into the match block | LL | 0..=255 => {} @@ -43,7 +43,7 @@ LL | RANGE2 => {} | `RANGE2` is interpreted as a constant, not a new binding | = note: expected type `i32` - found struct `RangeInclusive<i32>` + found struct `std::ops::RangeInclusive<i32>` = note: constants only support matching by type, if you meant to match against a range of values, consider using a range pattern like `min ..= max` in the match block error: aborting due to 3 previous errors diff --git a/tests/ui/iterators/iter-range.rs b/tests/ui/iterators/iter-range.rs index 9594729c06c..ec993317539 100644 --- a/tests/ui/iterators/iter-range.rs +++ b/tests/ui/iterators/iter-range.rs @@ -2,7 +2,7 @@ fn range_<F>(a: isize, b: isize, mut it: F) where F: FnMut(isize) { - assert!((a < b)); + assert!(a < b); let mut i: isize = a; while i < b { it(i); i += 1; } } diff --git a/tests/ui/json/json-multiple.rs b/tests/ui/json/json-multiple.rs index 296a60d2453..8ad57939d5d 100644 --- a/tests/ui/json/json-multiple.rs +++ b/tests/ui/json/json-multiple.rs @@ -1,5 +1,6 @@ //@ build-pass //@ ignore-pass (different metadata emitted in different modes) //@ compile-flags: --json=diagnostic-short --json artifacts --error-format=json +//@ normalize-stderr: "json-multiple\..+/libjson_multiple.rlib" -> "json-multiple/libjson_multiple.rlib" #![crate_type = "lib"] diff --git a/tests/ui/json/json-options.rs b/tests/ui/json/json-options.rs index 33df25e27b6..a6654bfcac6 100644 --- a/tests/ui/json/json-options.rs +++ b/tests/ui/json/json-options.rs @@ -1,5 +1,6 @@ //@ build-pass //@ ignore-pass (different metadata emitted in different modes) //@ compile-flags: --json=diagnostic-short,artifacts --error-format=json +//@ normalize-stderr: "json-options\..+/libjson_options.rlib" -> "json-options/libjson_options.rlib" #![crate_type = "lib"] diff --git a/tests/ui/lang-items/lang-item-missing.stderr b/tests/ui/lang-items/lang-item-missing.stderr index 08e679a7c55..63bca95adf7 100644 --- a/tests/ui/lang-items/lang-item-missing.stderr +++ b/tests/ui/lang-items/lang-item-missing.stderr @@ -1,4 +1,8 @@ error: requires `sized` lang_item + --> $DIR/lang-item-missing.rs:11:60 + | +LL | extern "C" fn main(_argc: i32, _argv: *const *const u8) -> i32 { + | ^^^ error: aborting due to 1 previous error diff --git a/tests/ui/lazy-type-alias/def-site-param-defaults-wf.rs b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.rs new file mode 100644 index 00000000000..90bb0a294f8 --- /dev/null +++ b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.rs @@ -0,0 +1,9 @@ +//! Ensure that we check generic parameter defaults for well-formedness at the definition site. +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +type Alias<T = Vec<str>, const N: usize = {0 - 1}> = T; +//~^ ERROR evaluation of constant value failed +//~| ERROR the size for values of type `str` cannot be known at compilation time + +fn main() {} diff --git a/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr new file mode 100644 index 00000000000..da0021ccaf4 --- /dev/null +++ b/tests/ui/lazy-type-alias/def-site-param-defaults-wf.stderr @@ -0,0 +1,20 @@ +error[E0080]: evaluation of constant value failed + --> $DIR/def-site-param-defaults-wf.rs:5:44 + | +LL | type Alias<T = Vec<str>, const N: usize = {0 - 1}> = T; + | ^^^^^ attempt to compute `0_usize - 1_usize`, which would overflow + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/def-site-param-defaults-wf.rs:5:16 + | +LL | type Alias<T = Vec<str>, const N: usize = {0 - 1}> = T; + | ^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` +note: required by an implicit `Sized` bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error: aborting due to 2 previous errors + +Some errors have detailed explanations: E0080, E0277. +For more information about an error, try `rustc --explain E0080`. diff --git a/tests/ui/lazy-type-alias/def-site-predicates-wf.rs b/tests/ui/lazy-type-alias/def-site-predicates-wf.rs new file mode 100644 index 00000000000..5d9235347cb --- /dev/null +++ b/tests/ui/lazy-type-alias/def-site-predicates-wf.rs @@ -0,0 +1,13 @@ +//! Ensure that we check the predicates at the definition site for well-formedness. +#![feature(lazy_type_alias)] +#![allow(incomplete_features)] + +type Alias0 = () +where + Vec<str>:; //~ ERROR the size for values of type `str` cannot be known at compilation time + +type Alias1 = () +where + Vec<str>: Sized; //~ ERROR the size for values of type `str` cannot be known at compilation time + +fn main() {} diff --git a/tests/ui/lazy-type-alias/def-site-predicates-wf.stderr b/tests/ui/lazy-type-alias/def-site-predicates-wf.stderr new file mode 100644 index 00000000000..b44e702c35c --- /dev/null +++ b/tests/ui/lazy-type-alias/def-site-predicates-wf.stderr @@ -0,0 +1,23 @@ +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/def-site-predicates-wf.rs:7:5 + | +LL | Vec<str>:; + | ^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` +note: required by an implicit `Sized` bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/def-site-predicates-wf.rs:11:15 + | +LL | Vec<str>: Sized; + | ^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` +note: required by an implicit `Sized` bound in `Vec` + --> $SRC_DIR/alloc/src/vec/mod.rs:LL:COL + +error: aborting due to 2 previous errors + +For more information about this error, try `rustc --explain E0277`. diff --git a/tests/ui/issues/issue-40408.rs b/tests/ui/lexer/floating-point-0e10-issue-40408.rs index a1c1c582181..a1c1c582181 100644 --- a/tests/ui/issues/issue-40408.rs +++ b/tests/ui/lexer/floating-point-0e10-issue-40408.rs diff --git a/tests/ui/lifetimes/tail-expr-lock-poisoning.rs b/tests/ui/lifetimes/tail-expr-lock-poisoning.rs index d7c7b2e2414..1c838a9e5e1 100644 --- a/tests/ui/lifetimes/tail-expr-lock-poisoning.rs +++ b/tests/ui/lifetimes/tail-expr-lock-poisoning.rs @@ -1,5 +1,4 @@ //@ revisions: edition2021 edition2024 -//@ ignore-wasm no panic support //@ needs-subprocess //@ [edition2024] edition: 2024 //@ run-pass diff --git a/tests/ui/linkage-attr/linkage-attr-does-not-panic-llvm-issue-33992.rs b/tests/ui/linkage-attr/linkage-attr-does-not-panic-llvm-issue-33992.rs index a169997927e..0717a2d5a6c 100644 --- a/tests/ui/linkage-attr/linkage-attr-does-not-panic-llvm-issue-33992.rs +++ b/tests/ui/linkage-attr/linkage-attr-does-not-panic-llvm-issue-33992.rs @@ -1,5 +1,4 @@ //@ run-pass -//@ ignore-windows //@ ignore-apple //@ ignore-wasm32 common linkage not implemented right now @@ -11,15 +10,14 @@ pub static TEST2: bool = true; #[linkage = "internal"] pub static TEST3: bool = true; +#[cfg(not(target_env = "msvc"))] #[linkage = "linkonce"] pub static TEST4: bool = true; +#[cfg(not(target_env = "msvc"))] #[linkage = "linkonce_odr"] pub static TEST5: bool = true; -#[linkage = "private"] -pub static TEST6: bool = true; - #[linkage = "weak"] pub static TEST7: bool = true; diff --git a/tests/ui/linkage-attr/propagate-generic-issue-18804/main.rs b/tests/ui/linkage-attr/propagate-generic-issue-18804/main.rs index 56a9358cce3..8c194ec50df 100644 --- a/tests/ui/linkage-attr/propagate-generic-issue-18804/main.rs +++ b/tests/ui/linkage-attr/propagate-generic-issue-18804/main.rs @@ -3,7 +3,6 @@ // functions. Failure results in a linker error. //@ ignore-emscripten no weak symbol support -//@ ignore-windows no extern_weak linkage //@ ignore-apple no extern_weak linkage //@ aux-build:lib.rs diff --git a/tests/ui/lint/lint-overflowing-int-136675.rs b/tests/ui/lint/lint-overflowing-int-136675.rs new file mode 100644 index 00000000000..616531519a6 --- /dev/null +++ b/tests/ui/lint/lint-overflowing-int-136675.rs @@ -0,0 +1,4 @@ +fn main() { + if let -129 = 0i8 {} //~ ERROR literal out of range for `i8` + let x: i8 = -129; //~ ERROR literal out of range for `i8` +} diff --git a/tests/ui/lint/lint-overflowing-int-136675.stderr b/tests/ui/lint/lint-overflowing-int-136675.stderr new file mode 100644 index 00000000000..3b67c663ac2 --- /dev/null +++ b/tests/ui/lint/lint-overflowing-int-136675.stderr @@ -0,0 +1,21 @@ +error: literal out of range for `i8` + --> $DIR/lint-overflowing-int-136675.rs:2:12 + | +LL | if let -129 = 0i8 {} + | ^^^^ + | + = note: the literal `-129` does not fit into the type `i8` whose range is `-128..=127` + = help: consider using the type `i16` instead + = note: `#[deny(overflowing_literals)]` on by default + +error: literal out of range for `i8` + --> $DIR/lint-overflowing-int-136675.rs:3:17 + | +LL | let x: i8 = -129; + | ^^^^ + | + = note: the literal `-129` does not fit into the type `i8` whose range is `-128..=127` + = help: consider using the type `i16` instead + +error: aborting due to 2 previous errors + diff --git a/tests/ui/logging-only-prints-once.rs b/tests/ui/logging-only-prints-once.rs index 5377d5eeae2..bb8c29694b5 100644 --- a/tests/ui/logging-only-prints-once.rs +++ b/tests/ui/logging-only-prints-once.rs @@ -1,5 +1,4 @@ //@ run-pass -//@ ignore-windows //@ needs-threads use std::cell::Cell; diff --git a/tests/ui/lto/auxiliary/dwarf-mixed-versions-lto-aux.rs b/tests/ui/lto/auxiliary/dwarf-mixed-versions-lto-aux.rs new file mode 100644 index 00000000000..3c81127ee65 --- /dev/null +++ b/tests/ui/lto/auxiliary/dwarf-mixed-versions-lto-aux.rs @@ -0,0 +1,5 @@ +//@ compile-flags: -g --crate-type=rlib -Zdwarf-version=4 + +pub fn say_hi() { + println!("hello there") +} diff --git a/tests/ui/lto/dwarf-mixed-versions-lto.rs b/tests/ui/lto/dwarf-mixed-versions-lto.rs new file mode 100644 index 00000000000..14ef65a868e --- /dev/null +++ b/tests/ui/lto/dwarf-mixed-versions-lto.rs @@ -0,0 +1,15 @@ +// This test verifies that we do not produce a warning when performing LTO on a +// crate graph that contains a mix of different DWARF version settings. This +// matches Clang's behavior. + +//@ ignore-msvc Platform must use DWARF +//@ aux-build:dwarf-mixed-versions-lto-aux.rs +//@ compile-flags: -C lto -g -Zdwarf-version=5 +//@ no-prefer-dynamic +//@ build-pass + +extern crate dwarf_mixed_versions_lto_aux; + +fn main() { + dwarf_mixed_versions_lto_aux::say_hi(); +} diff --git a/tests/ui/lto/weak-works.rs b/tests/ui/lto/weak-works.rs index 00e10b97d60..1ff47ca602d 100644 --- a/tests/ui/lto/weak-works.rs +++ b/tests/ui/lto/weak-works.rs @@ -1,7 +1,8 @@ //@ run-pass //@ compile-flags: -C codegen-units=8 -Z thinlto -//@ ignore-windows +//@ ignore-i686-pc-windows-gnu +//@ ignore-x86_64-pc-windows-gnu #![feature(linkage)] diff --git a/tests/ui/issues/issue-40136.rs b/tests/ui/macros/const-expr-invocations-issue-40136.rs index d5ccebdc85d..d5ccebdc85d 100644 --- a/tests/ui/issues/issue-40136.rs +++ b/tests/ui/macros/const-expr-invocations-issue-40136.rs diff --git a/tests/ui/issues/issue-40845.rs b/tests/ui/macros/macros-in-trait-positions-issue-40845.rs index a4ede6adfa3..a4ede6adfa3 100644 --- a/tests/ui/issues/issue-40845.rs +++ b/tests/ui/macros/macros-in-trait-positions-issue-40845.rs diff --git a/tests/ui/issues/issue-40845.stderr b/tests/ui/macros/macros-in-trait-positions-issue-40845.stderr index 66bf053204c..5c1b5f51e44 100644 --- a/tests/ui/issues/issue-40845.stderr +++ b/tests/ui/macros/macros-in-trait-positions-issue-40845.stderr @@ -1,11 +1,11 @@ error: cannot find macro `m` in this scope - --> $DIR/issue-40845.rs:1:11 + --> $DIR/macros-in-trait-positions-issue-40845.rs:1:11 | LL | trait T { m!(); } | ^ error: cannot find macro `m` in this scope - --> $DIR/issue-40845.rs:4:10 + --> $DIR/macros-in-trait-positions-issue-40845.rs:4:10 | LL | impl S { m!(); } | ^ diff --git a/tests/ui/macros/syntax-extension-source-utils.rs b/tests/ui/macros/syntax-extension-source-utils.rs index a16ebdc7504..2f88e508058 100644 --- a/tests/ui/macros/syntax-extension-source-utils.rs +++ b/tests/ui/macros/syntax-extension-source-utils.rs @@ -16,7 +16,7 @@ pub fn main() { assert_eq!(line!(), 16); assert_eq!(column!(), 16); assert_eq!(indirect_line!(), 18); - assert!((file!().ends_with("syntax-extension-source-utils.rs"))); + assert!(file!().ends_with("syntax-extension-source-utils.rs")); assert_eq!(stringify!((2*3) + 5).to_string(), "(2*3) + 5".to_string()); assert!(include!("syntax-extension-source-utils-files/includeme.\ fragment").to_string() @@ -30,7 +30,7 @@ pub fn main() { include_bytes!("syntax-extension-source-utils-files/includeme.fragment") [1] == (42 as u8)); // '*' // The Windows tests are wrapped in an extra module for some reason - assert!((m1::m2::where_am_i().ends_with("m1::m2"))); + assert!(m1::m2::where_am_i().ends_with("m1::m2")); assert_eq!((35, "(2*3) + 5"), (line!(), stringify!((2*3) + 5))); } diff --git a/tests/ui/issues/issue-41213.rs b/tests/ui/match/enum-and-break-in-match-issue-41213.rs index 97f80a99a83..7c42a3629c9 100644 --- a/tests/ui/issues/issue-41213.rs +++ b/tests/ui/match/enum-and-break-in-match-issue-41213.rs @@ -1,4 +1,4 @@ -//@ run-pass +//@ check-pass #![allow(dead_code)] enum A { A1, diff --git a/tests/ui/methods/issues/issue-61525.stderr b/tests/ui/methods/issues/issue-61525.stderr index 35001ae22a6..7ac3d3dc0cf 100644 --- a/tests/ui/methods/issues/issue-61525.stderr +++ b/tests/ui/methods/issues/issue-61525.stderr @@ -32,7 +32,7 @@ note: method defined here --> $DIR/issue-61525.rs:2:8 | LL | fn query<Q>(self, q: Q); - | ^^^^^ + | ^^^^^ - error: aborting due to 2 previous errors diff --git a/tests/ui/methods/method-call-err-msg.stderr b/tests/ui/methods/method-call-err-msg.stderr index 84005119a87..c17c4a23a3a 100644 --- a/tests/ui/methods/method-call-err-msg.stderr +++ b/tests/ui/methods/method-call-err-msg.stderr @@ -41,7 +41,7 @@ note: method defined here --> $DIR/method-call-err-msg.rs:7:8 | LL | fn two(self, _: isize, _: isize) -> Foo { self } - | ^^^ -------- -------- + | ^^^ -------- help: provide the argument | LL | .two(0, /* isize */); diff --git a/tests/ui/mir/null/borrowed_mut_null.rs b/tests/ui/mir/null/borrowed_mut_null.rs index 437955c452b..d26452b9dac 100644 --- a/tests/ui/mir/null/borrowed_mut_null.rs +++ b/tests/ui/mir/null/borrowed_mut_null.rs @@ -1,6 +1,6 @@ //@ run-fail //@ compile-flags: -C debug-assertions -//@ error-pattern: null pointer dereference occured +//@ error-pattern: null pointer dereference occurred fn main() { let ptr: *mut u32 = std::ptr::null_mut(); diff --git a/tests/ui/mir/null/borrowed_null.rs b/tests/ui/mir/null/borrowed_null.rs index eb0794efaa5..fefac3a7212 100644 --- a/tests/ui/mir/null/borrowed_null.rs +++ b/tests/ui/mir/null/borrowed_null.rs @@ -1,6 +1,6 @@ //@ run-fail //@ compile-flags: -C debug-assertions -//@ error-pattern: null pointer dereference occured +//@ error-pattern: null pointer dereference occurred fn main() { let ptr: *const u32 = std::ptr::null(); diff --git a/tests/ui/mir/null/borrowed_null_zst.rs b/tests/ui/mir/null/borrowed_null_zst.rs new file mode 100644 index 00000000000..835727c068b --- /dev/null +++ b/tests/ui/mir/null/borrowed_null_zst.rs @@ -0,0 +1,8 @@ +//@ run-fail +//@ compile-flags: -C debug-assertions +//@ error-pattern: null pointer dereference occurred + +fn main() { + let ptr: *const () = std::ptr::null(); + let _ptr: &() = unsafe { &*ptr }; +} diff --git a/tests/ui/mir/null/null_lhs.rs b/tests/ui/mir/null/null_lhs.rs index fd3bc3a78b8..238d350d1bd 100644 --- a/tests/ui/mir/null/null_lhs.rs +++ b/tests/ui/mir/null/null_lhs.rs @@ -1,6 +1,6 @@ //@ run-fail //@ compile-flags: -C debug-assertions -//@ error-pattern: null pointer dereference occured +//@ error-pattern: null pointer dereference occurred fn main() { let ptr: *mut u32 = std::ptr::null_mut(); diff --git a/tests/ui/mir/null/null_rhs.rs b/tests/ui/mir/null/null_rhs.rs index 45c8beb3fe8..18eafb61869 100644 --- a/tests/ui/mir/null/null_rhs.rs +++ b/tests/ui/mir/null/null_rhs.rs @@ -1,6 +1,6 @@ //@ run-fail //@ compile-flags: -C debug-assertions -//@ error-pattern: null pointer dereference occured +//@ error-pattern: null pointer dereference occurred fn main() { let ptr: *mut u32 = std::ptr::null_mut(); diff --git a/tests/ui/mir/null/place_without_read.rs b/tests/ui/mir/null/place_without_read.rs index d6bfb089b01..a259053d22b 100644 --- a/tests/ui/mir/null/place_without_read.rs +++ b/tests/ui/mir/null/place_without_read.rs @@ -6,5 +6,6 @@ fn main() { let ptr: *const u16 = std::ptr::null(); unsafe { let _ = *ptr; + let _ = &raw const *ptr; } } diff --git a/tests/ui/mir/null/place_without_read_zst.rs b/tests/ui/mir/null/place_without_read_zst.rs new file mode 100644 index 00000000000..c923ccea9a8 --- /dev/null +++ b/tests/ui/mir/null/place_without_read_zst.rs @@ -0,0 +1,11 @@ +// Make sure that we don't insert a check for places that do not read. +//@ run-pass +//@ compile-flags: -C debug-assertions + +fn main() { + let ptr: *const () = std::ptr::null(); + unsafe { + let _ = *ptr; + let _ = &raw const *ptr; + } +} diff --git a/tests/ui/mir/null/two_pointers.rs b/tests/ui/mir/null/two_pointers.rs index d9f0687fe0d..52b9510be12 100644 --- a/tests/ui/mir/null/two_pointers.rs +++ b/tests/ui/mir/null/two_pointers.rs @@ -1,6 +1,6 @@ //@ run-fail //@ compile-flags: -C debug-assertions -//@ error-pattern: null pointer dereference occured +//@ error-pattern: null pointer dereference occurred fn main() { let ptr = std::ptr::null(); diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed index 25943d11fc4..ba46a447802 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.current.fixed @@ -5,9 +5,9 @@ fn main() { let _ = (-10..=10).find(|x: &i32| x.signum() == 0); //[current]~^ ERROR type mismatch in closure arguments - //[next]~^^ ERROR expected a `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found + //[next]~^^ ERROR expected a `FnMut(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item)` closure, found let _ = (-10..=10).find(|x: &i32| x.signum() == 0); //[current]~^ ERROR type mismatch in closure arguments //[next]~^^ ERROR expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` - //[next]~| ERROR expected a `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found + //[next]~| ERROR expected a `FnMut(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item)` closure, found } diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr index 696214c0a3c..b7161310619 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.next.stderr @@ -1,14 +1,14 @@ -error[E0277]: expected a `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` +error[E0277]: expected a `FnMut(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` --> $DIR/closure-arg-type-mismatch-issue-45727.rs:6:29 | LL | let _ = (-10..=10).find(|x: i32| x.signum() == 0); - | ---- ^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnMut(&'a <RangeInclusive<{integer}> as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` + = help: the trait `for<'a> FnMut(&'a <std::ops::RangeInclusive<{integer}> as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:6:29: 6:37}` = note: expected a closure with arguments `(i32,)` - found a closure with arguments `(&<RangeInclusive<{integer}> as Iterator>::Item,)` + found a closure with arguments `(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item,)` note: required by a bound in `find` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL @@ -18,17 +18,17 @@ error[E0271]: expected `RangeInclusive<{integer}>` to be an iterator that yields LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); | ^^^^ expected `&&i32`, found integer -error[E0277]: expected a `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` +error[E0277]: expected a `FnMut(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` --> $DIR/closure-arg-type-mismatch-issue-45727.rs:9:29 | LL | let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); - | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` + | ---- ^^^^^^^^^^^^^^^^^^^^^^^^^^^ expected an `FnMut(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item)` closure, found `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` | | | required by a bound introduced by this call | - = help: the trait `for<'a> FnMut(&'a <RangeInclusive<{integer}> as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` + = help: the trait `for<'a> FnMut(&'a <std::ops::RangeInclusive<{integer}> as Iterator>::Item)` is not implemented for closure `{closure@$DIR/closure-arg-type-mismatch-issue-45727.rs:9:29: 9:40}` = note: expected a closure with arguments `(&&&i32,)` - found a closure with arguments `(&<RangeInclusive<{integer}> as Iterator>::Item,)` + found a closure with arguments `(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item,)` note: required by a bound in `find` --> $SRC_DIR/core/src/iter/traits/iterator.rs:LL:COL diff --git a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs index 9e44489cbf1..0fd56707763 100644 --- a/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs +++ b/tests/ui/mismatched_types/closure-arg-type-mismatch-issue-45727.rs @@ -5,9 +5,9 @@ fn main() { let _ = (-10..=10).find(|x: i32| x.signum() == 0); //[current]~^ ERROR type mismatch in closure arguments - //[next]~^^ ERROR expected a `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found + //[next]~^^ ERROR expected a `FnMut(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item)` closure, found let _ = (-10..=10).find(|x: &&&i32| x.signum() == 0); //[current]~^ ERROR type mismatch in closure arguments //[next]~^^ ERROR expected `RangeInclusive<{integer}>` to be an iterator that yields `&&i32`, but it yields `{integer}` - //[next]~| ERROR expected a `FnMut(&<RangeInclusive<{integer}> as Iterator>::Item)` closure, found + //[next]~| ERROR expected a `FnMut(&<std::ops::RangeInclusive<{integer}> as Iterator>::Item)` closure, found } diff --git a/tests/ui/mismatched_types/generic-mismatch-reporting-issue-116615.stderr b/tests/ui/mismatched_types/generic-mismatch-reporting-issue-116615.stderr index 0a86f884e70..9fc3a914447 100644 --- a/tests/ui/mismatched_types/generic-mismatch-reporting-issue-116615.stderr +++ b/tests/ui/mismatched_types/generic-mismatch-reporting-issue-116615.stderr @@ -31,9 +31,8 @@ note: function defined here --> $DIR/generic-mismatch-reporting-issue-116615.rs:2:4 | LL | fn foo_multi_same<T>(a: T, b: T, c: T, d: T, e: T, f: i32) {} - | ^^^^^^^^^^^^^^ - ---- ---- ---- ---- ---- ------ - | | | | | | | - | | | | | | this parameter needs to match the `&str` type of `a` and `b` + | ^^^^^^^^^^^^^^ - ---- ---- ---- ---- ---- this parameter needs to match the `&str` type of `a` and `b` + | | | | | | | | | | | this parameter needs to match the `&str` type of `a` and `b` | | | | this parameter needs to match the `&str` type of `a` and `b` | | | `c`, `d` and `e` need to match the `&str` type of this parameter @@ -83,9 +82,8 @@ note: function defined here --> $DIR/generic-mismatch-reporting-issue-116615.rs:2:4 | LL | fn foo_multi_same<T>(a: T, b: T, c: T, d: T, e: T, f: i32) {} - | ^^^^^^^^^^^^^^ - ---- ---- ---- ---- ---- ------ - | | | | | | | - | | | | | | `b` and `c` need to match the `&str` type of this parameter + | ^^^^^^^^^^^^^^ - ---- ---- ---- ---- ---- `b` and `c` need to match the `&str` type of this parameter + | | | | | | | | | | | `b` and `c` need to match the `&str` type of this parameter | | | | this parameter needs to match the `&str` type of `a`, `d` and `e` | | | this parameter needs to match the `&str` type of `a`, `d` and `e` diff --git a/tests/ui/mismatched_types/issue-26480.stderr b/tests/ui/mismatched_types/issue-26480.stderr index ae10a00671e..da8d73225f3 100644 --- a/tests/ui/mismatched_types/issue-26480.stderr +++ b/tests/ui/mismatched_types/issue-26480.stderr @@ -13,7 +13,7 @@ note: function defined here --> $DIR/issue-26480.rs:2:8 | LL | fn write(fildes: i32, buf: *const i8, nbyte: u64) -> i64; - | ^^^^^ + | ^^^^^ ----- = note: this error originates in the macro `write` (in Nightly builds, run with -Z macro-backtrace for more info) help: you can convert a `usize` to a `u64` and panic if the converted value doesn't fit | diff --git a/tests/ui/never_type/dont-suggest-turbofish-from-expansion.rs b/tests/ui/never_type/dont-suggest-turbofish-from-expansion.rs new file mode 100644 index 00000000000..9a53358464d --- /dev/null +++ b/tests/ui/never_type/dont-suggest-turbofish-from-expansion.rs @@ -0,0 +1,20 @@ +#![deny(dependency_on_unit_never_type_fallback)] + +fn create_ok_default<C>() -> Result<C, ()> +where + C: Default, +{ + Ok(C::default()) +} + +fn main() -> Result<(), ()> { + //~^ ERROR this function depends on never type fallback being `()` + //~| WARN this was previously accepted by the compiler but is being phased out + let (returned_value, _) = (|| { + let created = create_ok_default()?; + Ok((created, ())) + })()?; + + let _ = format_args!("{:?}", returned_value); + Ok(()) +} diff --git a/tests/ui/never_type/dont-suggest-turbofish-from-expansion.stderr b/tests/ui/never_type/dont-suggest-turbofish-from-expansion.stderr new file mode 100644 index 00000000000..3fe642a8401 --- /dev/null +++ b/tests/ui/never_type/dont-suggest-turbofish-from-expansion.stderr @@ -0,0 +1,26 @@ +error: this function depends on never type fallback being `()` + --> $DIR/dont-suggest-turbofish-from-expansion.rs:10:1 + | +LL | fn main() -> Result<(), ()> { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = warning: this was previously accepted by the compiler but is being phased out; it will become a hard error in Rust 2024 and in a future release in all editions! + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html> + = help: specify the types explicitly +note: in edition 2024, the requirement `!: Default` will fail + --> $DIR/dont-suggest-turbofish-from-expansion.rs:14:23 + | +LL | let created = create_ok_default()?; + | ^^^^^^^^^^^^^^^^^^^ +note: the lint level is defined here + --> $DIR/dont-suggest-turbofish-from-expansion.rs:1:9 + | +LL | #![deny(dependency_on_unit_never_type_fallback)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +help: use `()` annotations to avoid fallback changes + | +LL | let created: () = create_ok_default()?; + | ++++ + +error: aborting due to 1 previous error + diff --git a/tests/ui/never_type/issue-52443.stderr b/tests/ui/never_type/issue-52443.stderr index 1c5a0d65142..bb60c33595c 100644 --- a/tests/ui/never_type/issue-52443.stderr +++ b/tests/ui/never_type/issue-52443.stderr @@ -31,7 +31,7 @@ help: give the `break` a value of the expected type LL | [(); loop { break 42 }]; | ++ -error[E0015]: cannot use `for` loop on `RangeFrom<usize>` in constants +error[E0015]: cannot use `for` loop on `std::ops::RangeFrom<usize>` in constants --> $DIR/issue-52443.rs:9:21 | LL | [(); { for _ in 0usize.. {}; 0}]; @@ -39,7 +39,7 @@ LL | [(); { for _ in 0usize.. {}; 0}]; | = note: calls in constants are limited to constant functions, tuple structs and tuple variants -error[E0015]: cannot use `for` loop on `RangeFrom<usize>` in constants +error[E0015]: cannot use `for` loop on `std::ops::RangeFrom<usize>` in constants --> $DIR/issue-52443.rs:9:21 | LL | [(); { for _ in 0usize.. {}; 0}]; diff --git a/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2015.stderr b/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2015.stderr index 04cd2fcafd6..49b966f32ce 100644 --- a/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2015.stderr +++ b/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2015.stderr @@ -130,10 +130,6 @@ LL | msg_send!(); = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html> = help: specify the type explicitly = note: this warning originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info) -help: use `()` annotations to avoid fallback changes - | -LL | match send_message::<() /* ?0 */>() { - | ~~ warning: 10 warnings emitted diff --git a/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2024.stderr b/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2024.stderr index 7adba2cc709..4d3692a7b04 100644 --- a/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2024.stderr +++ b/tests/ui/never_type/lint-never-type-fallback-flowing-into-unsafe.e2024.stderr @@ -130,10 +130,6 @@ LL | msg_send!(); = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/never-type-fallback.html> = help: specify the type explicitly = note: this error originates in the macro `msg_send` (in Nightly builds, run with -Z macro-backtrace for more info) -help: use `()` annotations to avoid fallback changes - | -LL | match send_message::<() /* ?0 */>() { - | ~~ warning: the type `!` does not permit zero-initialization --> $DIR/lint-never-type-fallback-flowing-into-unsafe.rs:12:18 diff --git a/tests/ui/new-range/disabled.rs b/tests/ui/new-range/disabled.rs new file mode 100644 index 00000000000..1a5fe3f9743 --- /dev/null +++ b/tests/ui/new-range/disabled.rs @@ -0,0 +1,27 @@ +//@ check-pass + +#![feature(new_range_api)] + +fn main() { + // Unchanged + let a: core::range::RangeFull = ..; + let b: core::range::RangeTo<u8> = ..2; + let c: core::range::RangeToInclusive<u8> = ..=3; + + let _: core::ops::RangeFull = a; + let _: core::ops::RangeTo<u8> = b; + let _: core::ops::RangeToInclusive<u8> = c; + + // Changed + let a: core::range::legacy::RangeFrom<u8> = 1..; + let b: core::range::legacy::Range<u8> = 2..3; + let c: core::range::legacy::RangeInclusive<u8> = 4..=5; + + let a: core::ops::RangeFrom<u8> = a; + let b: core::ops::Range<u8> = b; + let c: core::ops::RangeInclusive<u8> = c; + + let _: core::ops::RangeFrom<u8> = a.into_iter(); + let _: core::ops::Range<u8> = b.into_iter(); + let _: core::ops::RangeInclusive<u8> = c.into_iter(); +} diff --git a/tests/ui/new-range/enabled.rs b/tests/ui/new-range/enabled.rs new file mode 100644 index 00000000000..a5fb76ad52b --- /dev/null +++ b/tests/ui/new-range/enabled.rs @@ -0,0 +1,24 @@ +//@ check-pass + +#![feature(new_range_api)] +#![feature(new_range)] + +fn main() { + // Unchanged + let a: core::range::RangeFull = ..; + let b: core::range::RangeTo<u8> = ..2; + let c: core::range::RangeToInclusive<u8> = ..=3; + + let _: core::ops::RangeFull = a; + let _: core::ops::RangeTo<u8> = b; + let _: core::ops::RangeToInclusive<u8> = c; + + // Changed + let a: core::range::RangeFrom<u8> = 1..; + let b: core::range::Range<u8> = 2..3; + let c: core::range::RangeInclusive<u8> = 4..=5; + + let _: core::range::IterRangeFrom<u8> = a.into_iter(); + let _: core::range::IterRange<u8> = b.into_iter(); + let _: core::range::IterRangeInclusive<u8> = c.into_iter(); +} diff --git a/tests/ui/nll/get_default.legacy.stderr b/tests/ui/nll/get_default.legacy.stderr new file mode 100644 index 00000000000..699250312dc --- /dev/null +++ b/tests/ui/nll/get_default.legacy.stderr @@ -0,0 +1,18 @@ +error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable + --> $DIR/get_default.rs:35:17 + | +LL | fn err(map: &mut Map) -> &String { + | - let's call the lifetime of this reference `'1` +LL | loop { +LL | match map.get() { + | --- immutable borrow occurs here +LL | Some(v) => { +LL | map.set(String::new()); // We always expect an error here. + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here +LL | +LL | return v; + | - returning this value requires that `*map` is borrowed for `'1` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/tests/ui/nll/get_default.stderr b/tests/ui/nll/get_default.nll.stderr index af79771e7e1..9b5976ca717 100644 --- a/tests/ui/nll/get_default.stderr +++ b/tests/ui/nll/get_default.nll.stderr @@ -1,5 +1,5 @@ error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable - --> $DIR/get_default.rs:21:17 + --> $DIR/get_default.rs:24:17 | LL | fn ok(map: &mut Map) -> &String { | - let's call the lifetime of this reference `'1` @@ -14,7 +14,7 @@ LL | map.set(String::new()); // Ideally, this would not error. | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable - --> $DIR/get_default.rs:32:17 + --> $DIR/get_default.rs:35:17 | LL | fn err(map: &mut Map) -> &String { | - let's call the lifetime of this reference `'1` @@ -22,14 +22,14 @@ LL | loop { LL | match map.get() { | --- immutable borrow occurs here LL | Some(v) => { -LL | map.set(String::new()); // Both AST and MIR error here +LL | map.set(String::new()); // We always expect an error here. | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here LL | LL | return v; | - returning this value requires that `*map` is borrowed for `'1` error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable - --> $DIR/get_default.rs:37:17 + --> $DIR/get_default.rs:40:17 | LL | fn err(map: &mut Map) -> &String { | - let's call the lifetime of this reference `'1` @@ -40,7 +40,7 @@ LL | match map.get() { LL | return v; | - returning this value requires that `*map` is borrowed for `'1` ... -LL | map.set(String::new()); // Ideally, just AST would error here +LL | map.set(String::new()); // Ideally, this would not error. | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here error: aborting due to 3 previous errors diff --git a/tests/ui/nll/get_default.polonius.stderr b/tests/ui/nll/get_default.polonius.stderr new file mode 100644 index 00000000000..699250312dc --- /dev/null +++ b/tests/ui/nll/get_default.polonius.stderr @@ -0,0 +1,18 @@ +error[E0502]: cannot borrow `*map` as mutable because it is also borrowed as immutable + --> $DIR/get_default.rs:35:17 + | +LL | fn err(map: &mut Map) -> &String { + | - let's call the lifetime of this reference `'1` +LL | loop { +LL | match map.get() { + | --- immutable borrow occurs here +LL | Some(v) => { +LL | map.set(String::new()); // We always expect an error here. + | ^^^^^^^^^^^^^^^^^^^^^^ mutable borrow occurs here +LL | +LL | return v; + | - returning this value requires that `*map` is borrowed for `'1` + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0502`. diff --git a/tests/ui/nll/get_default.rs b/tests/ui/nll/get_default.rs index ffac8a33da1..c3c09e9c2c5 100644 --- a/tests/ui/nll/get_default.rs +++ b/tests/ui/nll/get_default.rs @@ -1,7 +1,10 @@ // Basic test for free regions in the NLL code. This test ought to -// report an error due to a reborrowing constraint. Right now, we get -// a variety of errors from the older, AST-based machinery (notably -// borrowck), and then we get the NLL error at the end. +// report an error due to a reborrowing constraint. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius legacy +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] compile-flags: -Z polonius=legacy struct Map { } @@ -19,7 +22,7 @@ fn ok(map: &mut Map) -> &String { } None => { map.set(String::new()); // Ideally, this would not error. - //~^ ERROR borrowed as immutable + //[nll]~^ ERROR borrowed as immutable } } } @@ -29,13 +32,13 @@ fn err(map: &mut Map) -> &String { loop { match map.get() { Some(v) => { - map.set(String::new()); // Both AST and MIR error here + map.set(String::new()); // We always expect an error here. //~^ ERROR borrowed as immutable return v; } None => { - map.set(String::new()); // Ideally, just AST would error here - //~^ ERROR borrowed as immutable + map.set(String::new()); // Ideally, this would not error. + //[nll]~^ ERROR borrowed as immutable } } } diff --git a/tests/ui/nll/issue-46589.stderr b/tests/ui/nll/issue-46589.nll.stderr index abf62aaa510..dc80c1d08de 100644 --- a/tests/ui/nll/issue-46589.stderr +++ b/tests/ui/nll/issue-46589.nll.stderr @@ -1,5 +1,5 @@ error[E0499]: cannot borrow `**other` as mutable more than once at a time - --> $DIR/issue-46589.rs:23:21 + --> $DIR/issue-46589.rs:24:21 | LL | *other = match (*other).get_self() { | -------- first mutable borrow occurs here diff --git a/tests/ui/nll/issue-46589.rs b/tests/ui/nll/issue-46589.rs index 417d9cab657..10aff0d7b4e 100644 --- a/tests/ui/nll/issue-46589.rs +++ b/tests/ui/nll/issue-46589.rs @@ -1,8 +1,9 @@ -// This tests passes in Polonius mode, so is skipped in the automated compare-mode. -// We will manually check it passes in Polonius tests, as we can't have a test here -// which conditionally passes depending on a test revision/compile-flags. - -//@ ignore-compare-mode-polonius +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: nll polonius_next polonius +//@ [polonius_next] check-pass +//@ [polonius_next] compile-flags: -Zpolonius=next +//@ [polonius] check-pass +//@ [polonius] compile-flags: -Zpolonius struct Foo; @@ -21,7 +22,7 @@ impl Foo { *other = match (*other).get_self() { Some(s) => s, None => (*other).new_self() - //~^ ERROR cannot borrow `**other` as mutable more than once at a time [E0499] + //[nll]~^ ERROR cannot borrow `**other` as mutable more than once at a time [E0499] }; let c = other; diff --git a/tests/ui/nll/polonius/assignment-kills-loans.rs b/tests/ui/nll/polonius/assignment-kills-loans.rs index 182262e5c4b..56ea9c2f1f9 100644 --- a/tests/ui/nll/polonius/assignment-kills-loans.rs +++ b/tests/ui/nll/polonius/assignment-kills-loans.rs @@ -4,8 +4,11 @@ // facts only on simple assignments, but not projections, incorrectly causing errors to be emitted // for code accepted by NLL. They are all variations from example code in the NLL RFC. +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: polonius_next polonius //@ check-pass -//@ compile-flags: -Z polonius +//@ [polonius_next] compile-flags: -Z polonius=next +//@ [polonius] compile-flags: -Z polonius struct List<T> { value: T, diff --git a/tests/ui/nll/polonius/assignment-to-differing-field.stderr b/tests/ui/nll/polonius/assignment-to-differing-field.legacy.stderr index c46d010e4f5..cf5594dbd07 100644 --- a/tests/ui/nll/polonius/assignment-to-differing-field.stderr +++ b/tests/ui/nll/polonius/assignment-to-differing-field.legacy.stderr @@ -1,5 +1,5 @@ error[E0499]: cannot borrow `list.0.value` as mutable more than once at a time - --> $DIR/assignment-to-differing-field.rs:20:21 + --> $DIR/assignment-to-differing-field.rs:23:21 | LL | fn assignment_to_field_projection<'a, T>( | -- lifetime `'a` defined here @@ -11,7 +11,7 @@ LL | return result; | ------ returning this value requires that `list.0.value` is borrowed for `'a` error[E0499]: cannot borrow `list.0.next` as mutable more than once at a time - --> $DIR/assignment-to-differing-field.rs:23:26 + --> $DIR/assignment-to-differing-field.rs:26:26 | LL | fn assignment_to_field_projection<'a, T>( | -- lifetime `'a` defined here @@ -23,7 +23,7 @@ LL | list.1 = n; | ---------- assignment requires that `list.0.next` is borrowed for `'a` error[E0499]: cannot borrow `list.0.0.0.0.0.value` as mutable more than once at a time - --> $DIR/assignment-to-differing-field.rs:37:21 + --> $DIR/assignment-to-differing-field.rs:40:21 | LL | fn assignment_through_projection_chain<'a, T>( | -- lifetime `'a` defined here @@ -35,7 +35,7 @@ LL | return result; | ------ returning this value requires that `list.0.0.0.0.0.value` is borrowed for `'a` error[E0499]: cannot borrow `list.0.0.0.0.0.next` as mutable more than once at a time - --> $DIR/assignment-to-differing-field.rs:40:26 + --> $DIR/assignment-to-differing-field.rs:43:26 | LL | fn assignment_through_projection_chain<'a, T>( | -- lifetime `'a` defined here diff --git a/tests/ui/nll/polonius/assignment-to-differing-field.polonius.stderr b/tests/ui/nll/polonius/assignment-to-differing-field.polonius.stderr new file mode 100644 index 00000000000..cf5594dbd07 --- /dev/null +++ b/tests/ui/nll/polonius/assignment-to-differing-field.polonius.stderr @@ -0,0 +1,51 @@ +error[E0499]: cannot borrow `list.0.value` as mutable more than once at a time + --> $DIR/assignment-to-differing-field.rs:23:21 + | +LL | fn assignment_to_field_projection<'a, T>( + | -- lifetime `'a` defined here +... +LL | result.push(&mut (list.0).value); + | ^^^^^^^^^^^^^^^^^^^ `list.0.value` was mutably borrowed here in the previous iteration of the loop +... +LL | return result; + | ------ returning this value requires that `list.0.value` is borrowed for `'a` + +error[E0499]: cannot borrow `list.0.next` as mutable more than once at a time + --> $DIR/assignment-to-differing-field.rs:26:26 + | +LL | fn assignment_to_field_projection<'a, T>( + | -- lifetime `'a` defined here +... +LL | if let Some(n) = (list.0).next.as_mut() { + | ^^^^^^^^^^^^^ `list.0.next` was mutably borrowed here in the previous iteration of the loop +LL | +LL | list.1 = n; + | ---------- assignment requires that `list.0.next` is borrowed for `'a` + +error[E0499]: cannot borrow `list.0.0.0.0.0.value` as mutable more than once at a time + --> $DIR/assignment-to-differing-field.rs:40:21 + | +LL | fn assignment_through_projection_chain<'a, T>( + | -- lifetime `'a` defined here +... +LL | result.push(&mut ((((list.0).0).0).0).0.value); + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `list.0.0.0.0.0.value` was mutably borrowed here in the previous iteration of the loop +... +LL | return result; + | ------ returning this value requires that `list.0.0.0.0.0.value` is borrowed for `'a` + +error[E0499]: cannot borrow `list.0.0.0.0.0.next` as mutable more than once at a time + --> $DIR/assignment-to-differing-field.rs:43:26 + | +LL | fn assignment_through_projection_chain<'a, T>( + | -- lifetime `'a` defined here +... +LL | if let Some(n) = ((((list.0).0).0).0).0.next.as_mut() { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `list.0.0.0.0.0.next` was mutably borrowed here in the previous iteration of the loop +LL | +LL | *((((list.0).0).0).0).1 = n; + | --------------------------- assignment requires that `list.0.0.0.0.0.next` is borrowed for `'a` + +error: aborting due to 4 previous errors + +For more information about this error, try `rustc --explain E0499`. diff --git a/tests/ui/nll/polonius/assignment-to-differing-field.rs b/tests/ui/nll/polonius/assignment-to-differing-field.rs index fb6c9569525..9701cd2bb5e 100644 --- a/tests/ui/nll/polonius/assignment-to-differing-field.rs +++ b/tests/ui/nll/polonius/assignment-to-differing-field.rs @@ -4,7 +4,10 @@ // that we do not kill too many borrows. Assignments to the `.1` // field projections should leave the borrows on `.0` intact. -//@ compile-flags: -Z polonius +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: polonius legacy +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] compile-flags: -Z polonius=legacy struct List<T> { value: T, diff --git a/tests/ui/nll/polonius/call-kills-loans.rs b/tests/ui/nll/polonius/call-kills-loans.rs index c02293c9a78..0657c42f48c 100644 --- a/tests/ui/nll/polonius/call-kills-loans.rs +++ b/tests/ui/nll/polonius/call-kills-loans.rs @@ -4,8 +4,11 @@ // by NLL but was incorrectly rejected by Polonius because of these // missing `killed` facts. +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: polonius_next polonius //@ check-pass -//@ compile-flags: -Z polonius +//@ [polonius_next] compile-flags: -Z polonius=next +//@ [polonius] compile-flags: -Z polonius struct Thing; diff --git a/tests/ui/nll/polonius/issue-46589.rs b/tests/ui/nll/polonius/issue-46589.rs deleted file mode 100644 index af791f7e24d..00000000000 --- a/tests/ui/nll/polonius/issue-46589.rs +++ /dev/null @@ -1,31 +0,0 @@ -// This test is a copy of `ui/nll/issue-46589.rs` which fails in NLL but succeeds in Polonius. -// As we can't have a test here which conditionally passes depending on a test -// revision/compile-flags. We ensure here that it passes in Polonius mode. - -//@ check-pass -//@ compile-flags: -Z polonius - -struct Foo; - -impl Foo { - fn get_self(&mut self) -> Option<&mut Self> { - Some(self) - } - - fn new_self(&mut self) -> &mut Self { - self - } - - fn trigger_bug(&mut self) { - let other = &mut (&mut *self); - - *other = match (*other).get_self() { - Some(s) => s, - None => (*other).new_self() - }; - - let c = other; - } -} - -fn main() {} diff --git a/tests/ui/nll/polonius/location-insensitive-scopes-liveness.rs b/tests/ui/nll/polonius/location-insensitive-scopes-liveness.rs index cb56c8f6deb..677b7aa1df8 100644 --- a/tests/ui/nll/polonius/location-insensitive-scopes-liveness.rs +++ b/tests/ui/nll/polonius/location-insensitive-scopes-liveness.rs @@ -5,9 +5,11 @@ // than `liveness::trace`, on some specific CFGs shapes: a variable was dead during tracing but its // regions were marked live later, and live loans were not recomputed at this point. +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: polonius_next polonius //@ check-pass -//@ revisions: nll polonius -//@ [polonius] compile-flags: -Zpolonius=next +//@ [polonius_next] compile-flags: -Z polonius=next +//@ [polonius] compile-flags: -Z polonius // minimized from wavefc-cli-3.0.0 fn repro1() { diff --git a/tests/ui/nll/polonius/polonius-smoke-test.stderr b/tests/ui/nll/polonius/polonius-smoke-test.legacy.stderr index a8a8267290d..1268f6167f8 100644 --- a/tests/ui/nll/polonius/polonius-smoke-test.stderr +++ b/tests/ui/nll/polonius/polonius-smoke-test.legacy.stderr @@ -1,11 +1,11 @@ error[E0515]: cannot return reference to local variable `x` - --> $DIR/polonius-smoke-test.rs:6:5 + --> $DIR/polonius-smoke-test.rs:10:5 | LL | &x | ^^ returns a reference to data owned by the current function error[E0503]: cannot use `x` because it was mutably borrowed - --> $DIR/polonius-smoke-test.rs:12:13 + --> $DIR/polonius-smoke-test.rs:16:13 | LL | let y = &mut x; | ------ `x` is borrowed here @@ -15,7 +15,7 @@ LL | let w = y; | - borrow later used here error[E0505]: cannot move out of `x` because it is borrowed - --> $DIR/polonius-smoke-test.rs:18:13 + --> $DIR/polonius-smoke-test.rs:22:13 | LL | pub fn use_while_mut_fr(x: &mut i32) -> &mut i32 { | - - let's call the lifetime of this reference `'1` @@ -35,7 +35,7 @@ LL + let y = &mut x.clone(); | error[E0505]: cannot move out of `s` because it is borrowed - --> $DIR/polonius-smoke-test.rs:42:5 + --> $DIR/polonius-smoke-test.rs:46:5 | LL | let s = &mut 1; | - binding `s` declared here diff --git a/tests/ui/nll/polonius/polonius-smoke-test.polonius.stderr b/tests/ui/nll/polonius/polonius-smoke-test.polonius.stderr new file mode 100644 index 00000000000..1268f6167f8 --- /dev/null +++ b/tests/ui/nll/polonius/polonius-smoke-test.polonius.stderr @@ -0,0 +1,59 @@ +error[E0515]: cannot return reference to local variable `x` + --> $DIR/polonius-smoke-test.rs:10:5 + | +LL | &x + | ^^ returns a reference to data owned by the current function + +error[E0503]: cannot use `x` because it was mutably borrowed + --> $DIR/polonius-smoke-test.rs:16:13 + | +LL | let y = &mut x; + | ------ `x` is borrowed here +LL | let z = x; + | ^ use of borrowed `x` +LL | let w = y; + | - borrow later used here + +error[E0505]: cannot move out of `x` because it is borrowed + --> $DIR/polonius-smoke-test.rs:22:13 + | +LL | pub fn use_while_mut_fr(x: &mut i32) -> &mut i32 { + | - - let's call the lifetime of this reference `'1` + | | + | binding `x` declared here +LL | let y = &mut *x; + | ------- borrow of `*x` occurs here +LL | let z = x; + | ^ move out of `x` occurs here +LL | y + | - returning this value requires that `*x` is borrowed for `'1` + | +help: consider cloning the value if the performance cost is acceptable + | +LL - let y = &mut *x; +LL + let y = &mut x.clone(); + | + +error[E0505]: cannot move out of `s` because it is borrowed + --> $DIR/polonius-smoke-test.rs:46:5 + | +LL | let s = &mut 1; + | - binding `s` declared here +LL | let r = &mut *s; + | ------- borrow of `*s` occurs here +LL | let tmp = foo(&r); +LL | s; + | ^ move out of `s` occurs here +LL | tmp; + | --- borrow later used here + | +help: consider cloning the value if the performance cost is acceptable + | +LL - let r = &mut *s; +LL + let r = &mut s.clone(); + | + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0503, E0505, E0515. +For more information about an error, try `rustc --explain E0503`. diff --git a/tests/ui/nll/polonius/polonius-smoke-test.rs b/tests/ui/nll/polonius/polonius-smoke-test.rs index ea5cdb263f5..7fbb3f9b47c 100644 --- a/tests/ui/nll/polonius/polonius-smoke-test.rs +++ b/tests/ui/nll/polonius/polonius-smoke-test.rs @@ -1,5 +1,9 @@ -// Check that Polonius borrow check works for simple cases. -//@ compile-flags: -Z polonius +// Check that Polonius works for simple cases. + +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: polonius legacy +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] compile-flags: -Z polonius=legacy pub fn return_ref_to_local() -> &'static i32 { let x = 0; diff --git a/tests/ui/nll/polonius/storagedead-kills-loans.rs b/tests/ui/nll/polonius/storagedead-kills-loans.rs index 89cf919bb48..75a37e6ece5 100644 --- a/tests/ui/nll/polonius/storagedead-kills-loans.rs +++ b/tests/ui/nll/polonius/storagedead-kills-loans.rs @@ -3,8 +3,11 @@ // is correctly accepted by NLL but was incorrectly rejected by // Polonius because of these missing `killed` facts. +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: polonius_next polonius //@ check-pass -//@ compile-flags: -Z polonius +//@ [polonius_next] compile-flags: -Z polonius=next +//@ [polonius] compile-flags: -Z polonius use std::{io, mem}; use std::io::Read; diff --git a/tests/ui/nll/polonius/subset-relations.stderr b/tests/ui/nll/polonius/subset-relations.legacy.stderr index 9deca6449a8..10d42ca58d9 100644 --- a/tests/ui/nll/polonius/subset-relations.stderr +++ b/tests/ui/nll/polonius/subset-relations.legacy.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/subset-relations.rs:10:5 + --> $DIR/subset-relations.rs:13:5 | LL | fn missing_subset<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 { | -- -- lifetime `'b` defined here diff --git a/tests/ui/nll/polonius/subset-relations.polonius.stderr b/tests/ui/nll/polonius/subset-relations.polonius.stderr new file mode 100644 index 00000000000..10d42ca58d9 --- /dev/null +++ b/tests/ui/nll/polonius/subset-relations.polonius.stderr @@ -0,0 +1,14 @@ +error: lifetime may not live long enough + --> $DIR/subset-relations.rs:13:5 + | +LL | fn missing_subset<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 { + | -- -- lifetime `'b` defined here + | | + | lifetime `'a` defined here +LL | y + | ^ function was supposed to return data with lifetime `'a` but it is returning data with lifetime `'b` + | + = help: consider adding the following bound: `'b: 'a` + +error: aborting due to 1 previous error + diff --git a/tests/ui/nll/polonius/subset-relations.rs b/tests/ui/nll/polonius/subset-relations.rs index 3c1af1983cf..d47e4e05533 100644 --- a/tests/ui/nll/polonius/subset-relations.rs +++ b/tests/ui/nll/polonius/subset-relations.rs @@ -3,7 +3,10 @@ // two free regions outlive each other, without any evidence that this // relation holds. -//@ compile-flags: -Z polonius +//@ ignore-compare-mode-polonius (explicit revisions) +//@ revisions: polonius legacy +//@ [polonius] compile-flags: -Z polonius=next +//@ [legacy] compile-flags: -Z polonius=legacy // returning `y` requires that `'b: 'a`, but it's not known to be true fn missing_subset<'a, 'b>(x: &'a u32, y: &'b u32) -> &'a u32 { @@ -22,7 +25,7 @@ fn implied_bounds_subset<'a, 'b>(x: &'a &'b mut u32) -> &'a u32 { // `'b: 'a` is declared, and `'a: 'c` is known via implied bounds: // `'b: 'c` is therefore known to hold transitively -fn transitively_valid_subset<'a, 'b: 'a, 'c>(x: &'c &'a u32, y: &'b u32) -> &'c u32 { +fn transitively_valid_subset<'a, 'b: 'a, 'c>(x: &'c &'a u32, y: &'b u32) -> &'c u32 { y } diff --git a/tests/ui/not-enough-arguments.stderr b/tests/ui/not-enough-arguments.stderr index 89e98866667..66c96ba43c8 100644 --- a/tests/ui/not-enough-arguments.stderr +++ b/tests/ui/not-enough-arguments.stderr @@ -8,7 +8,7 @@ note: function defined here --> $DIR/not-enough-arguments.rs:5:4 | LL | fn foo(a: isize, b: isize, c: isize, d:isize) { - | ^^^ -------- -------- -------- ------- + | ^^^ ------- help: provide the argument | LL | foo(1, 2, 3, /* isize */); @@ -25,12 +25,7 @@ note: function defined here | LL | fn bar( | ^^^ -LL | a: i32, - | ------ -LL | b: i32, - | ------ -LL | c: i32, - | ------ +... LL | d: i32, | ------ LL | e: i32, diff --git a/tests/ui/numbers-arithmetic/arith-unsigned.rs b/tests/ui/numbers-arithmetic/arith-unsigned.rs index 5a285ceca32..4a1bae438ca 100644 --- a/tests/ui/numbers-arithmetic/arith-unsigned.rs +++ b/tests/ui/numbers-arithmetic/arith-unsigned.rs @@ -3,22 +3,22 @@ // Unsigned integer operations pub fn main() { - assert!((0u8 < 255u8)); - assert!((0u8 <= 255u8)); - assert!((255u8 > 0u8)); - assert!((255u8 >= 0u8)); + assert!(0u8 < 255u8); + assert!(0u8 <= 255u8); + assert!(255u8 > 0u8); + assert!(255u8 >= 0u8); assert_eq!(250u8 / 10u8, 25u8); assert_eq!(255u8 % 10u8, 5u8); - assert!((0u16 < 60000u16)); - assert!((0u16 <= 60000u16)); - assert!((60000u16 > 0u16)); - assert!((60000u16 >= 0u16)); + assert!(0u16 < 60000u16); + assert!(0u16 <= 60000u16); + assert!(60000u16 > 0u16); + assert!(60000u16 >= 0u16); assert_eq!(60000u16 / 10u16, 6000u16); assert_eq!(60005u16 % 10u16, 5u16); - assert!((0u32 < 4000000000u32)); - assert!((0u32 <= 4000000000u32)); - assert!((4000000000u32 > 0u32)); - assert!((4000000000u32 >= 0u32)); + assert!(0u32 < 4000000000u32); + assert!(0u32 <= 4000000000u32); + assert!(4000000000u32 > 0u32); + assert!(4000000000u32 >= 0u32); assert_eq!(4000000000u32 / 10u32, 400000000u32); assert_eq!(4000000005u32 % 10u32, 5u32); // 64-bit numbers have some flakiness yet. Not tested diff --git a/tests/ui/numbers-arithmetic/float-nan.rs b/tests/ui/numbers-arithmetic/float-nan.rs index 7d1af0155da..ee3718f6f93 100644 --- a/tests/ui/numbers-arithmetic/float-nan.rs +++ b/tests/ui/numbers-arithmetic/float-nan.rs @@ -2,7 +2,7 @@ pub fn main() { let nan: f64 = f64::NAN; - assert!((nan).is_nan()); + assert!(nan.is_nan()); let inf: f64 = f64::INFINITY; let neg_inf: f64 = -f64::INFINITY; diff --git a/tests/ui/numbers-arithmetic/float2.rs b/tests/ui/numbers-arithmetic/float2.rs index 1b7add01cc6..515220fee9f 100644 --- a/tests/ui/numbers-arithmetic/float2.rs +++ b/tests/ui/numbers-arithmetic/float2.rs @@ -15,12 +15,12 @@ pub fn main() { let j = 3.1e+9f64; let k = 3.2e-10f64; assert_eq!(a, b); - assert!((c < b)); + assert!(c < b); assert_eq!(c, d); - assert!((e < g)); - assert!((f < h)); + assert!(e < g); + assert!(f < h); assert_eq!(g, 1000000.0f32); assert_eq!(h, i); - assert!((j > k)); - assert!((k < a)); + assert!(j > k); + assert!(k < a); } diff --git a/tests/ui/numbers-arithmetic/floatlits.rs b/tests/ui/numbers-arithmetic/floatlits.rs index 21f19b69c49..2dab2242011 100644 --- a/tests/ui/numbers-arithmetic/floatlits.rs +++ b/tests/ui/numbers-arithmetic/floatlits.rs @@ -4,9 +4,9 @@ pub fn main() { let f = 4.999999999999f64; - assert!((f > 4.90f64)); - assert!((f < 5.0f64)); + assert!(f > 4.90f64); + assert!(f < 5.0f64); let g = 4.90000000001e-10f64; - assert!((g > 5e-11f64)); - assert!((g < 5e-9f64)); + assert!(g > 5e-11f64); + assert!(g < 5e-9f64); } diff --git a/tests/ui/panics/issue-47429-short-backtraces.rs b/tests/ui/panics/issue-47429-short-backtraces.rs index 4a73ebe8712..378ade67bfd 100644 --- a/tests/ui/panics/issue-47429-short-backtraces.rs +++ b/tests/ui/panics/issue-47429-short-backtraces.rs @@ -17,8 +17,6 @@ //@ ignore-msvc see #62897 and `backtrace-debuginfo.rs` test //@ ignore-android FIXME #17520 //@ ignore-openbsd no support for libbacktrace without filename -//@ ignore-wasm no panic support -//@ ignore-emscripten no panic support //@ ignore-fuchsia Backtraces not symbolized //@ needs-subprocess diff --git a/tests/ui/panics/issue-47429-short-backtraces.run.stderr b/tests/ui/panics/issue-47429-short-backtraces.run.stderr index c6e2d13fb5d..32dc6592271 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' panicked at $DIR/issue-47429-short-backtraces.rs:26:5: +thread 'main' panicked at $DIR/issue-47429-short-backtraces.rs:24: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 9f0be8c7ddf..7d5b4169340 100644 --- a/tests/ui/panics/runtime-switch.rs +++ b/tests/ui/panics/runtime-switch.rs @@ -18,7 +18,6 @@ //@ ignore-android FIXME #17520 //@ ignore-openbsd no support for libbacktrace without filename //@ ignore-wasm no backtrace support -//@ ignore-emscripten no panic support //@ ignore-fuchsia Backtrace not symbolized //@ needs-subprocess diff --git a/tests/ui/panics/runtime-switch.run.stderr b/tests/ui/panics/runtime-switch.run.stderr index 458a0ee534a..70ed127af86 100644 --- a/tests/ui/panics/runtime-switch.run.stderr +++ b/tests/ui/panics/runtime-switch.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/runtime-switch.rs:29:5: +thread 'main' panicked at $DIR/runtime-switch.rs:28:5: explicit panic stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/panics/short-ice-remove-middle-frames-2.rs b/tests/ui/panics/short-ice-remove-middle-frames-2.rs index 48f60b14170..660530f0ead 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames-2.rs +++ b/tests/ui/panics/short-ice-remove-middle-frames-2.rs @@ -5,7 +5,6 @@ //@ needs-unwind //@ ignore-android FIXME #17520 //@ ignore-openbsd no support for libbacktrace without filename -//@ ignore-emscripten no panic //@ ignore-sgx Backtraces not symbolized //@ ignore-fuchsia Backtraces not symbolized //@ ignore-msvc the `__rust_{begin,end}_short_backtrace` symbols aren't reliable. diff --git a/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr index 1fddcca6951..664d51e185d 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames-2.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/short-ice-remove-middle-frames-2.rs:63:5: +thread 'main' panicked at $DIR/short-ice-remove-middle-frames-2.rs:62:5: debug!!! stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/panics/short-ice-remove-middle-frames.rs b/tests/ui/panics/short-ice-remove-middle-frames.rs index 216c5127799..41fb6e9950e 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames.rs +++ b/tests/ui/panics/short-ice-remove-middle-frames.rs @@ -5,7 +5,6 @@ //@ needs-unwind //@ ignore-android FIXME #17520 //@ ignore-openbsd no support for libbacktrace without filename -//@ ignore-emscripten no panic //@ ignore-sgx Backtraces not symbolized //@ ignore-fuchsia Backtraces not symbolized //@ ignore-msvc the `__rust_{begin,end}_short_backtrace` symbols aren't reliable. diff --git a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr index 630b09d8d1e..e966462331f 100644 --- a/tests/ui/panics/short-ice-remove-middle-frames.run.stderr +++ b/tests/ui/panics/short-ice-remove-middle-frames.run.stderr @@ -1,5 +1,5 @@ -thread 'main' panicked at $DIR/short-ice-remove-middle-frames.rs:59:5: +thread 'main' panicked at $DIR/short-ice-remove-middle-frames.rs:58:5: debug!!! stack backtrace: 0: std::panicking::begin_panic diff --git a/tests/ui/parser/mod_file_not_exist.rs b/tests/ui/parser/mod_file_not_exist.rs index e7727944147..49ce44982ab 100644 --- a/tests/ui/parser/mod_file_not_exist.rs +++ b/tests/ui/parser/mod_file_not_exist.rs @@ -1,5 +1,3 @@ -//@ ignore-windows - mod not_a_real_file; //~ ERROR file not found for module `not_a_real_file` //~^ HELP to create the module `not_a_real_file`, create file diff --git a/tests/ui/parser/mod_file_not_exist.stderr b/tests/ui/parser/mod_file_not_exist.stderr index 40041b11c8b..d9e4e8f31f5 100644 --- a/tests/ui/parser/mod_file_not_exist.stderr +++ b/tests/ui/parser/mod_file_not_exist.stderr @@ -1,5 +1,5 @@ error[E0583]: file not found for module `not_a_real_file` - --> $DIR/mod_file_not_exist.rs:3:1 + --> $DIR/mod_file_not_exist.rs:1:1 | LL | mod not_a_real_file; | ^^^^^^^^^^^^^^^^^^^^ @@ -8,7 +8,7 @@ LL | mod not_a_real_file; = note: if there is a `mod not_a_real_file` elsewhere in the crate already, import it with `use crate::...` instead error[E0433]: failed to resolve: use of unresolved module or unlinked crate `mod_file_aux` - --> $DIR/mod_file_not_exist.rs:7:16 + --> $DIR/mod_file_not_exist.rs:5:16 | LL | assert_eq!(mod_file_aux::bar(), 10); | ^^^^^^^^^^^^ use of unresolved module or unlinked crate `mod_file_aux` diff --git a/tests/ui/pattern/overflowing-literals.rs b/tests/ui/pattern/overflowing-literals.rs new file mode 100644 index 00000000000..13016d3f7d1 --- /dev/null +++ b/tests/ui/pattern/overflowing-literals.rs @@ -0,0 +1,21 @@ +//! Check that overflowing literals are in patterns are rejected + +#![feature(pattern_types)] +#![feature(pattern_type_macro)] + +use std::pat::pattern_type; + +type TooBig = pattern_type!(u8 is 500..); +//~^ ERROR: literal out of range for `u8` +type TooSmall = pattern_type!(i8 is -500..); +//~^ ERROR: literal out of range for `i8` +type TooBigSigned = pattern_type!(i8 is 200..); +//~^ ERROR: literal out of range for `i8` + +fn main() { + match 5_u8 { + 500 => {} + //~^ ERROR literal out of range for `u8` + _ => {} + } +} diff --git a/tests/ui/pattern/overflowing-literals.stderr b/tests/ui/pattern/overflowing-literals.stderr new file mode 100644 index 00000000000..8164b97fd47 --- /dev/null +++ b/tests/ui/pattern/overflowing-literals.stderr @@ -0,0 +1,37 @@ +error: literal out of range for `u8` + --> $DIR/overflowing-literals.rs:8:35 + | +LL | type TooBig = pattern_type!(u8 is 500..); + | ^^^ + | + = note: the literal `500` does not fit into the type `u8` whose range is `0..=255` + = note: `#[deny(overflowing_literals)]` on by default + +error: literal out of range for `i8` + --> $DIR/overflowing-literals.rs:10:37 + | +LL | type TooSmall = pattern_type!(i8 is -500..); + | ^^^^ + | + = note: the literal `-500` does not fit into the type `i8` whose range is `-128..=127` + = help: consider using the type `i16` instead + +error: literal out of range for `i8` + --> $DIR/overflowing-literals.rs:12:41 + | +LL | type TooBigSigned = pattern_type!(i8 is 200..); + | ^^^ + | + = note: the literal `200` does not fit into the type `i8` whose range is `-128..=127` + = help: consider using the type `u8` instead + +error: literal out of range for `u8` + --> $DIR/overflowing-literals.rs:17:9 + | +LL | 500 => {} + | ^^^ + | + = note: the literal `500` does not fit into the type `u8` whose range is `0..=255` + +error: aborting due to 4 previous errors + diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2024.stderr index 331b86736a0..1c446178308 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.classic2024.stderr @@ -48,19 +48,19 @@ LL | let &ref mut x = &0; | ^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:35:23 + --> $DIR/borrowck-errors.rs:37:23 | LL | if let &Some(Some(x)) = &Some(&mut Some(0)) { | ^ cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:40:11 + --> $DIR/borrowck-errors.rs:42:11 | LL | let &[x] = &&mut [0]; | ^ cannot borrow as mutable error[E0508]: cannot move out of type `[&mut i32; 1]`, a non-copy array - --> $DIR/borrowck-errors.rs:44:20 + --> $DIR/borrowck-errors.rs:46:20 | LL | let [&mut x] = &mut [&mut 0]; | - ^^^^^^^^^^^^^ cannot move out of here diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs index 3f5d9c8db5d..59cafc50d86 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.rs @@ -32,6 +32,8 @@ pub fn main() { let &ref mut x = &0; //~^ cannot borrow data in a `&` reference as mutable [E0596] + // For 2021 edition, this is also a regression test for #136223 + // since the maximum mutability is downgraded during the pattern check process. if let &Some(Some(x)) = &Some(&mut Some(0)) { //[stable2021,classic2024]~^ ERROR: cannot borrow data in a `&` reference as mutable let _: &u32 = x; diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.stable2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.stable2021.stderr index 65c98e2da9c..deefe21ca7d 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.stable2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/borrowck-errors.stable2021.stderr @@ -52,13 +52,13 @@ LL | let &ref mut x = &0; | ^^^^^^^^^ cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:35:23 + --> $DIR/borrowck-errors.rs:37:23 | LL | if let &Some(Some(x)) = &Some(&mut Some(0)) { | ^ cannot borrow as mutable error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/borrowck-errors.rs:40:11 + --> $DIR/borrowck-errors.rs:42:11 | LL | let &[x] = &&mut [0]; | ^ cannot borrow as mutable diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr index 70cdcbd62eb..b7fb70dfd24 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.classic2024.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/ref-binding-on-inh-ref-errors.rs:60:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:54:10 | LL | let [&mut ref x] = &[&mut 0]; | ^^^^^ @@ -10,55 +10,75 @@ help: replace this `&mut` pattern with `&` LL | let [&ref x] = &[&mut 0]; | ~ -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:74:10 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:67:10 | LL | let [ref mut x] = &[0]; - | ^^^^^^^ cannot override to bind by-reference when that is the implicit default + | ^^^^^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:67:9 + | +LL | let [ref mut x] = &[0]; + | ^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[ref mut x] = &[0]; | + error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/ref-binding-on-inh-ref-errors.rs:74:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:67:10 | LL | let [ref mut x] = &[0]; | ^^^^^^^^^ cannot borrow as mutable -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:83:10 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:75:10 | LL | let [ref x] = &[0]; - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:75:9 + | +LL | let [ref x] = &[0]; + | ^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[ref x] = &[0]; | + -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:88:10 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:79:10 | LL | let [ref x] = &mut [0]; - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:79:9 + | +LL | let [ref x] = &mut [0]; + | ^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [ref x] = &mut [0]; | ++++ -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:93:10 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:83:10 | LL | let [ref mut x] = &mut [0]; - | ^^^^^^^ cannot override to bind by-reference when that is the implicit default + | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:83:9 + | +LL | let [ref mut x] = &mut [0]; + | ^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [ref mut x] = &mut [0]; diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.rs index 4c88c0c63ae..4e048570c33 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.rs +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.rs @@ -13,26 +13,22 @@ /// The eat-outer variant eats the inherited reference, so binding with `ref` isn't a problem. fn errors_from_eating_the_real_reference() { let [&ref x] = &[&0]; - //[structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024 - //[structural2024]~| cannot override to bind by-reference when that is the implicit default + //[structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(stable2021)] let _: &u32 = x; #[cfg(classic2024)] let _: &&u32 = x; let [&ref x] = &mut [&0]; - //[structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024 - //[structural2024]~| cannot override to bind by-reference when that is the implicit default + //[structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(stable2021)] let _: &u32 = x; #[cfg(classic2024)] let _: &&u32 = x; let [&mut ref x] = &mut [&mut 0]; - //[structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024 - //[structural2024]~| cannot override to bind by-reference when that is the implicit default + //[structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(stable2021)] let _: &u32 = x; #[cfg(classic2024)] let _: &&mut u32 = x; let [&mut ref mut x] = &mut [&mut 0]; - //[structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024 - //[structural2024]~| cannot override to bind by-reference when that is the implicit default + //[structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(stable2021)] let _: &mut u32 = x; #[cfg(classic2024)] let _: &mut &mut u32 = x; } @@ -43,15 +39,13 @@ fn errors_from_eating_the_real_reference_caught_in_hir_typeck_on_stable() { let [&ref x] = &[&mut 0]; //[stable2021]~^ ERROR: mismatched types //[stable2021]~| types differ in mutability - //[structural2024]~^^^ ERROR: this pattern relies on behavior which may change in edition 2024 - //[structural2024]~| cannot override to bind by-reference when that is the implicit default + //[structural2024]~^^^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(classic2024)] let _: &&mut u32 = x; let [&ref x] = &mut [&mut 0]; //[stable2021]~^ ERROR: mismatched types //[stable2021]~| types differ in mutability - //[structural2024]~^^^ ERROR: this pattern relies on behavior which may change in edition 2024 - //[structural2024]~| cannot override to bind by-reference when that is the implicit default + //[structural2024]~^^^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(classic2024)] let _: &&mut u32 = x; } @@ -60,8 +54,7 @@ fn errors_dependent_on_eating_order_caught_in_hir_typeck_when_eating_outer() { let [&mut ref x] = &[&mut 0]; //[classic2024]~^ ERROR: mismatched types //[classic2024]~| cannot match inherited `&` with `&mut` pattern - //[structural2024]~^^^ ERROR: this pattern relies on behavior which may change in edition 2024 - //[structural2024]~| cannot override to bind by-reference when that is the implicit default + //[structural2024]~^^^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(stable2021)] let _: &u32 = x; } @@ -73,25 +66,21 @@ fn errors_dependent_on_eating_order_caught_in_hir_typeck_when_eating_outer() { fn borrowck_errors_in_old_editions() { let [ref mut x] = &[0]; //~^ ERROR: cannot borrow data in a `&` reference as mutable - //[classic2024,structural2024]~| ERROR: this pattern relies on behavior which may change in edition 2024 - //[classic2024,structural2024]~| cannot override to bind by-reference when that is the implicit default + //[classic2024,structural2024]~| ERROR: binding modifiers may only be written when the default binding mode is `move` } /// The remaining tests are purely for testing `ref` bindings in the presence of an inherited /// reference. These should always fail on edition 2024 and succeed on edition 2021. pub fn main() { let [ref x] = &[0]; - //[classic2024,structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024 - //[classic2024,structural2024]~| cannot override to bind by-reference when that is the implicit default + //[classic2024,structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(stable2021)] let _: &u32 = x; let [ref x] = &mut [0]; - //[classic2024,structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024 - //[classic2024,structural2024]~| cannot override to bind by-reference when that is the implicit default + //[classic2024,structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(stable2021)] let _: &u32 = x; let [ref mut x] = &mut [0]; - //[classic2024,structural2024]~^ ERROR: this pattern relies on behavior which may change in edition 2024 - //[classic2024,structural2024]~| cannot override to bind by-reference when that is the implicit default + //[classic2024,structural2024]~^ ERROR: binding modifiers may only be written when the default binding mode is `move` #[cfg(stable2021)] let _: &mut u32 = x; } diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.stable2021.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.stable2021.stderr index a21e4bb5b8f..26095d84605 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.stable2021.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.stable2021.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/ref-binding-on-inh-ref-errors.rs:43:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:39:10 | LL | let [&ref x] = &[&mut 0]; | ^^^^^^ --------- this expression has type `&[&mut {integer}; 1]` @@ -15,7 +15,7 @@ LL + let [ref x] = &[&mut 0]; | error[E0308]: mismatched types - --> $DIR/ref-binding-on-inh-ref-errors.rs:50:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:45:10 | LL | let [&ref x] = &mut [&mut 0]; | ^^^^^^ ------------- this expression has type `&mut [&mut {integer}; 1]` @@ -31,7 +31,7 @@ LL + let [ref x] = &mut [&mut 0]; | error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/ref-binding-on-inh-ref-errors.rs:74:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:67:10 | LL | let [ref mut x] = &[0]; | ^^^^^^^^^ cannot borrow as mutable diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr index ee2c831bfcc..31930e8c033 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/experimental/ref-binding-on-inh-ref-errors.structural2024.stderr @@ -1,136 +1,191 @@ -error: this pattern relies on behavior which may change in edition 2024 +error: binding modifiers may only be written when the default binding mode is `move` --> $DIR/ref-binding-on-inh-ref-errors.rs:15:11 | LL | let [&ref x] = &[&0]; - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:15:9 + | +LL | let [&ref x] = &[&0]; + | ^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[&ref x] = &[&0]; | + -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:21:11 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:20:11 | LL | let [&ref x] = &mut [&0]; - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:20:9 + | +LL | let [&ref x] = &mut [&0]; + | ^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [&ref x] = &mut [&0]; | ++++ -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:27:15 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:25:15 | LL | let [&mut ref x] = &mut [&mut 0]; - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:25:9 + | +LL | let [&mut ref x] = &mut [&mut 0]; + | ^^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [&mut ref x] = &mut [&mut 0]; | ++++ -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:33:15 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:30:15 | LL | let [&mut ref mut x] = &mut [&mut 0]; - | ^^^^^^^ cannot override to bind by-reference when that is the implicit default + | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:30:9 + | +LL | let [&mut ref mut x] = &mut [&mut 0]; + | ^^^^^^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [&mut ref mut x] = &mut [&mut 0]; | ++++ -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:43:11 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:39:11 | LL | let [&ref x] = &[&mut 0]; - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:39:9 + | +LL | let [&ref x] = &[&mut 0]; + | ^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[&ref x] = &[&mut 0]; | + -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:50:11 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:45:11 | LL | let [&ref x] = &mut [&mut 0]; - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:45:9 + | +LL | let [&ref x] = &mut [&mut 0]; + | ^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [&ref x] = &mut [&mut 0]; | ++++ -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:60:15 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:54:15 | LL | let [&mut ref x] = &[&mut 0]; - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:54:9 + | +LL | let [&mut ref x] = &[&mut 0]; + | ^^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[&mut ref x] = &[&mut 0]; | + -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:74:10 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:67:10 | LL | let [ref mut x] = &[0]; - | ^^^^^^^ cannot override to bind by-reference when that is the implicit default + | ^^^^^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:67:9 + | +LL | let [ref mut x] = &[0]; + | ^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[ref mut x] = &[0]; | + error[E0596]: cannot borrow data in a `&` reference as mutable - --> $DIR/ref-binding-on-inh-ref-errors.rs:74:10 + --> $DIR/ref-binding-on-inh-ref-errors.rs:67:10 | LL | let [ref mut x] = &[0]; | ^^^^^^^^^ cannot borrow as mutable -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:83:10 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:75:10 | LL | let [ref x] = &[0]; - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:75:9 + | +LL | let [ref x] = &[0]; + | ^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &[ref x] = &[0]; | + -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:88:10 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:79:10 | LL | let [ref x] = &mut [0]; - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:79:9 + | +LL | let [ref x] = &mut [0]; + | ^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [ref x] = &mut [0]; | ++++ -error: this pattern relies on behavior which may change in edition 2024 - --> $DIR/ref-binding-on-inh-ref-errors.rs:93:10 +error: binding modifiers may only be written when the default binding mode is `move` + --> $DIR/ref-binding-on-inh-ref-errors.rs:83:10 | LL | let [ref mut x] = &mut [0]; - | ^^^^^^^ cannot override to bind by-reference when that is the implicit default + | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/ref-binding-on-inh-ref-errors.rs:83:9 + | +LL | let [ref mut x] = &mut [0]; + | ^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut [ref mut x] = &mut [0]; diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.fixed b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.fixed index e2b2c987610..0a22e939496 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.fixed +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.fixed @@ -23,22 +23,22 @@ fn main() { assert_type_eq(x, &mut 0u8); let &Foo(mut x) = &Foo(0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); let &mut Foo(mut x) = &mut Foo(0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); - let &Foo(ref x) = &Foo(0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + let Foo(x) = &Foo(0); + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, &0u8); let &mut Foo(ref x) = &mut Foo(0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, &0u8); @@ -55,22 +55,22 @@ fn main() { assert_type_eq(x, &0u8); let &Foo(&x) = &Foo(&0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); let &Foo(&mut x) = &Foo(&mut 0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); let &mut Foo(&x) = &mut Foo(&0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); let &mut Foo(&mut x) = &mut Foo(&mut 0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); @@ -79,25 +79,25 @@ fn main() { } if let &&&&&Some(&x) = &&&&&Some(&0u8) { - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); } if let &&&&&Some(&mut x) = &&&&&Some(&mut 0u8) { - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); } if let &&&&&mut Some(&x) = &&&&&mut Some(&0u8) { - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); } if let &mut Some(&mut Some(&mut Some(ref mut x))) = &mut Some(&mut Some(&mut Some(0u8))) { - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, &mut 0u8); } @@ -109,20 +109,20 @@ fn main() { } let &Struct { ref a, mut b, ref c } = &Struct { a: 0, b: 0, c: 0 }; - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(a, &0u32); assert_type_eq(b, 0u32); let &Struct { a: &a, ref b, ref c } = &Struct { a: &0, b: &0, c: &0 }; - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(a, 0u32); assert_type_eq(b, &&0u32); assert_type_eq(c, &&0u32); if let &Struct { a: &Some(a), b: &Some(&b), c: &Some(ref c) } = - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 &(Struct { a: &Some(&0), b: &Some(&0), c: &Some(&0) }) { @@ -135,10 +135,108 @@ fn main() { // The two patterns are the same syntactically, but because they're defined in different // editions they don't mean the same thing. &(Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => { - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` assert_type_eq(x, 0u32); assert_type_eq(y, 0u32); } _ => {} } + + let &mut [&mut &[ref a]] = &mut [&mut &[0]]; + //~^ ERROR: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + + let &[&(_)] = &[&0]; + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + + // NB: Most of the following tests are for possible future improvements to migration suggestions + + // Test removing multiple binding modifiers. + let Struct { a, b, c } = &Struct { a: 0, b: 0, c: 0 }; + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + assert_type_eq(c, &0u32); + + // Test that we don't change bindings' modes when removing binding modifiers. + let &mut Struct { ref a, ref mut b, ref mut c } = &mut Struct { a: 0, b: 0, c: 0 }; + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + assert_type_eq(b, &mut 0u32); + assert_type_eq(c, &mut 0u32); + + // Test removing multiple reference patterns of various mutabilities, plus a binding modifier. + let &mut &Struct { a: &[ref a], b: &mut [&[ref b]], ref c } = &mut &Struct { a: &[0], b: &mut [&[0]], c: 0 }; + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + assert_type_eq(b, &0u32); + assert_type_eq(c, &0u32); + + // Test that we don't change bindings' types when removing reference patterns. + let &Foo(&ref a) = &Foo(&0); + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + + // Test that we don't change bindings' modes when adding reference paterns (caught early). + let &(&a, ref b, &[ref c], &mut [&mut (ref d, &[ref e])]) = &(&0, 0, &[0], &mut [&mut (0, &[0])]); + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, 0u32); + assert_type_eq(b, &0u32); + assert_type_eq(c, &0u32); + assert_type_eq(d, &0u32); + assert_type_eq(e, &0u32); + + // Test that we don't change bindings' modes when adding reference patterns (caught late). + let &(ref a, &mut [ref b], &[mut c]) = &(0, &mut [0], &[0]); + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + assert_type_eq(b, &0u32); + assert_type_eq(c, 0u32); + + // Test featuring both additions and removals. + let &(&a, &mut (ref b, &[ref c])) = &(&0, &mut (0, &[0])); + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, 0u32); + assert_type_eq(b, &0u32); + assert_type_eq(c, &0u32); + + // Test that bindings' subpatterns' modes are updated properly. + let &[mut a @ ref b] = &[0]; + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, 0u32); + assert_type_eq(b, &0u32); + + // Test that bindings' subpatterns' modes are checked properly. + let &[ref a @ mut b] = &[0]; + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + assert_type_eq(b, 0u32); + + // Test that we respect bindings' subpatterns' types when rewriting `&ref x` to `x`. + let [&Foo(&ref a @ ref b), &Foo(&ref c @ d)] = [&Foo(&0); 2]; + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + assert_type_eq(b, &0u32); + assert_type_eq(c, &0u32); + assert_type_eq(d, 0u32); + + // Test that we respect bindings' subpatterns' modes when rewriting `&ref x` to `x`. + let [&Foo(&ref a @ [ref b]), &Foo(&ref c @ [d])] = [&Foo(&[0]); 2]; + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &[0u32]); + assert_type_eq(b, &0u32); + assert_type_eq(c, &[0u32]); + assert_type_eq(d, 0u32); } diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.rs index 098540adfa2..7a6f2269d44 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.rs +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.rs @@ -23,22 +23,22 @@ fn main() { assert_type_eq(x, &mut 0u8); let Foo(mut x) = &Foo(0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); let Foo(mut x) = &mut Foo(0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); let Foo(ref x) = &Foo(0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, &0u8); let Foo(ref x) = &mut Foo(0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, &0u8); @@ -55,22 +55,22 @@ fn main() { assert_type_eq(x, &0u8); let Foo(&x) = &Foo(&0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); let Foo(&mut x) = &Foo(&mut 0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); let Foo(&x) = &mut Foo(&0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); let Foo(&mut x) = &mut Foo(&mut 0); - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); @@ -79,25 +79,25 @@ fn main() { } if let Some(&x) = &&&&&Some(&0u8) { - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); } if let Some(&mut x) = &&&&&Some(&mut 0u8) { - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); } if let Some(&x) = &&&&&mut Some(&0u8) { - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, 0u8); } if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) { - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(x, &mut 0u8); } @@ -109,20 +109,20 @@ fn main() { } let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 }; - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(a, &0u32); assert_type_eq(b, 0u32); let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 }; - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 assert_type_eq(a, 0u32); assert_type_eq(b, &&0u32); assert_type_eq(c, &&0u32); if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } = - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 //~| WARN: this changes meaning in Rust 2024 &(Struct { a: &Some(&0), b: &Some(&0), c: &Some(&0) }) { @@ -135,10 +135,108 @@ fn main() { // The two patterns are the same syntactically, but because they're defined in different // editions they don't mean the same thing. (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => { - //~^ ERROR: this pattern relies on behavior which may change in edition 2024 + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` assert_type_eq(x, 0u32); assert_type_eq(y, 0u32); } _ => {} } + + let [&mut [ref a]] = &mut [&mut &[0]]; + //~^ ERROR: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + + let [&(_)] = &[&0]; + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + + // NB: Most of the following tests are for possible future improvements to migration suggestions + + // Test removing multiple binding modifiers. + let Struct { ref a, ref b, c } = &Struct { a: 0, b: 0, c: 0 }; + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + assert_type_eq(c, &0u32); + + // Test that we don't change bindings' modes when removing binding modifiers. + let Struct { ref a, ref mut b, c } = &mut Struct { a: 0, b: 0, c: 0 }; + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + assert_type_eq(b, &mut 0u32); + assert_type_eq(c, &mut 0u32); + + // Test removing multiple reference patterns of various mutabilities, plus a binding modifier. + let Struct { a: &[ref a], b: &mut [[b]], c } = &mut &Struct { a: &[0], b: &mut [&[0]], c: 0 }; + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + assert_type_eq(b, &0u32); + assert_type_eq(c, &0u32); + + // Test that we don't change bindings' types when removing reference patterns. + let Foo(&ref a) = &Foo(&0); + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + + // Test that we don't change bindings' modes when adding reference paterns (caught early). + let (&a, b, [c], [(d, [e])]) = &(&0, 0, &[0], &mut [&mut (0, &[0])]); + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, 0u32); + assert_type_eq(b, &0u32); + assert_type_eq(c, &0u32); + assert_type_eq(d, &0u32); + assert_type_eq(e, &0u32); + + // Test that we don't change bindings' modes when adding reference patterns (caught late). + let (a, [b], [mut c]) = &(0, &mut [0], &[0]); + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + assert_type_eq(b, &0u32); + assert_type_eq(c, 0u32); + + // Test featuring both additions and removals. + let (&a, (b, &[ref c])) = &(&0, &mut (0, &[0])); + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, 0u32); + assert_type_eq(b, &0u32); + assert_type_eq(c, &0u32); + + // Test that bindings' subpatterns' modes are updated properly. + let [mut a @ b] = &[0]; + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, 0u32); + assert_type_eq(b, &0u32); + + // Test that bindings' subpatterns' modes are checked properly. + let [a @ mut b] = &[0]; + //~^ ERROR: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + assert_type_eq(b, 0u32); + + // Test that we respect bindings' subpatterns' types when rewriting `&ref x` to `x`. + let [Foo(&ref a @ ref b), Foo(&ref c @ d)] = [&Foo(&0); 2]; + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &0u32); + assert_type_eq(b, &0u32); + assert_type_eq(c, &0u32); + assert_type_eq(d, 0u32); + + // Test that we respect bindings' subpatterns' modes when rewriting `&ref x` to `x`. + let [Foo(&ref a @ [ref b]), Foo(&ref c @ [d])] = [&Foo(&[0]); 2]; + //~^ ERROR: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + //~| WARN: this changes meaning in Rust 2024 + assert_type_eq(a, &[0u32]); + assert_type_eq(b, &0u32); + assert_type_eq(c, &[0u32]); + assert_type_eq(d, 0u32); } diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr index 83346b9dd4a..191800df07a 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/migration_lint.stderr @@ -1,11 +1,16 @@ -error: this pattern relies on behavior which may change in edition 2024 +error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:25:13 | LL | let Foo(mut x) = &Foo(0); - | ^^^ requires binding by-value, but the implicit default is by-reference + | ^^^ binding modifier not allowed under `ref` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:25:9 + | +LL | let Foo(mut x) = &Foo(0); + | ^^^^^^^^^^ this matches on type `&_` note: the lint level is defined here --> $DIR/migration_lint.rs:7:9 | @@ -16,206 +21,546 @@ help: make the implied reference pattern explicit LL | let &Foo(mut x) = &Foo(0); | + -error: this pattern relies on behavior which may change in edition 2024 +error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:30:13 | LL | let Foo(mut x) = &mut Foo(0); - | ^^^ requires binding by-value, but the implicit default is by-reference + | ^^^ binding modifier not allowed under `ref mut` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:30:9 + | +LL | let Foo(mut x) = &mut Foo(0); + | ^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut Foo(mut x) = &mut Foo(0); | ++++ -error: this pattern relies on behavior which may change in edition 2024 +error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:35:13 | LL | let Foo(ref x) = &Foo(0); - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> -help: make the implied reference pattern explicit +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:35:9 + | +LL | let Foo(ref x) = &Foo(0); + | ^^^^^^^^^^ this matches on type `&_` +help: remove the unnecessary binding modifier + | +LL - let Foo(ref x) = &Foo(0); +LL + let Foo(x) = &Foo(0); | -LL | let &Foo(ref x) = &Foo(0); - | + -error: this pattern relies on behavior which may change in edition 2024 +error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:40:13 | LL | let Foo(ref x) = &mut Foo(0); - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref mut` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:40:9 + | +LL | let Foo(ref x) = &mut Foo(0); + | ^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut Foo(ref x) = &mut Foo(0); | ++++ -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:57:13 | LL | let Foo(&x) = &Foo(&0); - | ^ cannot implicitly match against multiple layers of reference + | ^ reference pattern not allowed under `ref` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:57:9 + | +LL | let Foo(&x) = &Foo(&0); + | ^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &Foo(&x) = &Foo(&0); | + -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:62:13 | LL | let Foo(&mut x) = &Foo(&mut 0); - | ^^^^ cannot implicitly match against multiple layers of reference + | ^^^^ reference pattern not allowed under `ref` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:62:9 + | +LL | let Foo(&mut x) = &Foo(&mut 0); + | ^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | let &Foo(&mut x) = &Foo(&mut 0); | + -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:67:13 | LL | let Foo(&x) = &mut Foo(&0); - | ^ cannot implicitly match against multiple layers of reference + | ^ reference pattern not allowed under `ref mut` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:67:9 + | +LL | let Foo(&x) = &mut Foo(&0); + | ^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut Foo(&x) = &mut Foo(&0); | ++++ -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:72:13 | LL | let Foo(&mut x) = &mut Foo(&mut 0); - | ^^^^ cannot implicitly match against multiple layers of reference + | ^^^^ reference pattern not allowed under `ref mut` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:72:9 + | +LL | let Foo(&mut x) = &mut Foo(&mut 0); + | ^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference pattern explicit | LL | let &mut Foo(&mut x) = &mut Foo(&mut 0); | ++++ -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:81:17 | LL | if let Some(&x) = &&&&&Some(&0u8) { - | ^ cannot implicitly match against multiple layers of reference + | ^ reference pattern not allowed under `ref` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:81:12 + | +LL | if let Some(&x) = &&&&&Some(&0u8) { + | ^^^^^^^^ this matches on type `&_` help: make the implied reference patterns explicit | LL | if let &&&&&Some(&x) = &&&&&Some(&0u8) { | +++++ -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:87:17 | LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) { - | ^^^^ cannot implicitly match against multiple layers of reference + | ^^^^ reference pattern not allowed under `ref` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:87:12 + | +LL | if let Some(&mut x) = &&&&&Some(&mut 0u8) { + | ^^^^^^^^^^^^ this matches on type `&_` help: make the implied reference patterns explicit | LL | if let &&&&&Some(&mut x) = &&&&&Some(&mut 0u8) { | +++++ -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:93:17 | LL | if let Some(&x) = &&&&&mut Some(&0u8) { - | ^ cannot implicitly match against multiple layers of reference + | ^ reference pattern not allowed under `ref` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:93:12 + | +LL | if let Some(&x) = &&&&&mut Some(&0u8) { + | ^^^^^^^^ this matches on type `&_` help: make the implied reference patterns explicit | LL | if let &&&&&mut Some(&x) = &&&&&mut Some(&0u8) { | ++++++++ -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:99:17 | LL | if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) { - | ^^^^ cannot implicitly match against multiple layers of reference + | ^^^^ reference pattern not allowed under `ref mut` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:99:12 + | +LL | if let Some(&mut Some(Some(x))) = &mut Some(&mut Some(&mut Some(0u8))) { + | ^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&mut _` help: make the implied reference patterns and variable binding mode explicit | LL | if let &mut Some(&mut Some(&mut Some(ref mut x))) = &mut Some(&mut Some(&mut Some(0u8))) { | ++++ ++++ +++++++ -error: this pattern relies on behavior which may change in edition 2024 +error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:111:21 | LL | let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 }; - | ^^^ requires binding by-value, but the implicit default is by-reference + | ^^^ binding modifier not allowed under `ref` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:111:9 + | +LL | let Struct { a, mut b, c } = &Struct { a: 0, b: 0, c: 0 }; + | ^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern and variable binding modes explicit | LL | let &Struct { ref a, mut b, ref c } = &Struct { a: 0, b: 0, c: 0 }; | + +++ +++ -error: this pattern relies on behavior which may change in edition 2024 +error: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:117:21 | LL | let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 }; - | ^ ^^^ cannot override to bind by-reference when that is the implicit default + | ^ ^^^ binding modifier not allowed under `ref` default binding mode | | - | cannot implicitly match against multiple layers of reference + | reference pattern not allowed under `ref` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:117:9 + | +LL | let Struct { a: &a, b, ref c } = &Struct { a: &0, b: &0, c: &0 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern and variable binding mode explicit | LL | let &Struct { a: &a, ref b, ref c } = &Struct { a: &0, b: &0, c: &0 }; | + +++ -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 --> $DIR/migration_lint.rs:124:24 | LL | if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } = - | ^ ^ cannot implicitly match against multiple layers of reference + | ^ ^ reference pattern not allowed under `ref` default binding mode | | - | cannot implicitly match against multiple layers of reference + | reference pattern not allowed under `ref` default binding mode | = warning: this changes meaning in Rust 2024 = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:124:12 + | +LL | if let Struct { a: &Some(a), b: Some(&b), c: Some(c) } = + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` help: make the implied reference patterns and variable binding mode explicit | LL | if let &Struct { a: &Some(a), b: &Some(&b), c: &Some(ref c) } = | + + + +++ -error: this pattern relies on behavior which may change in edition 2024 +error: binding modifiers may only be written when the default binding mode is `move` --> $DIR/migration_lint.rs:137:15 | LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => { - | ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ default binding mode is reset within expansion + | ^^^ ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ occurs within macro expansion | | - | requires binding by-value, but the implicit default is by-reference + | binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:137:9 + | +LL | (Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` = note: this error originates in the macro `migration_lint_macros::mixed_edition_pat` (in Nightly builds, run with -Z macro-backtrace for more info) help: make the implied reference pattern explicit | LL | &(Some(mut x), migration_lint_macros::mixed_edition_pat!(y)) => { | + -error: aborting due to 16 previous errors +error: binding modifiers and reference patterns may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:145:10 + | +LL | let [&mut [ref a]] = &mut [&mut &[0]]; + | ^^^^ ^^^ binding modifier not allowed under `ref` default binding mode + | | + | reference pattern not allowed under `ref mut` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:145:15 + | +LL | let [&mut [ref a]] = &mut [&mut &[0]]; + | ^^^^^^^ this matches on type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:145:9 + | +LL | let [&mut [ref a]] = &mut [&mut &[0]]; + | ^^^^^^^^^^^^^^ this matches on type `&mut _` +help: make the implied reference patterns explicit + | +LL | let &mut [&mut &[ref a]] = &mut [&mut &[0]]; + | ++++ + + +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:150:10 + | +LL | let [&(_)] = &[&0]; + | ^ reference pattern not allowed under `ref` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:150:9 + | +LL | let [&(_)] = &[&0]; + | ^^^^^^ this matches on type `&_` +help: make the implied reference pattern explicit + | +LL | let &[&(_)] = &[&0]; + | + + +error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:157:18 + | +LL | let Struct { ref a, ref b, c } = &Struct { a: 0, b: 0, c: 0 }; + | ^^^ ^^^ binding modifier not allowed under `ref` default binding mode + | | + | binding modifier not allowed under `ref` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:157:9 + | +LL | let Struct { ref a, ref b, c } = &Struct { a: 0, b: 0, c: 0 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` +help: remove the unnecessary binding modifiers + | +LL - let Struct { ref a, ref b, c } = &Struct { a: 0, b: 0, c: 0 }; +LL + let Struct { a, b, c } = &Struct { a: 0, b: 0, c: 0 }; + | + +error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:164:18 + | +LL | let Struct { ref a, ref mut b, c } = &mut Struct { a: 0, b: 0, c: 0 }; + | ^^^ ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode + | | + | binding modifier not allowed under `ref mut` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:164:9 + | +LL | let Struct { ref a, ref mut b, c } = &mut Struct { a: 0, b: 0, c: 0 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&mut _` +help: make the implied reference pattern and variable binding mode explicit + | +LL | let &mut Struct { ref a, ref mut b, ref mut c } = &mut Struct { a: 0, b: 0, c: 0 }; + | ++++ +++++++ + +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:172:21 + | +LL | let Struct { a: &[ref a], b: &mut [[b]], c } = &mut &Struct { a: &[0], b: &mut [&[0]], c: 0 }; + | ^ ^^^^ reference pattern not allowed under `ref` default binding mode + | | + | reference pattern not allowed under `ref` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:172:9 + | +LL | let Struct { a: &[ref a], b: &mut [[b]], c } = &mut &Struct { a: &[0], b: &mut [&[0]], c: 0 }; + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` +help: make the implied reference patterns and variable binding modes explicit + | +LL | let &mut &Struct { a: &[ref a], b: &mut [&[ref b]], ref c } = &mut &Struct { a: &[0], b: &mut [&[0]], c: 0 }; + | ++++++ + +++ +++ + +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:180:13 + | +LL | let Foo(&ref a) = &Foo(&0); + | ^ reference pattern not allowed under `ref` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:180:9 + | +LL | let Foo(&ref a) = &Foo(&0); + | ^^^^^^^^^^^ this matches on type `&_` +help: make the implied reference pattern explicit + | +LL | let &Foo(&ref a) = &Foo(&0); + | + + +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:186:10 + | +LL | let (&a, b, [c], [(d, [e])]) = &(&0, 0, &[0], &mut [&mut (0, &[0])]); + | ^ reference pattern not allowed under `ref` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:186:9 + | +LL | let (&a, b, [c], [(d, [e])]) = &(&0, 0, &[0], &mut [&mut (0, &[0])]); + | ^^^^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` +help: make the implied reference patterns and variable binding modes explicit + | +LL | let &(&a, ref b, &[ref c], &mut [&mut (ref d, &[ref e])]) = &(&0, 0, &[0], &mut [&mut (0, &[0])]); + | + +++ + +++ ++++ ++++ +++ + +++ + +error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:196:19 + | +LL | let (a, [b], [mut c]) = &(0, &mut [0], &[0]); + | ^^^ binding modifier not allowed under `ref` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:196:9 + | +LL | let (a, [b], [mut c]) = &(0, &mut [0], &[0]); + | ^^^^^^^^^^^^^^^^^ this matches on type `&_` +help: make the implied reference patterns and variable binding modes explicit + | +LL | let &(ref a, &mut [ref b], &[mut c]) = &(0, &mut [0], &[0]); + | + +++ ++++ +++ + + +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:204:10 + | +LL | let (&a, (b, &[ref c])) = &(&0, &mut (0, &[0])); + | ^ ^ reference pattern not allowed under `ref` default binding mode + | | + | reference pattern not allowed under `ref` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:204:9 + | +LL | let (&a, (b, &[ref c])) = &(&0, &mut (0, &[0])); + | ^^^^^^^^^^^^^^^^^^^ this matches on type `&_` +help: make the implied reference patterns and variable binding mode explicit + | +LL | let &(&a, &mut (ref b, &[ref c])) = &(&0, &mut (0, &[0])); + | + ++++ +++ + +error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:212:10 + | +LL | let [mut a @ b] = &[0]; + | ^^^ binding modifier not allowed under `ref` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:212:9 + | +LL | let [mut a @ b] = &[0]; + | ^^^^^^^^^^^ this matches on type `&_` +help: make the implied reference pattern and variable binding mode explicit + | +LL | let &[mut a @ ref b] = &[0]; + | + +++ + +error: binding modifiers may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:219:14 + | +LL | let [a @ mut b] = &[0]; + | ^^^ binding modifier not allowed under `ref` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:219:9 + | +LL | let [a @ mut b] = &[0]; + | ^^^^^^^^^^^ this matches on type `&_` +help: make the implied reference pattern and variable binding mode explicit + | +LL | let &[ref a @ mut b] = &[0]; + | + +++ + +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:226:14 + | +LL | let [Foo(&ref a @ ref b), Foo(&ref c @ d)] = [&Foo(&0); 2]; + | ^ ^ reference pattern not allowed under `ref` default binding mode + | | + | reference pattern not allowed under `ref` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:226:31 + | +LL | let [Foo(&ref a @ ref b), Foo(&ref c @ d)] = [&Foo(&0); 2]; + | ^^^^^^^^^^^^^^^ this matches on type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:226:10 + | +LL | let [Foo(&ref a @ ref b), Foo(&ref c @ d)] = [&Foo(&0); 2]; + | ^^^^^^^^^^^^^^^^^^^ this matches on type `&_` +help: make the implied reference patterns explicit + | +LL | let [&Foo(&ref a @ ref b), &Foo(&ref c @ d)] = [&Foo(&0); 2]; + | + + + +error: reference patterns may only be written when the default binding mode is `move` in Rust 2024 + --> $DIR/migration_lint.rs:235:14 + | +LL | let [Foo(&ref a @ [ref b]), Foo(&ref c @ [d])] = [&Foo(&[0]); 2]; + | ^ ^ reference pattern not allowed under `ref` default binding mode + | | + | reference pattern not allowed under `ref` default binding mode + | + = warning: this changes meaning in Rust 2024 + = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:235:33 + | +LL | let [Foo(&ref a @ [ref b]), Foo(&ref c @ [d])] = [&Foo(&[0]); 2]; + | ^^^^^^^^^^^^^^^^^ this matches on type `&_` +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/migration_lint.rs:235:10 + | +LL | let [Foo(&ref a @ [ref b]), Foo(&ref c @ [d])] = [&Foo(&[0]); 2]; + | ^^^^^^^^^^^^^^^^^^^^^ this matches on type `&_` +help: make the implied reference patterns explicit + | +LL | let [&Foo(&ref a @ [ref b]), &Foo(&ref c @ [d])] = [&Foo(&[0]); 2]; + | + + + +error: aborting due to 29 previous errors diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.rs b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.rs index 5ba554fc6e5..4dc04d90aaf 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.rs +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.rs @@ -21,17 +21,17 @@ macro_rules! test_pat_on_type { } test_pat_on_type![(&x,): &(T,)]; //~ ERROR mismatched types -test_pat_on_type![(&x,): &(&T,)]; //~ ERROR this pattern relies on behavior which may change in edition 2024 +test_pat_on_type![(&x,): &(&T,)]; //~ ERROR reference patterns may only be written when the default binding mode is `move` test_pat_on_type![(&x,): &(&mut T,)]; //~ ERROR mismatched types test_pat_on_type![(&mut x,): &(&T,)]; //~ ERROR mismatched types -test_pat_on_type![(&mut x,): &(&mut T,)]; //~ ERROR this pattern relies on behavior which may change in edition 2024 +test_pat_on_type![(&mut x,): &(&mut T,)]; //~ ERROR reference patterns may only be written when the default binding mode is `move` test_pat_on_type![(&x,): &&mut &(T,)]; //~ ERROR mismatched types test_pat_on_type![Foo { f: (&x,) }: Foo]; //~ ERROR mismatched types test_pat_on_type![Foo { f: (&x,) }: &mut Foo]; //~ ERROR mismatched types -test_pat_on_type![Foo { f: &(x,) }: &Foo]; //~ ERROR this pattern relies on behavior which may change in edition 2024 -test_pat_on_type![(mut x,): &(T,)]; //~ ERROR this pattern relies on behavior which may change in edition 2024 -test_pat_on_type![(ref x,): &(T,)]; //~ ERROR this pattern relies on behavior which may change in edition 2024 -test_pat_on_type![(ref mut x,): &mut (T,)]; //~ ERROR this pattern relies on behavior which may change in edition 2024 +test_pat_on_type![Foo { f: &(x,) }: &Foo]; //~ ERROR reference patterns may only be written when the default binding mode is `move` +test_pat_on_type![(mut x,): &(T,)]; //~ ERROR binding modifiers may only be written when the default binding mode is `move` +test_pat_on_type![(ref x,): &(T,)]; //~ ERROR binding modifiers may only be written when the default binding mode is `move` +test_pat_on_type![(ref mut x,): &mut (T,)]; //~ ERROR binding modifiers may only be written when the default binding mode is `move` fn get<X>() -> X { unimplemented!() @@ -40,6 +40,6 @@ fn get<X>() -> X { // Make sure this works even when the underlying type is inferred. This test passes on rust stable. fn infer<X: Copy>() -> X { match &get() { - (&x,) => x, //~ ERROR this pattern relies on behavior which may change in edition 2024 + (&x,) => x, //~ ERROR reference patterns may only be written when the default binding mode is `move` } } diff --git a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr index affdca1d449..0c6b2ff3a2f 100644 --- a/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr +++ b/tests/ui/pattern/rfc-3627-match-ergonomics-2024/min_match_ergonomics_fail.stderr @@ -99,85 +99,122 @@ LL - test_pat_on_type![Foo { f: (&x,) }: &mut Foo]; LL + test_pat_on_type![Foo { f: (x,) }: &mut Foo]; | -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` --> $DIR/min_match_ergonomics_fail.rs:24:20 | LL | test_pat_on_type![(&x,): &(&T,)]; - | ^ cannot implicitly match against multiple layers of reference + | ^ reference pattern not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/min_match_ergonomics_fail.rs:24:19 + | +LL | test_pat_on_type![(&x,): &(&T,)]; + | ^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | test_pat_on_type![&(&x,): &(&T,)]; | + -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` --> $DIR/min_match_ergonomics_fail.rs:27:20 | LL | test_pat_on_type![(&mut x,): &(&mut T,)]; - | ^^^^ cannot implicitly match against multiple layers of reference + | ^^^^ reference pattern not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/min_match_ergonomics_fail.rs:27:19 + | +LL | test_pat_on_type![(&mut x,): &(&mut T,)]; + | ^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | test_pat_on_type![&(&mut x,): &(&mut T,)]; | + -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` --> $DIR/min_match_ergonomics_fail.rs:31:28 | LL | test_pat_on_type![Foo { f: &(x,) }: &Foo]; - | ^ cannot implicitly match against multiple layers of reference + | ^ reference pattern not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/min_match_ergonomics_fail.rs:31:19 + | +LL | test_pat_on_type![Foo { f: &(x,) }: &Foo]; + | ^^^^^^^^^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | test_pat_on_type![&Foo { f: &(x,) }: &Foo]; | + -error: this pattern relies on behavior which may change in edition 2024 +error: binding modifiers may only be written when the default binding mode is `move` --> $DIR/min_match_ergonomics_fail.rs:32:20 | LL | test_pat_on_type![(mut x,): &(T,)]; - | ^^^ requires binding by-value, but the implicit default is by-reference + | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/min_match_ergonomics_fail.rs:32:19 + | +LL | test_pat_on_type![(mut x,): &(T,)]; + | ^^^^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | test_pat_on_type![&(mut x,): &(T,)]; | + -error: this pattern relies on behavior which may change in edition 2024 +error: binding modifiers may only be written when the default binding mode is `move` --> $DIR/min_match_ergonomics_fail.rs:33:20 | LL | test_pat_on_type![(ref x,): &(T,)]; - | ^^^ cannot override to bind by-reference when that is the implicit default + | ^^^ binding modifier not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> -help: make the implied reference pattern explicit +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/min_match_ergonomics_fail.rs:33:19 + | +LL | test_pat_on_type![(ref x,): &(T,)]; + | ^^^^^^^^ this matches on type `&_` +help: remove the unnecessary binding modifier + | +LL - test_pat_on_type![(ref x,): &(T,)]; +LL + test_pat_on_type![(x,): &(T,)]; | -LL | test_pat_on_type![&(ref x,): &(T,)]; - | + -error: this pattern relies on behavior which may change in edition 2024 +error: binding modifiers may only be written when the default binding mode is `move` --> $DIR/min_match_ergonomics_fail.rs:34:20 | LL | test_pat_on_type![(ref mut x,): &mut (T,)]; - | ^^^^^^^ cannot override to bind by-reference when that is the implicit default + | ^^^^^^^ binding modifier not allowed under `ref mut` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> -help: make the implied reference pattern explicit +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/min_match_ergonomics_fail.rs:34:19 + | +LL | test_pat_on_type![(ref mut x,): &mut (T,)]; + | ^^^^^^^^^^^^ this matches on type `&mut _` +help: remove the unnecessary binding modifier + | +LL - test_pat_on_type![(ref mut x,): &mut (T,)]; +LL + test_pat_on_type![(x,): &mut (T,)]; | -LL | test_pat_on_type![&mut (ref mut x,): &mut (T,)]; - | ++++ -error: this pattern relies on behavior which may change in edition 2024 +error: reference patterns may only be written when the default binding mode is `move` --> $DIR/min_match_ergonomics_fail.rs:43:10 | LL | (&x,) => x, - | ^ cannot implicitly match against multiple layers of reference + | ^ reference pattern not allowed under `ref` default binding mode | = note: for more information, see <https://doc.rust-lang.org/nightly/edition-guide/rust-2024/match-ergonomics.html> +note: matching on a reference type with a non-reference pattern changes the default binding mode + --> $DIR/min_match_ergonomics_fail.rs:43:9 + | +LL | (&x,) => x, + | ^^^^^ this matches on type `&_` help: make the implied reference pattern explicit | LL | &(&x,) => x, diff --git a/tests/ui/privacy/privacy2.rs b/tests/ui/privacy/privacy2.rs index ab6d805544e..c82cd442559 100644 --- a/tests/ui/privacy/privacy2.rs +++ b/tests/ui/privacy/privacy2.rs @@ -14,16 +14,20 @@ mod bar { } pub fn foo() {} +//~^ ERROR requires `sized` lang_item fn test1() { + //~^ ERROR requires `sized` lang_item use bar::foo; //~^ ERROR unresolved import `bar::foo` [E0432] //~| no `foo` in `bar` } fn test2() { + //~^ ERROR requires `sized` lang_item use bar::glob::foo; //~^ ERROR `foo` is private } fn main() {} +//~^ ERROR requires `sized` lang_item diff --git a/tests/ui/privacy/privacy2.stderr b/tests/ui/privacy/privacy2.stderr index 46bb9823dbf..39bab67a660 100644 --- a/tests/ui/privacy/privacy2.stderr +++ b/tests/ui/privacy/privacy2.stderr @@ -1,11 +1,11 @@ error[E0432]: unresolved import `bar::foo` - --> $DIR/privacy2.rs:19:9 + --> $DIR/privacy2.rs:21:9 | LL | use bar::foo; | ^^^^^^^^ no `foo` in `bar` error[E0603]: function import `foo` is private - --> $DIR/privacy2.rs:25:20 + --> $DIR/privacy2.rs:28:20 | LL | use bar::glob::foo; | ^^^ private function import @@ -22,8 +22,40 @@ LL | pub fn foo() {} | ^^^^^^^^^^^^ you could import this directly error: requires `sized` lang_item + --> $DIR/privacy2.rs:16:14 + | +LL | pub fn foo() {} + | ^^ + +error: requires `sized` lang_item + --> $DIR/privacy2.rs:19:12 + | +LL | fn test1() { + | ____________^ +LL | | +LL | | use bar::foo; +... | +LL | | } + | |_^ + +error: requires `sized` lang_item + --> $DIR/privacy2.rs:26:12 + | +LL | fn test2() { + | ____________^ +LL | | +LL | | use bar::glob::foo; +LL | | +LL | | } + | |_^ + +error: requires `sized` lang_item + --> $DIR/privacy2.rs:32:11 + | +LL | fn main() {} + | ^^ -error: aborting due to 3 previous errors +error: aborting due to 6 previous errors Some errors have detailed explanations: E0432, E0603. For more information about an error, try `rustc --explain E0432`. diff --git a/tests/ui/privacy/privacy3.rs b/tests/ui/privacy/privacy3.rs index 6298a6bc8cf..2bb3c1b3c61 100644 --- a/tests/ui/privacy/privacy3.rs +++ b/tests/ui/privacy/privacy3.rs @@ -11,12 +11,15 @@ mod bar { mod glob { fn gpriv() {} + //~^ ERROR requires `sized` lang_item } } pub fn foo() {} +//~^ ERROR requires `sized` lang_item fn test1() { + //~^ ERROR requires `sized` lang_item use bar::gpriv; //~^ ERROR unresolved import `bar::gpriv` [E0432] //~| no `gpriv` in `bar` @@ -27,3 +30,4 @@ fn test1() { } fn main() {} +//~^ ERROR requires `sized` lang_item diff --git a/tests/ui/privacy/privacy3.stderr b/tests/ui/privacy/privacy3.stderr index df66c84751b..06a287d35ea 100644 --- a/tests/ui/privacy/privacy3.stderr +++ b/tests/ui/privacy/privacy3.stderr @@ -1,11 +1,39 @@ error[E0432]: unresolved import `bar::gpriv` - --> $DIR/privacy3.rs:20:9 + --> $DIR/privacy3.rs:23:9 | LL | use bar::gpriv; | ^^^^^^^^^^ no `gpriv` in `bar` error: requires `sized` lang_item + --> $DIR/privacy3.rs:18:14 + | +LL | pub fn foo() {} + | ^^ + +error: requires `sized` lang_item + --> $DIR/privacy3.rs:21:12 + | +LL | fn test1() { + | ____________^ +LL | | +LL | | use bar::gpriv; +... | +LL | | gpriv(); +LL | | } + | |_^ + +error: requires `sized` lang_item + --> $DIR/privacy3.rs:32:11 + | +LL | fn main() {} + | ^^ + +error: requires `sized` lang_item + --> $DIR/privacy3.rs:13:20 + | +LL | fn gpriv() {} + | ^^ -error: aborting due to 2 previous errors +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0432`. diff --git a/tests/ui/proc-macro/issue-59191-replace-root-with-fn.stderr b/tests/ui/proc-macro/issue-59191-replace-root-with-fn.stderr index 08e679a7c55..2d0c92ff297 100644 --- a/tests/ui/proc-macro/issue-59191-replace-root-with-fn.stderr +++ b/tests/ui/proc-macro/issue-59191-replace-root-with-fn.stderr @@ -1,4 +1,10 @@ error: requires `sized` lang_item + --> $DIR/issue-59191-replace-root-with-fn.rs:9:1 + | +LL | #![issue_59191::no_main] + | ^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this error originates in the attribute macro `issue_59191::no_main` (in Nightly builds, run with -Z macro-backtrace for more info) error: aborting due to 1 previous error diff --git a/tests/ui/process/win-creation-flags.rs b/tests/ui/process/win-creation-flags.rs new file mode 100644 index 00000000000..0c7c6883d68 --- /dev/null +++ b/tests/ui/process/win-creation-flags.rs @@ -0,0 +1,51 @@ +// Test that windows `creation_flags` extension to `Command` works. + +//@ run-pass +//@ only-windows +//@ needs-subprocess + +use std::env; +use std::os::windows::process::CommandExt; +use std::process::{Command, exit}; + +fn main() { + if env::args().skip(1).any(|s| s == "--child") { + child(); + } else { + parent(); + } +} + +fn parent() { + let exe = env::current_exe().unwrap(); + + // Use the DETACH_PROCESS to create a subprocess that isn't attached to the console. + // The subprocess's exit status will be 0 if it's detached. + let status = Command::new(&exe) + .arg("--child") + .creation_flags(DETACH_PROCESS) + .spawn() + .unwrap() + .wait() + .unwrap(); + assert_eq!(status.code(), Some(0)); + + // Try without DETACH_PROCESS to ensure this test works. + let status = Command::new(&exe).arg("--child").spawn().unwrap().wait().unwrap(); + assert_eq!(status.code(), Some(1)); +} + +// exits with 1 if the console is attached or 0 otherwise +fn child() { + // Get the attached console's code page. + // This will fail (return 0) if no console is attached. + let has_console = GetConsoleCP() != 0; + exit(has_console as i32); +} + +// Windows API definitions. +const DETACH_PROCESS: u32 = 0x00000008; +#[link(name = "kernel32")] +unsafe extern "system" { + safe fn GetConsoleCP() -> u32; +} diff --git a/tests/ui/process/win-proc-thread-attributes.rs b/tests/ui/process/win-proc-thread-attributes.rs new file mode 100644 index 00000000000..91bb0b17e95 --- /dev/null +++ b/tests/ui/process/win-proc-thread-attributes.rs @@ -0,0 +1,118 @@ +// Tests proc thread attributes by spawning a process with a custom parent process, +// then comparing the parent process ID with the expected parent process ID. + +//@ run-pass +//@ only-windows +//@ needs-subprocess +//@ edition: 2021 + +#![feature(windows_process_extensions_raw_attribute)] + +use std::os::windows::io::AsRawHandle; +use std::os::windows::process::{CommandExt, ProcThreadAttributeList}; +use std::process::{Child, Command}; +use std::{env, mem, ptr, thread, time}; + +// Make a best effort to ensure child processes always exit. +struct ProcessDropGuard(Child); +impl Drop for ProcessDropGuard { + fn drop(&mut self) { + let _ = self.0.kill(); + } +} + +fn main() { + if env::args().skip(1).any(|s| s == "--child") { + child(); + } else { + parent(); + } +} + +fn parent() { + let exe = env::current_exe().unwrap(); + + let (fake_parent_id, child_parent_id) = { + // Create a process to be our fake parent process. + let fake_parent = Command::new(&exe).arg("--child").spawn().unwrap(); + let fake_parent = ProcessDropGuard(fake_parent); + let parent_handle = fake_parent.0.as_raw_handle(); + + // Create another process with the parent process set to the fake. + let mut attribute_list = ProcThreadAttributeList::build() + .attribute(PROC_THREAD_ATTRIBUTE_PARENT_PROCESS, &parent_handle) + .finish() + .unwrap(); + let child = + Command::new(&exe).arg("--child").spawn_with_attributes(&mut attribute_list).unwrap(); + let child = ProcessDropGuard(child); + + // Return the fake's process id and the child's parent's id. + (process_info(&fake_parent.0).process_id(), process_info(&child.0).parent_id()) + }; + + assert_eq!(fake_parent_id, child_parent_id); +} + +// A process that stays running until killed. +fn child() { + // Don't wait forever if something goes wrong. + thread::sleep(time::Duration::from_secs(60)); +} + +fn process_info(child: &Child) -> PROCESS_BASIC_INFORMATION { + unsafe { + let mut info: PROCESS_BASIC_INFORMATION = mem::zeroed(); + let result = NtQueryInformationProcess( + child.as_raw_handle(), + ProcessBasicInformation, + ptr::from_mut(&mut info).cast(), + mem::size_of_val(&info).try_into().unwrap(), + ptr::null_mut(), + ); + assert_eq!(result, 0); + info + } +} + +// Windows API +mod winapi { + #![allow(nonstandard_style)] + use std::ffi::c_void; + + pub type HANDLE = *mut c_void; + type NTSTATUS = i32; + type PROCESSINFOCLASS = i32; + + pub const ProcessBasicInformation: i32 = 0; + pub const PROC_THREAD_ATTRIBUTE_PARENT_PROCESS: usize = 0x00020000; + #[repr(C)] + pub struct PROCESS_BASIC_INFORMATION { + pub ExitStatus: NTSTATUS, + pub PebBaseAddress: *mut (), + pub AffinityMask: usize, + pub BasePriority: i32, + pub UniqueProcessId: usize, + pub InheritedFromUniqueProcessId: usize, + } + impl PROCESS_BASIC_INFORMATION { + pub fn parent_id(&self) -> usize { + self.InheritedFromUniqueProcessId + } + pub fn process_id(&self) -> usize { + self.UniqueProcessId + } + } + + #[link(name = "ntdll")] + extern "system" { + pub fn NtQueryInformationProcess( + ProcessHandle: HANDLE, + ProcessInformationClass: PROCESSINFOCLASS, + ProcessInformation: *mut c_void, + ProcessInformationLength: u32, + ReturnLength: *mut u32, + ) -> NTSTATUS; + } +} +use winapi::*; diff --git a/tests/ui/range/issue-54505-no-literals.stderr b/tests/ui/range/issue-54505-no-literals.stderr index 5894bb6ba55..c6d4384bcd3 100644 --- a/tests/ui/range/issue-54505-no-literals.stderr +++ b/tests/ui/range/issue-54505-no-literals.stderr @@ -47,7 +47,7 @@ LL | take_range(std::ops::RangeFrom { start: 1 }); | arguments to this function are incorrect | = note: expected reference `&_` - found struct `RangeFrom<{integer}>` + found struct `std::ops::RangeFrom<{integer}>` note: function defined here --> $DIR/issue-54505-no-literals.rs:12:4 | @@ -67,7 +67,7 @@ LL | take_range(::std::ops::RangeFrom { start: 1 }); | arguments to this function are incorrect | = note: expected reference `&_` - found struct `RangeFrom<{integer}>` + found struct `std::ops::RangeFrom<{integer}>` note: function defined here --> $DIR/issue-54505-no-literals.rs:12:4 | @@ -127,7 +127,7 @@ LL | take_range(std::ops::RangeInclusive::new(0, 1)); | arguments to this function are incorrect | = note: expected reference `&_` - found struct `RangeInclusive<{integer}>` + found struct `std::ops::RangeInclusive<{integer}>` note: function defined here --> $DIR/issue-54505-no-literals.rs:12:4 | @@ -147,7 +147,7 @@ LL | take_range(::std::ops::RangeInclusive::new(0, 1)); | arguments to this function are incorrect | = note: expected reference `&_` - found struct `RangeInclusive<{integer}>` + found struct `std::ops::RangeInclusive<{integer}>` note: function defined here --> $DIR/issue-54505-no-literals.rs:12:4 | diff --git a/tests/ui/range/issue-54505.stderr b/tests/ui/range/issue-54505.stderr index 291e097e865..8b669b2910f 100644 --- a/tests/ui/range/issue-54505.stderr +++ b/tests/ui/range/issue-54505.stderr @@ -27,7 +27,7 @@ LL | take_range(1..); | arguments to this function are incorrect | = note: expected reference `&_` - found struct `RangeFrom<{integer}>` + found struct `std::ops::RangeFrom<{integer}>` note: function defined here --> $DIR/issue-54505.rs:10:4 | @@ -72,7 +72,7 @@ LL | take_range(0..=1); | arguments to this function are incorrect | = note: expected reference `&_` - found struct `RangeInclusive<{integer}>` + found struct `std::ops::RangeInclusive<{integer}>` note: function defined here --> $DIR/issue-54505.rs:10:4 | diff --git a/tests/ui/range/range-1.stderr b/tests/ui/range/range-1.stderr index f77601bc43c..37669dd3f47 100644 --- a/tests/ui/range/range-1.stderr +++ b/tests/ui/range/range-1.stderr @@ -30,7 +30,7 @@ LL | let range = *arr..; | ^^^^ doesn't have a size known at compile-time | = help: the trait `Sized` is not implemented for `[{integer}]` -note: required by an implicit `Sized` bound in `RangeFrom` +note: required by an implicit `Sized` bound in `std::ops::RangeFrom` --> $SRC_DIR/core/src/ops/range.rs:LL:COL error: aborting due to 3 previous errors diff --git a/tests/ui/repr/attr-usage-repr.rs b/tests/ui/repr/attr-usage-repr.rs index dc0d4f5be2e..d8515a12e05 100644 --- a/tests/ui/repr/attr-usage-repr.rs +++ b/tests/ui/repr/attr-usage-repr.rs @@ -16,18 +16,39 @@ struct SSimd([f64; 2]); struct SInt(f64, f64); #[repr(C)] -enum EExtern { A, B } +enum EExtern { + A, + B, +} #[repr(align(8))] -enum EAlign { A, B } +enum EAlign { + A, + B, +} #[repr(packed)] //~ ERROR: attribute should be applied to a struct -enum EPacked { A, B } +enum EPacked { + A, + B, +} #[repr(simd)] //~ ERROR: attribute should be applied to a struct -enum ESimd { A, B } +enum ESimd { + A, + B, +} #[repr(i8)] -enum EInt { A, B } +enum EInt { + A, + B, +} + +#[repr()] //~ attribute should be applied to a struct, enum, function, associated function, or union [E0517] +type SirThisIsAType = i32; + +#[repr()] +struct EmptyReprArgumentList(i32); fn main() {} diff --git a/tests/ui/repr/attr-usage-repr.stderr b/tests/ui/repr/attr-usage-repr.stderr index 42f65625a46..a25e68c483f 100644 --- a/tests/ui/repr/attr-usage-repr.stderr +++ b/tests/ui/repr/attr-usage-repr.stderr @@ -15,21 +15,35 @@ LL | struct SInt(f64, f64); | ---------------------- not an enum error[E0517]: attribute should be applied to a struct or union - --> $DIR/attr-usage-repr.rs:24:8 + --> $DIR/attr-usage-repr.rs:30:8 | -LL | #[repr(packed)] - | ^^^^^^ -LL | enum EPacked { A, B } - | --------------------- not a struct or union +LL | #[repr(packed)] + | ^^^^^^ +LL | / enum EPacked { +LL | | A, +LL | | B, +LL | | } + | |_- not a struct or union error[E0517]: attribute should be applied to a struct - --> $DIR/attr-usage-repr.rs:27:8 + --> $DIR/attr-usage-repr.rs:36:8 | -LL | #[repr(simd)] - | ^^^^ -LL | enum ESimd { A, B } - | ------------------- not a struct +LL | #[repr(simd)] + | ^^^^ +LL | / enum ESimd { +LL | | A, +LL | | B, +LL | | } + | |_- not a struct -error: aborting due to 4 previous errors +error[E0517]: attribute should be applied to a struct, enum, function, associated function, or union + --> $DIR/attr-usage-repr.rs:48:1 + | +LL | #[repr()] + | ^^^^^^^^^ +LL | type SirThisIsAType = i32; + | -------------------------- not a struct, enum, function, associated function, or union + +error: aborting due to 5 previous errors For more information about this error, try `rustc --explain E0517`. diff --git a/tests/ui/sanitizer/cfi/supertraits.rs b/tests/ui/sanitizer/cfi/supertraits.rs index 4bb6177577f..f80b3169188 100644 --- a/tests/ui/sanitizer/cfi/supertraits.rs +++ b/tests/ui/sanitizer/cfi/supertraits.rs @@ -1,4 +1,3 @@ -#![feature(trait_upcasting)] // Check that super-traits are callable. //@ revisions: cfi kcfi diff --git a/tests/ui/self/arbitrary_self_type_infinite_recursion.rs b/tests/ui/self/arbitrary_self_type_infinite_recursion.rs new file mode 100644 index 00000000000..6fbf35c0b86 --- /dev/null +++ b/tests/ui/self/arbitrary_self_type_infinite_recursion.rs @@ -0,0 +1,24 @@ +#![feature(arbitrary_self_types)] + +struct MySmartPtr<T>(T); + +impl<T> core::ops::Receiver for MySmartPtr<T> { + type Target = MySmartPtr<T>; +} + +struct Content; + +impl Content { + fn method(self: MySmartPtr<Self>) { // note self type + //~^ reached the recursion limit + //~| reached the recursion limit + //~| invalid `self` parameter type + } +} + +fn main() { + let p = MySmartPtr(Content); + p.method(); + //~^ reached the recursion limit + //~| no method named `method` +} diff --git a/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr b/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr new file mode 100644 index 00000000000..5e652efb364 --- /dev/null +++ b/tests/ui/self/arbitrary_self_type_infinite_recursion.stderr @@ -0,0 +1,47 @@ +error[E0055]: reached the recursion limit while auto-dereferencing `MySmartPtr<Content>` + --> $DIR/arbitrary_self_type_infinite_recursion.rs:12:19 + | +LL | fn method(self: MySmartPtr<Self>) { // note self type + | ^^^^^^^^^^^^^^^^ deref recursion limit reached + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`arbitrary_self_type_infinite_recursion`) + +error[E0055]: reached the recursion limit while auto-dereferencing `MySmartPtr<Content>` + --> $DIR/arbitrary_self_type_infinite_recursion.rs:12:19 + | +LL | fn method(self: MySmartPtr<Self>) { // note self type + | ^^^^^^^^^^^^^^^^ deref recursion limit reached + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`arbitrary_self_type_infinite_recursion`) + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error[E0307]: invalid `self` parameter type: `MySmartPtr<Content>` + --> $DIR/arbitrary_self_type_infinite_recursion.rs:12:19 + | +LL | fn method(self: MySmartPtr<Self>) { // note self type + | ^^^^^^^^^^^^^^^^ + | + = note: type of `self` must be `Self` or some type implementing `Receiver` + = help: consider changing to `self`, `&self`, `&mut self`, or a type implementing `Receiver` such as `self: Box<Self>`, `self: Rc<Self>`, or `self: Arc<Self>` + +error[E0055]: reached the recursion limit while auto-dereferencing `MySmartPtr<Content>` + --> $DIR/arbitrary_self_type_infinite_recursion.rs:21:5 + | +LL | p.method(); + | ^^^^^^ deref recursion limit reached + | + = help: consider increasing the recursion limit by adding a `#![recursion_limit = "256"]` attribute to your crate (`arbitrary_self_type_infinite_recursion`) + +error[E0599]: no method named `method` found for struct `MySmartPtr` in the current scope + --> $DIR/arbitrary_self_type_infinite_recursion.rs:21:5 + | +LL | struct MySmartPtr<T>(T); + | -------------------- method `method` not found for this struct +... +LL | p.method(); + | ^^^^^^ method not found in `MySmartPtr<Content>` + +error: aborting due to 5 previous errors + +Some errors have detailed explanations: E0055, E0307, E0599. +For more information about an error, try `rustc --explain E0055`. diff --git a/tests/ui/self/arbitrary_self_types_dispatch_to_vtable.rs b/tests/ui/self/arbitrary_self_types_dispatch_to_vtable.rs new file mode 100644 index 00000000000..f9e346ea11e --- /dev/null +++ b/tests/ui/self/arbitrary_self_types_dispatch_to_vtable.rs @@ -0,0 +1,33 @@ +//@ check-pass + +#![feature(derive_coerce_pointee)] +#![feature(arbitrary_self_types)] + +use std::marker::CoercePointee; +use std::ops::Receiver; + +// `CoercePointee` isn't needed here, it's just a simpler +// (and more conceptual) way of deriving `DispatchFromDyn`. +// You could think of `MyDispatcher` as a smart pointer +// that just doesn't deref to its target type. +#[derive(CoercePointee)] +#[repr(transparent)] +struct MyDispatcher<T: ?Sized>(*const T); + +impl<T: ?Sized> Receiver for MyDispatcher<T> { + type Target = T; +} +struct Test; + +trait Trait { + fn test(self: MyDispatcher<Self>); +} + +impl Trait for Test { + fn test(self: MyDispatcher<Self>) { + todo!() + } +} +fn main() { + MyDispatcher::<dyn Trait>(core::ptr::null_mut::<Test>()).test(); +} diff --git a/tests/ui/self/dispatch-from-dyn-layout-2.rs b/tests/ui/self/dispatch-from-dyn-layout-2.rs new file mode 100644 index 00000000000..cd52f060dc8 --- /dev/null +++ b/tests/ui/self/dispatch-from-dyn-layout-2.rs @@ -0,0 +1,16 @@ +//@ check-pass +// Regression test for #90110. + +// Make sure that object safety checking doesn't freak out when +// we have impossible-to-satisfy `Sized` predicates. + +trait Parser +where + for<'a> (dyn Parser + 'a): Sized, +{ + fn parse_line(&self); +} + +fn foo(_: &dyn Parser) {} + +fn main() {} diff --git a/tests/ui/self/dispatch-from-dyn-layout-3.rs b/tests/ui/self/dispatch-from-dyn-layout-3.rs new file mode 100644 index 00000000000..6878a4f4ac2 --- /dev/null +++ b/tests/ui/self/dispatch-from-dyn-layout-3.rs @@ -0,0 +1,19 @@ +//@ check-pass + +// Make sure that object safety checking doesn't freak out when +// we have impossible-to-satisfy `DispatchFromDyn` predicates. + +#![feature(dispatch_from_dyn)] +#![feature(arbitrary_self_types)] + +use std::ops::Deref; +use std::ops::DispatchFromDyn; + +trait Trait<T: Deref<Target = Self>> +where + for<'a> &'a T: DispatchFromDyn<&'a T>, +{ + fn foo(self: &T) -> Box<dyn Trait<T>>; +} + +fn main() {} diff --git a/tests/crashes/57276.rs b/tests/ui/self/dispatch-from-dyn-layout.rs index f70be4fba6d..468dc89a73e 100644 --- a/tests/crashes/57276.rs +++ b/tests/ui/self/dispatch-from-dyn-layout.rs @@ -1,4 +1,8 @@ -//@ known-bug: #57276 +//@ check-pass +// Regression test for #57276. + +// Make sure that object safety checking doesn't freak out when +// we have impossible-to-satisfy `DispatchFromDyn` predicates. #![feature(arbitrary_self_types, dispatch_from_dyn)] diff --git a/tests/ui/simd/array-trait.rs b/tests/ui/simd/array-trait.rs index 67583bf8208..32cbf01428c 100644 --- a/tests/ui/simd/array-trait.rs +++ b/tests/ui/simd/array-trait.rs @@ -24,10 +24,12 @@ pub struct T<S: Simd>([S::Lane; S::SIZE]); //~| ERROR SIMD vector element type should be a primitive scalar //~| ERROR unconstrained generic constant -extern "rust-intrinsic" { - fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; - fn simd_extract<T, E>(x: T, idx: u32) -> E; -} +#[rustc_intrinsic] +unsafe fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; + +#[rustc_intrinsic] +unsafe fn simd_extract<T, E>(x: T, idx: u32) -> E; + pub fn main() { let mut t = T::<i32x4>([0; 4]); diff --git a/tests/ui/simd/array-type.rs b/tests/ui/simd/array-type.rs index 8ca53b1a453..d1de7004416 100644 --- a/tests/ui/simd/array-type.rs +++ b/tests/ui/simd/array-type.rs @@ -12,10 +12,12 @@ struct S([i32; 4]); #[derive(Copy, Clone)] struct T<const N: usize>([i32; N]); -extern "rust-intrinsic" { - fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; - fn simd_extract<T, E>(x: T, idx: u32) -> E; -} +#[rustc_intrinsic] +unsafe fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; + +#[rustc_intrinsic] +unsafe fn simd_extract<T, E>(x: T, idx: u32) -> E; + pub fn main() { let mut s = S([0; 4]); diff --git a/tests/ui/simd/generics.rs b/tests/ui/simd/generics.rs index f96a7cd75e9..453ed86c14a 100644 --- a/tests/ui/simd/generics.rs +++ b/tests/ui/simd/generics.rs @@ -21,9 +21,8 @@ struct B<T>([T; 4]); struct C<T, const N: usize>([T; N]); -extern "rust-intrinsic" { - fn simd_add<T>(x: T, y: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_add<T>(x: T, y: T) -> T; fn add<T: ops::Add<Output=T>>(lhs: T, rhs: T) -> T { lhs + rhs diff --git a/tests/ui/simd/intrinsic/float-math-pass.rs b/tests/ui/simd/intrinsic/float-math-pass.rs index 24b9941133e..74cb51a0606 100644 --- a/tests/ui/simd/intrinsic/float-math-pass.rs +++ b/tests/ui/simd/intrinsic/float-math-pass.rs @@ -15,27 +15,59 @@ #[derive(Copy, Clone, PartialEq, Debug)] struct f32x4(pub [f32; 4]); -extern "rust-intrinsic" { - fn simd_fsqrt<T>(x: T) -> T; - fn simd_fabs<T>(x: T) -> T; - fn simd_fsin<T>(x: T) -> T; - fn simd_fcos<T>(x: T) -> T; - fn simd_fexp<T>(x: T) -> T; - fn simd_fexp2<T>(x: T) -> T; - fn simd_fma<T>(x: T, y: T, z: T) -> T; - fn simd_relaxed_fma<T>(x: T, y: T, z: T) -> T; - fn simd_flog<T>(x: T) -> T; - fn simd_flog10<T>(x: T) -> T; - fn simd_flog2<T>(x: T) -> T; - fn simd_fpow<T>(x: T, y: T) -> T; - fn simd_fpowi<T>(x: T, y: i32) -> T; - - // rounding functions - fn simd_ceil<T>(x: T) -> T; - fn simd_floor<T>(x: T) -> T; - fn simd_round<T>(x: T) -> T; - fn simd_trunc<T>(x: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_fsqrt<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fabs<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fsin<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fcos<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fexp<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fexp2<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fma<T>(x: T, y: T, z: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_relaxed_fma<T>(x: T, y: T, z: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_flog<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_flog10<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_flog2<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fpow<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_fpowi<T>(x: T, y: i32) -> T; + + +// rounding functions +#[rustc_intrinsic] +unsafe fn simd_ceil<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_floor<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_round<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_trunc<T>(x: T) -> T; + macro_rules! assert_approx_eq_f32 { ($a:expr, $b:expr) => ({ diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs index 663bcdf1981..0fcff8584c8 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.rs @@ -14,25 +14,54 @@ pub struct u32x4(pub [u32; 4]); #[derive(Copy, Clone)] pub struct f32x4(pub [f32; 4]); -extern "rust-intrinsic" { - fn simd_add<T>(x: T, y: T) -> T; - fn simd_sub<T>(x: T, y: T) -> T; - fn simd_mul<T>(x: T, y: T) -> T; - fn simd_div<T>(x: T, y: T) -> T; - fn simd_rem<T>(x: T, y: T) -> T; - fn simd_shl<T>(x: T, y: T) -> T; - fn simd_shr<T>(x: T, y: T) -> T; - fn simd_and<T>(x: T, y: T) -> T; - fn simd_or<T>(x: T, y: T) -> T; - fn simd_xor<T>(x: T, y: T) -> T; - - fn simd_neg<T>(x: T) -> T; - fn simd_bswap<T>(x: T) -> T; - fn simd_bitreverse<T>(x: T) -> T; - fn simd_ctlz<T>(x: T) -> T; - fn simd_ctpop<T>(x: T) -> T; - fn simd_cttz<T>(x: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_add<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_sub<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_mul<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_div<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_rem<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_shl<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_shr<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_and<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_or<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_xor<T>(x: T, y: T) -> T; + + +#[rustc_intrinsic] +unsafe fn simd_neg<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_bswap<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_bitreverse<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_ctlz<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_ctpop<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_cttz<T>(x: T) -> T; fn main() { let x = i32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr index 6f5f86d7d37..e67de2fe903 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr +++ b/tests/ui/simd/intrinsic/generic-arithmetic-2.stderr @@ -1,143 +1,143 @@ error[E0511]: invalid monomorphization of `simd_add` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:81:9 + --> $DIR/generic-arithmetic-2.rs:110:9 | LL | simd_add(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_sub` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:83:9 + --> $DIR/generic-arithmetic-2.rs:112:9 | LL | simd_sub(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_mul` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:85:9 + --> $DIR/generic-arithmetic-2.rs:114:9 | LL | simd_mul(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_div` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:87:9 + --> $DIR/generic-arithmetic-2.rs:116:9 | LL | simd_div(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:89:9 + --> $DIR/generic-arithmetic-2.rs:118:9 | LL | simd_shl(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:91:9 + --> $DIR/generic-arithmetic-2.rs:120:9 | LL | simd_shr(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_and` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:93:9 + --> $DIR/generic-arithmetic-2.rs:122:9 | LL | simd_and(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:95:9 + --> $DIR/generic-arithmetic-2.rs:124:9 | LL | simd_or(0, 0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:97:9 + --> $DIR/generic-arithmetic-2.rs:126:9 | LL | simd_xor(0, 0); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_neg` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:100:9 + --> $DIR/generic-arithmetic-2.rs:129:9 | LL | simd_neg(0); | ^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:102:9 + --> $DIR/generic-arithmetic-2.rs:131:9 | LL | simd_bswap(0); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:104:9 + --> $DIR/generic-arithmetic-2.rs:133:9 | LL | simd_bitreverse(0); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:106:9 + --> $DIR/generic-arithmetic-2.rs:135:9 | LL | simd_ctlz(0); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-arithmetic-2.rs:108:9 + --> $DIR/generic-arithmetic-2.rs:137:9 | LL | simd_cttz(0); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shl` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:111:9 + --> $DIR/generic-arithmetic-2.rs:140:9 | LL | simd_shl(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shr` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:113:9 + --> $DIR/generic-arithmetic-2.rs:142:9 | LL | simd_shr(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_and` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:115:9 + --> $DIR/generic-arithmetic-2.rs:144:9 | LL | simd_and(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_or` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:117:9 + --> $DIR/generic-arithmetic-2.rs:146:9 | LL | simd_or(z, z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_xor` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:119:9 + --> $DIR/generic-arithmetic-2.rs:148:9 | LL | simd_xor(z, z); | ^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bswap` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:121:9 + --> $DIR/generic-arithmetic-2.rs:150:9 | LL | simd_bswap(z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitreverse` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:123:9 + --> $DIR/generic-arithmetic-2.rs:152:9 | LL | simd_bitreverse(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctlz` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:125:9 + --> $DIR/generic-arithmetic-2.rs:154:9 | LL | simd_ctlz(z); | ^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ctpop` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:127:9 + --> $DIR/generic-arithmetic-2.rs:156:9 | LL | simd_ctpop(z); | ^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cttz` intrinsic: unsupported operation on `f32x4` with element `f32` - --> $DIR/generic-arithmetic-2.rs:129:9 + --> $DIR/generic-arithmetic-2.rs:158:9 | LL | simd_cttz(z); | ^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs index e4eb2a9da27..4a18c0164e4 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-pass.rs @@ -23,25 +23,54 @@ macro_rules! all_eq { }}; } -extern "rust-intrinsic" { - fn simd_add<T>(x: T, y: T) -> T; - fn simd_sub<T>(x: T, y: T) -> T; - fn simd_mul<T>(x: T, y: T) -> T; - fn simd_div<T>(x: T, y: T) -> T; - fn simd_rem<T>(x: T, y: T) -> T; - fn simd_shl<T>(x: T, y: T) -> T; - fn simd_shr<T>(x: T, y: T) -> T; - fn simd_and<T>(x: T, y: T) -> T; - fn simd_or<T>(x: T, y: T) -> T; - fn simd_xor<T>(x: T, y: T) -> T; - - fn simd_neg<T>(x: T) -> T; - fn simd_bswap<T>(x: T) -> T; - fn simd_bitreverse<T>(x: T) -> T; - fn simd_ctlz<T>(x: T) -> T; - fn simd_ctpop<T>(x: T) -> T; - fn simd_cttz<T>(x: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_add<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_sub<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_mul<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_div<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_rem<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_shl<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_shr<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_and<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_or<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_xor<T>(x: T, y: T) -> T; + + +#[rustc_intrinsic] +unsafe fn simd_neg<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_bswap<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_bitreverse<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_ctlz<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_ctpop<T>(x: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_cttz<T>(x: T) -> T; fn main() { let x1 = i32x4([1, 2, 3, 4]); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs index ec6ac78df1a..85464402d6a 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.rs @@ -14,10 +14,12 @@ pub struct x4<T>(pub [T; 4]); #[derive(Copy, Clone)] pub struct f32x4(pub [f32; 4]); -extern "rust-intrinsic" { - fn simd_saturating_add<T>(x: T, y: T) -> T; - fn simd_saturating_sub<T>(x: T, y: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_saturating_add<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_saturating_sub<T>(x: T, y: T) -> T; + fn main() { let x = i32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr index f349cb56560..cf275db7e43 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr +++ b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-2.stderr @@ -1,11 +1,11 @@ error[E0511]: invalid monomorphization of `simd_saturating_add` intrinsic: expected element type `f32` of vector type `f32x4` to be a signed or unsigned integer type - --> $DIR/generic-arithmetic-saturating-2.rs:33:9 + --> $DIR/generic-arithmetic-saturating-2.rs:35:9 | LL | simd_saturating_add(z, z); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_saturating_sub` intrinsic: expected element type `f32` of vector type `f32x4` to be a signed or unsigned integer type - --> $DIR/generic-arithmetic-saturating-2.rs:35:9 + --> $DIR/generic-arithmetic-saturating-2.rs:37:9 | LL | simd_saturating_sub(z, z); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs index 57bda5c2d62..5fe65257d15 100644 --- a/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs +++ b/tests/ui/simd/intrinsic/generic-arithmetic-saturating-pass.rs @@ -12,10 +12,12 @@ struct u32x4(pub [u32; 4]); #[derive(Copy, Clone)] struct I32<const N: usize>([i32; N]); -extern "rust-intrinsic" { - fn simd_saturating_add<T>(x: T, y: T) -> T; - fn simd_saturating_sub<T>(x: T, y: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_saturating_add<T>(x: T, y: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_saturating_sub<T>(x: T, y: T) -> T; + fn main() { // unsigned diff --git a/tests/ui/simd/intrinsic/generic-as.rs b/tests/ui/simd/intrinsic/generic-as.rs index e97bf12c144..124ca56bc88 100644 --- a/tests/ui/simd/intrinsic/generic-as.rs +++ b/tests/ui/simd/intrinsic/generic-as.rs @@ -2,9 +2,9 @@ #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_as<T, U>(x: T) -> U; -} + +#[rustc_intrinsic] +unsafe fn simd_as<T, U>(x: T) -> U; #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/intrinsic/generic-bitmask-pass.rs b/tests/ui/simd/intrinsic/generic-bitmask-pass.rs index db10020bd46..08526991fbe 100644 --- a/tests/ui/simd/intrinsic/generic-bitmask-pass.rs +++ b/tests/ui/simd/intrinsic/generic-bitmask-pass.rs @@ -21,9 +21,8 @@ struct u8x4(pub [u8; 4]); #[derive(Copy, Clone, PartialEq, Debug)] struct Tx4<T>(pub [T; 4]); -extern "rust-intrinsic" { - fn simd_bitmask<T, U>(x: T) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_bitmask<T, U>(x: T) -> U; fn main() { let z = u32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-bitmask.rs b/tests/ui/simd/intrinsic/generic-bitmask.rs index 29b9279c370..49589d22bbf 100644 --- a/tests/ui/simd/intrinsic/generic-bitmask.rs +++ b/tests/ui/simd/intrinsic/generic-bitmask.rs @@ -30,9 +30,8 @@ struct u8x32([u8; 32]); #[derive(Copy, Clone)] struct u8x64([u8; 64]); -extern "rust-intrinsic" { - fn simd_bitmask<T, U>(x: T) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_bitmask<T, U>(x: T) -> U; fn main() { let m2 = u32x2([0; 2]); diff --git a/tests/ui/simd/intrinsic/generic-bitmask.stderr b/tests/ui/simd/intrinsic/generic-bitmask.stderr index 0de3f8eead8..c217bb2d8f1 100644 --- a/tests/ui/simd/intrinsic/generic-bitmask.stderr +++ b/tests/ui/simd/intrinsic/generic-bitmask.stderr @@ -1,29 +1,29 @@ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u16`, expected `u8` or `[u8; 1]` - --> $DIR/generic-bitmask.rs:53:22 + --> $DIR/generic-bitmask.rs:52:22 | LL | let _: u16 = simd_bitmask(m2); | ^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u16`, expected `u8` or `[u8; 1]` - --> $DIR/generic-bitmask.rs:56:22 + --> $DIR/generic-bitmask.rs:55:22 | LL | let _: u16 = simd_bitmask(m8); | ^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u32`, expected `u16` or `[u8; 2]` - --> $DIR/generic-bitmask.rs:59:22 + --> $DIR/generic-bitmask.rs:58:22 | LL | let _: u32 = simd_bitmask(m16); | ^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u64`, expected `u32` or `[u8; 4]` - --> $DIR/generic-bitmask.rs:62:22 + --> $DIR/generic-bitmask.rs:61:22 | LL | let _: u64 = simd_bitmask(m32); | ^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_bitmask` intrinsic: cannot return `u128`, expected `u64` or `[u8; 8]` - --> $DIR/generic-bitmask.rs:65:23 + --> $DIR/generic-bitmask.rs:64:23 | LL | let _: u128 = simd_bitmask(m64); | ^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-bswap-byte.rs b/tests/ui/simd/intrinsic/generic-bswap-byte.rs index f1702538165..4521573636c 100644 --- a/tests/ui/simd/intrinsic/generic-bswap-byte.rs +++ b/tests/ui/simd/intrinsic/generic-bswap-byte.rs @@ -10,9 +10,8 @@ struct i8x4([i8; 4]); #[derive(Copy, Clone)] struct u8x4([u8; 4]); -extern "rust-intrinsic" { - fn simd_bswap<T>(x: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_bswap<T>(x: T) -> T; fn main() { unsafe { diff --git a/tests/ui/simd/intrinsic/generic-cast-pass.rs b/tests/ui/simd/intrinsic/generic-cast-pass.rs index e0319a6461a..2155d845864 100644 --- a/tests/ui/simd/intrinsic/generic-cast-pass.rs +++ b/tests/ui/simd/intrinsic/generic-cast-pass.rs @@ -3,9 +3,9 @@ #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_cast<T, U>(x: T) -> U; -} + +#[rustc_intrinsic] +unsafe fn simd_cast<T, U>(x: T) -> U; use std::cmp::{max, min}; diff --git a/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs b/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs index 1c09a9fbf3b..9f28898654f 100644 --- a/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs +++ b/tests/ui/simd/intrinsic/generic-cast-pointer-width.rs @@ -1,9 +1,8 @@ //@ run-pass #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_cast<T, U>(x: T) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_cast<T, U>(x: T) -> U; #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/intrinsic/generic-cast.rs b/tests/ui/simd/intrinsic/generic-cast.rs index 33978a2f739..7f398804eb4 100644 --- a/tests/ui/simd/intrinsic/generic-cast.rs +++ b/tests/ui/simd/intrinsic/generic-cast.rs @@ -21,9 +21,8 @@ struct f32x4([f32; 4]); struct f32x8([f32; 8]); -extern "rust-intrinsic" { - fn simd_cast<T, U>(x: T) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_cast<T, U>(x: T) -> U; fn main() { let x = i32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-cast.stderr b/tests/ui/simd/intrinsic/generic-cast.stderr index 2f9d44037af..1b6ac03f8c9 100644 --- a/tests/ui/simd/intrinsic/generic-cast.stderr +++ b/tests/ui/simd/intrinsic/generic-cast.stderr @@ -1,23 +1,23 @@ error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-cast.rs:32:9 + --> $DIR/generic-cast.rs:31:9 | LL | simd_cast::<i32, i32>(0); | ^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-cast.rs:34:9 + --> $DIR/generic-cast.rs:33:9 | LL | simd_cast::<i32, i32x4>(0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-cast.rs:36:9 + --> $DIR/generic-cast.rs:35:9 | LL | simd_cast::<i32x4, i32>(x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_cast` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i32x8` with length 8 - --> $DIR/generic-cast.rs:38:9 + --> $DIR/generic-cast.rs:37:9 | LL | simd_cast::<_, i32x8>(x); | ^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-comparison-pass.rs b/tests/ui/simd/intrinsic/generic-comparison-pass.rs index a4d84a4c534..68f98372e1d 100644 --- a/tests/ui/simd/intrinsic/generic-comparison-pass.rs +++ b/tests/ui/simd/intrinsic/generic-comparison-pass.rs @@ -14,14 +14,24 @@ struct u32x4(pub [u32; 4]); #[derive(Copy, Clone)] struct f32x4(pub [f32; 4]); -extern "rust-intrinsic" { - fn simd_eq<T, U>(x: T, y: T) -> U; - fn simd_ne<T, U>(x: T, y: T) -> U; - fn simd_lt<T, U>(x: T, y: T) -> U; - fn simd_le<T, U>(x: T, y: T) -> U; - fn simd_gt<T, U>(x: T, y: T) -> U; - fn simd_ge<T, U>(x: T, y: T) -> U; -} + +#[rustc_intrinsic] +unsafe fn simd_eq<T, U>(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_ne<T, U>(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_lt<T, U>(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_le<T, U>(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_gt<T, U>(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_ge<T, U>(x: T, y: T) -> U; macro_rules! cmp { ($method: ident($lhs: expr, $rhs: expr)) => {{ diff --git a/tests/ui/simd/intrinsic/generic-comparison.rs b/tests/ui/simd/intrinsic/generic-comparison.rs index f7f0655f3d2..e5adb49f6a3 100644 --- a/tests/ui/simd/intrinsic/generic-comparison.rs +++ b/tests/ui/simd/intrinsic/generic-comparison.rs @@ -11,14 +11,24 @@ struct i32x4([i32; 4]); #[allow(non_camel_case_types)] struct i16x8([i16; 8]); -extern "rust-intrinsic" { - fn simd_eq<T, U>(x: T, y: T) -> U; - fn simd_ne<T, U>(x: T, y: T) -> U; - fn simd_lt<T, U>(x: T, y: T) -> U; - fn simd_le<T, U>(x: T, y: T) -> U; - fn simd_gt<T, U>(x: T, y: T) -> U; - fn simd_ge<T, U>(x: T, y: T) -> U; -} + +#[rustc_intrinsic] +unsafe fn simd_eq<T, U>(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_ne<T, U>(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_lt<T, U>(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_le<T, U>(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_gt<T, U>(x: T, y: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_ge<T, U>(x: T, y: T) -> U; fn main() { let x = i32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-comparison.stderr b/tests/ui/simd/intrinsic/generic-comparison.stderr index ac4d4918827..cc66d2ce40a 100644 --- a/tests/ui/simd/intrinsic/generic-comparison.stderr +++ b/tests/ui/simd/intrinsic/generic-comparison.stderr @@ -1,107 +1,107 @@ error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:27:9 + --> $DIR/generic-comparison.rs:37:9 | LL | simd_eq::<i32, i32>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:29:9 + --> $DIR/generic-comparison.rs:39:9 | LL | simd_ne::<i32, i32>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:31:9 + --> $DIR/generic-comparison.rs:41:9 | LL | simd_lt::<i32, i32>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:33:9 + --> $DIR/generic-comparison.rs:43:9 | LL | simd_le::<i32, i32>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:35:9 + --> $DIR/generic-comparison.rs:45:9 | LL | simd_gt::<i32, i32>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:37:9 + --> $DIR/generic-comparison.rs:47:9 | LL | simd_ge::<i32, i32>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:40:9 + --> $DIR/generic-comparison.rs:50:9 | LL | simd_eq::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:42:9 + --> $DIR/generic-comparison.rs:52:9 | LL | simd_ne::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:44:9 + --> $DIR/generic-comparison.rs:54:9 | LL | simd_lt::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:46:9 + --> $DIR/generic-comparison.rs:56:9 | LL | simd_le::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:48:9 + --> $DIR/generic-comparison.rs:58:9 | LL | simd_gt::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected SIMD return type, found non-SIMD `i32` - --> $DIR/generic-comparison.rs:50:9 + --> $DIR/generic-comparison.rs:60:9 | LL | simd_ge::<_, i32>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_eq` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:53:9 + --> $DIR/generic-comparison.rs:63:9 | LL | simd_eq::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ne` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:55:9 + --> $DIR/generic-comparison.rs:65:9 | LL | simd_ne::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_lt` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:57:9 + --> $DIR/generic-comparison.rs:67:9 | LL | simd_lt::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_le` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:59:9 + --> $DIR/generic-comparison.rs:69:9 | LL | simd_le::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_gt` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:61:9 + --> $DIR/generic-comparison.rs:71:9 | LL | simd_gt::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_ge` intrinsic: expected return type with length 4 (same as input type `i32x4`), found `i16x8` with length 8 - --> $DIR/generic-comparison.rs:63:9 + --> $DIR/generic-comparison.rs:73:9 | LL | simd_ge::<_, i16x8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-elements-pass.rs b/tests/ui/simd/intrinsic/generic-elements-pass.rs index 7b1bda4fbcd..8cb600bc9e4 100644 --- a/tests/ui/simd/intrinsic/generic-elements-pass.rs +++ b/tests/ui/simd/intrinsic/generic-elements-pass.rs @@ -16,12 +16,15 @@ struct i32x4([i32; 4]); #[allow(non_camel_case_types)] struct i32x8([i32; 8]); -extern "rust-intrinsic" { - fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; - fn simd_extract<T, E>(x: T, idx: u32) -> E; +#[rustc_intrinsic] +unsafe fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; - fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_extract<T, E>(x: T, idx: u32) -> E; + + +#[rustc_intrinsic] +unsafe fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; #[repr(simd)] struct SimdShuffleIdx<const LEN: usize>([u32; LEN]); diff --git a/tests/ui/simd/intrinsic/generic-elements.rs b/tests/ui/simd/intrinsic/generic-elements.rs index 5d784a25eab..4be6645f029 100644 --- a/tests/ui/simd/intrinsic/generic-elements.rs +++ b/tests/ui/simd/intrinsic/generic-elements.rs @@ -29,13 +29,20 @@ struct f32x4([f32; 4]); #[allow(non_camel_case_types)] struct f32x8([f32; 8]); -extern "rust-intrinsic" { - fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; - fn simd_extract<T, E>(x: T, idx: u32) -> E; - fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; - fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_insert<T, E>(x: T, idx: u32, y: E) -> T; + +#[rustc_intrinsic] +unsafe fn simd_extract<T, E>(x: T, idx: u32) -> E; + + +#[rustc_intrinsic] +unsafe fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; + +#[rustc_intrinsic] +unsafe fn simd_shuffle_generic<T, U, const IDX: &'static [u32]>(x: T, y: T) -> U; + #[repr(simd)] struct SimdShuffleIdx<const LEN: usize>([u32; LEN]); diff --git a/tests/ui/simd/intrinsic/generic-elements.stderr b/tests/ui/simd/intrinsic/generic-elements.stderr index fd726d75326..8104c3ba5a2 100644 --- a/tests/ui/simd/intrinsic/generic-elements.stderr +++ b/tests/ui/simd/intrinsic/generic-elements.stderr @@ -1,125 +1,125 @@ error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:47:9 + --> $DIR/generic-elements.rs:54:9 | LL | simd_insert(0, 0, 0); | ^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_insert` intrinsic: expected inserted type `i32` (element of input `i32x4`), found `f64` - --> $DIR/generic-elements.rs:49:9 + --> $DIR/generic-elements.rs:56:9 | LL | simd_insert(x, 0, 1.0); | ^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_extract` intrinsic: expected return type `i32` (element of input `i32x4`), found `f32` - --> $DIR/generic-elements.rs:51:9 + --> $DIR/generic-elements.rs:58:9 | LL | simd_extract::<_, f32>(x, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:55:9 + --> $DIR/generic-elements.rs:62:9 | LL | simd_shuffle::<i32, _, i32>(0, 0, IDX2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:58:9 + --> $DIR/generic-elements.rs:65:9 | LL | simd_shuffle::<i32, _, i32>(0, 0, IDX4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:61:9 + --> $DIR/generic-elements.rs:68:9 | LL | simd_shuffle::<i32, _, i32>(0, 0, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` - --> $DIR/generic-elements.rs:64:9 + --> $DIR/generic-elements.rs:71:9 | LL | simd_shuffle::<_, _, f32x2>(x, x, IDX2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` - --> $DIR/generic-elements.rs:66:9 + --> $DIR/generic-elements.rs:73:9 | LL | simd_shuffle::<_, _, f32x4>(x, x, IDX4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` - --> $DIR/generic-elements.rs:68:9 + --> $DIR/generic-elements.rs:75:9 | LL | simd_shuffle::<_, _, f32x8>(x, x, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 2, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:71:9 + --> $DIR/generic-elements.rs:78:9 | LL | simd_shuffle::<_, _, i32x8>(x, x, IDX2); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 4, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:73:9 + --> $DIR/generic-elements.rs:80:9 | LL | simd_shuffle::<_, _, i32x8>(x, x, IDX4); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle` intrinsic: expected return type of length 8, found `i32x2` with length 2 - --> $DIR/generic-elements.rs:75:9 + --> $DIR/generic-elements.rs:82:9 | LL | simd_shuffle::<_, _, i32x2>(x, x, IDX8); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:79:9 + --> $DIR/generic-elements.rs:86:9 | LL | simd_shuffle_generic::<i32, i32, I2>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:82:9 + --> $DIR/generic-elements.rs:89:9 | LL | simd_shuffle_generic::<i32, i32, I4>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected SIMD input type, found non-SIMD `i32` - --> $DIR/generic-elements.rs:85:9 + --> $DIR/generic-elements.rs:92:9 | LL | simd_shuffle_generic::<i32, i32, I8>(0, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x2` with element type `f32` - --> $DIR/generic-elements.rs:88:9 + --> $DIR/generic-elements.rs:95:9 | LL | simd_shuffle_generic::<_, f32x2, I2>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x4` with element type `f32` - --> $DIR/generic-elements.rs:90:9 + --> $DIR/generic-elements.rs:97:9 | LL | simd_shuffle_generic::<_, f32x4, I4>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return element type `i32` (element of input `i32x4`), found `f32x8` with element type `f32` - --> $DIR/generic-elements.rs:92:9 + --> $DIR/generic-elements.rs:99:9 | LL | simd_shuffle_generic::<_, f32x8, I8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 2, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:95:9 + --> $DIR/generic-elements.rs:102:9 | LL | simd_shuffle_generic::<_, i32x8, I2>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 4, found `i32x8` with length 8 - --> $DIR/generic-elements.rs:97:9 + --> $DIR/generic-elements.rs:104:9 | LL | simd_shuffle_generic::<_, i32x8, I4>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_shuffle_generic` intrinsic: expected return type of length 8, found `i32x2` with length 2 - --> $DIR/generic-elements.rs:99:9 + --> $DIR/generic-elements.rs:106:9 | LL | simd_shuffle_generic::<_, i32x2, I8>(x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-gather-pass.rs b/tests/ui/simd/intrinsic/generic-gather-pass.rs index 3315d1cdaa2..0b2cf47e989 100644 --- a/tests/ui/simd/intrinsic/generic-gather-pass.rs +++ b/tests/ui/simd/intrinsic/generic-gather-pass.rs @@ -10,10 +10,11 @@ #[derive(Copy, Clone, PartialEq, Debug)] struct x4<T>(pub [T; 4]); -extern "rust-intrinsic" { - fn simd_gather<T, U, V>(x: T, y: U, z: V) -> T; - fn simd_scatter<T, U, V>(x: T, y: U, z: V) -> (); -} +#[rustc_intrinsic] +unsafe fn simd_gather<T, U, V>(x: T, y: U, z: V) -> T; + +#[rustc_intrinsic] +unsafe fn simd_scatter<T, U, V>(x: T, y: U, z: V) -> (); fn main() { let mut x = [0_f32, 1., 2., 3., 4., 5., 6., 7.]; diff --git a/tests/ui/simd/intrinsic/generic-reduction-pass.rs b/tests/ui/simd/intrinsic/generic-reduction-pass.rs index 699fb396259..8408d0f203b 100644 --- a/tests/ui/simd/intrinsic/generic-reduction-pass.rs +++ b/tests/ui/simd/intrinsic/generic-reduction-pass.rs @@ -24,19 +24,38 @@ struct f32x4(pub [f32; 4]); #[derive(Copy, Clone)] struct b8x4(pub [i8; 4]); -extern "rust-intrinsic" { - fn simd_reduce_add_unordered<T, U>(x: T) -> U; - fn simd_reduce_mul_unordered<T, U>(x: T) -> U; - fn simd_reduce_add_ordered<T, U>(x: T, acc: U) -> U; - fn simd_reduce_mul_ordered<T, U>(x: T, acc: U) -> U; - fn simd_reduce_min<T, U>(x: T) -> U; - fn simd_reduce_max<T, U>(x: T) -> U; - fn simd_reduce_and<T, U>(x: T) -> U; - fn simd_reduce_or<T, U>(x: T) -> U; - fn simd_reduce_xor<T, U>(x: T) -> U; - fn simd_reduce_all<T>(x: T) -> bool; - fn simd_reduce_any<T>(x: T) -> bool; -} +#[rustc_intrinsic] +unsafe fn simd_reduce_add_unordered<T, U>(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_mul_unordered<T, U>(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_add_ordered<T, U>(x: T, acc: U) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_mul_ordered<T, U>(x: T, acc: U) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_min<T, U>(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_max<T, U>(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_and<T, U>(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_or<T, U>(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_xor<T, U>(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_all<T>(x: T) -> bool; + +#[rustc_intrinsic] +unsafe fn simd_reduce_any<T>(x: T) -> bool; fn main() { unsafe { diff --git a/tests/ui/simd/intrinsic/generic-reduction.rs b/tests/ui/simd/intrinsic/generic-reduction.rs index 1986deafb6a..ead13250643 100644 --- a/tests/ui/simd/intrinsic/generic-reduction.rs +++ b/tests/ui/simd/intrinsic/generic-reduction.rs @@ -15,16 +15,26 @@ pub struct f32x4(pub [f32; 4]); #[derive(Copy, Clone)] pub struct u32x4(pub [u32; 4]); +#[rustc_intrinsic] +unsafe fn simd_reduce_add_ordered<T, U>(x: T, y: U) -> U; -extern "rust-intrinsic" { - fn simd_reduce_add_ordered<T, U>(x: T, y: U) -> U; - fn simd_reduce_mul_ordered<T, U>(x: T, y: U) -> U; - fn simd_reduce_and<T, U>(x: T) -> U; - fn simd_reduce_or<T, U>(x: T) -> U; - fn simd_reduce_xor<T, U>(x: T) -> U; - fn simd_reduce_all<T>(x: T) -> bool; - fn simd_reduce_any<T>(x: T) -> bool; -} +#[rustc_intrinsic] +unsafe fn simd_reduce_mul_ordered<T, U>(x: T, y: U) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_and<T, U>(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_or<T, U>(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_xor<T, U>(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_reduce_all<T>(x: T) -> bool; + +#[rustc_intrinsic] +unsafe fn simd_reduce_any<T>(x: T) -> bool; fn main() { let x = u32x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-reduction.stderr b/tests/ui/simd/intrinsic/generic-reduction.stderr index 1028faf69a7..302b9ae1d77 100644 --- a/tests/ui/simd/intrinsic/generic-reduction.stderr +++ b/tests/ui/simd/intrinsic/generic-reduction.stderr @@ -1,59 +1,59 @@ error[E0511]: invalid monomorphization of `simd_reduce_add_ordered` intrinsic: expected return type `f32` (element of input `f32x4`), found `i32` - --> $DIR/generic-reduction.rs:34:9 + --> $DIR/generic-reduction.rs:44:9 | LL | simd_reduce_add_ordered(z, 0); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_mul_ordered` intrinsic: expected return type `f32` (element of input `f32x4`), found `i32` - --> $DIR/generic-reduction.rs:36:9 + --> $DIR/generic-reduction.rs:46:9 | LL | simd_reduce_mul_ordered(z, 1); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_and` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` - --> $DIR/generic-reduction.rs:39:22 + --> $DIR/generic-reduction.rs:49:22 | LL | let _: f32 = simd_reduce_and(x); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_or` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` - --> $DIR/generic-reduction.rs:41:22 + --> $DIR/generic-reduction.rs:51:22 | LL | let _: f32 = simd_reduce_or(x); | ^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_xor` intrinsic: expected return type `u32` (element of input `u32x4`), found `f32` - --> $DIR/generic-reduction.rs:43:22 + --> $DIR/generic-reduction.rs:53:22 | LL | let _: f32 = simd_reduce_xor(x); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_and` intrinsic: unsupported simd_reduce_and from `f32x4` with element `f32` to `f32` - --> $DIR/generic-reduction.rs:46:22 + --> $DIR/generic-reduction.rs:56:22 | LL | let _: f32 = simd_reduce_and(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_or` intrinsic: unsupported simd_reduce_or from `f32x4` with element `f32` to `f32` - --> $DIR/generic-reduction.rs:48:22 + --> $DIR/generic-reduction.rs:58:22 | LL | let _: f32 = simd_reduce_or(z); | ^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_xor` intrinsic: unsupported simd_reduce_xor from `f32x4` with element `f32` to `f32` - --> $DIR/generic-reduction.rs:50:22 + --> $DIR/generic-reduction.rs:60:22 | LL | let _: f32 = simd_reduce_xor(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_all` intrinsic: unsupported simd_reduce_all from `f32x4` with element `f32` to `bool` - --> $DIR/generic-reduction.rs:53:23 + --> $DIR/generic-reduction.rs:63:23 | LL | let _: bool = simd_reduce_all(z); | ^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_reduce_any` intrinsic: unsupported simd_reduce_any from `f32x4` with element `f32` to `bool` - --> $DIR/generic-reduction.rs:55:23 + --> $DIR/generic-reduction.rs:65:23 | LL | let _: bool = simd_reduce_any(z); | ^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-select-pass.rs b/tests/ui/simd/intrinsic/generic-select-pass.rs index 5690bad5048..6b1b6cb79db 100644 --- a/tests/ui/simd/intrinsic/generic-select-pass.rs +++ b/tests/ui/simd/intrinsic/generic-select-pass.rs @@ -29,10 +29,12 @@ struct f32x4(pub [f32; 4]); #[derive(Copy, Clone, PartialEq, Debug)] struct b8x4(pub [i8; 4]); -extern "rust-intrinsic" { - fn simd_select<T, U>(x: T, a: U, b: U) -> U; - fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_select<T, U>(x: T, a: U, b: U) -> U; + +#[rustc_intrinsic] +unsafe fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U; + fn main() { let m0 = b8x4([!0, !0, !0, !0]); diff --git a/tests/ui/simd/intrinsic/generic-select.rs b/tests/ui/simd/intrinsic/generic-select.rs index 52e02649590..340fe3f3592 100644 --- a/tests/ui/simd/intrinsic/generic-select.rs +++ b/tests/ui/simd/intrinsic/generic-select.rs @@ -22,10 +22,13 @@ struct b8x4(pub [i8; 4]); #[derive(Copy, Clone, PartialEq)] struct b8x8(pub [i8; 8]); -extern "rust-intrinsic" { - fn simd_select<T, U>(x: T, a: U, b: U) -> U; - fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U; -} + +#[rustc_intrinsic] +unsafe fn simd_select<T, U>(x: T, a: U, b: U) -> U; + +#[rustc_intrinsic] +unsafe fn simd_select_bitmask<T, U>(x: T, a: U, b: U) -> U; + fn main() { let m4 = b8x4([0, 0, 0, 0]); diff --git a/tests/ui/simd/intrinsic/generic-select.stderr b/tests/ui/simd/intrinsic/generic-select.stderr index d576f1bc774..a97fc91f951 100644 --- a/tests/ui/simd/intrinsic/generic-select.stderr +++ b/tests/ui/simd/intrinsic/generic-select.stderr @@ -1,47 +1,47 @@ error[E0511]: invalid monomorphization of `simd_select` intrinsic: mismatched lengths: mask length `8` != other vector length `4` - --> $DIR/generic-select.rs:39:9 + --> $DIR/generic-select.rs:42:9 | LL | simd_select(m8, x, x); | ^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `u32`, expected `i_` - --> $DIR/generic-select.rs:42:9 + --> $DIR/generic-select.rs:45:9 | LL | simd_select(x, x, x); | ^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select` intrinsic: mask element type is `f32`, expected `i_` - --> $DIR/generic-select.rs:45:9 + --> $DIR/generic-select.rs:48:9 | LL | simd_select(z, z, z); | ^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select` intrinsic: expected SIMD argument type, found non-SIMD `u32` - --> $DIR/generic-select.rs:48:9 + --> $DIR/generic-select.rs:51:9 | LL | simd_select(m4, 0u32, 1u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: invalid bitmask `u16`, expected `u8` or `[u8; 1]` - --> $DIR/generic-select.rs:51:9 + --> $DIR/generic-select.rs:54:9 | LL | simd_select_bitmask(0u16, x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: expected SIMD argument type, found non-SIMD `u32` - --> $DIR/generic-select.rs:54:9 + --> $DIR/generic-select.rs:57:9 | LL | simd_select_bitmask(0u8, 1u32, 2u32); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: invalid bitmask `f32`, expected `u8` or `[u8; 1]` - --> $DIR/generic-select.rs:57:9 + --> $DIR/generic-select.rs:60:9 | LL | simd_select_bitmask(0.0f32, x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0511]: invalid monomorphization of `simd_select_bitmask` intrinsic: invalid bitmask `&str`, expected `u8` or `[u8; 1]` - --> $DIR/generic-select.rs:60:9 + --> $DIR/generic-select.rs:63:9 | LL | simd_select_bitmask("x", x, x); | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/simd/intrinsic/generic-shuffle.rs b/tests/ui/simd/intrinsic/generic-shuffle.rs index 2752718d99d..1223b8ebe19 100644 --- a/tests/ui/simd/intrinsic/generic-shuffle.rs +++ b/tests/ui/simd/intrinsic/generic-shuffle.rs @@ -9,9 +9,9 @@ #[derive(Copy, Clone)] pub struct Simd<T, const N: usize>([T; N]); -extern "rust-intrinsic" { - fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; + fn main() { const I: Simd<u32, 2> = Simd([0; 2]); diff --git a/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs b/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs index d9239ef5801..b324ac40749 100644 --- a/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs +++ b/tests/ui/simd/intrinsic/inlining-issue67557-ice.rs @@ -5,9 +5,8 @@ //@ compile-flags: -Zmir-opt-level=4 #![feature(intrinsics, repr_simd)] -extern "rust-intrinsic" { - fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; #[repr(simd)] #[derive(Debug, PartialEq)] diff --git a/tests/ui/simd/intrinsic/inlining-issue67557.rs b/tests/ui/simd/intrinsic/inlining-issue67557.rs index 23dd5075f96..319bb15c015 100644 --- a/tests/ui/simd/intrinsic/inlining-issue67557.rs +++ b/tests/ui/simd/intrinsic/inlining-issue67557.rs @@ -5,9 +5,8 @@ //@ compile-flags: -Zmir-opt-level=4 #![feature(intrinsics, repr_simd)] -extern "rust-intrinsic" { - fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_shuffle<T, I, U>(x: T, y: T, idx: I) -> U; #[repr(simd)] #[derive(Debug, PartialEq)] diff --git a/tests/ui/simd/intrinsic/issue-85855.rs b/tests/ui/simd/intrinsic/issue-85855.rs index dc04699f7f8..daeea793d1b 100644 --- a/tests/ui/simd/intrinsic/issue-85855.rs +++ b/tests/ui/simd/intrinsic/issue-85855.rs @@ -5,15 +5,18 @@ #![feature(intrinsics)] #![crate_type="lib"] -extern "rust-intrinsic" { - fn simd_saturating_add<'a, T: 'a>(x: T, y: T); - //~^ ERROR: intrinsic has wrong number of lifetime parameters - fn simd_add<'a, T>(x: T, y: T) -> T; +#[rustc_intrinsic] +unsafe fn simd_saturating_add<'a, T: 'a>(x: T, y: T); +//~^ ERROR: intrinsic has wrong number of lifetime parameters - fn simd_sub<T, U>(x: T, y: U); - //~^ ERROR: intrinsic has wrong number of type parameters +#[rustc_intrinsic] +unsafe fn simd_add<'a, T>(x: T, y: T) -> T; - fn simd_mul<T, const N: usize>(x: T, y: T); - //~^ ERROR: intrinsic has wrong number of const parameters -} +#[rustc_intrinsic] +unsafe fn simd_sub<T, U>(x: T, y: U); +//~^ ERROR: intrinsic has wrong number of type parameters + +#[rustc_intrinsic] +unsafe fn simd_mul<T, const N: usize>(x: T, y: T); +//~^ ERROR: intrinsic has wrong number of const parameters diff --git a/tests/ui/simd/intrinsic/issue-85855.stderr b/tests/ui/simd/intrinsic/issue-85855.stderr index fb2f1fbc5b1..b91a606ba68 100644 --- a/tests/ui/simd/intrinsic/issue-85855.stderr +++ b/tests/ui/simd/intrinsic/issue-85855.stderr @@ -1,20 +1,20 @@ error[E0094]: intrinsic has wrong number of lifetime parameters: found 1, expected 0 - --> $DIR/issue-85855.rs:9:27 + --> $DIR/issue-85855.rs:10:30 | -LL | fn simd_saturating_add<'a, T: 'a>(x: T, y: T); - | ^^^^^^^^^^^ expected 0 lifetime parameters +LL | unsafe fn simd_saturating_add<'a, T: 'a>(x: T, y: T); + | ^^^^^^^^^^^ expected 0 lifetime parameters error[E0094]: intrinsic has wrong number of type parameters: found 2, expected 1 - --> $DIR/issue-85855.rs:14:16 + --> $DIR/issue-85855.rs:17:19 | -LL | fn simd_sub<T, U>(x: T, y: U); - | ^^^^^^ expected 1 type parameter +LL | unsafe fn simd_sub<T, U>(x: T, y: U); + | ^^^^^^ expected 1 type parameter error[E0094]: intrinsic has wrong number of const parameters: found 1, expected 0 - --> $DIR/issue-85855.rs:17:16 + --> $DIR/issue-85855.rs:21:19 | -LL | fn simd_mul<T, const N: usize>(x: T, y: T); - | ^^^^^^^^^^^^^^^^^^^ expected 0 const parameters +LL | unsafe fn simd_mul<T, const N: usize>(x: T, y: T); + | ^^^^^^^^^^^^^^^^^^^ expected 0 const parameters error: aborting due to 3 previous errors diff --git a/tests/ui/simd/intrinsic/ptr-cast.rs b/tests/ui/simd/intrinsic/ptr-cast.rs index 0490734b48a..559b8ba1b5c 100644 --- a/tests/ui/simd/intrinsic/ptr-cast.rs +++ b/tests/ui/simd/intrinsic/ptr-cast.rs @@ -2,11 +2,15 @@ #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_cast_ptr<T, U>(x: T) -> U; - fn simd_expose_provenance<T, U>(x: T) -> U; - fn simd_with_exposed_provenance<T, U>(x: T) -> U; -} + +#[rustc_intrinsic] +unsafe fn simd_cast_ptr<T, U>(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_expose_provenance<T, U>(x: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_with_exposed_provenance<T, U>(x: T) -> U; #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/issue-105439.rs b/tests/ui/simd/issue-105439.rs index 3cb43fc8b1a..108bb282df2 100644 --- a/tests/ui/simd/issue-105439.rs +++ b/tests/ui/simd/issue-105439.rs @@ -9,9 +9,8 @@ #[repr(simd)] struct i32x4([i32; 4]); -extern "rust-intrinsic" { - pub(crate) fn simd_add<T>(x: T, y: T) -> T; -} +#[rustc_intrinsic] +pub(crate) unsafe fn simd_add<T>(x: T, y: T) -> T; #[inline(always)] fn to_array(a: i32x4) -> [i32; 4] { diff --git a/tests/ui/simd/issue-39720.rs b/tests/ui/simd/issue-39720.rs index 2b51c0224c6..8d7666faaf9 100644 --- a/tests/ui/simd/issue-39720.rs +++ b/tests/ui/simd/issue-39720.rs @@ -11,9 +11,8 @@ pub struct Char3(pub [i8; 3]); #[derive(Copy, Clone, Debug)] pub struct Short3(pub [i16; 3]); -extern "rust-intrinsic" { - fn simd_cast<T, U>(x: T) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_cast<T, U>(x: T) -> U; fn main() { let cast: Short3 = unsafe { simd_cast(Char3([10, -3, -9])) }; diff --git a/tests/ui/simd/issue-85915-simd-ptrs.rs b/tests/ui/simd/issue-85915-simd-ptrs.rs index edf60e0205c..2e7baf48ee3 100644 --- a/tests/ui/simd/issue-85915-simd-ptrs.rs +++ b/tests/ui/simd/issue-85915-simd-ptrs.rs @@ -22,10 +22,12 @@ struct f32x4([f32; 4]); #[derive(Copy, Clone, PartialEq, Debug)] struct i32x4([i32; 4]); -extern "rust-intrinsic" { - fn simd_gather<T, U, V>(x: T, y: U, z: V) -> T; - fn simd_scatter<T, U, V>(x: T, y: U, z: V) -> (); -} + +#[rustc_intrinsic] +unsafe fn simd_gather<T, U, V>(x: T, y: U, z: V) -> T; + +#[rustc_intrinsic] +unsafe fn simd_scatter<T, U, V>(x: T, y: U, z: V) -> (); fn main() { let mut x = [0_f32, 1., 2., 3., 4., 5., 6., 7.]; diff --git a/tests/ui/simd/issue-89193.rs b/tests/ui/simd/issue-89193.rs index 9530124a7cc..4b4fb9d9169 100644 --- a/tests/ui/simd/issue-89193.rs +++ b/tests/ui/simd/issue-89193.rs @@ -10,9 +10,8 @@ #[derive(Copy, Clone, PartialEq, Debug)] struct x4<T>(pub [T; 4]); -extern "rust-intrinsic" { - fn simd_gather<T, U, V>(x: T, y: U, z: V) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_gather<T, U, V>(x: T, y: U, z: V) -> T; fn main() { let x: [usize; 4] = [10, 11, 12, 13]; diff --git a/tests/ui/simd/masked-load-store-build-fail.rs b/tests/ui/simd/masked-load-store-build-fail.rs index fbd657763c9..b8742184eb0 100644 --- a/tests/ui/simd/masked-load-store-build-fail.rs +++ b/tests/ui/simd/masked-load-store-build-fail.rs @@ -1,10 +1,12 @@ //@ build-fail #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; - fn simd_masked_store<M, P, T>(mask: M, pointer: P, values: T) -> (); -} + +#[rustc_intrinsic] +unsafe fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_masked_store<M, P, T>(mask: M, pointer: P, values: T) -> (); #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/masked-load-store-build-fail.stderr b/tests/ui/simd/masked-load-store-build-fail.stderr index 59af83fe0e8..8a8d8eb99e2 100644 --- a/tests/ui/simd/masked-load-store-build-fail.stderr +++ b/tests/ui/simd/masked-load-store-build-fail.stderr @@ -1,5 +1,5 @@ error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected third argument with length 8 (same as input type `Simd<i8, 8>`), found `Simd<u8, 4>` with length 4 - --> $DIR/masked-load-store-build-fail.rs:18:9 + --> $DIR/masked-load-store-build-fail.rs:20:9 | LL | / simd_masked_load( LL | | Simd::<i8, 8>([-1, 0, -1, -1, 0, 0, 0, 0]), @@ -9,7 +9,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected element type `u8` of second argument `*const i8` to be a pointer to the element type `u8` of the first argument `Simd<u8, 4>`, found `u8` != `*_ u8` - --> $DIR/masked-load-store-build-fail.rs:25:9 + --> $DIR/masked-load-store-build-fail.rs:27:9 | LL | / simd_masked_load( LL | | Simd::<i8, 4>([-1, 0, -1, -1]), @@ -19,7 +19,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected element type `u32` of second argument `*const u8` to be a pointer to the element type `u32` of the first argument `Simd<u32, 4>`, found `u32` != `*_ u32` - --> $DIR/masked-load-store-build-fail.rs:32:9 + --> $DIR/masked-load-store-build-fail.rs:34:9 | LL | / simd_masked_load( LL | | Simd::<i8, 4>([-1, 0, -1, -1]), @@ -29,7 +29,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_load` intrinsic: expected element type `u8` of third argument `Simd<u8, 4>` to be a signed integer type - --> $DIR/masked-load-store-build-fail.rs:39:9 + --> $DIR/masked-load-store-build-fail.rs:41:9 | LL | / simd_masked_load( LL | | Simd::<u8, 4>([1, 0, 1, 1]), @@ -39,7 +39,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected element type `u32` of second argument `*const u8` to be a pointer to the element type `u32` of the first argument `Simd<u32, 4>`, found `u32` != `*mut u32` - --> $DIR/masked-load-store-build-fail.rs:46:9 + --> $DIR/masked-load-store-build-fail.rs:48:9 | LL | / simd_masked_store( LL | | Simd([-1i8; 4]), @@ -49,7 +49,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected element type `u8` of second argument `*const u8` to be a pointer to the element type `u8` of the first argument `Simd<u8, 4>`, found `u8` != `*mut u8` - --> $DIR/masked-load-store-build-fail.rs:53:9 + --> $DIR/masked-load-store-build-fail.rs:55:9 | LL | / simd_masked_store( LL | | Simd([-1i8; 4]), @@ -59,7 +59,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected third argument with length 4 (same as input type `Simd<i8, 4>`), found `Simd<u8, 2>` with length 2 - --> $DIR/masked-load-store-build-fail.rs:60:9 + --> $DIR/masked-load-store-build-fail.rs:62:9 | LL | / simd_masked_store( LL | | Simd([-1i8; 4]), @@ -69,7 +69,7 @@ LL | | ); | |_________^ error[E0511]: invalid monomorphization of `simd_masked_store` intrinsic: expected element type `u8` of third argument `Simd<u32, 4>` to be a signed integer type - --> $DIR/masked-load-store-build-fail.rs:67:9 + --> $DIR/masked-load-store-build-fail.rs:69:9 | LL | / simd_masked_store( LL | | Simd([1u32; 4]), diff --git a/tests/ui/simd/masked-load-store-check-fail.rs b/tests/ui/simd/masked-load-store-check-fail.rs index 39c82c41385..0f36bf6443f 100644 --- a/tests/ui/simd/masked-load-store-check-fail.rs +++ b/tests/ui/simd/masked-load-store-check-fail.rs @@ -1,10 +1,11 @@ //@ check-fail #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; - fn simd_masked_store<M, P, T>(mask: M, pointer: P, values: T) -> (); -} +#[rustc_intrinsic] +unsafe fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_masked_store<M, P, T>(mask: M, pointer: P, values: T) -> (); #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/masked-load-store-check-fail.stderr b/tests/ui/simd/masked-load-store-check-fail.stderr index 5d205d607c9..fa65798fc94 100644 --- a/tests/ui/simd/masked-load-store-check-fail.stderr +++ b/tests/ui/simd/masked-load-store-check-fail.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/masked-load-store-check-fail.rs:21:13 + --> $DIR/masked-load-store-check-fail.rs:22:13 | LL | let _x: Simd<u8, 2> = simd_masked_load( | ---------------- arguments to this function are incorrect @@ -10,7 +10,7 @@ LL | Simd::<u8, 4>([9; 4]) = note: expected struct `Simd<_, 2>` found struct `Simd<_, 4>` help: the return type of this call is `Simd<u8, 4>` due to the type of the argument passed - --> $DIR/masked-load-store-check-fail.rs:18:31 + --> $DIR/masked-load-store-check-fail.rs:19:31 | LL | let _x: Simd<u8, 2> = simd_masked_load( | _______________________________^ @@ -21,13 +21,13 @@ LL | | Simd::<u8, 4>([9; 4]) LL | | ); | |_________^ note: function defined here - --> $DIR/masked-load-store-check-fail.rs:5:8 + --> $DIR/masked-load-store-check-fail.rs:5:11 | -LL | fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; - | ^^^^^^^^^^^^^^^^ +LL | unsafe fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; + | ^^^^^^^^^^^^^^^^ --------- error[E0308]: mismatched types - --> $DIR/masked-load-store-check-fail.rs:28:13 + --> $DIR/masked-load-store-check-fail.rs:29:13 | LL | let _x: Simd<u32, 4> = simd_masked_load( | ---------------- arguments to this function are incorrect @@ -38,7 +38,7 @@ LL | default = note: expected struct `Simd<u32, _>` found struct `Simd<u8, _>` help: the return type of this call is `Simd<u8, 4>` due to the type of the argument passed - --> $DIR/masked-load-store-check-fail.rs:25:32 + --> $DIR/masked-load-store-check-fail.rs:26:32 | LL | let _x: Simd<u32, 4> = simd_masked_load( | ________________________________^ @@ -49,10 +49,10 @@ LL | | default LL | | ); | |_________^ note: function defined here - --> $DIR/masked-load-store-check-fail.rs:5:8 + --> $DIR/masked-load-store-check-fail.rs:5:11 | -LL | fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; - | ^^^^^^^^^^^^^^^^ +LL | unsafe fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; + | ^^^^^^^^^^^^^^^^ --------- error: aborting due to 2 previous errors diff --git a/tests/ui/simd/masked-load-store.rs b/tests/ui/simd/masked-load-store.rs index 902143f9261..4b4195f51f1 100644 --- a/tests/ui/simd/masked-load-store.rs +++ b/tests/ui/simd/masked-load-store.rs @@ -1,10 +1,11 @@ //@ run-pass #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; - fn simd_masked_store<M, P, T>(mask: M, pointer: P, values: T) -> (); -} +#[rustc_intrinsic] +unsafe fn simd_masked_load<M, P, T>(mask: M, pointer: P, values: T) -> T; + +#[rustc_intrinsic] +unsafe fn simd_masked_store<M, P, T>(mask: M, pointer: P, values: T) -> (); #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/monomorphize-shuffle-index.generic.stderr b/tests/ui/simd/monomorphize-shuffle-index.generic.stderr index 2d1fa1f8da2..b0a8da59fac 100644 --- a/tests/ui/simd/monomorphize-shuffle-index.generic.stderr +++ b/tests/ui/simd/monomorphize-shuffle-index.generic.stderr @@ -1,5 +1,5 @@ error: overly complex generic constant - --> $DIR/monomorphize-shuffle-index.rs:29:45 + --> $DIR/monomorphize-shuffle-index.rs:32:45 | LL | return simd_shuffle_generic::<_, _, { &Self::I.0 }>(a, b); | ^^----------^^ diff --git a/tests/ui/simd/monomorphize-shuffle-index.rs b/tests/ui/simd/monomorphize-shuffle-index.rs index 140cf6fbe96..01926408a2c 100644 --- a/tests/ui/simd/monomorphize-shuffle-index.rs +++ b/tests/ui/simd/monomorphize-shuffle-index.rs @@ -4,12 +4,15 @@ #![feature(repr_simd, intrinsics, adt_const_params, unsized_const_params, generic_const_exprs)] #![allow(incomplete_features)] -extern "rust-intrinsic" { - #[cfg(old)] - fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; - #[cfg(any(generic, generic_with_fn))] - fn simd_shuffle_generic<T, U, const I: &'static [u32]>(a: T, b: T) -> U; -} + +#[rustc_intrinsic] +#[cfg(old)] +unsafe fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; + +#[rustc_intrinsic] +#[cfg(any(generic, generic_with_fn))] +unsafe fn simd_shuffle_generic<T, U, const I: &'static [u32]>(a: T, b: T) -> U; + #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/simd/repr_packed.rs b/tests/ui/simd/repr_packed.rs index 1ba15bda98d..a666892226e 100644 --- a/tests/ui/simd/repr_packed.rs +++ b/tests/ui/simd/repr_packed.rs @@ -22,9 +22,8 @@ fn check_ty<T>() { check_size_align::<T, 15>(); } -extern "rust-intrinsic" { - fn simd_add<T>(a: T, b: T) -> T; -} +#[rustc_intrinsic] +unsafe fn simd_add<T>(a: T, b: T) -> T; fn main() { check_ty::<u8>(); diff --git a/tests/ui/simd/shuffle.rs b/tests/ui/simd/shuffle.rs index 96c0ed2118f..2cae5a1e7de 100644 --- a/tests/ui/simd/shuffle.rs +++ b/tests/ui/simd/shuffle.rs @@ -8,9 +8,8 @@ use std::marker::ConstParamTy; -extern "rust-intrinsic" { - fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_shuffle<T, I, U>(a: T, b: T, i: I) -> U; #[derive(Copy, Clone, ConstParamTy, PartialEq, Eq)] #[repr(simd)] diff --git a/tests/ui/simd/simd-bitmask-notpow2.rs b/tests/ui/simd/simd-bitmask-notpow2.rs index 3499bf33ed5..d7572ef4a2a 100644 --- a/tests/ui/simd/simd-bitmask-notpow2.rs +++ b/tests/ui/simd/simd-bitmask-notpow2.rs @@ -4,10 +4,12 @@ //@ ignore-endian-big #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_bitmask<T, U>(v: T) -> U; - fn simd_select_bitmask<T, U>(m: T, a: U, b: U) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_bitmask<T, U>(v: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_select_bitmask<T, U>(m: T, a: U, b: U) -> U; + fn main() { // Non-power-of-2 multi-byte mask. diff --git a/tests/ui/simd/simd-bitmask.rs b/tests/ui/simd/simd-bitmask.rs index 82f73fca951..4275ab0f40c 100644 --- a/tests/ui/simd/simd-bitmask.rs +++ b/tests/ui/simd/simd-bitmask.rs @@ -1,10 +1,12 @@ //@run-pass #![feature(repr_simd, intrinsics)] -extern "rust-intrinsic" { - fn simd_bitmask<T, U>(v: T) -> U; - fn simd_select_bitmask<T, U>(m: T, a: U, b: U) -> U; -} +#[rustc_intrinsic] +unsafe fn simd_bitmask<T, U>(v: T) -> U; + +#[rustc_intrinsic] +unsafe fn simd_select_bitmask<T, U>(m: T, a: U, b: U) -> U; + #[derive(Copy, Clone)] #[repr(simd)] diff --git a/tests/ui/span/issue-34264.stderr b/tests/ui/span/issue-34264.stderr index b581cdd0be2..c8046a1bddf 100644 --- a/tests/ui/span/issue-34264.stderr +++ b/tests/ui/span/issue-34264.stderr @@ -60,7 +60,7 @@ note: function defined here --> $DIR/issue-34264.rs:1:4 | LL | fn foo(Option<i32>, String) {} - | ^^^ ----------- ------ + | ^^^ help: remove the extra argument | LL - foo(Some(42), 2, ""); @@ -91,7 +91,7 @@ note: function defined here --> $DIR/issue-34264.rs:3:4 | LL | fn bar(x, y: usize) {} - | ^^^ - -------- + | ^^^ help: remove the extra argument | LL - bar(1, 2, 3); diff --git a/tests/ui/span/missing-unit-argument.stderr b/tests/ui/span/missing-unit-argument.stderr index 79980f48ab6..6261831b752 100644 --- a/tests/ui/span/missing-unit-argument.stderr +++ b/tests/ui/span/missing-unit-argument.stderr @@ -37,7 +37,7 @@ note: function defined here --> $DIR/missing-unit-argument.rs:1:4 | LL | fn foo(():(), ():()) {} - | ^^^ ----- ----- + | ^^^ ----- help: provide the argument | LL | foo((), ()); diff --git a/tests/ui/static/issue-24446.rs b/tests/ui/static/issue-24446.rs index 6cf8846506d..830e373c189 100644 --- a/tests/ui/static/issue-24446.rs +++ b/tests/ui/static/issue-24446.rs @@ -2,7 +2,6 @@ fn main() { static foo: dyn Fn() -> u32 = || -> u32 { //~^ ERROR the size for values of type //~| ERROR cannot be shared between threads safely - //~| ERROR the size for values of type //~| ERROR mismatched types 0 }; diff --git a/tests/ui/static/issue-24446.stderr b/tests/ui/static/issue-24446.stderr index 8cb034000be..033caf07d8e 100644 --- a/tests/ui/static/issue-24446.stderr +++ b/tests/ui/static/issue-24446.stderr @@ -15,33 +15,19 @@ LL | static foo: dyn Fn() -> u32 = || -> u32 { | = help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)` -error[E0277]: the size for values of type `(dyn Fn() -> u32 + 'static)` cannot be known at compilation time - --> $DIR/issue-24446.rs:2:35 - | -LL | static foo: dyn Fn() -> u32 = || -> u32 { - | ___________________________________^ -... | -LL | | 0 -LL | | }; - | |_____^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `(dyn Fn() -> u32 + 'static)` - = note: constant expressions must have a statically known size - error[E0308]: mismatched types --> $DIR/issue-24446.rs:2:35 | LL | static foo: dyn Fn() -> u32 = || -> u32 { | ___________________________________^ ... | -LL | | 0 LL | | }; | |_____^ expected `dyn Fn`, found closure | = note: expected trait object `(dyn Fn() -> u32 + 'static)` found closure `{closure@$DIR/issue-24446.rs:2:35: 2:44}` -error: aborting due to 4 previous errors +error: aborting due to 3 previous errors Some errors have detailed explanations: E0277, E0308. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/statics/unsized_type2.stderr b/tests/ui/statics/unsized_type2.stderr index b18a99fab72..ffbbe218c87 100644 --- a/tests/ui/statics/unsized_type2.stderr +++ b/tests/ui/statics/unsized_type2.stderr @@ -11,6 +11,12 @@ note: required because it appears within the type `Foo` LL | pub struct Foo { | ^^^ +error[E0308]: mismatched types + --> $DIR/unsized_type2.rs:14:45 + | +LL | pub static WITH_ERROR: Foo = Foo { version: 0 }; + | ^ expected `str`, found integer + error[E0277]: the size for values of type `str` cannot be known at compilation time --> $DIR/unsized_type2.rs:14:30 | @@ -23,13 +29,7 @@ note: required because it appears within the type `Foo` | LL | pub struct Foo { | ^^^ - = note: constant expressions must have a statically known size - -error[E0308]: mismatched types - --> $DIR/unsized_type2.rs:14:45 - | -LL | pub static WITH_ERROR: Foo = Foo { version: 0 }; - | ^ expected `str`, found integer + = note: structs must have a statically known size to be initialized error: aborting due to 3 previous errors diff --git a/tests/ui/structs-enums/class-impl-very-parameterized-trait.rs b/tests/ui/structs-enums/class-impl-very-parameterized-trait.rs index 0b37192fc3b..6caec1e2034 100644 --- a/tests/ui/structs-enums/class-impl-very-parameterized-trait.rs +++ b/tests/ui/structs-enums/class-impl-very-parameterized-trait.rs @@ -102,6 +102,6 @@ pub fn main() { let mut spotty: cat<cat_type> = cat::new(2, 57, cat_type::tuxedo); for _ in 0_usize..6 { spotty.speak(); } assert_eq!(spotty.len(), 8); - assert!((spotty.contains_key(&2))); + assert!(spotty.contains_key(&2)); assert_eq!(spotty.get(&3), &cat_type::tuxedo); } diff --git a/tests/ui/structs-enums/class-implement-trait-cross-crate.rs b/tests/ui/structs-enums/class-implement-trait-cross-crate.rs index 7a5969451cb..781ac6ad10d 100644 --- a/tests/ui/structs-enums/class-implement-trait-cross-crate.rs +++ b/tests/ui/structs-enums/class-implement-trait-cross-crate.rs @@ -53,7 +53,7 @@ fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { pub fn main() { let mut nyan = cat(0_usize, 2, "nyan".to_string()); nyan.eat(); - assert!((!nyan.eat())); + assert!(!nyan.eat()); for _ in 1_usize..10_usize { nyan.speak(); }; - assert!((nyan.eat())); + assert!(nyan.eat()); } diff --git a/tests/ui/structs-enums/class-implement-traits.rs b/tests/ui/structs-enums/class-implement-traits.rs index 04a7b706edb..3a514ff9d75 100644 --- a/tests/ui/structs-enums/class-implement-traits.rs +++ b/tests/ui/structs-enums/class-implement-traits.rs @@ -57,7 +57,7 @@ fn make_speak<C:noisy>(mut c: C) { pub fn main() { let mut nyan = cat(0_usize, 2, "nyan".to_string()); nyan.eat(); - assert!((!nyan.eat())); + assert!(!nyan.eat()); for _ in 1_usize..10_usize { make_speak(nyan.clone()); } diff --git a/tests/ui/structs-enums/classes-cross-crate.rs b/tests/ui/structs-enums/classes-cross-crate.rs index 0160d3fd85c..6fb5f2e3cc9 100644 --- a/tests/ui/structs-enums/classes-cross-crate.rs +++ b/tests/ui/structs-enums/classes-cross-crate.rs @@ -7,7 +7,7 @@ use cci_class_4::kitties::cat; pub fn main() { let mut nyan = cat(0_usize, 2, "nyan".to_string()); nyan.eat(); - assert!((!nyan.eat())); + assert!(!nyan.eat()); for _ in 1_usize..10_usize { nyan.speak(); }; - assert!((nyan.eat())); + assert!(nyan.eat()); } diff --git a/tests/ui/structs-enums/classes.rs b/tests/ui/structs-enums/classes.rs index d1c1922f4b5..05976f6a759 100644 --- a/tests/ui/structs-enums/classes.rs +++ b/tests/ui/structs-enums/classes.rs @@ -45,7 +45,7 @@ fn cat(in_x : usize, in_y : isize, in_name: String) -> cat { pub fn main() { let mut nyan = cat(0_usize, 2, "nyan".to_string()); nyan.eat(); - assert!((!nyan.eat())); + assert!(!nyan.eat()); for _ in 1_usize..10_usize { nyan.speak(); }; - assert!((nyan.eat())); + assert!(nyan.eat()); } diff --git a/tests/ui/structs-enums/tag.rs b/tests/ui/structs-enums/tag.rs index 16e6b2341cf..542b517e66d 100644 --- a/tests/ui/structs-enums/tag.rs +++ b/tests/ui/structs-enums/tag.rs @@ -25,6 +25,6 @@ impl PartialEq for colour { fn ne(&self, other: &colour) -> bool { !(*self).eq(other) } } -fn f() { let x = colour::red(1, 2); let y = colour::green; assert!((x != y)); } +fn f() { let x = colour::red(1, 2); let y = colour::green; assert!(x != y); } pub fn main() { f(); } diff --git a/tests/ui/suggestions/dyn-incompatible-trait-references-self.stderr b/tests/ui/suggestions/dyn-incompatible-trait-references-self.stderr index ae009d26029..4576017abaf 100644 --- a/tests/ui/suggestions/dyn-incompatible-trait-references-self.stderr +++ b/tests/ui/suggestions/dyn-incompatible-trait-references-self.stderr @@ -34,6 +34,18 @@ LL | trait Other: Sized {} | this trait is not dyn compatible... error[E0277]: the size for values of type `Self` cannot be known at compilation time + --> $DIR/dyn-incompatible-trait-references-self.rs:4:22 + | +LL | fn bat(&self) -> Self {} + | ^^^^ doesn't have a size known at compile-time + | + = note: the return type of a function must have a statically known size +help: consider further restricting `Self` + | +LL | fn bat(&self) -> Self where Self: Sized {} + | +++++++++++++++++ + +error[E0277]: the size for values of type `Self` cannot be known at compilation time --> $DIR/dyn-incompatible-trait-references-self.rs:2:22 | LL | fn baz(&self, _: Self) {} @@ -61,18 +73,6 @@ LL | fn bat(&self) -> Self {} = note: expected type parameter `Self` found unit type `()` -error[E0277]: the size for values of type `Self` cannot be known at compilation time - --> $DIR/dyn-incompatible-trait-references-self.rs:4:22 - | -LL | fn bat(&self) -> Self {} - | ^^^^ doesn't have a size known at compile-time - | - = note: the return type of a function must have a statically known size -help: consider further restricting `Self` - | -LL | fn bat(&self) -> Self where Self: Sized {} - | +++++++++++++++++ - error: aborting due to 5 previous errors Some errors have detailed explanations: E0038, E0277, E0308. diff --git a/tests/ui/issues/issue-40782.fixed b/tests/ui/suggestions/for-loop-missing-in.fixed index ff376b5a52c..ff376b5a52c 100644 --- a/tests/ui/issues/issue-40782.fixed +++ b/tests/ui/suggestions/for-loop-missing-in.fixed diff --git a/tests/ui/issues/issue-40782.rs b/tests/ui/suggestions/for-loop-missing-in.rs index 28c12aec665..28c12aec665 100644 --- a/tests/ui/issues/issue-40782.rs +++ b/tests/ui/suggestions/for-loop-missing-in.rs diff --git a/tests/ui/issues/issue-40782.stderr b/tests/ui/suggestions/for-loop-missing-in.stderr index 61498020238..61830b800a6 100644 --- a/tests/ui/issues/issue-40782.stderr +++ b/tests/ui/suggestions/for-loop-missing-in.stderr @@ -1,5 +1,5 @@ error: missing `in` in `for` loop - --> $DIR/issue-40782.rs:4:11 + --> $DIR/for-loop-missing-in.rs:4:11 | LL | for _i 0..2 { | ^ @@ -10,7 +10,7 @@ LL | for _i in 0..2 { | ++ error: missing `in` in `for` loop - --> $DIR/issue-40782.rs:6:12 + --> $DIR/for-loop-missing-in.rs:6:12 | LL | for _i of 0..2 { | ^^ diff --git a/tests/ui/suggestions/missing-lifetime-specifier.rs b/tests/ui/suggestions/missing-lifetime-specifier.rs index dd437fc0c0b..a957477897d 100644 --- a/tests/ui/suggestions/missing-lifetime-specifier.rs +++ b/tests/ui/suggestions/missing-lifetime-specifier.rs @@ -1,6 +1,5 @@ // The specific errors produced depend the thread-local implementation. // Run only on platforms with "fast" TLS. -//@ ignore-windows FIXME(#84933) //@ ignore-wasm globals are used instead of thread locals //@ ignore-emscripten globals are used instead of thread locals //@ ignore-android does not use #[thread_local] diff --git a/tests/ui/suggestions/missing-lifetime-specifier.stderr b/tests/ui/suggestions/missing-lifetime-specifier.stderr index e0b6bb872b5..1fdbf3b0c79 100644 --- a/tests/ui/suggestions/missing-lifetime-specifier.stderr +++ b/tests/ui/suggestions/missing-lifetime-specifier.stderr @@ -1,5 +1,5 @@ error[E0106]: missing lifetime specifiers - --> $DIR/missing-lifetime-specifier.rs:28:44 + --> $DIR/missing-lifetime-specifier.rs:27:44 | LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo>>>> = RefCell::new(HashMap::new()); | ^^^ expected 2 lifetime parameters @@ -11,7 +11,7 @@ LL | static a: RefCell<HashMap<i32, Vec<Vec<Foo<'static, 'static>>>>> = RefC | ++++++++++++++++++ error[E0106]: missing lifetime specifiers - --> $DIR/missing-lifetime-specifier.rs:32:44 + --> $DIR/missing-lifetime-specifier.rs:31:44 | LL | static b: RefCell<HashMap<i32, Vec<Vec<&Bar>>>> = RefCell::new(HashMap::new()); | ^^^^ expected 2 lifetime parameters @@ -25,7 +25,7 @@ LL | static b: RefCell<HashMap<i32, Vec<Vec<&'static Bar<'static, 'static>>> | +++++++ ++++++++++++++++++ error[E0106]: missing lifetime specifiers - --> $DIR/missing-lifetime-specifier.rs:36:47 + --> $DIR/missing-lifetime-specifier.rs:35:47 | LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<i32>>>>> = RefCell::new(HashMap::new()); | ^ expected 2 lifetime parameters @@ -37,7 +37,7 @@ LL | static c: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = | +++++++++++++++++ error[E0106]: missing lifetime specifiers - --> $DIR/missing-lifetime-specifier.rs:40:44 + --> $DIR/missing-lifetime-specifier.rs:39:44 | LL | static d: RefCell<HashMap<i32, Vec<Vec<&Tar<i32>>>>> = RefCell::new(HashMap::new()); | ^ ^ expected 2 lifetime parameters @@ -51,7 +51,7 @@ LL | static d: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, 'static, i | +++++++ +++++++++++++++++ error[E0106]: missing lifetime specifier - --> $DIR/missing-lifetime-specifier.rs:49:44 + --> $DIR/missing-lifetime-specifier.rs:48:44 | LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^ expected named lifetime parameter @@ -63,7 +63,7 @@ LL | static f: RefCell<HashMap<i32, Vec<Vec<&'static Tar<'static, i32>>>>> = | +++++++ error[E0107]: union takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing-lifetime-specifier.rs:45:44 + --> $DIR/missing-lifetime-specifier.rs:44:44 | LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^^^ ------- supplied 1 lifetime argument @@ -71,7 +71,7 @@ LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, i32>>>>> = RefCell: | expected 2 lifetime arguments | note: union defined here, with 2 lifetime parameters: `'t`, `'k` - --> $DIR/missing-lifetime-specifier.rs:21:11 + --> $DIR/missing-lifetime-specifier.rs:20:11 | LL | pub union Qux<'t, 'k, I> { | ^^^ -- -- @@ -81,7 +81,7 @@ LL | static e: RefCell<HashMap<i32, Vec<Vec<Qux<'static, 'static, i32>>>>> = | +++++++++ error[E0107]: trait takes 2 lifetime arguments but 1 lifetime argument was supplied - --> $DIR/missing-lifetime-specifier.rs:49:45 + --> $DIR/missing-lifetime-specifier.rs:48:45 | LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell::new(HashMap::new()); | ^^^ ------- supplied 1 lifetime argument @@ -89,7 +89,7 @@ LL | static f: RefCell<HashMap<i32, Vec<Vec<&Tar<'static, i32>>>>> = RefCell | expected 2 lifetime arguments | note: trait defined here, with 2 lifetime parameters: `'t`, `'k` - --> $DIR/missing-lifetime-specifier.rs:25:7 + --> $DIR/missing-lifetime-specifier.rs:24:7 | LL | trait Tar<'t, 'k, I> {} | ^^^ -- -- diff --git a/tests/ui/suggestions/suggest-null-ptr.stderr b/tests/ui/suggestions/suggest-null-ptr.stderr index 66a79d0749e..a811d6d19c7 100644 --- a/tests/ui/suggestions/suggest-null-ptr.stderr +++ b/tests/ui/suggestions/suggest-null-ptr.stderr @@ -12,7 +12,7 @@ note: function defined here --> $DIR/suggest-null-ptr.rs:7:8 | LL | fn foo(ptr: *const u8); - | ^^^ + | ^^^ --- help: if you meant to create a null pointer, use `std::ptr::null()` | LL | foo(std::ptr::null()); @@ -32,7 +32,7 @@ note: function defined here --> $DIR/suggest-null-ptr.rs:9:8 | LL | fn foo_mut(ptr: *mut u8); - | ^^^^^^^ + | ^^^^^^^ --- help: if you meant to create a null pointer, use `std::ptr::null_mut()` | LL | foo_mut(std::ptr::null_mut()); @@ -52,7 +52,7 @@ note: function defined here --> $DIR/suggest-null-ptr.rs:11:8 | LL | fn usize(ptr: *const usize); - | ^^^^^ + | ^^^^^ --- help: if you meant to create a null pointer, use `std::ptr::null()` | LL | usize(std::ptr::null()); @@ -72,7 +72,7 @@ note: function defined here --> $DIR/suggest-null-ptr.rs:13:8 | LL | fn usize_mut(ptr: *mut usize); - | ^^^^^^^^^ + | ^^^^^^^^^ --- help: if you meant to create a null pointer, use `std::ptr::null_mut()` | LL | usize_mut(std::ptr::null_mut()); diff --git a/tests/ui/suggestions/suggest-std-when-using-type.fixed b/tests/ui/suggestions/suggest-std-when-using-type.fixed index ebbb854175b..0547940f94d 100644 --- a/tests/ui/suggestions/suggest-std-when-using-type.fixed +++ b/tests/ui/suggestions/suggest-std-when-using-type.fixed @@ -1,8 +1,5 @@ //@ run-rustfix fn main() { let pi = std::f32::consts::PI; //~ ERROR ambiguous associated type - let bytes = "hello world".as_bytes(); - let string = std::str::from_utf8(bytes).unwrap(); - //~^ ERROR no function or associated item named `from_utf8` found - println!("{pi} {bytes:?} {string}"); + println!("{pi}"); } diff --git a/tests/ui/suggestions/suggest-std-when-using-type.rs b/tests/ui/suggestions/suggest-std-when-using-type.rs index 06aab63d688..cd55c5d13bd 100644 --- a/tests/ui/suggestions/suggest-std-when-using-type.rs +++ b/tests/ui/suggestions/suggest-std-when-using-type.rs @@ -1,8 +1,5 @@ //@ run-rustfix fn main() { let pi = f32::consts::PI; //~ ERROR ambiguous associated type - let bytes = "hello world".as_bytes(); - let string = str::from_utf8(bytes).unwrap(); - //~^ ERROR no function or associated item named `from_utf8` found - println!("{pi} {bytes:?} {string}"); + println!("{pi}"); } diff --git a/tests/ui/suggestions/suggest-std-when-using-type.stderr b/tests/ui/suggestions/suggest-std-when-using-type.stderr index 6f890b87b24..7f8545f461d 100644 --- a/tests/ui/suggestions/suggest-std-when-using-type.stderr +++ b/tests/ui/suggestions/suggest-std-when-using-type.stderr @@ -9,18 +9,6 @@ help: you are looking for the module in `std`, not the primitive type LL | let pi = std::f32::consts::PI; | +++++ -error[E0599]: no function or associated item named `from_utf8` found for type `str` in the current scope - --> $DIR/suggest-std-when-using-type.rs:5:23 - | -LL | let string = str::from_utf8(bytes).unwrap(); - | ^^^^^^^^^ function or associated item not found in `str` - | -help: you are looking for the module in `std`, not the primitive type - | -LL | let string = std::str::from_utf8(bytes).unwrap(); - | +++++ - -error: aborting due to 2 previous errors +error: aborting due to 1 previous error -Some errors have detailed explanations: E0223, E0599. -For more information about an error, try `rustc --explain E0223`. +For more information about this error, try `rustc --explain E0223`. diff --git a/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr b/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr index 980c2455c8e..df59a28c4b9 100644 --- a/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr +++ b/tests/ui/suggestions/trait-with-missing-associated-type-restriction.stderr @@ -94,7 +94,7 @@ note: method defined here --> $DIR/trait-with-missing-associated-type-restriction.rs:9:8 | LL | fn funk(&self, _: Self::A); - | ^^^^ + | ^^^^ - help: consider constraining the associated type `<T as Trait<i32>>::A` to `{integer}` | LL | fn bar2<T: Trait<i32, A = {integer}>>(x: T) { diff --git a/tests/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr b/tests/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr index 8b48ee9f124..c0162ec2cab 100644 --- a/tests/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr +++ b/tests/ui/suggestions/unnecessary_dot_for_floating_point_literal.stderr @@ -22,7 +22,7 @@ LL | let _: f64 = 1..; | expected due to this | = note: expected type `f64` - found struct `RangeFrom<{integer}>` + found struct `std::ops::RangeFrom<{integer}>` help: remove the unnecessary `.` operator for a floating point literal | LL | let _: f64 = 1.; diff --git a/tests/ui/tail-cps.rs b/tests/ui/tail-cps.rs index 6305e9ecdbc..fe99dadf795 100644 --- a/tests/ui/tail-cps.rs +++ b/tests/ui/tail-cps.rs @@ -1,6 +1,6 @@ //@ run-pass -fn checktrue(rs: bool) -> bool { assert!((rs)); return true; } +fn checktrue(rs: bool) -> bool { assert!(rs); return true; } pub fn main() { let k = checktrue; evenk(42, k); oddk(45, k); } diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.rs index dab01179c0b..215e64979f7 100644 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.rs +++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.rs @@ -1,3 +1,4 @@ +//! Ensure ABI-incompatible features cannot be enabled via `#[target_feature]`. //@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib //@ needs-llvm-components: riscv #![feature(no_core, lang_items, riscv_target_feature)] diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.stderr b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.stderr index 9df56d86729..bfe767e5ffb 100644 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.stderr +++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-attribute.stderr @@ -1,5 +1,5 @@ error: target feature `d` cannot be enabled with `#[target_feature]`: this feature is incompatible with the target ABI - --> $DIR/forbidden-hardfloat-target-feature-attribute.rs:9:18 + --> $DIR/forbidden-hardfloat-target-feature-attribute.rs:10:18 | LL | #[target_feature(enable = "d")] | ^^^^^^^^^^^^ diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-cfg.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-cfg.rs deleted file mode 100644 index 8755791c1c0..00000000000 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-cfg.rs +++ /dev/null @@ -1,14 +0,0 @@ -//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib -//@ needs-llvm-components: x86 -//@ check-pass -#![feature(no_core, lang_items)] -#![no_core] -#![allow(unexpected_cfgs)] - -#[lang = "sized"] -pub trait Sized {} - -// The compile_error macro does not exist, so if the `cfg` evaluates to `true` this -// complains about the missing macro rather than showing the error... but that's good enough. -#[cfg(not(target_feature = "x87"))] -compile_error!("the x87 feature *should* be exposed in `cfg`"); diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-implied.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-implied.rs index 3d09217327a..81f138b175f 100644 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-implied.rs +++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-implied.rs @@ -1,8 +1,11 @@ +//! Ensure that if disabling a target feature implies disabling an ABI-required target feature, +//! we complain. //@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib //@ needs-llvm-components: x86 //@ compile-flags: -Ctarget-feature=-sse // For now this is just a warning. //@ build-pass +//@error-pattern: must be enabled to ensure that the ABI #![feature(no_core, lang_items)] #![no_core] diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-neon.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-neon.rs index 95c366bb3f5..7242bcc85bf 100644 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-neon.rs +++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable-neon.rs @@ -3,6 +3,7 @@ //@ compile-flags: -Ctarget-feature=-neon // For now this is just a warning. //@ build-pass +//@error-pattern: must be enabled to ensure that the ABI #![feature(no_core, lang_items)] #![no_core] diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable.rs index fd8023664da..7eebcf05dc0 100644 --- a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable.rs +++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag-disable.rs @@ -1,8 +1,10 @@ +//! Ensure ABI-required features cannot be disabled via `-Ctarget-feature`. //@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib //@ needs-llvm-components: x86 //@ compile-flags: -Ctarget-feature=-x87 // For now this is just a warning. //@ build-pass +//@error-pattern: must be enabled to ensure that the ABI #![feature(no_core, lang_items)] #![no_core] diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag.rs b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag.rs new file mode 100644 index 00000000000..f277a309cd6 --- /dev/null +++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag.rs @@ -0,0 +1,12 @@ +//! Ensure ABI-incompatible features cannot be enabled via `-Ctarget-feature`. +//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib +//@ needs-llvm-components: x86 +//@ compile-flags: -Ctarget-feature=+soft-float +// For now this is just a warning. +//@ build-pass +//@error-pattern: must be disabled to ensure that the ABI +#![feature(no_core, lang_items, riscv_target_feature)] +#![no_core] + +#[lang = "sized"] +pub trait Sized {} diff --git a/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag.stderr b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag.stderr new file mode 100644 index 00000000000..e49672f33b9 --- /dev/null +++ b/tests/ui/target-feature/forbidden-hardfloat-target-feature-flag.stderr @@ -0,0 +1,11 @@ +warning: target feature `soft-float` must be disabled to ensure that the ABI of the current target can be implemented correctly + | + = note: 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 #116344 <https://github.com/rust-lang/rust/issues/116344> + +warning: unstable feature specified for `-Ctarget-feature`: `soft-float` + | + = note: this feature is not stably supported; its behavior can change in the future + +warning: 2 warnings emitted + diff --git a/tests/ui/target-feature/forbidden-target-feature-attribute.rs b/tests/ui/target-feature/forbidden-target-feature-attribute.rs index 2ba5f2215c7..6bb6f8aaffb 100644 --- a/tests/ui/target-feature/forbidden-target-feature-attribute.rs +++ b/tests/ui/target-feature/forbidden-target-feature-attribute.rs @@ -1,11 +1,12 @@ -//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib -//@ needs-llvm-components: x86 +//! Ensure "forbidden" target features cannot be enabled via `#[target_feature]`. +//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib +//@ needs-llvm-components: riscv #![feature(no_core, lang_items)] #![no_core] #[lang = "sized"] pub trait Sized {} -#[target_feature(enable = "soft-float")] +#[target_feature(enable = "forced-atomics")] //~^ERROR: cannot be enabled with pub unsafe fn my_fun() {} diff --git a/tests/ui/target-feature/forbidden-target-feature-attribute.stderr b/tests/ui/target-feature/forbidden-target-feature-attribute.stderr index f3d54cc19d3..f8ea0c0e793 100644 --- a/tests/ui/target-feature/forbidden-target-feature-attribute.stderr +++ b/tests/ui/target-feature/forbidden-target-feature-attribute.stderr @@ -1,8 +1,8 @@ -error: target feature `soft-float` cannot be enabled with `#[target_feature]`: unsound because it changes float ABI - --> $DIR/forbidden-target-feature-attribute.rs:9:18 +error: target feature `forced-atomics` cannot be enabled with `#[target_feature]`: unsound because it changes the ABI of atomic operations + --> $DIR/forbidden-target-feature-attribute.rs:10:18 | -LL | #[target_feature(enable = "soft-float")] - | ^^^^^^^^^^^^^^^^^^^^^ +LL | #[target_feature(enable = "forced-atomics")] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ error: aborting due to 1 previous error diff --git a/tests/ui/target-feature/forbidden-target-feature-cfg.rs b/tests/ui/target-feature/forbidden-target-feature-cfg.rs index 1f001e9f8ff..e848ffde018 100644 --- a/tests/ui/target-feature/forbidden-target-feature-cfg.rs +++ b/tests/ui/target-feature/forbidden-target-feature-cfg.rs @@ -1,5 +1,6 @@ -//@ compile-flags: --target=x86_64-unknown-none --crate-type=lib -//@ needs-llvm-components: x86 +//! Ensure "forbidden" target features are not exposed via `cfg`. +//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib +//@ needs-llvm-components: riscv //@ check-pass #![feature(no_core, lang_items)] #![no_core] @@ -10,5 +11,5 @@ pub trait Sized {} // The compile_error macro does not exist, so if the `cfg` evaluates to `true` this // complains about the missing macro rather than showing the error... but that's good enough. -#[cfg(target_feature = "soft-float")] -compile_error!("the soft-float feature should not be exposed in `cfg`"); +#[cfg(target_feature = "forced-atomics")] +compile_error!("the forced-atomics feature should not be exposed in `cfg`"); diff --git a/tests/ui/target-feature/forbidden-target-feature-flag-disable.rs b/tests/ui/target-feature/forbidden-target-feature-flag-disable.rs index b09c53bd46a..cf85c521228 100644 --- a/tests/ui/target-feature/forbidden-target-feature-flag-disable.rs +++ b/tests/ui/target-feature/forbidden-target-feature-flag-disable.rs @@ -1,8 +1,10 @@ -//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib -//@ needs-llvm-components: x86 -//@ compile-flags: -Ctarget-feature=-soft-float +//! Ensure "forbidden" target features cannot be disabled via `-Ctarget-feature`. +//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib +//@ needs-llvm-components: riscv +//@ compile-flags: -Ctarget-feature=-forced-atomics // For now this is just a warning. //@ build-pass +//@error-pattern: unsound because it changes the ABI #![feature(no_core, lang_items)] #![no_core] diff --git a/tests/ui/target-feature/forbidden-target-feature-flag-disable.stderr b/tests/ui/target-feature/forbidden-target-feature-flag-disable.stderr index 797cd4be5c2..171ed0de6aa 100644 --- a/tests/ui/target-feature/forbidden-target-feature-flag-disable.stderr +++ b/tests/ui/target-feature/forbidden-target-feature-flag-disable.stderr @@ -1,4 +1,4 @@ -warning: target feature `soft-float` cannot be disabled with `-Ctarget-feature`: unsound because it changes float ABI +warning: target feature `forced-atomics` cannot be disabled with `-Ctarget-feature`: unsound because it changes the ABI of atomic operations | = note: 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 #116344 <https://github.com/rust-lang/rust/issues/116344> diff --git a/tests/ui/target-feature/forbidden-target-feature-flag.rs b/tests/ui/target-feature/forbidden-target-feature-flag.rs index 0f688fde7f4..245841eb039 100644 --- a/tests/ui/target-feature/forbidden-target-feature-flag.rs +++ b/tests/ui/target-feature/forbidden-target-feature-flag.rs @@ -1,8 +1,10 @@ -//@ compile-flags: --target=x86_64-unknown-linux-gnu --crate-type=lib -//@ needs-llvm-components: x86 -//@ compile-flags: -Ctarget-feature=+soft-float +//! Ensure "forbidden" target features cannot be enabled via `-Ctarget-feature`. +//@ compile-flags: --target=riscv32e-unknown-none-elf --crate-type=lib +//@ needs-llvm-components: riscv +//@ compile-flags: -Ctarget-feature=+forced-atomics // For now this is just a warning. //@ build-pass +//@error-pattern: unsound because it changes the ABI #![feature(no_core, lang_items)] #![no_core] diff --git a/tests/ui/target-feature/forbidden-target-feature-flag.stderr b/tests/ui/target-feature/forbidden-target-feature-flag.stderr index 075666fbf66..f8490f066d1 100644 --- a/tests/ui/target-feature/forbidden-target-feature-flag.stderr +++ b/tests/ui/target-feature/forbidden-target-feature-flag.stderr @@ -1,4 +1,4 @@ -warning: target feature `soft-float` cannot be enabled with `-Ctarget-feature`: unsound because it changes float ABI +warning: target feature `forced-atomics` cannot be enabled with `-Ctarget-feature`: unsound because it changes the ABI of atomic operations | = note: 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 #116344 <https://github.com/rust-lang/rust/issues/116344> diff --git a/tests/ui/test-attrs/test-panic-abort-disabled.rs b/tests/ui/test-attrs/test-panic-abort-disabled.rs index 05dd9395c2b..e83be65f925 100644 --- a/tests/ui/test-attrs/test-panic-abort-disabled.rs +++ b/tests/ui/test-attrs/test-panic-abort-disabled.rs @@ -4,8 +4,6 @@ //@ run-flags: --test-threads=1 //@ needs-unwind -//@ ignore-wasm no panic support -//@ ignore-emscripten no panic support //@ needs-subprocess #![cfg(test)] diff --git a/tests/ui/test-attrs/test-panic-abort-nocapture.rs b/tests/ui/test-attrs/test-panic-abort-nocapture.rs index f7e15dbdbc3..6a1025ea087 100644 --- a/tests/ui/test-attrs/test-panic-abort-nocapture.rs +++ b/tests/ui/test-attrs/test-panic-abort-nocapture.rs @@ -7,8 +7,6 @@ //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" //@ ignore-android #120567 -//@ ignore-wasm no panic support -//@ ignore-emscripten no panic support //@ needs-subprocess #![cfg(test)] diff --git a/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr b/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr index 25681171170..b9f267838b1 100644 --- a/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr +++ b/tests/ui/test-attrs/test-panic-abort-nocapture.run.stderr @@ -1,11 +1,11 @@ -thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:34:5: +thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:32:5: assertion `left == right` failed left: 2 right: 4 note: run with `RUST_BACKTRACE=1` environment variable to display a backtrace -thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:28:5: +thread 'main' panicked at $DIR/test-panic-abort-nocapture.rs:26:5: assertion `left == right` failed left: 2 right: 4 diff --git a/tests/ui/test-attrs/test-panic-abort.rs b/tests/ui/test-attrs/test-panic-abort.rs index 951cf54346b..6c9b641fb6f 100644 --- a/tests/ui/test-attrs/test-panic-abort.rs +++ b/tests/ui/test-attrs/test-panic-abort.rs @@ -7,8 +7,6 @@ //@ normalize-stdout: "finished in \d+\.\d+s" -> "finished in $$TIME" //@ ignore-android #120567 -//@ ignore-wasm no panic support -//@ ignore-emscripten no panic support //@ needs-subprocess #![cfg(test)] diff --git a/tests/ui/test-attrs/test-panic-abort.run.stdout b/tests/ui/test-attrs/test-panic-abort.run.stdout index 844808e8637..0faa7f0dfce 100644 --- a/tests/ui/test-attrs/test-panic-abort.run.stdout +++ b/tests/ui/test-attrs/test-panic-abort.run.stdout @@ -18,7 +18,7 @@ testing123 ---- it_fails stderr ---- testing321 -thread 'main' panicked at $DIR/test-panic-abort.rs:39:5: +thread 'main' panicked at $DIR/test-panic-abort.rs:37:5: assertion `left == right` failed left: 2 right: 5 diff --git a/tests/ui/threads-sendsync/spawning-with-debug.rs b/tests/ui/threads-sendsync/spawning-with-debug.rs index 90a81c1e53b..3b7107e2dbf 100644 --- a/tests/ui/threads-sendsync/spawning-with-debug.rs +++ b/tests/ui/threads-sendsync/spawning-with-debug.rs @@ -1,7 +1,6 @@ //@ run-pass #![allow(unused_must_use)] #![allow(unused_mut)] -//@ ignore-windows //@ exec-env:RUST_LOG=debug //@ needs-threads diff --git a/tests/ui/threads-sendsync/thread-local-extern-static.rs b/tests/ui/threads-sendsync/thread-local-extern-static.rs index ca66f8ad1d3..ce2a221ec2e 100644 --- a/tests/ui/threads-sendsync/thread-local-extern-static.rs +++ b/tests/ui/threads-sendsync/thread-local-extern-static.rs @@ -1,5 +1,5 @@ //@ run-pass -//@ ignore-windows +//@ ignore-windows FIXME(134939): thread_local + no_mangle doesn't work on Windows //@ aux-build:thread-local-extern-static.rs #![feature(cfg_target_thread_local, thread_local)] diff --git a/tests/ui/issues/issue-40827.rs b/tests/ui/trait-bounds/deep-level-Send-bound-check-issue-40827.rs index 6e42c506169..6e42c506169 100644 --- a/tests/ui/issues/issue-40827.rs +++ b/tests/ui/trait-bounds/deep-level-Send-bound-check-issue-40827.rs diff --git a/tests/ui/issues/issue-40827.stderr b/tests/ui/trait-bounds/deep-level-Send-bound-check-issue-40827.stderr index 7f5c578ae4f..7b59fe72f43 100644 --- a/tests/ui/issues/issue-40827.stderr +++ b/tests/ui/trait-bounds/deep-level-Send-bound-check-issue-40827.stderr @@ -1,5 +1,5 @@ error[E0277]: `Rc<Foo>` cannot be shared between threads safely - --> $DIR/issue-40827.rs:14:7 + --> $DIR/deep-level-Send-bound-check-issue-40827.rs:14:7 | LL | f(Foo(Arc::new(Bar::B(None)))); | - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Rc<Foo>` cannot be shared between threads safely @@ -8,24 +8,24 @@ LL | f(Foo(Arc::new(Bar::B(None)))); | = help: within `Bar`, the trait `Sync` is not implemented for `Rc<Foo>` note: required because it appears within the type `Bar` - --> $DIR/issue-40827.rs:6:6 + --> $DIR/deep-level-Send-bound-check-issue-40827.rs:6:6 | LL | enum Bar { | ^^^ = note: required for `Arc<Bar>` to implement `Send` note: required because it appears within the type `Foo` - --> $DIR/issue-40827.rs:4:8 + --> $DIR/deep-level-Send-bound-check-issue-40827.rs:4:8 | LL | struct Foo(Arc<Bar>); | ^^^ note: required by a bound in `f` - --> $DIR/issue-40827.rs:11:9 + --> $DIR/deep-level-Send-bound-check-issue-40827.rs:11:9 | LL | fn f<T: Send>(_: T) {} | ^^^^ required by this bound in `f` error[E0277]: `Rc<Foo>` cannot be sent between threads safely - --> $DIR/issue-40827.rs:14:7 + --> $DIR/deep-level-Send-bound-check-issue-40827.rs:14:7 | LL | f(Foo(Arc::new(Bar::B(None)))); | - ^^^^^^^^^^^^^^^^^^^^^^^^^^^ `Rc<Foo>` cannot be sent between threads safely @@ -34,18 +34,18 @@ LL | f(Foo(Arc::new(Bar::B(None)))); | = help: within `Bar`, the trait `Send` is not implemented for `Rc<Foo>` note: required because it appears within the type `Bar` - --> $DIR/issue-40827.rs:6:6 + --> $DIR/deep-level-Send-bound-check-issue-40827.rs:6:6 | LL | enum Bar { | ^^^ = note: required for `Arc<Bar>` to implement `Send` note: required because it appears within the type `Foo` - --> $DIR/issue-40827.rs:4:8 + --> $DIR/deep-level-Send-bound-check-issue-40827.rs:4:8 | LL | struct Foo(Arc<Bar>); | ^^^ note: required by a bound in `f` - --> $DIR/issue-40827.rs:11:9 + --> $DIR/deep-level-Send-bound-check-issue-40827.rs:11:9 | LL | fn f<T: Send>(_: T) {} | ^^^^ required by this bound in `f` diff --git a/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.rs b/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.rs index c3a2ab82adc..5277de29464 100644 --- a/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.rs +++ b/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.rs @@ -8,7 +8,6 @@ type Fn = dyn FnOnce() -> u8; const TEST: Fn = some_fn; //~^ ERROR cannot find value `some_fn` in this scope //~| ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time -//~| ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time const TEST2: (Fn, u8) = (TEST, 0); //~^ ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time //~| ERROR the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time diff --git a/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.stderr b/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.stderr index 0e92979ccd5..76e015a7238 100644 --- a/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.stderr +++ b/tests/ui/trait-bounds/ice-unsized-tuple-const-issue-121443.stderr @@ -13,16 +13,7 @@ LL | const TEST: Fn = some_fn; = help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)` error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time - --> $DIR/ice-unsized-tuple-const-issue-121443.rs:8:18 - | -LL | const TEST: Fn = some_fn; - | ^^^^^^^ doesn't have a size known at compile-time - | - = help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)` - = note: constant expressions must have a statically known size - -error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time - --> $DIR/ice-unsized-tuple-const-issue-121443.rs:12:14 + --> $DIR/ice-unsized-tuple-const-issue-121443.rs:11:14 | LL | const TEST2: (Fn, u8) = (TEST, 0); | ^^^^^^^^ doesn't have a size known at compile-time @@ -31,7 +22,7 @@ LL | const TEST2: (Fn, u8) = (TEST, 0); = note: only the last element of a tuple may have a dynamically sized type error[E0277]: the size for values of type `(dyn FnOnce() -> u8 + 'static)` cannot be known at compilation time - --> $DIR/ice-unsized-tuple-const-issue-121443.rs:12:25 + --> $DIR/ice-unsized-tuple-const-issue-121443.rs:11:25 | LL | const TEST2: (Fn, u8) = (TEST, 0); | ^^^^^^^^^ doesn't have a size known at compile-time @@ -39,7 +30,7 @@ LL | const TEST2: (Fn, u8) = (TEST, 0); = help: the trait `Sized` is not implemented for `(dyn FnOnce() -> u8 + 'static)` = note: only the last element of a tuple may have a dynamically sized type -error: aborting due to 5 previous errors +error: aborting due to 4 previous errors Some errors have detailed explanations: E0277, E0425. For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/traits/const-traits/span-bug-issue-121418.stderr b/tests/ui/traits/const-traits/span-bug-issue-121418.stderr index f41c19b4573..92cfecd0540 100644 --- a/tests/ui/traits/const-traits/span-bug-issue-121418.stderr +++ b/tests/ui/traits/const-traits/span-bug-issue-121418.stderr @@ -8,17 +8,6 @@ LL | impl const dyn T { | = note: only trait implementations may be annotated with `const` -error[E0308]: mismatched types - --> $DIR/span-bug-issue-121418.rs:8:27 - | -LL | pub const fn new() -> std::sync::Mutex<dyn T> {} - | --- ^^^^^^^^^^^^^^^^^^^^^^^ expected `Mutex<dyn T>`, found `()` - | | - | implicitly returns `()` as its body has no tail or `return` expression - | - = note: expected struct `Mutex<(dyn T + 'static)>` - found unit type `()` - error[E0277]: the size for values of type `(dyn T + 'static)` cannot be known at compilation time --> $DIR/span-bug-issue-121418.rs:8:27 | @@ -30,6 +19,17 @@ note: required because it appears within the type `Mutex<(dyn T + 'static)>` --> $SRC_DIR/std/src/sync/poison/mutex.rs:LL:COL = note: the return type of a function must have a statically known size +error[E0308]: mismatched types + --> $DIR/span-bug-issue-121418.rs:8:27 + | +LL | pub const fn new() -> std::sync::Mutex<dyn T> {} + | --- ^^^^^^^^^^^^^^^^^^^^^^^ expected `Mutex<dyn T>`, found `()` + | | + | implicitly returns `()` as its body has no tail or `return` expression + | + = note: expected struct `Mutex<(dyn T + 'static)>` + found unit type `()` + error: aborting due to 3 previous errors Some errors have detailed explanations: E0277, E0308. diff --git a/tests/ui/traits/issue-52893.stderr b/tests/ui/traits/issue-52893.stderr index c37dde90e33..3c5df82fcdc 100644 --- a/tests/ui/traits/issue-52893.stderr +++ b/tests/ui/traits/issue-52893.stderr @@ -22,7 +22,7 @@ note: method defined here --> $DIR/issue-52893.rs:11:8 | LL | fn push(self, other: T) -> Self::PushRes; - | ^^^^ + | ^^^^ ----- error: aborting due to 1 previous error diff --git a/tests/ui/traits/issue-77982.rs b/tests/ui/traits/issue-77982.rs index dce25e62e46..b2a488e18e8 100644 --- a/tests/ui/traits/issue-77982.rs +++ b/tests/ui/traits/issue-77982.rs @@ -1,5 +1,6 @@ -//@ ignore-windows different list of satisfying impls -//@ ignore-arm different list of satisfying impls +//@ ignore-windows FIXME: We get an extra E0283 on Windows +//@ ignore-arm extra satisfying impls + use std::collections::HashMap; fn what() { diff --git a/tests/ui/traits/issue-77982.stderr b/tests/ui/traits/issue-77982.stderr index 2b26a1b7ab1..4907a6dd17a 100644 --- a/tests/ui/traits/issue-77982.stderr +++ b/tests/ui/traits/issue-77982.stderr @@ -1,5 +1,5 @@ error[E0283]: type annotations needed - --> $DIR/issue-77982.rs:10:10 + --> $DIR/issue-77982.rs:11:10 | LL | opts.get(opt.as_ref()); | ^^^ ------------ type must be known at this point @@ -18,7 +18,7 @@ LL | opts.get::<Q>(opt.as_ref()); | +++++ error[E0283]: type annotations needed - --> $DIR/issue-77982.rs:10:10 + --> $DIR/issue-77982.rs:11:10 | LL | opts.get(opt.as_ref()); | ^^^ ------ type must be known at this point @@ -36,7 +36,7 @@ LL | opts.get::<Q>(opt.as_ref()); | +++++ error[E0283]: type annotations needed - --> $DIR/issue-77982.rs:15:59 + --> $DIR/issue-77982.rs:16:59 | LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(0u32.into())).collect(); | --- ^^^^ @@ -56,13 +56,13 @@ LL | let ips: Vec<_> = (0..100_000).map(|_| u32::from(<u32 as Into<T>>::into | +++++++++++++++++++++++ ~ error[E0283]: type annotations needed for `Box<_>` - --> $DIR/issue-77982.rs:38:9 + --> $DIR/issue-77982.rs:39:9 | LL | let _ = ().foo(); | ^ --- type must be known at this point | note: multiple `impl`s satisfying `(): Foo<'_, _>` found - --> $DIR/issue-77982.rs:31:1 + --> $DIR/issue-77982.rs:32:1 | LL | impl Foo<'static, u32> for () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ @@ -74,13 +74,13 @@ LL | let _: Box<T> = ().foo(); | ++++++++ error[E0283]: type annotations needed for `Box<_>` - --> $DIR/issue-77982.rs:42:9 + --> $DIR/issue-77982.rs:43:9 | LL | let _ = (&()).bar(); | ^ --- type must be known at this point | note: multiple `impl`s satisfying `&(): Bar<'_, _>` found - --> $DIR/issue-77982.rs:34:1 + --> $DIR/issue-77982.rs:35:1 | LL | impl<'a> Bar<'static, u32> for &'a () {} | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-bound.rs b/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-bound.rs index cbd591eec96..ea6df938704 100644 --- a/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-bound.rs +++ b/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-bound.rs @@ -13,8 +13,9 @@ fn main() { } fn weird0() -> impl Sized + !Sized {} -//~^ ERROR the trait bound `(): !Sized` is not satisfied +//~^ ERROR type mismatch resolving fn weird1() -> impl !Sized + Sized {} -//~^ ERROR the trait bound `(): !Sized` is not satisfied +//~^ ERROR type mismatch resolving fn weird2() -> impl !Sized {} -//~^ ERROR the trait bound `(): !Sized` is not satisfied +//~^ ERROR type mismatch resolving +//~| ERROR the size for values of type diff --git a/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-bound.stderr b/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-bound.stderr index 3dad6d534fd..41d9e74f807 100644 --- a/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-bound.stderr +++ b/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-bound.stderr @@ -1,20 +1,29 @@ -error[E0277]: the trait bound `(): !Sized` is not satisfied +error[E0277]: the size for values of type `impl !Sized` cannot be known at compilation time + --> $DIR/opaque-type-unsatisfied-bound.rs:19:16 + | +LL | fn weird2() -> impl !Sized {} + | ^^^^^^^^^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `impl !Sized` + = note: the return type of a function must have a statically known size + +error[E0271]: type mismatch resolving `impl !Sized + Sized == ()` --> $DIR/opaque-type-unsatisfied-bound.rs:15:16 | LL | fn weird0() -> impl Sized + !Sized {} - | ^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied + | ^^^^^^^^^^^^^^^^^^^ types differ -error[E0277]: the trait bound `(): !Sized` is not satisfied +error[E0271]: type mismatch resolving `impl !Sized + Sized == ()` --> $DIR/opaque-type-unsatisfied-bound.rs:17:16 | LL | fn weird1() -> impl !Sized + Sized {} - | ^^^^^^^^^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied + | ^^^^^^^^^^^^^^^^^^^ types differ -error[E0277]: the trait bound `(): !Sized` is not satisfied +error[E0271]: type mismatch resolving `impl !Sized == ()` --> $DIR/opaque-type-unsatisfied-bound.rs:19:16 | LL | fn weird2() -> impl !Sized {} - | ^^^^^^^^^^^ the trait bound `(): !Sized` is not satisfied + | ^^^^^^^^^^^ types differ error[E0277]: the trait bound `impl !Trait: Trait` is not satisfied --> $DIR/opaque-type-unsatisfied-bound.rs:12:13 @@ -30,6 +39,7 @@ note: required by a bound in `consume` LL | fn consume(_: impl Trait) {} | ^^^^^ required by this bound in `consume` -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors -For more information about this error, try `rustc --explain E0277`. +Some errors have detailed explanations: E0271, E0277. +For more information about an error, try `rustc --explain E0271`. diff --git a/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-fn-bound.rs b/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-fn-bound.rs index 39422914afc..ce42bce0ad4 100644 --- a/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-fn-bound.rs +++ b/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-fn-bound.rs @@ -3,6 +3,6 @@ #![feature(negative_bounds, unboxed_closures)] fn produce() -> impl !Fn<(u32,)> {} -//~^ ERROR the trait bound `(): !Fn(u32)` is not satisfied +//~^ ERROR type mismatch resolving fn main() {} diff --git a/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-fn-bound.stderr b/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-fn-bound.stderr index 760e5aa62f2..e1b84e0df7a 100644 --- a/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-fn-bound.stderr +++ b/tests/ui/traits/negative-bounds/opaque-type-unsatisfied-fn-bound.stderr @@ -1,9 +1,9 @@ -error[E0277]: the trait bound `(): !Fn(u32)` is not satisfied +error[E0271]: type mismatch resolving `impl !Fn<(u32,)> == ()` --> $DIR/opaque-type-unsatisfied-fn-bound.rs:5:17 | LL | fn produce() -> impl !Fn<(u32,)> {} - | ^^^^^^^^^^^^^^^^ the trait bound `(): !Fn(u32)` is not satisfied + | ^^^^^^^^^^^^^^^^ types differ error: aborting due to 1 previous error -For more information about this error, try `rustc --explain E0277`. +For more information about this error, try `rustc --explain E0271`. diff --git a/tests/ui/traits/next-solver/diagnostics/coerce-in-may-coerce.stderr b/tests/ui/traits/next-solver/diagnostics/coerce-in-may-coerce.stderr index 1938b3375a5..9c28f7b0792 100644 --- a/tests/ui/traits/next-solver/diagnostics/coerce-in-may-coerce.stderr +++ b/tests/ui/traits/next-solver/diagnostics/coerce-in-may-coerce.stderr @@ -10,7 +10,7 @@ note: function defined here --> $DIR/coerce-in-may-coerce.rs:12:4 | LL | fn arg_error(x: <fn() as Mirror>::Assoc, y: ()) { todo!() } - | ^^^^^^^^^ -------------------------- ----- + | ^^^^^^^^^ help: swap these arguments | LL | arg_error(|| (), ()); diff --git a/tests/ui/traits/next-solver/normalize/normalize-unsize-rhs.rs b/tests/ui/traits/next-solver/normalize/normalize-unsize-rhs.rs index dc5912b123a..bbf9bafde9f 100644 --- a/tests/ui/traits/next-solver/normalize/normalize-unsize-rhs.rs +++ b/tests/ui/traits/next-solver/normalize/normalize-unsize-rhs.rs @@ -1,6 +1,5 @@ //@ compile-flags: -Znext-solver //@ check-pass -#![feature(trait_upcasting)] trait A {} trait B: A {} diff --git a/tests/ui/traits/next-solver/specialization-transmute.rs b/tests/ui/traits/next-solver/specialization-transmute.rs index 9e31fed9b18..376fa22ae19 100644 --- a/tests/ui/traits/next-solver/specialization-transmute.rs +++ b/tests/ui/traits/next-solver/specialization-transmute.rs @@ -1,5 +1,4 @@ //@ compile-flags: -Znext-solver -//~^ ERROR cannot normalize `<T as Default>::Id: '_` #![feature(specialization)] //~^ WARN the feature `specialization` is incomplete @@ -14,6 +13,7 @@ impl<T> Default for T { // This will be fixed by #111994 fn intu(&self) -> &Self::Id { //~^ ERROR type annotations needed + //~| ERROR cannot normalize `<T as Default>::Id: '_` self //~ ERROR cannot satisfy } } diff --git a/tests/ui/traits/next-solver/specialization-transmute.stderr b/tests/ui/traits/next-solver/specialization-transmute.stderr index 2d0c503bc95..eeb101911c4 100644 --- a/tests/ui/traits/next-solver/specialization-transmute.stderr +++ b/tests/ui/traits/next-solver/specialization-transmute.stderr @@ -1,5 +1,5 @@ warning: the feature `specialization` is incomplete and may not be safe to use and/or cause compiler crashes - --> $DIR/specialization-transmute.rs:3:12 + --> $DIR/specialization-transmute.rs:2:12 | LL | #![feature(specialization)] | ^^^^^^^^^^^^^^ @@ -9,9 +9,13 @@ LL | #![feature(specialization)] = note: `#[warn(incomplete_features)]` on by default error: cannot normalize `<T as Default>::Id: '_` + --> $DIR/specialization-transmute.rs:14:5 + | +LL | fn intu(&self) -> &Self::Id { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^ error[E0282]: type annotations needed - --> $DIR/specialization-transmute.rs:15:23 + --> $DIR/specialization-transmute.rs:14:23 | LL | fn intu(&self) -> &Self::Id { | ^^^^^^^^^ cannot infer type for reference `&<T as Default>::Id` diff --git a/tests/ui/traits/next-solver/trait-upcast-lhs-needs-normalization.rs b/tests/ui/traits/next-solver/trait-upcast-lhs-needs-normalization.rs index ee6a7a0986d..c6094b45775 100644 --- a/tests/ui/traits/next-solver/trait-upcast-lhs-needs-normalization.rs +++ b/tests/ui/traits/next-solver/trait-upcast-lhs-needs-normalization.rs @@ -1,6 +1,5 @@ //@ check-pass //@ compile-flags: -Znext-solver -#![feature(trait_upcasting)] pub trait A {} pub trait B: A {} diff --git a/tests/ui/traits/next-solver/unsound-region-obligation.rs b/tests/ui/traits/next-solver/unsound-region-obligation.rs index 733be204354..e7fa60a2e3f 100644 --- a/tests/ui/traits/next-solver/unsound-region-obligation.rs +++ b/tests/ui/traits/next-solver/unsound-region-obligation.rs @@ -1,4 +1,3 @@ -//~ ERROR the type `&'a ()` does not fulfill the required lifetime //@ compile-flags: -Znext-solver // Regression test for rust-lang/trait-system-refactor-initiative#59 @@ -8,6 +7,7 @@ trait StaticTy { impl StaticTy for () { type Item<'a> = &'a (); + //~^ ERROR the type `&'a ()` does not fulfill the required lifetime } fn main() {} diff --git a/tests/ui/traits/next-solver/unsound-region-obligation.stderr b/tests/ui/traits/next-solver/unsound-region-obligation.stderr index fe96a184f43..dea3b62334c 100644 --- a/tests/ui/traits/next-solver/unsound-region-obligation.stderr +++ b/tests/ui/traits/next-solver/unsound-region-obligation.stderr @@ -1,4 +1,8 @@ error[E0477]: the type `&'a ()` does not fulfill the required lifetime + --> $DIR/unsound-region-obligation.rs:9:21 + | +LL | type Item<'a> = &'a (); + | ^^^^^^ | = note: type must satisfy the static lifetime diff --git a/tests/ui/traits/next-solver/upcast-right-substs.rs b/tests/ui/traits/next-solver/upcast-right-substs.rs index bbb8a039aa7..7a566b59b83 100644 --- a/tests/ui/traits/next-solver/upcast-right-substs.rs +++ b/tests/ui/traits/next-solver/upcast-right-substs.rs @@ -1,6 +1,5 @@ //@ compile-flags: -Znext-solver //@ check-pass -#![feature(trait_upcasting)] trait Foo: Bar<i32> + Bar<u32> {} diff --git a/tests/ui/traits/trait-upcasting/add-supertrait-auto-traits.rs b/tests/ui/traits/trait-upcasting/add-supertrait-auto-traits.rs index ffc21a4a9ea..5b22fce6311 100644 --- a/tests/ui/traits/trait-upcasting/add-supertrait-auto-traits.rs +++ b/tests/ui/traits/trait-upcasting/add-supertrait-auto-traits.rs @@ -3,8 +3,6 @@ //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -#![feature(trait_upcasting)] - trait Target {} trait Source: Send + Target {} diff --git a/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.rs b/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.rs index 4a5e445d1ef..927a9d6b94f 100644 --- a/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.rs +++ b/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.rs @@ -1,4 +1,3 @@ -#![feature(trait_upcasting)] #![feature(trait_alias)] // Although we *elaborate* `T: Alias` to `i32: B`, we should diff --git a/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.stderr b/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.stderr index 99c82b88d9c..1a410519a4e 100644 --- a/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.stderr +++ b/tests/ui/traits/trait-upcasting/alias-where-clause-isnt-supertrait.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/alias-where-clause-isnt-supertrait.rs:27:5 + --> $DIR/alias-where-clause-isnt-supertrait.rs:26:5 | LL | fn test(x: &dyn C) -> &dyn B { | ------ expected `&dyn B` because of return type diff --git a/tests/ui/traits/trait-upcasting/basic.rs b/tests/ui/traits/trait-upcasting/basic.rs index 9b9669565ba..0a8d16a42dd 100644 --- a/tests/ui/traits/trait-upcasting/basic.rs +++ b/tests/ui/traits/trait-upcasting/basic.rs @@ -1,7 +1,5 @@ //@ run-pass -#![feature(trait_upcasting)] - trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { 10 diff --git a/tests/ui/traits/trait-upcasting/correct-supertrait-substitution.rs b/tests/ui/traits/trait-upcasting/correct-supertrait-substitution.rs index 7f4343dbd2f..0a02784f29c 100644 --- a/tests/ui/traits/trait-upcasting/correct-supertrait-substitution.rs +++ b/tests/ui/traits/trait-upcasting/correct-supertrait-substitution.rs @@ -1,5 +1,4 @@ //@ run-pass -#![feature(trait_upcasting)] trait Foo<T: Default + ToString>: Bar<i32> + Bar<T> {} trait Bar<T: Default + ToString> { diff --git a/tests/ui/traits/trait-upcasting/deref-upcast-behavioral-change.rs b/tests/ui/traits/trait-upcasting/deref-upcast-behavioral-change.rs deleted file mode 100644 index e4784fa4101..00000000000 --- a/tests/ui/traits/trait-upcasting/deref-upcast-behavioral-change.rs +++ /dev/null @@ -1,35 +0,0 @@ -#![deny(deref_into_dyn_supertrait)] -use std::ops::Deref; - -trait Bar<T> {} -impl<T, U> Bar<U> for T {} - -trait Foo: Bar<i32> { - fn as_dyn_bar_u32<'a>(&self) -> &(dyn Bar<u32> + 'a); -} - -impl Foo for () { - fn as_dyn_bar_u32<'a>(&self) -> &(dyn Bar<u32> + 'a) { - self - } -} - -impl<'a> Deref for dyn Foo + 'a { - //~^ ERROR this `Deref` implementation is covered by an implicit supertrait coercion - //~| WARN this will change its meaning in a future release! - type Target = dyn Bar<u32> + 'a; - - fn deref(&self) -> &Self::Target { - self.as_dyn_bar_u32() - } -} - -fn take_dyn<T>(x: &dyn Bar<T>) -> T { - todo!() -} - -fn main() { - let x: &dyn Foo = &(); - let y = take_dyn(x); - let z: u32 = y; -} diff --git a/tests/ui/traits/trait-upcasting/deref-upcast-behavioral-change.stderr b/tests/ui/traits/trait-upcasting/deref-upcast-behavioral-change.stderr deleted file mode 100644 index fa93e28c73b..00000000000 --- a/tests/ui/traits/trait-upcasting/deref-upcast-behavioral-change.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: this `Deref` implementation is covered by an implicit supertrait coercion - --> $DIR/deref-upcast-behavioral-change.rs:17:1 - | -LL | impl<'a> Deref for dyn Foo + 'a { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Foo` implements `Deref<Target = dyn Bar<u32>>` which conflicts with supertrait `Bar<i32>` -... -LL | type Target = dyn Bar<u32> + 'a; - | -------------------------------- target type is a supertrait of `dyn Foo` - | - = warning: this will change its meaning in a future release! - = note: for more information, see issue #89460 <https://github.com/rust-lang/rust/issues/89460> -note: the lint level is defined here - --> $DIR/deref-upcast-behavioral-change.rs:1:9 - | -LL | #![deny(deref_into_dyn_supertrait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/traits/trait-upcasting/deref-upcast-shadowing-lint.rs b/tests/ui/traits/trait-upcasting/deref-upcast-shadowing-lint.rs new file mode 100644 index 00000000000..ab84527edcf --- /dev/null +++ b/tests/ui/traits/trait-upcasting/deref-upcast-shadowing-lint.rs @@ -0,0 +1,17 @@ +//@ check-pass +#![warn(deref_into_dyn_supertrait)] +use std::ops::Deref; + +trait Bar<T> {} +trait Foo: Bar<i32> {} + +impl<'a> Deref for dyn Foo + 'a { + //~^ warn: this `Deref` implementation is covered by an implicit supertrait coercion + type Target = dyn Bar<u32> + 'a; + + fn deref(&self) -> &Self::Target { + todo!() + } +} + +fn main() {} diff --git a/tests/ui/traits/trait-upcasting/deref-upcast-shadowing-lint.stderr b/tests/ui/traits/trait-upcasting/deref-upcast-shadowing-lint.stderr new file mode 100644 index 00000000000..0d7f957a50e --- /dev/null +++ b/tests/ui/traits/trait-upcasting/deref-upcast-shadowing-lint.stderr @@ -0,0 +1,17 @@ +warning: this `Deref` implementation is covered by an implicit supertrait coercion + --> $DIR/deref-upcast-shadowing-lint.rs:8:1 + | +LL | impl<'a> Deref for dyn Foo + 'a { + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Foo` implements `Deref<Target = dyn Bar<u32>>` which conflicts with supertrait `Bar<i32>` +LL | +LL | type Target = dyn Bar<u32> + 'a; + | -------------------------------- target type is a supertrait of `dyn Foo` + | +note: the lint level is defined here + --> $DIR/deref-upcast-shadowing-lint.rs:2:9 + | +LL | #![warn(deref_into_dyn_supertrait)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ + +warning: 1 warning emitted + diff --git a/tests/ui/traits/trait-upcasting/diamond.rs b/tests/ui/traits/trait-upcasting/diamond.rs index 303c99b67bd..c3f15a6d582 100644 --- a/tests/ui/traits/trait-upcasting/diamond.rs +++ b/tests/ui/traits/trait-upcasting/diamond.rs @@ -1,7 +1,5 @@ //@ run-pass -#![feature(trait_upcasting)] - trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { 10 diff --git a/tests/ui/traits/trait-upcasting/fewer-associated.rs b/tests/ui/traits/trait-upcasting/fewer-associated.rs index 45e8673b859..c2ea2a09d3a 100644 --- a/tests/ui/traits/trait-upcasting/fewer-associated.rs +++ b/tests/ui/traits/trait-upcasting/fewer-associated.rs @@ -4,8 +4,6 @@ //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -#![feature(trait_upcasting)] - trait A: B { type Assoc; } diff --git a/tests/ui/traits/trait-upcasting/higher-ranked-upcasting-ok.rs b/tests/ui/traits/trait-upcasting/higher-ranked-upcasting-ok.rs index c4c070e49fd..9f9bf21b5a9 100644 --- a/tests/ui/traits/trait-upcasting/higher-ranked-upcasting-ok.rs +++ b/tests/ui/traits/trait-upcasting/higher-ranked-upcasting-ok.rs @@ -6,8 +6,6 @@ // Check that we are able to instantiate a binder during trait upcasting, // and that it doesn't cause any issues with codegen either. -#![feature(trait_upcasting)] - trait Supertrait<'a, 'b> {} trait Subtrait<'a, 'b>: Supertrait<'a, 'b> {} diff --git a/tests/ui/traits/trait-upcasting/higher-ranked-upcasting-ub.rs b/tests/ui/traits/trait-upcasting/higher-ranked-upcasting-ub.rs index 2cf6fc75e77..af2594b95f3 100644 --- a/tests/ui/traits/trait-upcasting/higher-ranked-upcasting-ub.rs +++ b/tests/ui/traits/trait-upcasting/higher-ranked-upcasting-ub.rs @@ -5,7 +5,7 @@ // We previously wrongly instantiated binders during trait upcasting, // allowing the super trait to be more generic than the sub trait. // This was unsound. -#![feature(trait_upcasting)] + trait Supertrait<'a, 'b> { fn cast(&self, x: &'a str) -> &'b str; } diff --git a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.current.stderr b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.current.stderr index 28be189ff1e..596380b0dbb 100644 --- a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.current.stderr +++ b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.current.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/illegal-upcast-from-impl.rs:17:66 + --> $DIR/illegal-upcast-from-impl.rs:15:66 | LL | fn illegal(x: &dyn Sub<Assoc = ()>) -> &dyn Super<Assoc = i32> { x } | ----------------------- ^ expected trait `Super`, found trait `Sub` diff --git a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.next.stderr b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.next.stderr index 28be189ff1e..596380b0dbb 100644 --- a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.next.stderr +++ b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.next.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/illegal-upcast-from-impl.rs:17:66 + --> $DIR/illegal-upcast-from-impl.rs:15:66 | LL | fn illegal(x: &dyn Sub<Assoc = ()>) -> &dyn Super<Assoc = i32> { x } | ----------------------- ^ expected trait `Super`, found trait `Sub` diff --git a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs index 0c771db4121..43ec4ece429 100644 --- a/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs +++ b/tests/ui/traits/trait-upcasting/illegal-upcast-from-impl.rs @@ -2,8 +2,6 @@ //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -#![feature(trait_upcasting)] - trait Super { type Assoc; } diff --git a/tests/ui/traits/trait-upcasting/illegal-upcast-to-impl-opaque.rs b/tests/ui/traits/trait-upcasting/illegal-upcast-to-impl-opaque.rs index d0418e75fab..2760c1696b5 100644 --- a/tests/ui/traits/trait-upcasting/illegal-upcast-to-impl-opaque.rs +++ b/tests/ui/traits/trait-upcasting/illegal-upcast-to-impl-opaque.rs @@ -9,8 +9,6 @@ //@[next] rustc-env:RUST_BACKTRACE=0 //@ check-pass -#![feature(trait_upcasting)] - trait Super { type Assoc; } diff --git a/tests/ui/traits/trait-upcasting/inference-behavior-change-deref.rs b/tests/ui/traits/trait-upcasting/inference-behavior-change-deref.rs index 79fb643eacd..0103aaa2ac9 100644 --- a/tests/ui/traits/trait-upcasting/inference-behavior-change-deref.rs +++ b/tests/ui/traits/trait-upcasting/inference-behavior-change-deref.rs @@ -1,6 +1,3 @@ -#![deny(deref_into_dyn_supertrait)] -#![feature(trait_upcasting)] // remove this and the test compiles - use std::ops::Deref; trait Bar<T> {} @@ -32,5 +29,5 @@ fn main() { let x: &dyn Foo = &(); let y = take_dyn(x); let z: u32 = y; - //~^ ERROR mismatched types + //~^ error: mismatched types } diff --git a/tests/ui/traits/trait-upcasting/inference-behavior-change-deref.stderr b/tests/ui/traits/trait-upcasting/inference-behavior-change-deref.stderr index 6b6a26d1593..45eabbc723a 100644 --- a/tests/ui/traits/trait-upcasting/inference-behavior-change-deref.stderr +++ b/tests/ui/traits/trait-upcasting/inference-behavior-change-deref.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/inference-behavior-change-deref.rs:34:18 + --> $DIR/inference-behavior-change-deref.rs:31:18 | LL | let z: u32 = y; | --- ^ expected `u32`, found `i32` diff --git a/tests/ui/traits/trait-upcasting/invalid-upcast.rs b/tests/ui/traits/trait-upcasting/invalid-upcast.rs index e634bbd5ac6..9269a5e3e9f 100644 --- a/tests/ui/traits/trait-upcasting/invalid-upcast.rs +++ b/tests/ui/traits/trait-upcasting/invalid-upcast.rs @@ -1,5 +1,3 @@ -#![feature(trait_upcasting)] - trait Foo { fn a(&self) -> i32 { 10 diff --git a/tests/ui/traits/trait-upcasting/invalid-upcast.stderr b/tests/ui/traits/trait-upcasting/invalid-upcast.stderr index 3aa21ee3ddd..e70b99d28c7 100644 --- a/tests/ui/traits/trait-upcasting/invalid-upcast.stderr +++ b/tests/ui/traits/trait-upcasting/invalid-upcast.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:53:35 + --> $DIR/invalid-upcast.rs:51:35 | LL | let _: &dyn std::fmt::Debug = baz; | -------------------- ^^^ expected trait `Debug`, found trait `Baz` @@ -10,7 +10,7 @@ LL | let _: &dyn std::fmt::Debug = baz; found reference `&dyn Baz` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:55:24 + --> $DIR/invalid-upcast.rs:53:24 | LL | let _: &dyn Send = baz; | --------- ^^^ expected trait `Send`, found trait `Baz` @@ -21,7 +21,7 @@ LL | let _: &dyn Send = baz; found reference `&dyn Baz` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:57:24 + --> $DIR/invalid-upcast.rs:55:24 | LL | let _: &dyn Sync = baz; | --------- ^^^ expected trait `Sync`, found trait `Baz` @@ -32,7 +32,7 @@ LL | let _: &dyn Sync = baz; found reference `&dyn Baz` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:60:25 + --> $DIR/invalid-upcast.rs:58:25 | LL | let bar: &dyn Bar = baz; | -------- ^^^ expected trait `Bar`, found trait `Baz` @@ -43,7 +43,7 @@ LL | let bar: &dyn Bar = baz; found reference `&dyn Baz` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:62:35 + --> $DIR/invalid-upcast.rs:60:35 | LL | let _: &dyn std::fmt::Debug = bar; | -------------------- ^^^ expected trait `Debug`, found trait `Bar` @@ -54,7 +54,7 @@ LL | let _: &dyn std::fmt::Debug = bar; found reference `&dyn Bar` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:64:24 + --> $DIR/invalid-upcast.rs:62:24 | LL | let _: &dyn Send = bar; | --------- ^^^ expected trait `Send`, found trait `Bar` @@ -65,7 +65,7 @@ LL | let _: &dyn Send = bar; found reference `&dyn Bar` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:66:24 + --> $DIR/invalid-upcast.rs:64:24 | LL | let _: &dyn Sync = bar; | --------- ^^^ expected trait `Sync`, found trait `Bar` @@ -76,7 +76,7 @@ LL | let _: &dyn Sync = bar; found reference `&dyn Bar` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:69:25 + --> $DIR/invalid-upcast.rs:67:25 | LL | let foo: &dyn Foo = baz; | -------- ^^^ expected trait `Foo`, found trait `Baz` @@ -87,7 +87,7 @@ LL | let foo: &dyn Foo = baz; found reference `&dyn Baz` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:71:35 + --> $DIR/invalid-upcast.rs:69:35 | LL | let _: &dyn std::fmt::Debug = foo; | -------------------- ^^^ expected trait `Debug`, found trait `Foo` @@ -98,7 +98,7 @@ LL | let _: &dyn std::fmt::Debug = foo; found reference `&dyn Foo` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:73:24 + --> $DIR/invalid-upcast.rs:71:24 | LL | let _: &dyn Send = foo; | --------- ^^^ expected trait `Send`, found trait `Foo` @@ -109,7 +109,7 @@ LL | let _: &dyn Send = foo; found reference `&dyn Foo` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:75:24 + --> $DIR/invalid-upcast.rs:73:24 | LL | let _: &dyn Sync = foo; | --------- ^^^ expected trait `Sync`, found trait `Foo` @@ -120,7 +120,7 @@ LL | let _: &dyn Sync = foo; found reference `&dyn Foo` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:78:25 + --> $DIR/invalid-upcast.rs:76:25 | LL | let foo: &dyn Foo = bar; | -------- ^^^ expected trait `Foo`, found trait `Bar` @@ -131,7 +131,7 @@ LL | let foo: &dyn Foo = bar; found reference `&dyn Bar` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:80:35 + --> $DIR/invalid-upcast.rs:78:35 | LL | let _: &dyn std::fmt::Debug = foo; | -------------------- ^^^ expected trait `Debug`, found trait `Foo` @@ -142,7 +142,7 @@ LL | let _: &dyn std::fmt::Debug = foo; found reference `&dyn Foo` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:82:24 + --> $DIR/invalid-upcast.rs:80:24 | LL | let _: &dyn Send = foo; | --------- ^^^ expected trait `Send`, found trait `Foo` @@ -153,7 +153,7 @@ LL | let _: &dyn Send = foo; found reference `&dyn Foo` error[E0308]: mismatched types - --> $DIR/invalid-upcast.rs:84:24 + --> $DIR/invalid-upcast.rs:82:24 | LL | let _: &dyn Sync = foo; | --------- ^^^ expected trait `Sync`, found trait `Foo` diff --git a/tests/ui/traits/trait-upcasting/issue-11515-upcast-fn_mut-fn.rs b/tests/ui/traits/trait-upcasting/issue-11515-upcast-fn_mut-fn.rs index ef3d366c381..8bf32efbe2e 100644 --- a/tests/ui/traits/trait-upcasting/issue-11515-upcast-fn_mut-fn.rs +++ b/tests/ui/traits/trait-upcasting/issue-11515-upcast-fn_mut-fn.rs @@ -1,5 +1,4 @@ //@ run-pass -#![feature(trait_upcasting)] struct Test { func: Box<dyn FnMut() + 'static>, diff --git a/tests/ui/traits/trait-upcasting/issue-11515.current.stderr b/tests/ui/traits/trait-upcasting/issue-11515.current.stderr deleted file mode 100644 index 8ce7d46012f..00000000000 --- a/tests/ui/traits/trait-upcasting/issue-11515.current.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0658]: cannot cast `dyn Fn()` to `dyn FnMut()`, trait upcasting coercion is experimental - --> $DIR/issue-11515.rs:11:38 - | -LL | let test = Box::new(Test { func: closure }); - | ^^^^^^^ - | - = note: see issue #65991 <https://github.com/rust-lang/rust/issues/65991> for more information - = help: add `#![feature(trait_upcasting)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: required when coercing `Box<(dyn Fn() + 'static)>` into `Box<(dyn FnMut() + 'static)>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/trait-upcasting/issue-11515.next.stderr b/tests/ui/traits/trait-upcasting/issue-11515.next.stderr deleted file mode 100644 index 8ce7d46012f..00000000000 --- a/tests/ui/traits/trait-upcasting/issue-11515.next.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0658]: cannot cast `dyn Fn()` to `dyn FnMut()`, trait upcasting coercion is experimental - --> $DIR/issue-11515.rs:11:38 - | -LL | let test = Box::new(Test { func: closure }); - | ^^^^^^^ - | - = note: see issue #65991 <https://github.com/rust-lang/rust/issues/65991> for more information - = help: add `#![feature(trait_upcasting)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: required when coercing `Box<(dyn Fn() + 'static)>` into `Box<(dyn FnMut() + 'static)>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/trait-upcasting/issue-11515.rs b/tests/ui/traits/trait-upcasting/issue-11515.rs index d251e804c3e..3b1f0a19cb9 100644 --- a/tests/ui/traits/trait-upcasting/issue-11515.rs +++ b/tests/ui/traits/trait-upcasting/issue-11515.rs @@ -1,3 +1,4 @@ +//@ check-pass //@ revisions: current next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver @@ -8,5 +9,5 @@ struct Test { fn main() { let closure: Box<dyn Fn() + 'static> = Box::new(|| ()); - let test = Box::new(Test { func: closure }); //~ ERROR trait upcasting coercion is experimental [E0658] + let test = Box::new(Test { func: closure }); } diff --git a/tests/ui/traits/trait-upcasting/lifetime.rs b/tests/ui/traits/trait-upcasting/lifetime.rs index ab006f8bedc..a3cbfd777a0 100644 --- a/tests/ui/traits/trait-upcasting/lifetime.rs +++ b/tests/ui/traits/trait-upcasting/lifetime.rs @@ -1,7 +1,5 @@ //@ run-pass -#![feature(trait_upcasting)] - trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { 10 diff --git a/tests/ui/traits/trait-upcasting/lifetime.stderr b/tests/ui/traits/trait-upcasting/lifetime.stderr index ca8f9cf63f3..589e9816d5a 100644 --- a/tests/ui/traits/trait-upcasting/lifetime.stderr +++ b/tests/ui/traits/trait-upcasting/lifetime.stderr @@ -1,5 +1,5 @@ warning: methods `z` and `y` are never used - --> $DIR/lifetime.rs:10:8 + --> $DIR/lifetime.rs:8:8 | LL | trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { | --- methods in this trait @@ -13,7 +13,7 @@ LL | fn y(&self) -> i32 { = note: `#[warn(dead_code)]` on by default warning: method `w` is never used - --> $DIR/lifetime.rs:24:8 + --> $DIR/lifetime.rs:22:8 | LL | trait Bar: Foo { | --- method in this trait diff --git a/tests/ui/traits/trait-upcasting/migrate-lint-deny-regions.rs b/tests/ui/traits/trait-upcasting/migrate-lint-deny-regions.rs index da1a9cc2775..d33d3bfd5dc 100644 --- a/tests/ui/traits/trait-upcasting/migrate-lint-deny-regions.rs +++ b/tests/ui/traits/trait-upcasting/migrate-lint-deny-regions.rs @@ -1,4 +1,5 @@ -#![deny(deref_into_dyn_supertrait)] +//@ check-pass +#![warn(deref_into_dyn_supertrait)] use std::ops::Deref; @@ -6,8 +7,7 @@ trait Bar<'a> {} trait Foo<'a>: Bar<'a> {} impl<'a> Deref for dyn Foo<'a> { - //~^ ERROR this `Deref` implementation is covered by an implicit supertrait coercion - //~| WARN this will change its meaning in a future release! + //~^ warn: this `Deref` implementation is covered by an implicit supertrait coercion type Target = dyn Bar<'a>; fn deref(&self) -> &Self::Target { diff --git a/tests/ui/traits/trait-upcasting/migrate-lint-deny-regions.stderr b/tests/ui/traits/trait-upcasting/migrate-lint-deny-regions.stderr index a5f3660d4bc..806c57e44a2 100644 --- a/tests/ui/traits/trait-upcasting/migrate-lint-deny-regions.stderr +++ b/tests/ui/traits/trait-upcasting/migrate-lint-deny-regions.stderr @@ -1,19 +1,17 @@ -error: this `Deref` implementation is covered by an implicit supertrait coercion - --> $DIR/migrate-lint-deny-regions.rs:8:1 +warning: this `Deref` implementation is covered by an implicit supertrait coercion + --> $DIR/migrate-lint-deny-regions.rs:9:1 | LL | impl<'a> Deref for dyn Foo<'a> { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Foo<'_>` implements `Deref<Target = dyn Bar<'_>>` which conflicts with supertrait `Bar<'_>` -... +LL | LL | type Target = dyn Bar<'a>; | -------------------------- target type is a supertrait of `dyn Foo<'_>` | - = warning: this will change its meaning in a future release! - = note: for more information, see issue #89460 <https://github.com/rust-lang/rust/issues/89460> note: the lint level is defined here - --> $DIR/migrate-lint-deny-regions.rs:1:9 + --> $DIR/migrate-lint-deny-regions.rs:2:9 | -LL | #![deny(deref_into_dyn_supertrait)] +LL | #![warn(deref_into_dyn_supertrait)] | ^^^^^^^^^^^^^^^^^^^^^^^^^ -error: aborting due to 1 previous error +warning: 1 warning emitted diff --git a/tests/ui/traits/trait-upcasting/migrate-lint-deny.rs b/tests/ui/traits/trait-upcasting/migrate-lint-deny.rs deleted file mode 100644 index 926b3649e01..00000000000 --- a/tests/ui/traits/trait-upcasting/migrate-lint-deny.rs +++ /dev/null @@ -1,25 +0,0 @@ -#![deny(deref_into_dyn_supertrait)] - -use std::ops::Deref; - -// issue 89190 -trait A {} -trait B: A {} - -impl<'a> Deref for dyn 'a + B { - //~^ ERROR this `Deref` implementation is covered by an implicit supertrait coercion - //~| WARN this will change its meaning in a future release! - - type Target = dyn A; - fn deref(&self) -> &Self::Target { - todo!() - } -} - -fn take_a(_: &dyn A) {} - -fn whoops(b: &dyn B) { - take_a(b) -} - -fn main() {} diff --git a/tests/ui/traits/trait-upcasting/migrate-lint-deny.stderr b/tests/ui/traits/trait-upcasting/migrate-lint-deny.stderr deleted file mode 100644 index 29997a9b3d9..00000000000 --- a/tests/ui/traits/trait-upcasting/migrate-lint-deny.stderr +++ /dev/null @@ -1,19 +0,0 @@ -error: this `Deref` implementation is covered by an implicit supertrait coercion - --> $DIR/migrate-lint-deny.rs:9:1 - | -LL | impl<'a> Deref for dyn 'a + B { - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn B` implements `Deref<Target = dyn A>` which conflicts with supertrait `A` -... -LL | type Target = dyn A; - | -------------------- target type is a supertrait of `dyn B` - | - = warning: this will change its meaning in a future release! - = note: for more information, see issue #89460 <https://github.com/rust-lang/rust/issues/89460> -note: the lint level is defined here - --> $DIR/migrate-lint-deny.rs:1:9 - | -LL | #![deny(deref_into_dyn_supertrait)] - | ^^^^^^^^^^^^^^^^^^^^^^^^^ - -error: aborting due to 1 previous error - diff --git a/tests/ui/traits/trait-upcasting/migrate-lint-different-substs.rs b/tests/ui/traits/trait-upcasting/migrate-lint-different-substs.rs index 8e62c4b95b0..20806f22886 100644 --- a/tests/ui/traits/trait-upcasting/migrate-lint-different-substs.rs +++ b/tests/ui/traits/trait-upcasting/migrate-lint-different-substs.rs @@ -1,4 +1,5 @@ //@ check-pass +#![warn(deref_into_dyn_supertrait)] use std::ops::Deref; @@ -9,8 +10,7 @@ trait Foo: Bar<i32> { } impl<'a> Deref for dyn Foo + 'a { - //~^ WARN this `Deref` implementation is covered by an implicit supertrait coercion - //~| WARN this will change its meaning in a future release! + //~^ warn: this `Deref` implementation is covered by an implicit supertrait coercion type Target = dyn Bar<u32> + 'a; fn deref(&self) -> &Self::Target { diff --git a/tests/ui/traits/trait-upcasting/migrate-lint-different-substs.stderr b/tests/ui/traits/trait-upcasting/migrate-lint-different-substs.stderr index 6245da5a176..86cff5233ff 100644 --- a/tests/ui/traits/trait-upcasting/migrate-lint-different-substs.stderr +++ b/tests/ui/traits/trait-upcasting/migrate-lint-different-substs.stderr @@ -1,15 +1,17 @@ warning: this `Deref` implementation is covered by an implicit supertrait coercion - --> $DIR/migrate-lint-different-substs.rs:11:1 + --> $DIR/migrate-lint-different-substs.rs:12:1 | LL | impl<'a> Deref for dyn Foo + 'a { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ `dyn Foo` implements `Deref<Target = dyn Bar<u32>>` which conflicts with supertrait `Bar<i32>` -... +LL | LL | type Target = dyn Bar<u32> + 'a; | -------------------------------- target type is a supertrait of `dyn Foo` | - = warning: this will change its meaning in a future release! - = note: for more information, see issue #89460 <https://github.com/rust-lang/rust/issues/89460> - = note: `#[warn(deref_into_dyn_supertrait)]` on by default +note: the lint level is defined here + --> $DIR/migrate-lint-different-substs.rs:2:9 + | +LL | #![warn(deref_into_dyn_supertrait)] + | ^^^^^^^^^^^^^^^^^^^^^^^^^ warning: 1 warning emitted diff --git a/tests/ui/traits/trait-upcasting/mono-impossible.rs b/tests/ui/traits/trait-upcasting/mono-impossible.rs new file mode 100644 index 00000000000..f19f0538efa --- /dev/null +++ b/tests/ui/traits/trait-upcasting/mono-impossible.rs @@ -0,0 +1,24 @@ +//@ build-pass + +trait Supertrait<T> { + fn method(&self) {} +} +impl<T> Supertrait<T> for () {} + +trait WithAssoc { + type Assoc; +} +trait Trait<P: WithAssoc>: Supertrait<P::Assoc> + Supertrait<()> {} + +fn upcast<P>(x: &dyn Trait<P>) -> &dyn Supertrait<()> { + x +} + +fn call<P>(x: &dyn Trait<P>) { + x.method(); +} + +fn main() { + println!("{:p}", upcast::<()> as *const ()); + println!("{:p}", call::<()> as *const ()); +} diff --git a/tests/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.rs b/tests/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.rs index 754437a3bec..0bf0d14c259 100644 --- a/tests/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.rs +++ b/tests/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.rs @@ -1,5 +1,4 @@ //@ check-fail -#![feature(trait_upcasting)] trait Bar<T> { fn bar(&self, _: T) {} diff --git a/tests/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr b/tests/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr index 70ba1fcaf38..c888ccc1ebb 100644 --- a/tests/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr +++ b/tests/ui/traits/trait-upcasting/multiple-occurrence-ambiguousity.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/multiple-occurrence-ambiguousity.rs:20:26 + --> $DIR/multiple-occurrence-ambiguousity.rs:19:26 | LL | let t: &dyn Bar<_> = s; | ----------- ^ expected trait `Bar`, found trait `Foo` diff --git a/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-binder.rs b/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-binder.rs index 510a1471af2..a0bb1c57adb 100644 --- a/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-binder.rs +++ b/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-binder.rs @@ -1,10 +1,8 @@ +// Test for <https://github.com/rust-lang/rust/issues/135316>. +// //@ run-pass //@ check-run-results -// Test for <https://github.com/rust-lang/rust/issues/135316>. - -#![feature(trait_upcasting)] - trait Supertrait<T> { fn _print_numbers(&self, mem: &[usize; 100]) { println!("{mem:?}"); diff --git a/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-normalization-vtable.rs b/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-normalization-vtable.rs index 69a71859a5c..6b9ddf9bedc 100644 --- a/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-normalization-vtable.rs +++ b/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-normalization-vtable.rs @@ -1,5 +1,4 @@ #![feature(rustc_attrs)] -#![feature(trait_upcasting)] // Test for <https://github.com/rust-lang/rust/issues/135315>. diff --git a/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-normalization-vtable.stderr b/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-normalization-vtable.stderr index 757e2dc6939..04b1afae7be 100644 --- a/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-normalization-vtable.stderr +++ b/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-normalization-vtable.stderr @@ -5,7 +5,7 @@ error: vtable entries: [ Method(<() as Supertrait<()>>::_print_numbers), Method(<() as Middle<()>>::say_hello), ] - --> $DIR/multiple-supertraits-modulo-normalization-vtable.rs:30:1 + --> $DIR/multiple-supertraits-modulo-normalization-vtable.rs:29:1 | LL | impl Trait for () {} | ^^^^^^^^^^^^^^^^^ @@ -17,7 +17,7 @@ error: vtable entries: [ Method(<dyn Middle<()> as Supertrait<()>>::_print_numbers - shim(reify)), Method(<dyn Middle<()> as Middle<()>>::say_hello - shim(reify)), ] - --> $DIR/multiple-supertraits-modulo-normalization-vtable.rs:34:1 + --> $DIR/multiple-supertraits-modulo-normalization-vtable.rs:33:1 | LL | type Virtual = dyn Middle<()>; | ^^^^^^^^^^^^ diff --git a/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-normalization.rs b/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-normalization.rs index c744e6e64f5..08ec49971ac 100644 --- a/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-normalization.rs +++ b/tests/ui/traits/trait-upcasting/multiple-supertraits-modulo-normalization.rs @@ -1,10 +1,8 @@ +// Test for <https://github.com/rust-lang/rust/issues/135315>. +// //@ run-pass //@ check-run-results -#![feature(trait_upcasting)] - -// Test for <https://github.com/rust-lang/rust/issues/135315>. - trait Supertrait<T> { fn _print_numbers(&self, mem: &[usize; 100]) { println!("{mem:?}"); diff --git a/tests/ui/traits/trait-upcasting/normalization.rs b/tests/ui/traits/trait-upcasting/normalization.rs index ae5a6a5243c..b714479961f 100644 --- a/tests/ui/traits/trait-upcasting/normalization.rs +++ b/tests/ui/traits/trait-upcasting/normalization.rs @@ -4,8 +4,6 @@ //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -#![feature(trait_upcasting)] - trait Mirror { type Assoc; } diff --git a/tests/ui/traits/trait-upcasting/prefer-lower-candidates.rs b/tests/ui/traits/trait-upcasting/prefer-lower-candidates.rs index 4bc59b09fb5..09557ba0260 100644 --- a/tests/ui/traits/trait-upcasting/prefer-lower-candidates.rs +++ b/tests/ui/traits/trait-upcasting/prefer-lower-candidates.rs @@ -6,8 +6,6 @@ // Ensure we don't have ambiguity when upcasting to two supertraits // that are identical modulo normalization. -#![feature(trait_upcasting)] - trait Supertrait<T> { fn method(&self) {} } diff --git a/tests/ui/traits/trait-upcasting/replace-vptr.rs b/tests/ui/traits/trait-upcasting/replace-vptr.rs index 4829e3c5c12..6ca5864669b 100644 --- a/tests/ui/traits/trait-upcasting/replace-vptr.rs +++ b/tests/ui/traits/trait-upcasting/replace-vptr.rs @@ -1,7 +1,5 @@ //@ run-pass -#![feature(trait_upcasting)] - trait A { fn foo_a(&self); //~ WARN method `foo_a` is never used } diff --git a/tests/ui/traits/trait-upcasting/replace-vptr.stderr b/tests/ui/traits/trait-upcasting/replace-vptr.stderr index 823094761b3..1a8bfd1bfa6 100644 --- a/tests/ui/traits/trait-upcasting/replace-vptr.stderr +++ b/tests/ui/traits/trait-upcasting/replace-vptr.stderr @@ -1,5 +1,5 @@ warning: method `foo_a` is never used - --> $DIR/replace-vptr.rs:6:8 + --> $DIR/replace-vptr.rs:4:8 | LL | trait A { | - method in this trait @@ -9,7 +9,7 @@ LL | fn foo_a(&self); = note: `#[warn(dead_code)]` on by default warning: method `foo_c` is never used - --> $DIR/replace-vptr.rs:14:8 + --> $DIR/replace-vptr.rs:12:8 | LL | trait C: A + B { | - method in this trait diff --git a/tests/ui/traits/trait-upcasting/struct.rs b/tests/ui/traits/trait-upcasting/struct.rs index 39da20259a0..51e6f006fbf 100644 --- a/tests/ui/traits/trait-upcasting/struct.rs +++ b/tests/ui/traits/trait-upcasting/struct.rs @@ -1,7 +1,5 @@ //@ run-pass -#![feature(trait_upcasting)] - use std::rc::Rc; use std::sync::Arc; diff --git a/tests/ui/traits/trait-upcasting/subtrait-method.rs b/tests/ui/traits/trait-upcasting/subtrait-method.rs index 136d15af0e8..20277280440 100644 --- a/tests/ui/traits/trait-upcasting/subtrait-method.rs +++ b/tests/ui/traits/trait-upcasting/subtrait-method.rs @@ -1,5 +1,3 @@ -#![feature(trait_upcasting)] - trait Foo: PartialEq<i32> + std::fmt::Debug + Send + Sync { fn a(&self) -> i32 { 10 diff --git a/tests/ui/traits/trait-upcasting/subtrait-method.stderr b/tests/ui/traits/trait-upcasting/subtrait-method.stderr index 0408be6986b..a7658a7bcd3 100644 --- a/tests/ui/traits/trait-upcasting/subtrait-method.stderr +++ b/tests/ui/traits/trait-upcasting/subtrait-method.stderr @@ -1,12 +1,12 @@ error[E0599]: no method named `c` found for reference `&dyn Bar` in the current scope - --> $DIR/subtrait-method.rs:55:9 + --> $DIR/subtrait-method.rs:53:9 | LL | bar.c(); | ^ | = help: items from traits can only be used if the trait is implemented and in scope note: `Baz` defines an item `c`, perhaps you need to implement it - --> $DIR/subtrait-method.rs:27:1 + --> $DIR/subtrait-method.rs:25:1 | LL | trait Baz: Bar { | ^^^^^^^^^^^^^^ @@ -16,14 +16,14 @@ LL | bar.a(); | ~ error[E0599]: no method named `b` found for reference `&dyn Foo` in the current scope - --> $DIR/subtrait-method.rs:59:9 + --> $DIR/subtrait-method.rs:57:9 | LL | foo.b(); | ^ | = help: items from traits can only be used if the trait is implemented and in scope note: `Bar` defines an item `b`, perhaps you need to implement it - --> $DIR/subtrait-method.rs:17:1 + --> $DIR/subtrait-method.rs:15:1 | LL | trait Bar: Foo { | ^^^^^^^^^^^^^^ @@ -33,14 +33,14 @@ LL | foo.a(); | ~ error[E0599]: no method named `c` found for reference `&dyn Foo` in the current scope - --> $DIR/subtrait-method.rs:61:9 + --> $DIR/subtrait-method.rs:59:9 | LL | foo.c(); | ^ | = help: items from traits can only be used if the trait is implemented and in scope note: `Baz` defines an item `c`, perhaps you need to implement it - --> $DIR/subtrait-method.rs:27:1 + --> $DIR/subtrait-method.rs:25:1 | LL | trait Baz: Bar { | ^^^^^^^^^^^^^^ @@ -50,14 +50,14 @@ LL | foo.a(); | ~ error[E0599]: no method named `b` found for reference `&dyn Foo` in the current scope - --> $DIR/subtrait-method.rs:65:9 + --> $DIR/subtrait-method.rs:63:9 | LL | foo.b(); | ^ | = help: items from traits can only be used if the trait is implemented and in scope note: `Bar` defines an item `b`, perhaps you need to implement it - --> $DIR/subtrait-method.rs:17:1 + --> $DIR/subtrait-method.rs:15:1 | LL | trait Bar: Foo { | ^^^^^^^^^^^^^^ @@ -67,14 +67,14 @@ LL | foo.a(); | ~ error[E0599]: no method named `c` found for reference `&dyn Foo` in the current scope - --> $DIR/subtrait-method.rs:67:9 + --> $DIR/subtrait-method.rs:65:9 | LL | foo.c(); | ^ | = help: items from traits can only be used if the trait is implemented and in scope note: `Baz` defines an item `c`, perhaps you need to implement it - --> $DIR/subtrait-method.rs:27:1 + --> $DIR/subtrait-method.rs:25:1 | LL | trait Baz: Bar { | ^^^^^^^^^^^^^^ diff --git a/tests/ui/traits/trait-upcasting/supertraits-modulo-inner-binder.rs b/tests/ui/traits/trait-upcasting/supertraits-modulo-inner-binder.rs index 6cd74b6c7f7..e65cb60d993 100644 --- a/tests/ui/traits/trait-upcasting/supertraits-modulo-inner-binder.rs +++ b/tests/ui/traits/trait-upcasting/supertraits-modulo-inner-binder.rs @@ -1,7 +1,5 @@ //@ run-pass -#![feature(trait_upcasting)] - trait Super<U> { fn call(&self) where diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr b/tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr index 9a9ad9bbf77..2f27d1522a6 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr +++ b/tests/ui/traits/trait-upcasting/type-checking-test-1.current.stderr @@ -1,5 +1,5 @@ error[E0605]: non-primitive cast: `&dyn Foo` as `&dyn Bar<_>` - --> $DIR/type-checking-test-1.rs:20:13 + --> $DIR/type-checking-test-1.rs:18:13 | LL | let _ = x as &dyn Bar<_>; // Ambiguous | ^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-1.next.stderr b/tests/ui/traits/trait-upcasting/type-checking-test-1.next.stderr index 9a9ad9bbf77..2f27d1522a6 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-1.next.stderr +++ b/tests/ui/traits/trait-upcasting/type-checking-test-1.next.stderr @@ -1,5 +1,5 @@ error[E0605]: non-primitive cast: `&dyn Foo` as `&dyn Bar<_>` - --> $DIR/type-checking-test-1.rs:20:13 + --> $DIR/type-checking-test-1.rs:18:13 | LL | let _ = x as &dyn Bar<_>; // Ambiguous | ^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-1.rs b/tests/ui/traits/trait-upcasting/type-checking-test-1.rs index fd902fd87e0..b06f5e04528 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-1.rs +++ b/tests/ui/traits/trait-upcasting/type-checking-test-1.rs @@ -2,8 +2,6 @@ //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver -#![feature(trait_upcasting)] - trait Foo: Bar<i32> + Bar<u32> {} trait Bar<T> { fn bar(&self) -> Option<T> { diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-2.rs b/tests/ui/traits/trait-upcasting/type-checking-test-2.rs index b024b27750b..b4df0f5a902 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-2.rs +++ b/tests/ui/traits/trait-upcasting/type-checking-test-2.rs @@ -1,5 +1,3 @@ -#![feature(trait_upcasting)] - trait Foo<T>: Bar<i32> + Bar<T> {} trait Bar<T> { fn bar(&self) -> Option<T> { diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-2.stderr b/tests/ui/traits/trait-upcasting/type-checking-test-2.stderr index 3e59b9d3363..f84ea93dc67 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-2.stderr +++ b/tests/ui/traits/trait-upcasting/type-checking-test-2.stderr @@ -1,11 +1,11 @@ error[E0605]: non-primitive cast: `&dyn Foo<i32>` as `&dyn Bar<u32>` - --> $DIR/type-checking-test-2.rs:19:13 + --> $DIR/type-checking-test-2.rs:17:13 | LL | let _ = x as &dyn Bar<u32>; // Error | ^^^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object error[E0605]: non-primitive cast: `&dyn Foo<u32>` as `&dyn Bar<_>` - --> $DIR/type-checking-test-2.rs:24:13 + --> $DIR/type-checking-test-2.rs:22:13 | LL | let a = x as &dyn Bar<_>; // Ambiguous | ^^^^^^^^^^^^^^^^ an `as` expression can only be used to convert between primitive types or to coerce to a specific trait object diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-3.rs b/tests/ui/traits/trait-upcasting/type-checking-test-3.rs index b2db3a12797..3685569d98d 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-3.rs +++ b/tests/ui/traits/trait-upcasting/type-checking-test-3.rs @@ -1,5 +1,3 @@ -#![feature(trait_upcasting)] - trait Foo<'a>: Bar<'a> {} trait Bar<'a> {} diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-3.stderr b/tests/ui/traits/trait-upcasting/type-checking-test-3.stderr index 01b8da645f3..d80649638ae 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-3.stderr +++ b/tests/ui/traits/trait-upcasting/type-checking-test-3.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/type-checking-test-3.rs:11:13 + --> $DIR/type-checking-test-3.rs:9:13 | LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { | -- lifetime `'a` defined here @@ -7,7 +7,7 @@ LL | let _ = x as &dyn Bar<'a>; // Error | ^^^^^^^^^^^^^^^^^ cast requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-3.rs:16:18 + --> $DIR/type-checking-test-3.rs:14:18 | LL | fn test_wrong2<'a>(x: &dyn Foo<'a>) { | -- lifetime `'a` defined here diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-4.rs b/tests/ui/traits/trait-upcasting/type-checking-test-4.rs index 01759ec7a93..20de722ee9b 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-4.rs +++ b/tests/ui/traits/trait-upcasting/type-checking-test-4.rs @@ -1,5 +1,3 @@ -#![feature(trait_upcasting)] - trait Foo<'a>: Bar<'a, 'a> {} trait Bar<'a, 'b> { fn get_b(&self) -> Option<&'a u32> { diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-4.stderr b/tests/ui/traits/trait-upcasting/type-checking-test-4.stderr index e91ea193a01..55a5e4cd497 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-4.stderr +++ b/tests/ui/traits/trait-upcasting/type-checking-test-4.stderr @@ -1,5 +1,5 @@ error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:19:13 + --> $DIR/type-checking-test-4.rs:17:13 | LL | fn test_wrong1<'a>(x: &dyn Foo<'static>, y: &'a u32) { | -- lifetime `'a` defined here @@ -7,7 +7,7 @@ LL | let _ = x as &dyn Bar<'static, 'a>; // Error | ^^^^^^^^^^^^^^^^^^^^^^^^^^ cast requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:24:18 + --> $DIR/type-checking-test-4.rs:22:18 | LL | fn test_wrong2<'a>(x: &dyn Foo<'static>, y: &'a u32) { | -- lifetime `'a` defined here @@ -15,7 +15,7 @@ LL | let _ = x as &dyn Bar<'a, 'static>; // Error | ^^^^^^^^^^^^^^^^^^^^^ type annotation requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:30:5 + --> $DIR/type-checking-test-4.rs:28:5 | LL | fn test_wrong3<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | -- lifetime `'a` defined here @@ -24,7 +24,7 @@ LL | y.get_b() // ERROR | ^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:35:5 + --> $DIR/type-checking-test-4.rs:33:5 | LL | fn test_wrong4<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | -- lifetime `'a` defined here @@ -32,7 +32,7 @@ LL | <_ as Bar>::get_b(x) // ERROR | ^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:40:5 + --> $DIR/type-checking-test-4.rs:38:5 | LL | fn test_wrong5<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | -- lifetime `'a` defined here @@ -40,7 +40,7 @@ LL | <_ as Bar<'_, '_>>::get_b(x) // ERROR | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^ returning this value requires that `'a` must outlive `'static` error: lifetime may not live long enough - --> $DIR/type-checking-test-4.rs:48:5 + --> $DIR/type-checking-test-4.rs:46:5 | LL | fn test_wrong6<'a>(x: &dyn Foo<'a>) -> Option<&'static u32> { | -- lifetime `'a` defined here diff --git a/tests/ui/traits/trait-upcasting/type-checking-test-opaques.rs b/tests/ui/traits/trait-upcasting/type-checking-test-opaques.rs index a3a1ce29465..ab3817da28b 100644 --- a/tests/ui/traits/trait-upcasting/type-checking-test-opaques.rs +++ b/tests/ui/traits/trait-upcasting/type-checking-test-opaques.rs @@ -1,4 +1,4 @@ -#![feature(trait_upcasting, type_alias_impl_trait)] +#![feature(type_alias_impl_trait)] //@ check-pass diff --git a/tests/ui/traits/trait-upcasting/upcast-defining-opaque.rs b/tests/ui/traits/trait-upcasting/upcast-defining-opaque.rs index 07f1549e177..0548eda0468 100644 --- a/tests/ui/traits/trait-upcasting/upcast-defining-opaque.rs +++ b/tests/ui/traits/trait-upcasting/upcast-defining-opaque.rs @@ -3,7 +3,7 @@ //@ ignore-compare-mode-next-solver (explicit revisions) //@check-pass -#![feature(trait_upcasting, type_alias_impl_trait)] +#![feature(type_alias_impl_trait)] trait Super { type Assoc; diff --git a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.current.stderr b/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.current.stderr deleted file mode 100644 index 239f8279194..00000000000 --- a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.current.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0658]: cannot cast `dyn A` to `dyn B`, trait upcasting coercion is experimental - --> $DIR/upcast-through-struct-tail.rs:11:5 - | -LL | x - | ^ - | - = note: see issue #65991 <https://github.com/rust-lang/rust/issues/65991> for more information - = help: add `#![feature(trait_upcasting)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: required when coercing `Box<Wrapper<(dyn A + 'a)>>` into `Box<Wrapper<(dyn B + 'a)>>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.next.stderr b/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.next.stderr deleted file mode 100644 index 239f8279194..00000000000 --- a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.next.stderr +++ /dev/null @@ -1,14 +0,0 @@ -error[E0658]: cannot cast `dyn A` to `dyn B`, trait upcasting coercion is experimental - --> $DIR/upcast-through-struct-tail.rs:11:5 - | -LL | x - | ^ - | - = note: see issue #65991 <https://github.com/rust-lang/rust/issues/65991> for more information - = help: add `#![feature(trait_upcasting)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date - = note: required when coercing `Box<Wrapper<(dyn A + 'a)>>` into `Box<Wrapper<(dyn B + 'a)>>` - -error: aborting due to 1 previous error - -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs b/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs index e40cca4e0a8..dd4d91f8d4f 100644 --- a/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs +++ b/tests/ui/traits/trait-upcasting/upcast-through-struct-tail.rs @@ -1,3 +1,4 @@ +//@ check-pass //@ revisions: current next //@ ignore-compare-mode-next-solver (explicit revisions) //@[next] compile-flags: -Znext-solver @@ -9,7 +10,6 @@ trait B {} fn test<'a>(x: Box<Wrapper<dyn A + 'a>>) -> Box<Wrapper<dyn B + 'a>> { x - //~^ ERROR cannot cast `dyn A` to `dyn B`, trait upcasting coercion is experimental } fn main() {} diff --git a/tests/ui/traits/upcast_reorder.rs b/tests/ui/traits/upcast_reorder.rs index 55e6ad4c368..43fc1517a3b 100644 --- a/tests/ui/traits/upcast_reorder.rs +++ b/tests/ui/traits/upcast_reorder.rs @@ -2,8 +2,6 @@ // // issue: <https://github.com/rust-lang/rust/issues/131813> -#![feature(trait_upcasting)] - trait Pollable { #[allow(unused)] fn poll(&self) {} diff --git a/tests/ui/traits/upcast_soundness_bug.rs b/tests/ui/traits/upcast_soundness_bug.rs index 0ddae1d1417..4c89fa135e7 100644 --- a/tests/ui/traits/upcast_soundness_bug.rs +++ b/tests/ui/traits/upcast_soundness_bug.rs @@ -1,4 +1,3 @@ -#![feature(trait_upcasting)] //@ check-fail // // issue: <https://github.com/rust-lang/rust/pull/120222> diff --git a/tests/ui/traits/upcast_soundness_bug.stderr b/tests/ui/traits/upcast_soundness_bug.stderr index 19d1a5e5926..f5fa6bdc999 100644 --- a/tests/ui/traits/upcast_soundness_bug.stderr +++ b/tests/ui/traits/upcast_soundness_bug.stderr @@ -1,5 +1,5 @@ error[E0606]: casting `*const dyn Trait<u8, u8>` as `*const dyn Trait<u8, u16>` is invalid - --> $DIR/upcast_soundness_bug.rs:59:13 + --> $DIR/upcast_soundness_bug.rs:58:13 | LL | let p = p as *const dyn Trait<u8, u16>; // <- this is bad! | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/transmutability/malformed-program-gracefulness/wrong-adt-assume.rs b/tests/ui/transmutability/malformed-program-gracefulness/wrong-adt-assume.rs new file mode 100644 index 00000000000..2340df25025 --- /dev/null +++ b/tests/ui/transmutability/malformed-program-gracefulness/wrong-adt-assume.rs @@ -0,0 +1,20 @@ +//! Test that we don't ICE when passing the wrong ADT to ASSUME. + +#![feature(adt_const_params)] +#![feature(transmutability)] + +use std::marker::ConstParamTy; +use std::mem::TransmuteFrom; + +#[derive(ConstParamTy, PartialEq, Eq)] +struct NotAssume; + +fn foo<const ASSUME: NotAssume>() +where + u8: TransmuteFrom<u8, ASSUME>, //~ ERROR the constant `ASSUME` is not of type `Assume` +{ +} + +fn main() { + foo::<{ NotAssume }>(); +} diff --git a/tests/ui/transmutability/malformed-program-gracefulness/wrong-adt-assume.stderr b/tests/ui/transmutability/malformed-program-gracefulness/wrong-adt-assume.stderr new file mode 100644 index 00000000000..cae700ecfdc --- /dev/null +++ b/tests/ui/transmutability/malformed-program-gracefulness/wrong-adt-assume.stderr @@ -0,0 +1,11 @@ +error: the constant `ASSUME` is not of type `Assume` + --> $DIR/wrong-adt-assume.rs:14:9 + | +LL | u8: TransmuteFrom<u8, ASSUME>, + | ^^^^^^^^^^^^^^^^^^^^^^^^^ expected `Assume`, found `NotAssume` + | +note: required by a const generic parameter in `TransmuteFrom` + --> $SRC_DIR/core/src/mem/transmutability.rs:LL:COL + +error: aborting due to 1 previous error + diff --git a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs index 1aa64810d19..38dd6dd0af2 100644 --- a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs +++ b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.rs @@ -1,5 +1,4 @@ //@ edition: 2021 -//@ build-fail #![feature(impl_trait_in_assoc_type)] diff --git a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr index 6cbffaaed4d..304ed12e944 100644 --- a/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr +++ b/tests/ui/type-alias-impl-trait/indirect-recursion-issue-112047.stderr @@ -1,11 +1,11 @@ error[E0733]: recursion in an async block requires boxing - --> $DIR/indirect-recursion-issue-112047.rs:22:9 + --> $DIR/indirect-recursion-issue-112047.rs:21:9 | LL | async move { recur(self).await; } | ^^^^^^^^^^ ----------------- recursive call here | note: which leads to this async fn - --> $DIR/indirect-recursion-issue-112047.rs:14:1 + --> $DIR/indirect-recursion-issue-112047.rs:13:1 | LL | async fn recur(t: impl Recur) { | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ diff --git a/tests/ui/type/pattern_types/assoc_const.default.stderr b/tests/ui/type/pattern_types/assoc_const.default.stderr new file mode 100644 index 00000000000..abda40e4681 --- /dev/null +++ b/tests/ui/type/pattern_types/assoc_const.default.stderr @@ -0,0 +1,36 @@ +error: constant expression depends on a generic parameter + --> $DIR/assoc_const.rs:17:19 + | +LL | fn foo<T: Foo>(_: pattern_type!(u32 is <T as Foo>::START..=<T as Foo>::END)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: constant expression depends on a generic parameter + --> $DIR/assoc_const.rs:17:19 + | +LL | fn foo<T: Foo>(_: pattern_type!(u32 is <T as Foo>::START..=<T as Foo>::END)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: constant expression depends on a generic parameter + --> $DIR/assoc_const.rs:20:19 + | +LL | fn bar<T: Foo>(_: pattern_type!(u32 is T::START..=T::END)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + +error: constant expression depends on a generic parameter + --> $DIR/assoc_const.rs:20:19 + | +LL | fn bar<T: Foo>(_: pattern_type!(u32 is T::START..=T::END)) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | + = note: this may fail depending on what value the parameter takes + = note: duplicate diagnostic emitted due to `-Z deduplicate-diagnostics=no` + +error: aborting due to 4 previous errors + diff --git a/tests/ui/type/pattern_types/assoc_const.rs b/tests/ui/type/pattern_types/assoc_const.rs new file mode 100644 index 00000000000..af0f7e4cbf3 --- /dev/null +++ b/tests/ui/type/pattern_types/assoc_const.rs @@ -0,0 +1,24 @@ +#![feature(pattern_types)] +#![feature(pattern_type_macro)] +#![cfg_attr(const_arg, feature(generic_const_exprs))] +#![expect(incomplete_features)] + +//@ revisions: default const_arg + +//@[const_arg] check-pass + +use std::pat::pattern_type; + +trait Foo { + const START: u32; + const END: u32; +} + +fn foo<T: Foo>(_: pattern_type!(u32 is <T as Foo>::START..=<T as Foo>::END)) {} +//[default]~^ ERROR: constant expression depends on a generic parameter +//[default]~| ERROR: constant expression depends on a generic parameter +fn bar<T: Foo>(_: pattern_type!(u32 is T::START..=T::END)) {} +//[default]~^ ERROR: constant expression depends on a generic parameter +//[default]~| ERROR: constant expression depends on a generic parameter + +fn main() {} diff --git a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs index c5f8b2764ec..0f10bf8ce62 100644 --- a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs +++ b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.rs @@ -1,10 +1,14 @@ +//@known-bug: #127972 +//@ failure-status: 101 +//@ normalize-stderr: "note: .*\n\n" -> "" +//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" +//@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " +//@ rustc-env:RUST_BACKTRACE=0 + #![feature(pattern_types, pattern_type_macro)] #![allow(internal_features)] type Pat<const START: u32, const END: u32> = std::pat::pattern_type!(u32 is START::<(), i32, 2>..=END::<_, Assoc = ()>); -//~^ ERROR type and const arguments are not allowed on const parameter `START` -//~| ERROR generic arguments are not allowed on const parameter `END` -//~| ERROR associated item constraints are not allowed here fn main() {} diff --git a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr index f31809bf397..fbe80a19863 100644 --- a/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr +++ b/tests/ui/type/pattern_types/bad_const_generics_args_on_const_param.stderr @@ -1,38 +1,14 @@ -error[E0109]: type and const arguments are not allowed on const parameter `START` - --> $DIR/bad_const_generics_args_on_const_param.rs:5:44 +error: internal compiler error: compiler/rustc_hir_analysis/src/hir_ty_lowering/mod.rs:LL:CC: try_lower_anon_const_lit: received const param which shouldn't be possible + --> $DIR/bad_const_generics_args_on_const_param.rs:12:36 | LL | std::pat::pattern_type!(u32 is START::<(), i32, 2>..=END::<_, Assoc = ()>); - | ----- ^^ ^^^ ^ type and const arguments not allowed - | | - | not allowed on const parameter `START` - | -note: const parameter `START` defined here - --> $DIR/bad_const_generics_args_on_const_param.rs:4:16 - | -LL | type Pat<const START: u32, const END: u32> = - | ^^^^^ + | ^^^^^^^^^^^^^^^^^^^ -error[E0109]: generic arguments are not allowed on const parameter `END` - --> $DIR/bad_const_generics_args_on_const_param.rs:5:64 - | -LL | std::pat::pattern_type!(u32 is START::<(), i32, 2>..=END::<_, Assoc = ()>); - | --- ^ generic argument not allowed - | | - | not allowed on const parameter `END` - | -note: const parameter `END` defined here - --> $DIR/bad_const_generics_args_on_const_param.rs:4:34 - | -LL | type Pat<const START: u32, const END: u32> = - | ^^^ - -error[E0229]: associated item constraints are not allowed here - --> $DIR/bad_const_generics_args_on_const_param.rs:5:67 - | -LL | std::pat::pattern_type!(u32 is START::<(), i32, 2>..=END::<_, Assoc = ()>); - | ^^^^^^^^^^ associated item constraint not allowed here -error: aborting due to 3 previous errors +Box<dyn Any> +query stack during panic: +#0 [type_of] expanding type alias `Pat` +#1 [check_well_formed] checking that `Pat` is well-formed +... and 2 other queries... use `env RUST_BACKTRACE=1` to see the full query stack +error: aborting due to 1 previous error -Some errors have detailed explanations: E0109, E0229. -For more information about an error, try `rustc --explain E0109`. diff --git a/tests/ui/type/pattern_types/bad_pat.rs b/tests/ui/type/pattern_types/bad_pat.rs index 6cb2a0f1f8e..549b0d11dd1 100644 --- a/tests/ui/type/pattern_types/bad_pat.rs +++ b/tests/ui/type/pattern_types/bad_pat.rs @@ -8,6 +8,6 @@ type NonNullU32_2 = pattern_type!(u32 is 1..=); type Positive2 = pattern_type!(i32 is 0..=); //~^ ERROR: inclusive range with no end type Wild = pattern_type!(() is _); -//~^ ERROR: wildcard patterns are not permitted for pattern types +//~^ ERROR: pattern not supported in pattern types fn main() {} diff --git a/tests/ui/type/pattern_types/bad_pat.stderr b/tests/ui/type/pattern_types/bad_pat.stderr index c857cc3c3ad..d2a5a20bf89 100644 --- a/tests/ui/type/pattern_types/bad_pat.stderr +++ b/tests/ui/type/pattern_types/bad_pat.stderr @@ -24,7 +24,7 @@ LL - type Positive2 = pattern_type!(i32 is 0..=); LL + type Positive2 = pattern_type!(i32 is 0..); | -error: wildcard patterns are not permitted for pattern types +error: pattern not supported in pattern types --> $DIR/bad_pat.rs:10:33 | LL | type Wild = pattern_type!(() is _); diff --git a/tests/ui/type/pattern_types/const_block.rs b/tests/ui/type/pattern_types/const_block.rs new file mode 100644 index 00000000000..49c87f4fa0d --- /dev/null +++ b/tests/ui/type/pattern_types/const_block.rs @@ -0,0 +1,10 @@ +#![feature(pattern_types)] +#![feature(pattern_type_macro)] +#![feature(inline_const_pat)] + +use std::pat::pattern_type; + +fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} +//~^ ERROR: cycle + +fn main() {} diff --git a/tests/ui/type/pattern_types/const_block.stderr b/tests/ui/type/pattern_types/const_block.stderr new file mode 100644 index 00000000000..82b616105af --- /dev/null +++ b/tests/ui/type/pattern_types/const_block.stderr @@ -0,0 +1,72 @@ +error[E0391]: cycle detected when evaluating type-level constant + --> $DIR/const_block.rs:7:36 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^^^^^^ + | +note: ...which requires const-evaluating + checking `bar::{constant#2}`... + --> $DIR/const_block.rs:7:36 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^^^^^^ +note: ...which requires caching mir of `bar::{constant#2}` for CTFE... + --> $DIR/const_block.rs:7:36 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^^^^^^ +note: ...which requires elaborating drops for `bar::{constant#2}`... + --> $DIR/const_block.rs:7:36 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^^^^^^ +note: ...which requires borrow-checking `bar::{constant#2}`... + --> $DIR/const_block.rs:7:36 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^^^^^^ +note: ...which requires borrow-checking `bar::{constant#0}`... + --> $DIR/const_block.rs:7:41 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^ +note: ...which requires promoting constants in MIR for `bar::{constant#0}`... + --> $DIR/const_block.rs:7:41 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^ +note: ...which requires const checking `bar::{constant#0}`... + --> $DIR/const_block.rs:7:41 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^ +note: ...which requires building MIR for `bar::{constant#0}`... + --> $DIR/const_block.rs:7:41 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^ +note: ...which requires match-checking `bar::{constant#0}`... + --> $DIR/const_block.rs:7:41 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^ +note: ...which requires type-checking `bar::{constant#0}`... + --> $DIR/const_block.rs:7:41 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^ +note: ...which requires type-checking `bar`... + --> $DIR/const_block.rs:7:1 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: ...which again requires evaluating type-level constant, completing the cycle +note: cycle used when checking that `bar` is well-formed + --> $DIR/const_block.rs:7:1 + | +LL | fn bar(x: pattern_type!(u32 is 0..=const{ 5 + 5 })) {} + | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + = note: see https://rustc-dev-guide.rust-lang.org/overview.html#queries and https://rustc-dev-guide.rust-lang.org/query.html for more information + +error: aborting due to 1 previous error + +For more information about this error, try `rustc --explain E0391`. diff --git a/tests/ui/type/pattern_types/free_const.rs b/tests/ui/type/pattern_types/free_const.rs new file mode 100644 index 00000000000..2e29fce2379 --- /dev/null +++ b/tests/ui/type/pattern_types/free_const.rs @@ -0,0 +1,13 @@ +//@ check-pass + +#![feature(pattern_types)] +#![feature(pattern_type_macro)] + +use std::pat::pattern_type; + +const START: u32 = 0; +const END: u32 = 10; + +fn foo(_: pattern_type!(u32 is START..=END)) {} + +fn main() {} diff --git a/tests/ui/type/pattern_types/nested.rs b/tests/ui/type/pattern_types/nested.rs index 519fb3f05b4..9ca9c7923de 100644 --- a/tests/ui/type/pattern_types/nested.rs +++ b/tests/ui/type/pattern_types/nested.rs @@ -9,16 +9,20 @@ use std::pat::pattern_type; // or still validate correctly. const BAD_NESTING: pattern_type!(pattern_type!(u32 is 1..) is 0..) = todo!(); //~^ ERROR: not a valid base type for range patterns +//~| ERROR: mismatched types // We want to get the most narrowest version that a pattern could be const BAD_NESTING2: pattern_type!(pattern_type!(i32 is 1..) is ..=-1) = todo!(); //~^ ERROR: not a valid base type for range patterns +//~| ERROR: mismatched types const BAD_NESTING3: pattern_type!(pattern_type!(i32 is 1..) is ..0) = todo!(); //~^ ERROR: not a valid base type for range patterns +//~| ERROR: mismatched types const BAD_NESTING4: pattern_type!(() is ..0) = todo!(); //~^ ERROR: not a valid base type for range patterns +//~| ERROR: mismatched types const BAD_NESTING5: pattern_type!(f32 is 1.0 .. 2.0) = todo!(); //~^ ERROR: not a valid base type for range patterns diff --git a/tests/ui/type/pattern_types/nested.stderr b/tests/ui/type/pattern_types/nested.stderr index 99d3979e98c..b753b0a9c9b 100644 --- a/tests/ui/type/pattern_types/nested.stderr +++ b/tests/ui/type/pattern_types/nested.stderr @@ -11,52 +11,86 @@ LL | const BAD_NESTING: pattern_type!(pattern_type!(u32 is 1..) is 0..) = todo!( | ^^^ error: `(i32) is 1..=` is not a valid base type for range patterns - --> $DIR/nested.rs:14:35 + --> $DIR/nested.rs:15:35 | LL | const BAD_NESTING2: pattern_type!(pattern_type!(i32 is 1..) is ..=-1) = todo!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: range patterns only support integers - --> $DIR/nested.rs:14:64 + --> $DIR/nested.rs:15:64 | LL | const BAD_NESTING2: pattern_type!(pattern_type!(i32 is 1..) is ..=-1) = todo!(); | ^^^^^ error: `(i32) is 1..=` is not a valid base type for range patterns - --> $DIR/nested.rs:17:35 + --> $DIR/nested.rs:19:35 | LL | const BAD_NESTING3: pattern_type!(pattern_type!(i32 is 1..) is ..0) = todo!(); | ^^^^^^^^^^^^^^^^^^^^^^^^^ | note: range patterns only support integers - --> $DIR/nested.rs:17:64 + --> $DIR/nested.rs:19:64 | LL | const BAD_NESTING3: pattern_type!(pattern_type!(i32 is 1..) is ..0) = todo!(); | ^^^ error: `()` is not a valid base type for range patterns - --> $DIR/nested.rs:20:35 + --> $DIR/nested.rs:23:35 | LL | const BAD_NESTING4: pattern_type!(() is ..0) = todo!(); | ^^ | note: range patterns only support integers - --> $DIR/nested.rs:20:41 + --> $DIR/nested.rs:23:41 | LL | const BAD_NESTING4: pattern_type!(() is ..0) = todo!(); | ^^^ error: `f32` is not a valid base type for range patterns - --> $DIR/nested.rs:23:35 + --> $DIR/nested.rs:27:35 | LL | const BAD_NESTING5: pattern_type!(f32 is 1.0 .. 2.0) = todo!(); | ^^^ | note: range patterns only support integers - --> $DIR/nested.rs:23:42 + --> $DIR/nested.rs:27:42 | LL | const BAD_NESTING5: pattern_type!(f32 is 1.0 .. 2.0) = todo!(); | ^^^^^^^^^^ -error: aborting due to 5 previous errors +error[E0308]: mismatched types + --> $DIR/nested.rs:10:63 + | +LL | const BAD_NESTING: pattern_type!(pattern_type!(u32 is 1..) is 0..) = todo!(); + | ^ expected `(u32) is 1..=`, found integer + | + = note: expected pattern type `(u32) is 1..=` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/nested.rs:15:67 + | +LL | const BAD_NESTING2: pattern_type!(pattern_type!(i32 is 1..) is ..=-1) = todo!(); + | ^^ expected `(i32) is 1..=`, found integer + | + = note: expected pattern type `(i32) is 1..=` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/nested.rs:19:66 + | +LL | const BAD_NESTING3: pattern_type!(pattern_type!(i32 is 1..) is ..0) = todo!(); + | ^ expected `(i32) is 1..=`, found integer + | + = note: expected pattern type `(i32) is 1..=` + found type `{integer}` + +error[E0308]: mismatched types + --> $DIR/nested.rs:23:43 + | +LL | const BAD_NESTING4: pattern_type!(() is ..0) = todo!(); + | ^ expected `()`, found integer + +error: aborting due to 9 previous errors +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type/pattern_types/pattern_type_mismatch.rs b/tests/ui/type/pattern_types/pattern_type_mismatch.rs index 8d375d7932b..0c88f27d836 100644 --- a/tests/ui/type/pattern_types/pattern_type_mismatch.rs +++ b/tests/ui/type/pattern_types/pattern_type_mismatch.rs @@ -1,20 +1,16 @@ //! Check that pattern types patterns must be of the type of the base type -//@ known-bug: unknown -//@ failure-status: 101 -//@ normalize-stderr: "note: .*\n\n" -> "" -//@ normalize-stderr: "thread 'rustc' panicked.*\n" -> "" -//@ normalize-stderr: "(error: internal compiler error: [^:]+):\d+:\d+: " -> "$1:LL:CC: " -//@ normalize-stderr: "(delayed at compiler/rustc_mir_transform/src/lib.rs:)\d+:\d+" -> "$1:LL:CC" -//@ rustc-env:RUST_BACKTRACE=0 - #![feature(pattern_types)] #![feature(pattern_type_macro)] use std::pat::pattern_type; const BAD_NESTING4: pattern_type!(u8 is 'a'..='a') = todo!(); +//~^ ERROR: mismatched types +//~| ERROR: mismatched types const BAD_NESTING5: pattern_type!(char is 1..=1) = todo!(); +//~^ ERROR: mismatched types +//~| ERROR: mismatched types fn main() {} diff --git a/tests/ui/type/pattern_types/pattern_type_mismatch.stderr b/tests/ui/type/pattern_types/pattern_type_mismatch.stderr index ee413133ab3..19b0c1059c8 100644 --- a/tests/ui/type/pattern_types/pattern_type_mismatch.stderr +++ b/tests/ui/type/pattern_types/pattern_type_mismatch.stderr @@ -1,31 +1,37 @@ -error: internal compiler error: ty::ConstKind::Error constructed but no error reported +error[E0308]: mismatched types + --> $DIR/pattern_type_mismatch.rs:8:41 | - = error: internal compiler error: ty::ConstKind::Error constructed but no error reported +LL | const BAD_NESTING4: pattern_type!(u8 is 'a'..='a') = todo!(); + | ^^^ expected `u8`, found `char` + | +help: if you meant to write a byte literal, prefix with `b` | - = note: delayed at compiler/rustc_mir_build/src/thir/constant.rs:72:21 - disabled backtrace - = error: internal compiler error: mir_const_qualif: MIR had errors - --> $DIR/pattern_type_mismatch.rs:16:1 +LL | const BAD_NESTING4: pattern_type!(u8 is b'a'..='a') = todo!(); + | ~~~~ + +error[E0308]: mismatched types + --> $DIR/pattern_type_mismatch.rs:8:47 | LL | const BAD_NESTING4: pattern_type!(u8 is 'a'..='a') = todo!(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^^^ expected `u8`, found `char` | -note: delayed at compiler/rustc_mir_transform/src/lib.rs::LL:CC - disabled backtrace - --> $DIR/pattern_type_mismatch.rs:16:1 +help: if you meant to write a byte literal, prefix with `b` | -LL | const BAD_NESTING4: pattern_type!(u8 is 'a'..='a') = todo!(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ +LL | const BAD_NESTING4: pattern_type!(u8 is 'a'..=b'a') = todo!(); + | ~~~~ -error: internal compiler error: mir_const_qualif: MIR had errors - --> $DIR/pattern_type_mismatch.rs:18:1 +error[E0308]: mismatched types + --> $DIR/pattern_type_mismatch.rs:12:43 | LL | const BAD_NESTING5: pattern_type!(char is 1..=1) = todo!(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | -note: delayed at compiler/rustc_mir_transform/src/lib.rs::LL:CC - disabled backtrace - --> $DIR/pattern_type_mismatch.rs:18:1 + | ^ expected `char`, found `u8` + +error[E0308]: mismatched types + --> $DIR/pattern_type_mismatch.rs:12:47 | LL | const BAD_NESTING5: pattern_type!(char is 1..=1) = todo!(); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ + | ^ expected `char`, found `u8` + +error: aborting due to 4 previous errors -query stack during panic: -end of query stack +For more information about this error, try `rustc --explain E0308`. diff --git a/tests/ui/type/pattern_types/signed_ranges.rs b/tests/ui/type/pattern_types/signed_ranges.rs new file mode 100644 index 00000000000..3725fbda729 --- /dev/null +++ b/tests/ui/type/pattern_types/signed_ranges.rs @@ -0,0 +1,24 @@ +#![feature(pattern_types)] +#![feature(pattern_type_macro)] + +use std::pat::pattern_type; + +type Sign = pattern_type!(u32 is -10..); +//~^ ERROR: cannot apply unary operator `-` + +type SignedChar = pattern_type!(char is -'A'..); +//~^ ERROR: cannot apply unary operator `-` + +fn main() { + match 42_u8 { + -10..253 => {} + //~^ ERROR `u8: Neg` is not satisfied + _ => {} + } + + match 'A' { + -'\0'..'a' => {} + //~^ ERROR `char: Neg` is not satisfied + _ => {} + } +} diff --git a/tests/ui/type/pattern_types/signed_ranges.stderr b/tests/ui/type/pattern_types/signed_ranges.stderr new file mode 100644 index 00000000000..79bf8501b63 --- /dev/null +++ b/tests/ui/type/pattern_types/signed_ranges.stderr @@ -0,0 +1,41 @@ +error[E0277]: the trait bound `u8: Neg` is not satisfied + --> $DIR/signed_ranges.rs:14:9 + | +LL | -10..253 => {} + | ^^^ the trait `Neg` is not implemented for `u8` + | + = help: the following other types implement trait `Neg`: + &f128 + &f16 + &f32 + &f64 + &i128 + &i16 + &i32 + &i64 + and 12 others + +error[E0277]: the trait bound `char: Neg` is not satisfied + --> $DIR/signed_ranges.rs:20:9 + | +LL | -'\0'..'a' => {} + | ^^^^^ the trait `Neg` is not implemented for `char` + +error[E0600]: cannot apply unary operator `-` to type `u32` + --> $DIR/signed_ranges.rs:6:34 + | +LL | type Sign = pattern_type!(u32 is -10..); + | ^^^ cannot apply unary operator `-` + | + = note: unsigned values cannot be negated + +error[E0600]: cannot apply unary operator `-` to type `char` + --> $DIR/signed_ranges.rs:9:41 + | +LL | type SignedChar = pattern_type!(char is -'A'..); + | ^^^^ cannot apply unary operator `-` + +error: aborting due to 4 previous errors + +Some errors have detailed explanations: E0277, E0600. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/type/pattern_types/unimplemented_pat.rs b/tests/ui/type/pattern_types/unimplemented_pat.rs index b2398cec7c9..44851ec1a10 100644 --- a/tests/ui/type/pattern_types/unimplemented_pat.rs +++ b/tests/ui/type/pattern_types/unimplemented_pat.rs @@ -1,14 +1,14 @@ //! This test ensures we do not ICE for unimplemented -//! patterns unless the feature gate is enabled. +//! patterns even if the feature gate is enabled. -#![feature(pattern_type_macro)] +#![feature(pattern_type_macro, pattern_types)] use std::pat::pattern_type; type Always = pattern_type!(Option<u32> is Some(_)); -//~^ ERROR: pattern types are unstable +//~^ ERROR: pattern not supported type Binding = pattern_type!(Option<u32> is x); -//~^ ERROR: pattern types are unstable +//~^ ERROR: pattern not supported fn main() {} diff --git a/tests/ui/type/pattern_types/unimplemented_pat.stderr b/tests/ui/type/pattern_types/unimplemented_pat.stderr index 7b0f9cbaa6a..a1e55ed02c4 100644 --- a/tests/ui/type/pattern_types/unimplemented_pat.stderr +++ b/tests/ui/type/pattern_types/unimplemented_pat.stderr @@ -1,23 +1,14 @@ -error[E0658]: pattern types are unstable - --> $DIR/unimplemented_pat.rs:8:15 +error: pattern not supported in pattern types + --> $DIR/unimplemented_pat.rs:8:44 | LL | type Always = pattern_type!(Option<u32> is Some(_)); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #123646 <https://github.com/rust-lang/rust/issues/123646> for more information - = help: add `#![feature(pattern_types)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + | ^^^^^^^ -error[E0658]: pattern types are unstable - --> $DIR/unimplemented_pat.rs:11:16 +error: pattern not supported in pattern types + --> $DIR/unimplemented_pat.rs:11:45 | LL | type Binding = pattern_type!(Option<u32> is x); - | ^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^^ - | - = note: see issue #123646 <https://github.com/rust-lang/rust/issues/123646> for more information - = help: add `#![feature(pattern_types)]` to the crate attributes to enable - = note: this compiler was built on YYYY-MM-DD; consider upgrading it if it is out of date + | ^ error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0658`. diff --git a/tests/ui/type/type-check/point-at-inference-4.rs b/tests/ui/type/type-check/point-at-inference-4.rs index 5745b738532..258374f299e 100644 --- a/tests/ui/type/type-check/point-at-inference-4.rs +++ b/tests/ui/type/type-check/point-at-inference-4.rs @@ -4,7 +4,6 @@ impl<A, B> S<A, B> { fn infer(&self, a: A, b: B) {} //~^ NOTE method defined here //~| NOTE - //~| NOTE } fn main() { diff --git a/tests/ui/type/type-check/point-at-inference-4.stderr b/tests/ui/type/type-check/point-at-inference-4.stderr index a953ca70ea2..544c25934ec 100644 --- a/tests/ui/type/type-check/point-at-inference-4.stderr +++ b/tests/ui/type/type-check/point-at-inference-4.stderr @@ -1,5 +1,5 @@ error[E0061]: this method takes 2 arguments but 1 argument was supplied - --> $DIR/point-at-inference-4.rs:12:7 + --> $DIR/point-at-inference-4.rs:11:7 | LL | s.infer(0i32); | ^^^^^------ argument #2 is missing @@ -8,14 +8,14 @@ note: method defined here --> $DIR/point-at-inference-4.rs:4:8 | LL | fn infer(&self, a: A, b: B) {} - | ^^^^^ ---- ---- + | ^^^^^ ---- help: provide the argument | LL | s.infer(0i32, /* b */); | ~~~~~~~~~~~~~~~ error[E0308]: mismatched types - --> $DIR/point-at-inference-4.rs:19:24 + --> $DIR/point-at-inference-4.rs:18:24 | LL | s.infer(0i32); | - ---- this argument has type `i32`... diff --git a/tests/ui/issues/issue-40610.rs b/tests/ui/typeck/coercion-check-for-addition-issue-40610.rs index c01233605b5..c01233605b5 100644 --- a/tests/ui/issues/issue-40610.rs +++ b/tests/ui/typeck/coercion-check-for-addition-issue-40610.rs diff --git a/tests/ui/issues/issue-40610.stderr b/tests/ui/typeck/coercion-check-for-addition-issue-40610.stderr index 1bd1c4dd57d..5e424862d97 100644 --- a/tests/ui/issues/issue-40610.stderr +++ b/tests/ui/typeck/coercion-check-for-addition-issue-40610.stderr @@ -1,5 +1,5 @@ error[E0369]: cannot add `()` to `()` - --> $DIR/issue-40610.rs:4:8 + --> $DIR/coercion-check-for-addition-issue-40610.rs:4:8 | LL | () + f(&[1.0]); | -- ^ --------- () diff --git a/tests/ui/issues/issue-40861.rs b/tests/ui/typeck/coercion-check-for-indexing-expression-issue-40861.rs index d8a8384a544..d8a8384a544 100644 --- a/tests/ui/issues/issue-40861.rs +++ b/tests/ui/typeck/coercion-check-for-indexing-expression-issue-40861.rs diff --git a/tests/ui/issues/issue-40861.stderr b/tests/ui/typeck/coercion-check-for-indexing-expression-issue-40861.stderr index dec9af4b6d1..13bc0cd94f3 100644 --- a/tests/ui/issues/issue-40861.stderr +++ b/tests/ui/typeck/coercion-check-for-indexing-expression-issue-40861.stderr @@ -1,5 +1,5 @@ error[E0608]: cannot index into a value of type `()` - --> $DIR/issue-40861.rs:4:7 + --> $DIR/coercion-check-for-indexing-expression-issue-40861.rs:4:7 | LL | ()[f(&[1.0])]; | ^^^^^^^^^^^ diff --git a/tests/ui/typeck/issue-105946.rs b/tests/ui/typeck/issue-105946.rs index f53f31138f8..0ee70f9346c 100644 --- a/tests/ui/typeck/issue-105946.rs +++ b/tests/ui/typeck/issue-105946.rs @@ -1,4 +1,5 @@ fn digit() -> str { + //~^ ERROR the size for values of type return {}; //~^ ERROR: mismatched types [E0308] } diff --git a/tests/ui/typeck/issue-105946.stderr b/tests/ui/typeck/issue-105946.stderr index 33d4e0b141a..30fe2000a46 100644 --- a/tests/ui/typeck/issue-105946.stderr +++ b/tests/ui/typeck/issue-105946.stderr @@ -1,5 +1,5 @@ error[E0425]: cannot find value `_y` in this scope - --> $DIR/issue-105946.rs:6:10 + --> $DIR/issue-105946.rs:7:10 | LL | let [_y..] = [Box::new(1), Box::new(2)]; | ^^ not found in this scope @@ -10,7 +10,7 @@ LL | let [_y @ ..] = [Box::new(1), Box::new(2)]; | + error[E0658]: `X..` patterns in slices are experimental - --> $DIR/issue-105946.rs:6:10 + --> $DIR/issue-105946.rs:7:10 | LL | let [_y..] = [Box::new(1), Box::new(2)]; | ^^^^ @@ -19,19 +19,28 @@ LL | let [_y..] = [Box::new(1), Box::new(2)]; = help: add `#![feature(half_open_range_patterns_in_slices)]` 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[E0277]: the size for values of type `str` cannot be known at compilation time + --> $DIR/issue-105946.rs:1:15 + | +LL | fn digit() -> str { + | ^^^ doesn't have a size known at compile-time + | + = help: the trait `Sized` is not implemented for `str` + = note: the return type of a function must have a statically known size + error[E0308]: mismatched types - --> $DIR/issue-105946.rs:2:12 + --> $DIR/issue-105946.rs:3:12 | LL | return {}; | ^^ expected `str`, found `()` error[E0527]: pattern requires 1 element but array has 2 - --> $DIR/issue-105946.rs:6:9 + --> $DIR/issue-105946.rs:7:9 | LL | let [_y..] = [Box::new(1), Box::new(2)]; | ^^^^^^ expected 2 elements -error: aborting due to 4 previous errors +error: aborting due to 5 previous errors -Some errors have detailed explanations: E0308, E0425, E0527, E0658. -For more information about an error, try `rustc --explain E0308`. +Some errors have detailed explanations: E0277, E0308, E0425, E0527, E0658. +For more information about an error, try `rustc --explain E0277`. diff --git a/tests/ui/typeck/issue-43189.rs b/tests/ui/typeck/issue-43189.rs index 9c8cc70e63a..ee0fe15eeba 100644 --- a/tests/ui/typeck/issue-43189.rs +++ b/tests/ui/typeck/issue-43189.rs @@ -1,7 +1,6 @@ // Issue 46112: An extern crate pub re-exporting libcore was causing // paths rooted from `std` to be misrendered in the diagnostic output. -//@ ignore-windows //@ aux-build:xcrate-issue-43189-a.rs //@ aux-build:xcrate-issue-43189-b.rs diff --git a/tests/ui/typeck/issue-43189.stderr b/tests/ui/typeck/issue-43189.stderr index 8432cbeca2a..3cc1ba9ddfe 100644 --- a/tests/ui/typeck/issue-43189.stderr +++ b/tests/ui/typeck/issue-43189.stderr @@ -1,5 +1,5 @@ error[E0599]: no method named `a` found for unit type `()` in the current scope - --> $DIR/issue-43189.rs:10:8 + --> $DIR/issue-43189.rs:9:8 | LL | ().a(); | ^ method not found in `()` diff --git a/tests/ui/typeck/issue-46112.rs b/tests/ui/typeck/issue-46112.rs index 4671ddd06c8..cc8029771d6 100644 --- a/tests/ui/typeck/issue-46112.rs +++ b/tests/ui/typeck/issue-46112.rs @@ -1,7 +1,6 @@ // Issue 46112: An extern crate pub re-exporting libcore was causing // paths rooted from `std` to be misrendered in the diagnostic output. -//@ ignore-windows //@ aux-build:xcrate-issue-46112-rexport-core.rs extern crate xcrate_issue_46112_rexport_core; diff --git a/tests/ui/typeck/issue-46112.stderr b/tests/ui/typeck/issue-46112.stderr index 16beaea75db..9d439d10f1e 100644 --- a/tests/ui/typeck/issue-46112.stderr +++ b/tests/ui/typeck/issue-46112.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-46112.rs:9:21 + --> $DIR/issue-46112.rs:8:21 | LL | fn main() { test(Ok(())); } | -- ^^ expected `Option<()>`, found `()` @@ -9,7 +9,7 @@ LL | fn main() { test(Ok(())); } = note: expected enum `Option<()>` found unit type `()` help: the type constructed contains `()` due to the type of the argument passed - --> $DIR/issue-46112.rs:9:18 + --> $DIR/issue-46112.rs:8:18 | LL | fn main() { test(Ok(())); } | ^^^--^ diff --git a/tests/ui/typeck/remove-extra-argument.stderr b/tests/ui/typeck/remove-extra-argument.stderr index d4e0dcb50ae..17e1b613cd9 100644 --- a/tests/ui/typeck/remove-extra-argument.stderr +++ b/tests/ui/typeck/remove-extra-argument.stderr @@ -8,7 +8,7 @@ note: function defined here --> $DIR/remove-extra-argument.rs:3:4 | LL | fn l(_a: Vec<u8>) {} - | ^ ----------- + | ^ help: remove the extra argument | LL - l(vec![], vec![]) diff --git a/tests/ui/issues/issue-41139.rs b/tests/ui/typeck/unsized-rvalue-issue-41139.rs index 94c53216f50..94c53216f50 100644 --- a/tests/ui/issues/issue-41139.rs +++ b/tests/ui/typeck/unsized-rvalue-issue-41139.rs diff --git a/tests/ui/issues/issue-41139.stderr b/tests/ui/typeck/unsized-rvalue-issue-41139.stderr index d7b35245d8f..aba0423eeb3 100644 --- a/tests/ui/issues/issue-41139.stderr +++ b/tests/ui/typeck/unsized-rvalue-issue-41139.stderr @@ -1,5 +1,5 @@ error[E0618]: expected function, found `&dyn Fn() -> (dyn Trait + 'static)` - --> $DIR/issue-41139.rs:10:26 + --> $DIR/unsized-rvalue-issue-41139.rs:10:26 | LL | fn get_function<'a>() -> &'a dyn Fn() -> dyn Trait { | -------------------------------------------------- `get_function` defined here returns `&dyn Fn() -> (dyn Trait + 'static)` diff --git a/tests/ui/unsized/box-instead-of-dyn-fn.rs b/tests/ui/unsized/box-instead-of-dyn-fn.rs index 321c2ebf5a1..720176081d6 100644 --- a/tests/ui/unsized/box-instead-of-dyn-fn.rs +++ b/tests/ui/unsized/box-instead-of-dyn-fn.rs @@ -3,7 +3,7 @@ use std::fmt::Debug; // Test to suggest boxing the return type, and the closure branch of the `if` fn print_on_or_the_other<'a>(a: i32, b: &'a String) -> dyn Fn() + 'a { - //~^ ERROR return type cannot have an unboxed trait object + //~^ ERROR return type cannot be a trait object without pointer indirection if a % 2 == 0 { move || println!("{a}") } else { diff --git a/tests/ui/unsized/box-instead-of-dyn-fn.stderr b/tests/ui/unsized/box-instead-of-dyn-fn.stderr index 1f1845569ef..1836d5dfffe 100644 --- a/tests/ui/unsized/box-instead-of-dyn-fn.stderr +++ b/tests/ui/unsized/box-instead-of-dyn-fn.stderr @@ -1,4 +1,4 @@ -error[E0746]: return type cannot have an unboxed trait object +error[E0746]: return type cannot be a trait object without pointer indirection --> $DIR/box-instead-of-dyn-fn.rs:5:56 | LL | fn print_on_or_the_other<'a>(a: i32, b: &'a String) -> dyn Fn() + 'a { diff --git a/tests/ui/unsized/issue-91801.rs b/tests/ui/unsized/issue-91801.rs index 096b1a93574..d906a08a55a 100644 --- a/tests/ui/unsized/issue-91801.rs +++ b/tests/ui/unsized/issue-91801.rs @@ -6,7 +6,7 @@ pub static ALL_VALIDATORS: &[(&'static str, &'static Validator)] = &[("validate that credits and debits balance", &validate_something)]; fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> Validator<'a> { - //~^ ERROR return type cannot have an unboxed trait object + //~^ ERROR return type cannot be a trait object without pointer indirection return Box::new(move |something: &'_ Something| -> Result<(), ()> { first(something).or_else(|_| second(something)) }); diff --git a/tests/ui/unsized/issue-91801.stderr b/tests/ui/unsized/issue-91801.stderr index e13cabbb81d..28e10f9caa4 100644 --- a/tests/ui/unsized/issue-91801.stderr +++ b/tests/ui/unsized/issue-91801.stderr @@ -1,4 +1,4 @@ -error[E0746]: return type cannot have an unboxed trait object +error[E0746]: return type cannot be a trait object without pointer indirection --> $DIR/issue-91801.rs:8:77 | LL | fn or<'a>(first: &'static Validator<'a>, second: &'static Validator<'a>) -> Validator<'a> { diff --git a/tests/ui/unsized/issue-91803.rs b/tests/ui/unsized/issue-91803.rs index c74897cc4bc..8d35c7582b8 100644 --- a/tests/ui/unsized/issue-91803.rs +++ b/tests/ui/unsized/issue-91803.rs @@ -1,7 +1,7 @@ trait Foo<'a> {} fn or<'a>(first: &'static dyn Foo<'a>) -> dyn Foo<'a> { - //~^ ERROR return type cannot have an unboxed trait object + //~^ ERROR return type cannot be a trait object without pointer indirection return Box::new(panic!()); } diff --git a/tests/ui/unsized/issue-91803.stderr b/tests/ui/unsized/issue-91803.stderr index 3b89066499d..e0fde4b1c1b 100644 --- a/tests/ui/unsized/issue-91803.stderr +++ b/tests/ui/unsized/issue-91803.stderr @@ -1,4 +1,4 @@ -error[E0746]: return type cannot have an unboxed trait object +error[E0746]: return type cannot be a trait object without pointer indirection --> $DIR/issue-91803.rs:3:43 | LL | fn or<'a>(first: &'static dyn Foo<'a>) -> dyn Foo<'a> { diff --git a/tests/ui/wait-forked-but-failed-child.rs b/tests/ui/wait-forked-but-failed-child.rs index 04f1c1a65d5..4a7f2bee9d9 100644 --- a/tests/ui/wait-forked-but-failed-child.rs +++ b/tests/ui/wait-forked-but-failed-child.rs @@ -31,8 +31,17 @@ fn find_zombies() { // https://pubs.opengroup.org/onlinepubs/9699919799/utilities/ps.html let ps_cmd_output = Command::new("ps").args(&["-A", "-o", "pid,ppid,args"]).output().unwrap(); let ps_output = String::from_utf8_lossy(&ps_cmd_output.stdout); + // On AIX, the PPID is not always present, such as when a process is blocked + // (marked as <exiting>), or if a process is idle. In these situations, + // the PPID column contains a "-" for the respective process. + // Filter out any lines that have a "-" as the PPID as the PPID is + // expected to be an integer. + let filtered_ps: Vec<_> = ps_output + .lines() + .filter(|line| line.split_whitespace().nth(1) != Some("-")) + .collect(); - for (line_no, line) in ps_output.split('\n').enumerate() { + for (line_no, line) in filtered_ps.into_iter().enumerate() { if 0 < line_no && 0 < line.len() && my_pid == line.split(' ').filter(|w| 0 < w.len()).nth(1) .expect("1st column should be PPID") diff --git a/tests/ui/weird-exprs.rs b/tests/ui/weird-exprs.rs index 08b5517aae2..55a8d580a8b 100644 --- a/tests/ui/weird-exprs.rs +++ b/tests/ui/weird-exprs.rs @@ -34,7 +34,7 @@ fn what() { let i = &Cell::new(false); let dont = {||the(i)}; dont(); - assert!((i.get())); + assert!(i.get()); } fn zombiejesus() { @@ -69,8 +69,8 @@ fn notsure() { fn canttouchthis() -> usize { fn p() -> bool { true } - let _a = (assert!((true)) == (assert!(p()))); - let _c = (assert!((p())) == ()); + let _a = (assert!(true) == (assert!(p()))); + let _c = (assert!(p()) == ()); let _b: bool = (println!("{}", 0) == (return 0)); } diff --git a/tests/ui/issues/issue-40749.rs b/tests/ui/wf/range-expr-root-of-constant-issue-40749.rs index 0a847853b12..0a847853b12 100644 --- a/tests/ui/issues/issue-40749.rs +++ b/tests/ui/wf/range-expr-root-of-constant-issue-40749.rs diff --git a/tests/ui/issues/issue-40749.stderr b/tests/ui/wf/range-expr-root-of-constant-issue-40749.stderr index f7770e00013..482773a3944 100644 --- a/tests/ui/issues/issue-40749.stderr +++ b/tests/ui/wf/range-expr-root-of-constant-issue-40749.stderr @@ -1,5 +1,5 @@ error[E0308]: mismatched types - --> $DIR/issue-40749.rs:2:9 + --> $DIR/range-expr-root-of-constant-issue-40749.rs:2:9 | LL | [0; ..10]; | ^^^^ expected `usize`, found `RangeTo<{integer}>` diff --git a/tests/ui/where-clauses/ignore-err-clauses.rs b/tests/ui/where-clauses/ignore-err-clauses.rs index c76f0e1a8b2..428ebf4b408 100644 --- a/tests/ui/where-clauses/ignore-err-clauses.rs +++ b/tests/ui/where-clauses/ignore-err-clauses.rs @@ -1,6 +1,7 @@ use std::ops::Add; fn dbl<T>(x: T) -> <T as Add>::Output +//~^ ERROR type annotations needed where T: Copy + Add, UUU: Copy, diff --git a/tests/ui/where-clauses/ignore-err-clauses.stderr b/tests/ui/where-clauses/ignore-err-clauses.stderr index 4cf553da4c5..fbf1b99334f 100644 --- a/tests/ui/where-clauses/ignore-err-clauses.stderr +++ b/tests/ui/where-clauses/ignore-err-clauses.stderr @@ -1,9 +1,16 @@ error[E0412]: cannot find type `UUU` in this scope - --> $DIR/ignore-err-clauses.rs:6:5 + --> $DIR/ignore-err-clauses.rs:7:5 | LL | UUU: Copy, | ^^^ not found in this scope -error: aborting due to 1 previous error +error[E0282]: type annotations needed + --> $DIR/ignore-err-clauses.rs:3:14 + | +LL | fn dbl<T>(x: T) -> <T as Add>::Output + | ^ cannot infer type for type parameter `T` + +error: aborting due to 2 previous errors -For more information about this error, try `rustc --explain E0412`. +Some errors have detailed explanations: E0282, E0412. +For more information about an error, try `rustc --explain E0282`. diff --git a/tests/ui/issues/issue-40235.rs b/tests/ui/while/while-let-scope-issue-40235.rs index 2bdbb2f229e..7d5dfc64a90 100644 --- a/tests/ui/issues/issue-40235.rs +++ b/tests/ui/while/while-let-scope-issue-40235.rs @@ -1,4 +1,4 @@ -//@ run-pass +//@ check-pass #![allow(unused_variables)] fn foo() {} |
